From d2bed27414ecf505ececf589846c950157d7daec Mon Sep 17 00:00:00 2001 From: CoffeeIsLife <36961653+CoffeeIsLife87@users.noreply.github.com> Date: Sat, 18 Feb 2023 11:38:06 -0600 Subject: [PATCH] Add mouse layer to Kprepublic BM40HSRGB Coffee layout (#19878) Co-authored-by: Fae --- .../bm40hsrgb/keymaps/coffee/config.h | 8 ++ .../bm40hsrgb/keymaps/coffee/keymap.c | 37 +++++++- .../bm40hsrgb/keymaps/coffee/readme.md | 94 +++++++++++-------- .../bm40hsrgb/keymaps/coffee/rules.mk | 2 +- 4 files changed, 102 insertions(+), 39 deletions(-) diff --git a/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/config.h b/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/config.h index c366c20a8c..b5c19a31b8 100644 --- a/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/config.h +++ b/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/config.h @@ -81,5 +81,13 @@ #ifdef MOUSEKEY_ENABLE # define MOUSEKEY_INTERVAL 16 // 60 FPS + +// Speed up the slowest preset +# define MK_C_OFFSET_0 4 +# define MK_C_INTERVAL_0 16 + +// Speed up the medium preset +# define MK_C_OFFSET_1 16 + # define MK_3_SPEED #endif \ No newline at end of file diff --git a/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/keymap.c b/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/keymap.c index 720c7a1d3f..53f605c54d 100644 --- a/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/keymap.c +++ b/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/keymap.c @@ -10,15 +10,30 @@ enum custom_keycodes { MCR_REC, // Macro record MCR_SWT, // Swap active macro #endif + #ifdef MOUSEKEY_ENABLE + MS_ACL_U, + MS_ACL_D, + #endif }; enum layout_names { _MAIN = 0, // Keys Layout: The main keyboard layout that has all the characters _SUB, // Extension to Main _CTR, // Macros, RGB, Audio controls, layer access. More or less the control center of my keyboard + #ifdef MOUSEKEY_ENABLE + _MSE, + #endif // MOUSEKEY_ENABLE _END, }; +#ifdef MOUSEKEY_ENABLE +#include "action.h" +#define TOG_MSE TG(_MSE) +static int current_accel = 0; +#else +#define TOG_MSE XXXXXXX +#endif // MOUSEKEY_ENABLE + #ifdef DYNAMIC_MACRO_ENABLE // Macro 1 is = 1, Macro 2 = -1, No macro = 0 static bool MACRO1 = true; @@ -57,8 +72,16 @@ const uint16_t PROGMEM keymaps[_END][MATRIX_ROWS][MATRIX_COLS] = { XXXXXXX, RGB_SPD, RGB_VAI, RGB_SPI, RGB_HUI, RGB_SAI, XXXXXXX, XXXXXXX, KC_VOLU, XXXXXXX, XXXXXXX, MCR_REC, XXXXXXX, RGB_RMOD,RGB_VAD, RGB_MOD, RGB_HUD, RGB_SAD, XXXXXXX, KC_MPRV, KC_MPLY, KC_MNXT, XXXXXXX, MCR_PLY, XXXXXXX, XXXXXXX, RGB_TOG, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_VOLD, XXXXXXX, XXXXXXX, MCR_SWT, - XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, TOG_MSE, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX ) + #ifdef MOUSEKEY_ENABLE + ,[_MSE] = LAYOUT_planck_mit( + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R, XXXXXXX, XXXXXXX, KC_BTN1, KC_WH_D, KC_WH_U, KC_BTN2, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, MS_ACL_D, TOG_MSE, MS_ACL_U,XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX + ) + #endif // MOUSEKEY_ENABLE }; #define LAYER (get_highest_layer(layer_state)) @@ -126,6 +149,18 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } #endif + #ifdef MOUSEKEY_ENABLE + if (keycode == MS_ACL_U || keycode == MS_ACL_D) { + if (record->event.pressed) { + if ( (keycode == MS_ACL_U) && (current_accel < 2) ) { current_accel += 1; } + if ( (keycode == MS_ACL_D) && (current_accel > 0) ) { current_accel -= 1; } + } + keycode = KC_ACL0 + current_accel; + action_t mousekey_action = action_for_keycode(keycode); + process_action(record, mousekey_action); + } + #endif + switch (keycode) { #ifdef DYNAMIC_MACRO_ENABLE case MCR_SWT: diff --git a/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/readme.md b/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/readme.md index 66c518e347..2798567b5e 100644 --- a/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/readme.md +++ b/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/readme.md @@ -5,48 +5,68 @@ A layout that aims to be familiar to people that have used larger boards ## The layout The primary layer ( `_MAIN` ) is as close to standard qwerty as I could get. -``` -esc | q | w | e | r | t | y | u | i | o | p | bksp -tab | a | s | d | f | g | h | j | k | l | ; | ' -shft | z | x | c | v | b | n | m | , | . | / | rtrn -ctrl | win | | alt | SUB | spc | CTR | lft | dwn | up | rght -``` +| row | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | +|-----|------|------|---|-----|-----|-----|-----|-----|-----|-----|----|------| +| 1 | esc | q | w | e | r | t | y | u | i | o | p | bksp | +| 2 | tab | a | s | d | f | g | h | j | k | l | ; | ' | +| 3 | shft | z | x | c | v | b | n | m | , | . | / | rtrn | +| 4 | ctrl | win | | alt | SUB | spc | <- | CTR | lft | dwn | up | rght | The secondary layer ( `_SUB` ) is for syntax, F keys, and number keys -``` -grv | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | del - | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | pgup - _ | F7 | F8 | F9 | F10 | F11 | F12 | | home | end | \ | pgdn - _ | _ | | _ | _ | _ | _ | | | | -``` +| row | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | +|-----|-----|----|----|----|-----|-----|-----|----|------|-----|----|------| +| 1 | grv | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | del | +| 2 | | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | pgup | +| 3 | _ | F7 | F8 | F9 | F10 | F11 | F12 | | home | end | \ | pgdn | +| 4 | _ | _ | | _ | _ | _ | <- | _ | | | | | The control layer ( `_CTR` ) is for lighting, media, and macros -``` - | SPD- | BRI+ | SPD+ | HUE+ | SAT+ | | | VOL+ | | | MCR_REC - | EFCT- | BRI- | EFCT+ | HUE- | SAT- | | PREV | PLAY | NEXT | | MCR_PLY - | | TOG | | | | | | VOL- | | | MCR_SWT - | | | | | _ | | | | | -``` +| row | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | +|-----|---|-------|------|-------|------|---------|-----|------|------|------|----|---------| +| 1 | | SPD- | BRI+ | SPD+ | HUE+ | SAT+ | | | VOL+ | | | MCR_REC | +| 2 | | EFCT- | BRI- | EFCT+ | HUE- | SAT- | | PREV | PLAY | NEXT | | MCR_PLY | +| 3 | | | TOG | | | | | | VOL- | | | MCR_SWT | +| 4 | | | | | | MSE_TOG | <- | | | | | | -| Key name | Explanation | -| -------- | -------------------------------------- | -| \_ | Passthrough the key on the layer below | -| SUB | Goes to _SUB layer while held down | -| CTR | Goes to _CTR layer while held down | -| SPD +/- | Changes speed for the RGB effect | -| BRI +/- | Changes the brightness of the lighting | -| EFCT +/- | Moves to the next/previous effect | -| TOG | Toggles the lighting on or off | -| HUE +/- | Changes the hue for RGB effects | -| SAT +/- | Changes the saturation for RGB effects | -| MSE | Toggles the Mouse layer | -| VOL +/- | Raises or lowers media volume | -| PREV | Goes to previous media | -| PLAY | Play/Pause media | -| NEXT | Goes to next media | -| MCR_REC | Record macro ( Press again to stop ) | -| MCR_PLY | Play recorded macro | -| MCR_SWT | Switch active macro | +The mouse layer ( `_MSE` ) is for making the keyboard function as a mouse as well +| row | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | +|-----|---|------|------|------|-------|---------|-----|-------|-------|-------|-------|----| +| 1 | | | | | | | | | | | | | +| 2 | | MS_L | MS_D | MS_U | MS_R | | | L_CLC | SCR_D | SCR_U | R_CLC | | +| 3 | | | | | | | | | | | | | +| 4 | | | | | ACL_D | MSE_TOG | <- | ACL_U | | | | | + +| Key name | Explanation | +|----------|----------------------------------------------| +| \_ | Passthrough the key on the layer below | +| <- | Same key as imediate left. Used for spacebar | +| SUB | Goes to _SUB layer while held down | +| CTR | Goes to _CTR layer while held down | +| MSE_TOG | Toggles the mouse layer on or off | +| SPD +/- | Changes speed for the RGB effect | +| BRI +/- | Changes the brightness of the lighting | +| EFCT +/- | Moves to the next/previous effect | +| TOG | Toggles the lighting on or off | +| HUE +/- | Changes the hue for RGB effects | +| SAT +/- | Changes the saturation for RGB effects | +| MSE | Toggles the Mouse layer | +| VOL +/- | Raises or lowers media volume | +| PREV | Goes to previous media | +| PLAY | Play/Pause media | +| NEXT | Goes to next media | +| MCR_REC | Record macro ( Press again to stop ) | +| MCR_PLY | Play recorded macro | +| MCR_SWT | Switch active macro | +| MS_L | Move mouse cursor left | +| MS_U | Move mouse cursor up | +| MS_D | Move mouse cursor down | +| MD_R | Move mouse cursor right | +| L_CLC | Mouse left click | +| R_CLC | Mouse right click | +| SCR_U | Mouse scroll up | +| SCR_D | Mouse scroll down | +| ACL_U | Raise mouse/scroll speed | +| ACL_D | Lower mouse/scroll speed | ## Compiling diff --git a/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/rules.mk b/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/rules.mk index 5d3039b8e2..1f143e6026 100644 --- a/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/rules.mk +++ b/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/rules.mk @@ -1,4 +1,4 @@ -MOUSEKEY_ENABLE = no +MOUSEKEY_ENABLE = yes NKRO_ENABLE = yes DYNAMIC_MACRO_ENABLE = yes LTO_ENABLE = yes \ No newline at end of file