aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2022-02-11 13:31:19 +1100
committerGitHub <noreply@github.com>2022-02-11 02:31:19 +0000
commit2bc4a216dfbb83a6d2b57da397d370210087cff5 (patch)
tree9a16383f77159d03bd4ec5ca4ad8918f766ea16b
parent63c310f6fd205e6332d69a718b2a295ee7792675 (diff)
downloadqmk_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
-rw-r--r--keyboards/maxr1998/pulse4k/keymaps/default/keymap.c40
-rw-r--r--keyboards/maxr1998/pulse4k/keymaps/default/rules.mk1
-rw-r--r--keyboards/maxr1998/pulse4k/keymaps/maxr1998/keymap.c40
-rw-r--r--keyboards/maxr1998/pulse4k/keymaps/maxr1998/rules.mk1
-rw-r--r--keyboards/maxr1998/pulse4k/pulse4k.c36
-rw-r--r--keyboards/maxr1998/pulse4k/rules.mk1
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
24enum combo_events {
25 LED_ADJUST
26};
27
24const uint16_t PROGMEM led_adjust_combo[] = {KC_LEFT, KC_RGHT, COMBO_END}; 28const uint16_t PROGMEM led_adjust_combo[] = {KC_LEFT, KC_RGHT, COMBO_END};
25 29
26const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 30const 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
37combo_t key_combos[COMBO_COUNT] = {
38 [LED_ADJUST] = COMBO_ACTION(led_adjust_combo)
39};
40
41bool led_adjust_active = false;
42
43void process_combo_event(uint16_t combo_index, bool pressed) {
44 if (combo_index == LED_ADJUST) {
45 led_adjust_active = pressed;
46 }
47}
48
49bool 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
24enum combo_events {
25 LED_ADJUST
26};
27
24const uint16_t PROGMEM led_adjust_combo[] = {KC_F22, KC_F24, COMBO_END}; 28const uint16_t PROGMEM led_adjust_combo[] = {KC_F22, KC_F24, COMBO_END};
25 29
26const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 30const 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
37combo_t key_combos[COMBO_COUNT] = {
38 [LED_ADJUST] = COMBO_ACTION(led_adjust_combo)
39};
40
41bool led_adjust_active = false;
42
43void process_combo_event(uint16_t combo_index, bool pressed) {
44 if (combo_index == LED_ADJUST) {
45 led_adjust_active = pressed;
46 }
47}
48
49bool 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
33void encoder_one_update(bool clockwise) { 73void 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
21enum combo_events {
22 LED_ADJUST
23};
24
25extern const uint16_t PROGMEM led_adjust_combo[3];
26
27combo_t key_combos[COMBO_COUNT] = {
28 [LED_ADJUST] = COMBO_ACTION(led_adjust_combo)
29};
30
31bool led_adjust_active = false;
32
33void process_combo_event(uint16_t combo_index, bool pressed) {
34 if (combo_index == LED_ADJUST) {
35 led_adjust_active = pressed;
36 }
37}
38 19
39bool encoder_update_kb(uint8_t index, bool clockwise) { 20bool 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
13EXTRAKEY_ENABLE = yes # Audio control and System control 13EXTRAKEY_ENABLE = yes # Audio control and System control
14CONSOLE_ENABLE = yes # Console for debug 14CONSOLE_ENABLE = yes # Console for debug
15COMMAND_ENABLE = no # Commands for debug and configuration 15COMMAND_ENABLE = no # Commands for debug and configuration
16COMBO_ENABLE = yes # Key combo feature
17NKRO_ENABLE = yes # Enable N-Key Rollover 16NKRO_ENABLE = yes # Enable N-Key Rollover
18BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality 17BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
19AUDIO_ENABLE = no # Audio output 18AUDIO_ENABLE = no # Audio output