diff options
| author | Ryan <fauxpark@gmail.com> | 2022-02-11 13:31:19 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-11 02:31:19 +0000 |
| commit | 2bc4a216dfbb83a6d2b57da397d370210087cff5 (patch) | |
| tree | 9a16383f77159d03bd4ec5ca4ad8918f766ea16b /keyboards/maxr1998 | |
| parent | 63c310f6fd205e6332d69a718b2a295ee7792675 (diff) | |
| download | qmk_firmware-2bc4a216dfbb83a6d2b57da397d370210087cff5.tar.gz qmk_firmware-2bc4a216dfbb83a6d2b57da397d370210087cff5.zip | |
maxr1998/pulse4k: Move Combo code to keymap level (#16301)
* maxr1998/pulse4k: Move Combo code to keymap level
* Reorder code
Diffstat (limited to 'keyboards/maxr1998')
| -rw-r--r-- | keyboards/maxr1998/pulse4k/keymaps/default/keymap.c | 40 | ||||
| -rw-r--r-- | keyboards/maxr1998/pulse4k/keymaps/default/rules.mk | 1 | ||||
| -rw-r--r-- | keyboards/maxr1998/pulse4k/keymaps/maxr1998/keymap.c | 40 | ||||
| -rw-r--r-- | keyboards/maxr1998/pulse4k/keymaps/maxr1998/rules.mk | 1 | ||||
| -rw-r--r-- | keyboards/maxr1998/pulse4k/pulse4k.c | 36 | ||||
| -rw-r--r-- | keyboards/maxr1998/pulse4k/rules.mk | 1 |
6 files changed, 85 insertions, 34 deletions
diff --git a/keyboards/maxr1998/pulse4k/keymaps/default/keymap.c b/keyboards/maxr1998/pulse4k/keymaps/default/keymap.c index 1ed4b5f1a..243a96ba7 100644 --- a/keyboards/maxr1998/pulse4k/keymaps/default/keymap.c +++ b/keyboards/maxr1998/pulse4k/keymaps/default/keymap.c | |||
| @@ -21,6 +21,10 @@ enum layers { | |||
| 21 | DEFAULT | 21 | DEFAULT |
| 22 | }; | 22 | }; |
| 23 | 23 | ||
| 24 | enum combo_events { | ||
| 25 | LED_ADJUST | ||
| 26 | }; | ||
| 27 | |||
| 24 | const uint16_t PROGMEM led_adjust_combo[] = {KC_LEFT, KC_RGHT, COMBO_END}; | 28 | const uint16_t PROGMEM led_adjust_combo[] = {KC_LEFT, KC_RGHT, COMBO_END}; |
| 25 | 29 | ||
| 26 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | 30 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { |
| @@ -29,3 +33,39 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 29 | KC_LEFT, KC_DOWN, KC_RGHT | 33 | KC_LEFT, KC_DOWN, KC_RGHT |
| 30 | ) | 34 | ) |
| 31 | }; | 35 | }; |
| 36 | |||
| 37 | combo_t key_combos[COMBO_COUNT] = { | ||
| 38 | [LED_ADJUST] = COMBO_ACTION(led_adjust_combo) | ||
| 39 | }; | ||
| 40 | |||
| 41 | bool led_adjust_active = false; | ||
| 42 | |||
| 43 | void process_combo_event(uint16_t combo_index, bool pressed) { | ||
| 44 | if (combo_index == LED_ADJUST) { | ||
| 45 | led_adjust_active = pressed; | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | bool encoder_update_user(uint8_t index, bool clockwise) { | ||
| 50 | if (index == 0) { | ||
| 51 | if (led_adjust_active) { | ||
| 52 | if (clockwise) { | ||
| 53 | rgblight_increase_val(); | ||
| 54 | } else { | ||
| 55 | rgblight_decrease_val(); | ||
| 56 | } | ||
| 57 | return false; | ||
| 58 | } | ||
| 59 | } else if (index == 1) { | ||
| 60 | if (led_adjust_active) { | ||
| 61 | if (clockwise) { | ||
| 62 | rgblight_increase_hue(); | ||
| 63 | } else { | ||
| 64 | rgblight_decrease_hue(); | ||
| 65 | } | ||
| 66 | return false; | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | return true; | ||
| 71 | } | ||
diff --git a/keyboards/maxr1998/pulse4k/keymaps/default/rules.mk b/keyboards/maxr1998/pulse4k/keymaps/default/rules.mk new file mode 100644 index 000000000..ab1e43818 --- /dev/null +++ b/keyboards/maxr1998/pulse4k/keymaps/default/rules.mk | |||
| @@ -0,0 +1 @@ | |||
| COMBO_ENABLE = yes | |||
diff --git a/keyboards/maxr1998/pulse4k/keymaps/maxr1998/keymap.c b/keyboards/maxr1998/pulse4k/keymaps/maxr1998/keymap.c index 9eec3f0ae..2aad1fa34 100644 --- a/keyboards/maxr1998/pulse4k/keymaps/maxr1998/keymap.c +++ b/keyboards/maxr1998/pulse4k/keymaps/maxr1998/keymap.c | |||
| @@ -21,6 +21,10 @@ enum layers { | |||
| 21 | DEFAULT | 21 | DEFAULT |
| 22 | }; | 22 | }; |
| 23 | 23 | ||
| 24 | enum combo_events { | ||
| 25 | LED_ADJUST | ||
| 26 | }; | ||
| 27 | |||
| 24 | const uint16_t PROGMEM led_adjust_combo[] = {KC_F22, KC_F24, COMBO_END}; | 28 | const uint16_t PROGMEM led_adjust_combo[] = {KC_F22, KC_F24, COMBO_END}; |
| 25 | 29 | ||
| 26 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | 30 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { |
| @@ -30,6 +34,42 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 30 | ) | 34 | ) |
| 31 | }; | 35 | }; |
| 32 | 36 | ||
| 37 | combo_t key_combos[COMBO_COUNT] = { | ||
| 38 | [LED_ADJUST] = COMBO_ACTION(led_adjust_combo) | ||
| 39 | }; | ||
| 40 | |||
| 41 | bool led_adjust_active = false; | ||
| 42 | |||
| 43 | void process_combo_event(uint16_t combo_index, bool pressed) { | ||
| 44 | if (combo_index == LED_ADJUST) { | ||
| 45 | led_adjust_active = pressed; | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | bool encoder_update_user(uint8_t index, bool clockwise) { | ||
| 50 | if (index == 0) { | ||
| 51 | if (led_adjust_active) { | ||
| 52 | if (clockwise) { | ||
| 53 | rgblight_increase_val(); | ||
| 54 | } else { | ||
| 55 | rgblight_decrease_val(); | ||
| 56 | } | ||
| 57 | return false; | ||
| 58 | } | ||
| 59 | } else if (index == 1) { | ||
| 60 | if (led_adjust_active) { | ||
| 61 | if (clockwise) { | ||
| 62 | rgblight_increase_hue(); | ||
| 63 | } else { | ||
| 64 | rgblight_decrease_hue(); | ||
| 65 | } | ||
| 66 | return false; | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | return true; | ||
| 71 | } | ||
| 72 | |||
| 33 | void encoder_one_update(bool clockwise) { | 73 | void encoder_one_update(bool clockwise) { |
| 34 | tap_code(!clockwise ? KC_F18 : KC_F19); | 74 | tap_code(!clockwise ? KC_F18 : KC_F19); |
| 35 | } | 75 | } |
diff --git a/keyboards/maxr1998/pulse4k/keymaps/maxr1998/rules.mk b/keyboards/maxr1998/pulse4k/keymaps/maxr1998/rules.mk new file mode 100644 index 000000000..ab1e43818 --- /dev/null +++ b/keyboards/maxr1998/pulse4k/keymaps/maxr1998/rules.mk | |||
| @@ -0,0 +1 @@ | |||
| COMBO_ENABLE = yes | |||
diff --git a/keyboards/maxr1998/pulse4k/pulse4k.c b/keyboards/maxr1998/pulse4k/pulse4k.c index 21bbe5d68..f31eb6db3 100644 --- a/keyboards/maxr1998/pulse4k/pulse4k.c +++ b/keyboards/maxr1998/pulse4k/pulse4k.c | |||
| @@ -16,44 +16,14 @@ | |||
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | #include "pulse4k.h" | 18 | #include "pulse4k.h" |
| 19 | #include "rgblight.h" | ||
| 20 | |||
| 21 | enum combo_events { | ||
| 22 | LED_ADJUST | ||
| 23 | }; | ||
| 24 | |||
| 25 | extern const uint16_t PROGMEM led_adjust_combo[3]; | ||
| 26 | |||
| 27 | combo_t key_combos[COMBO_COUNT] = { | ||
| 28 | [LED_ADJUST] = COMBO_ACTION(led_adjust_combo) | ||
| 29 | }; | ||
| 30 | |||
| 31 | bool led_adjust_active = false; | ||
| 32 | |||
| 33 | void process_combo_event(uint16_t combo_index, bool pressed) { | ||
| 34 | if (combo_index == LED_ADJUST) { | ||
| 35 | led_adjust_active = pressed; | ||
| 36 | } | ||
| 37 | } | ||
| 38 | 19 | ||
| 39 | bool encoder_update_kb(uint8_t index, bool clockwise) { | 20 | bool encoder_update_kb(uint8_t index, bool clockwise) { |
| 40 | if (!encoder_update_user(index, clockwise)) return false; | 21 | if (!encoder_update_user(index, clockwise)) return false; |
| 22 | |||
| 41 | if (index == 0) { | 23 | if (index == 0) { |
| 42 | if (led_adjust_active) { | 24 | encoder_one_update(clockwise); |
| 43 | if (clockwise) { | ||
| 44 | rgblight_increase_val(); | ||
| 45 | } else { | ||
| 46 | rgblight_decrease_val(); | ||
| 47 | } | ||
| 48 | } else encoder_one_update(clockwise); | ||
| 49 | } else if (index == 1) { | 25 | } else if (index == 1) { |
| 50 | if (led_adjust_active) { | 26 | encoder_two_update(clockwise); |
| 51 | if (clockwise) { | ||
| 52 | rgblight_increase_hue(); | ||
| 53 | } else { | ||
| 54 | rgblight_decrease_hue(); | ||
| 55 | } | ||
| 56 | } else encoder_two_update(clockwise); | ||
| 57 | } | 27 | } |
| 58 | return true; | 28 | return true; |
| 59 | } | 29 | } |
diff --git a/keyboards/maxr1998/pulse4k/rules.mk b/keyboards/maxr1998/pulse4k/rules.mk index 3cfa6867a..5533ac6f3 100644 --- a/keyboards/maxr1998/pulse4k/rules.mk +++ b/keyboards/maxr1998/pulse4k/rules.mk | |||
| @@ -13,7 +13,6 @@ ENCODER_ENABLE = yes # Rotary encoders | |||
| 13 | EXTRAKEY_ENABLE = yes # Audio control and System control | 13 | EXTRAKEY_ENABLE = yes # Audio control and System control |
| 14 | CONSOLE_ENABLE = yes # Console for debug | 14 | CONSOLE_ENABLE = yes # Console for debug |
| 15 | COMMAND_ENABLE = no # Commands for debug and configuration | 15 | COMMAND_ENABLE = no # Commands for debug and configuration |
| 16 | COMBO_ENABLE = yes # Key combo feature | ||
| 17 | NKRO_ENABLE = yes # Enable N-Key Rollover | 16 | NKRO_ENABLE = yes # Enable N-Key Rollover |
| 18 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality | 17 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality |
| 19 | AUDIO_ENABLE = no # Audio output | 18 | AUDIO_ENABLE = no # Audio output |
