aboutsummaryrefslogtreecommitdiff
path: root/keyboards
diff options
context:
space:
mode:
authorAlin Marin Elena <alin@elena.space>2022-01-13 17:16:26 +0000
committerGitHub <noreply@github.com>2022-01-13 09:16:26 -0800
commit2c8098ea8839d242a5037821d6ba0255637cd15e (patch)
tree19ad1adcaf7ce6dae1b5ab9aba8a8930ae8d5a6a /keyboards
parenta3af4b09b0786e7c228828b2b3676fb7dd9a1c2f (diff)
downloadqmk_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.c50
-rw-r--r--keyboards/mlego/m48/keymaps/via/keymap.c50
-rw-r--r--keyboards/mlego/m48/m48.h30
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
20enum layer_names {
21 _QW = 0,
22 _LWR,
23 _RSE,
24 _ADJ
25};
26
20#ifdef RGBLIGHT_ENABLE 27#ifdef RGBLIGHT_ENABLE
21 28
22const rgblight_segment_t PROGMEM my_qwerty_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_PURPLE}); 29const 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
153bool encoder_update_user(uint8_t index, bool clockwise) {
154 my_encoders(index, clockwise);
155 return true;
156}
157#endif
158
159layer_state_t layer_state_set_user(layer_state_t state) { 158layer_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
187static 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
212bool 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
20enum layer_names {
21 _QW = 0,
22 _LWR,
23 _RSE,
24 _ADJ
25};
26
20#ifdef RGBLIGHT_ENABLE 27#ifdef RGBLIGHT_ENABLE
21 28
22const rgblight_segment_t PROGMEM my_qwerty_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_PURPLE}); 29const 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
108bool encoder_update_user(uint8_t index, bool clockwise) {
109 my_encoders(index, clockwise);
110 return true;
111}
112#endif
113
114layer_state_t layer_state_set_user(layer_state_t state) { 113layer_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
142static 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
167bool 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
34enum layer_names { _QW = 0, _LWR, _RSE, _ADJ };
35static inline void led_lwr(const bool on) { 34static 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
56static 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