diff options
| author | Alin Marin Elena <alin@elena.space> | 2022-01-13 17:16:26 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-13 09:16:26 -0800 |
| commit | 2c8098ea8839d242a5037821d6ba0255637cd15e (patch) | |
| tree | 19ad1adcaf7ce6dae1b5ab9aba8a8930ae8d5a6a /keyboards | |
| parent | a3af4b09b0786e7c228828b2b3676fb7dd9a1c2f (diff) | |
| download | qmk_firmware-2c8098ea8839d242a5037821d6ba0255637cd15e.tar.gz qmk_firmware-2c8098ea8839d242a5037821d6ba0255637cd15e.zip | |
[Keyboard] move enum_layers in keymaps, in sync with the other mlego/m* (#15832)
Diffstat (limited to 'keyboards')
| -rw-r--r-- | keyboards/mlego/m48/keymaps/default/keymap.c | 50 | ||||
| -rw-r--r-- | keyboards/mlego/m48/keymaps/via/keymap.c | 50 | ||||
| -rw-r--r-- | keyboards/mlego/m48/m48.h | 30 |
3 files changed, 84 insertions, 46 deletions
diff --git a/keyboards/mlego/m48/keymaps/default/keymap.c b/keyboards/mlego/m48/keymaps/default/keymap.c index 8a76993c0..df9e1bb46 100644 --- a/keyboards/mlego/m48/keymaps/default/keymap.c +++ b/keyboards/mlego/m48/keymaps/default/keymap.c | |||
| @@ -17,6 +17,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 17 | 17 | ||
| 18 | #include QMK_KEYBOARD_H | 18 | #include QMK_KEYBOARD_H |
| 19 | 19 | ||
| 20 | enum layer_names { | ||
| 21 | _QW = 0, | ||
| 22 | _LWR, | ||
| 23 | _RSE, | ||
| 24 | _ADJ | ||
| 25 | }; | ||
| 26 | |||
| 20 | #ifdef RGBLIGHT_ENABLE | 27 | #ifdef RGBLIGHT_ENABLE |
| 21 | 28 | ||
| 22 | const rgblight_segment_t PROGMEM my_qwerty_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_PURPLE}); | 29 | const rgblight_segment_t PROGMEM my_qwerty_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_PURPLE}); |
| @@ -148,14 +155,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t* record) { | |||
| 148 | } | 155 | } |
| 149 | } | 156 | } |
| 150 | 157 | ||
| 151 | #ifdef ENCODER_ENABLE | ||
| 152 | |||
| 153 | bool encoder_update_user(uint8_t index, bool clockwise) { | ||
| 154 | my_encoders(index, clockwise); | ||
| 155 | return true; | ||
| 156 | } | ||
| 157 | #endif | ||
| 158 | |||
| 159 | layer_state_t layer_state_set_user(layer_state_t state) { | 158 | layer_state_t layer_state_set_user(layer_state_t state) { |
| 160 | #ifdef RGBLIGHT_ENABLE | 159 | #ifdef RGBLIGHT_ENABLE |
| 161 | 160 | ||
| @@ -180,3 +179,38 @@ void keyboard_post_init_user(void) { | |||
| 180 | rgblight_layers = my_rgb_layers; | 179 | rgblight_layers = my_rgb_layers; |
| 181 | } | 180 | } |
| 182 | #endif | 181 | #endif |
| 182 | |||
| 183 | #ifdef ENCODER_ENABLE | ||
| 184 | |||
| 185 | # define MEDIA_KEY_DELAY 10 | ||
| 186 | |||
| 187 | static inline void my_encoders(const uint8_t index, const bool clockwise) { | ||
| 188 | if (index == 0) { /* First encoder */ | ||
| 189 | if (IS_LAYER_ON(_LWR)) { | ||
| 190 | if (clockwise) { | ||
| 191 | rgblight_decrease_val_noeeprom(); | ||
| 192 | } else { | ||
| 193 | rgblight_increase_val_noeeprom(); | ||
| 194 | } | ||
| 195 | } else if (IS_LAYER_ON(_RSE)) { | ||
| 196 | if (clockwise) { | ||
| 197 | rgblight_decrease_hue_noeeprom(); | ||
| 198 | } else { | ||
| 199 | rgblight_increase_hue_noeeprom(); | ||
| 200 | } | ||
| 201 | |||
| 202 | } else { | ||
| 203 | if (clockwise) { | ||
| 204 | tap_code_delay(KC_VOLD, MEDIA_KEY_DELAY); | ||
| 205 | } else { | ||
| 206 | tap_code_delay(KC_VOLU, MEDIA_KEY_DELAY); | ||
| 207 | } | ||
| 208 | } | ||
| 209 | } | ||
| 210 | } | ||
| 211 | |||
| 212 | bool encoder_update_user(uint8_t index, bool clockwise) { | ||
| 213 | my_encoders(index, clockwise); | ||
| 214 | return true; | ||
| 215 | } | ||
| 216 | #endif | ||
diff --git a/keyboards/mlego/m48/keymaps/via/keymap.c b/keyboards/mlego/m48/keymaps/via/keymap.c index 54ef03cd5..af625ef20 100644 --- a/keyboards/mlego/m48/keymaps/via/keymap.c +++ b/keyboards/mlego/m48/keymaps/via/keymap.c | |||
| @@ -17,6 +17,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 17 | 17 | ||
| 18 | #include QMK_KEYBOARD_H | 18 | #include QMK_KEYBOARD_H |
| 19 | 19 | ||
| 20 | enum layer_names { | ||
| 21 | _QW = 0, | ||
| 22 | _LWR, | ||
| 23 | _RSE, | ||
| 24 | _ADJ | ||
| 25 | }; | ||
| 26 | |||
| 20 | #ifdef RGBLIGHT_ENABLE | 27 | #ifdef RGBLIGHT_ENABLE |
| 21 | 28 | ||
| 22 | const rgblight_segment_t PROGMEM my_qwerty_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_PURPLE}); | 29 | const rgblight_segment_t PROGMEM my_qwerty_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_PURPLE}); |
| @@ -103,14 +110,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t* record) { | |||
| 103 | } | 110 | } |
| 104 | } | 111 | } |
| 105 | 112 | ||
| 106 | #ifdef ENCODER_ENABLE | ||
| 107 | |||
| 108 | bool encoder_update_user(uint8_t index, bool clockwise) { | ||
| 109 | my_encoders(index, clockwise); | ||
| 110 | return true; | ||
| 111 | } | ||
| 112 | #endif | ||
| 113 | |||
| 114 | layer_state_t layer_state_set_user(layer_state_t state) { | 113 | layer_state_t layer_state_set_user(layer_state_t state) { |
| 115 | #ifdef RGBLIGHT_ENABLE | 114 | #ifdef RGBLIGHT_ENABLE |
| 116 | 115 | ||
| @@ -135,3 +134,38 @@ void keyboard_post_init_user(void) { | |||
| 135 | rgblight_layers = my_rgb_layers; | 134 | rgblight_layers = my_rgb_layers; |
| 136 | } | 135 | } |
| 137 | #endif | 136 | #endif |
| 137 | |||
| 138 | #ifdef ENCODER_ENABLE | ||
| 139 | |||
| 140 | # define MEDIA_KEY_DELAY 10 | ||
| 141 | |||
| 142 | static inline void my_encoders(const uint8_t index, const bool clockwise) { | ||
| 143 | if (index == 0) { /* First encoder */ | ||
| 144 | if (IS_LAYER_ON(_LWR)) { | ||
| 145 | if (clockwise) { | ||
| 146 | rgblight_decrease_val_noeeprom(); | ||
| 147 | } else { | ||
| 148 | rgblight_increase_val_noeeprom(); | ||
| 149 | } | ||
| 150 | } else if (IS_LAYER_ON(_RSE)) { | ||
| 151 | if (clockwise) { | ||
| 152 | rgblight_decrease_hue_noeeprom(); | ||
| 153 | } else { | ||
| 154 | rgblight_increase_hue_noeeprom(); | ||
| 155 | } | ||
| 156 | |||
| 157 | } else { | ||
| 158 | if (clockwise) { | ||
| 159 | tap_code_delay(KC_VOLD, MEDIA_KEY_DELAY); | ||
| 160 | } else { | ||
| 161 | tap_code_delay(KC_VOLU, MEDIA_KEY_DELAY); | ||
| 162 | } | ||
| 163 | } | ||
| 164 | } | ||
| 165 | } | ||
| 166 | |||
| 167 | bool encoder_update_user(uint8_t index, bool clockwise) { | ||
| 168 | my_encoders(index, clockwise); | ||
| 169 | return true; | ||
| 170 | } | ||
| 171 | #endif | ||
diff --git a/keyboards/mlego/m48/m48.h b/keyboards/mlego/m48/m48.h index 766f38124..f9ef8aee3 100644 --- a/keyboards/mlego/m48/m48.h +++ b/keyboards/mlego/m48/m48.h | |||
| @@ -31,7 +31,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 31 | { K300, K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311 } \ | 31 | { K300, K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311 } \ |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | enum layer_names { _QW = 0, _LWR, _RSE, _ADJ }; | ||
| 35 | static inline void led_lwr(const bool on) { | 34 | static inline void led_lwr(const bool on) { |
| 36 | #ifdef LED_NUM_LOCK_PIN | 35 | #ifdef LED_NUM_LOCK_PIN |
| 37 | writePin(LED_NUM_LOCK_PIN, on); | 36 | writePin(LED_NUM_LOCK_PIN, on); |
| @@ -49,32 +48,3 @@ static inline void led_caps(const bool on) { | |||
| 49 | #endif | 48 | #endif |
| 50 | } | 49 | } |
| 51 | 50 | ||
| 52 | #ifdef ENCODER_ENABLE | ||
| 53 | |||
| 54 | # define MEDIA_KEY_DELAY 10 | ||
| 55 | |||
| 56 | static inline void my_encoders(const uint8_t index, const bool clockwise) { | ||
| 57 | if (index == 0) { /* First encoder */ | ||
| 58 | if (IS_LAYER_ON(_LWR)) { | ||
| 59 | if (clockwise) { | ||
| 60 | rgblight_decrease_val_noeeprom(); | ||
| 61 | } else { | ||
| 62 | rgblight_increase_val_noeeprom(); | ||
| 63 | } | ||
| 64 | } else if (IS_LAYER_ON(_RSE)) { | ||
| 65 | if (clockwise) { | ||
| 66 | rgblight_decrease_hue_noeeprom(); | ||
| 67 | } else { | ||
| 68 | rgblight_increase_hue_noeeprom(); | ||
| 69 | } | ||
| 70 | |||
| 71 | } else { | ||
| 72 | if (clockwise) { | ||
| 73 | tap_code_delay(KC_VOLD, MEDIA_KEY_DELAY); | ||
| 74 | } else { | ||
| 75 | tap_code_delay(KC_VOLU, MEDIA_KEY_DELAY); | ||
| 76 | } | ||
| 77 | } | ||
| 78 | } | ||
| 79 | } | ||
| 80 | #endif | ||
