summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2019-05-13 14:48:53 -0700
committerDrashna Jaelre <drashna@live.com>2019-05-17 15:02:19 -0700
commit6689f900fc0ed9022706af7605d40225a3348f63 (patch)
tree2cd43786afb5540a0db850db4ba5e3336fa6e217
parentf520316124fb789af0981fd6e5381f090c300acb (diff)
Consolidate RGB Matrix layer indication function
And changes to iris
-rw-r--r--keyboards/crkbd/keymaps/drashna/keymap.c54
-rw-r--r--keyboards/keebio/iris/keymaps/drashna/keymap.c2
-rw-r--r--layouts/community/ergodox/drashna/keymap.c37
-rw-r--r--layouts/community/ortho_4x12/drashna/keymap.c30
-rw-r--r--users/drashna/rgb_stuff.c11
-rw-r--r--users/drashna/rgb_stuff.h2
6 files changed, 92 insertions, 44 deletions
diff --git a/keyboards/crkbd/keymaps/drashna/keymap.c b/keyboards/crkbd/keymaps/drashna/keymap.c
index 3eea7af9f9..75b62cad80 100644
--- a/keyboards/crkbd/keymaps/drashna/keymap.c
+++ b/keyboards/crkbd/keymaps/drashna/keymap.c
@@ -22,7 +22,7 @@ enum crkbd_keycodes {
KC_ESC, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, KC_MINS, \
KC_TAB, ALT_T(K11), K12, K13, K14, K15, K16, K17, K18, K19, K1A, RGUI_T(KC_QUOT), \
OS_LSFT, CTL_T(K21), K22, K23, K24, K25, K26, K27, K28, K29, RCTL_T(K2A), OS_RSFT, \
- LT(_LOWER,KC_GRV), KC_SPC, KC_BSPC, KC_DEL, KC_ENT, RAISE \
+ KC_GRV, KC_SPC, LT(_LOWER,KC_BSPC), LT(_RAISE,KC_DEL), KC_ENT, RAISE \
)
#define LAYOUT_crkbd_base_wrapper(...) LAYOUT_crkbd_base(__VA_ARGS__)
@@ -156,6 +156,8 @@ void add_keylog(uint16_t keycode) {
if (keycode < 60) {
keylog_str[0] = code_to_name[keycode];
}
+ keylog_str[KEYLOG_LEN] = 0;
+
log_timer = timer_read();
}
@@ -267,3 +269,53 @@ uint16_t get_tapping_term(uint16_t keycode) {
return TAPPING_TERM;
}
}
+
+#ifdef RGB_MATRIX_ENABLE
+
+void rgb_matrix_indicators_user(void) {
+ if ( userspace_config.rgb_layer_change &&
+#ifdef RGB_DISABLE_WHEN_USB_SUSPENDED
+ !g_suspend_state &&
+#endif
+#if defined(RGBLIGHT_ENABLE)
+ (!rgblight_config.enable && rgb_matrix_config.enable)
+#else
+ rgb_matrix_config.enable
+#endif
+ ) {
+ switch (biton32(layer_state)) {
+ case _MODS:
+ rgb_matrix_layer_helper(0xFF, 0xFF, 0x00, LED_FLAG_UNDERGLOW); break;
+ case _GAMEPAD:
+ rgb_matrix_layer_helper(0xFF, 0x80, 0x00, LED_FLAG_UNDERGLOW); break;
+ case _DIABLO:
+ rgb_matrix_layer_helper(0xFF, 0x00, 0x00, LED_FLAG_UNDERGLOW); break;
+ case _RAISE:
+ rgb_matrix_layer_helper(0xFF, 0xFF, 0x00, LED_FLAG_UNDERGLOW); break;
+ case _LOWER:
+ rgb_matrix_layer_helper(0x00, 0xFF, 0x00, LED_FLAG_UNDERGLOW); break;
+ case _ADJUST:
+ rgb_matrix_layer_helper(0xFF, 0x00, 0x00, LED_FLAG_UNDERGLOW); break;
+ default:
+ switch (biton32(default_layer_state)) {
+ case _QWERTY:
+ rgb_matrix_layer_helper(0x00, 0xFF, 0xFF, LED_FLAG_UNDERGLOW); break;
+ case _COLEMAK:
+ rgb_matrix_layer_helper(0xFF, 0x00, 0xFF, LED_FLAG_UNDERGLOW); break;
+ case _DVORAK:
+ rgb_matrix_layer_helper(0x00, 0xFF, 0x00, LED_FLAG_UNDERGLOW); break;
+ case _WORKMAN:
+ rgb_matrix_layer_helper(0xD9, 0xA5, 0x21, LED_FLAG_UNDERGLOW); break;
+ case _NORMAN:
+ rgb_matrix_layer_helper(0xFF, 0x7C, 0x4D, LED_FLAG_UNDERGLOW); break;
+ case _MALTRON:
+ rgb_matrix_layer_helper(0xFF, 0xFF, 0x00, LED_FLAG_UNDERGLOW); break;
+ case _EUCALYN:
+ rgb_matrix_layer_helper(0xFF, 0x80, 0xBF, LED_FLAG_UNDERGLOW); break;
+ case _CARPLAX:
+ rgb_matrix_layer_helper(0x00, 0x00, 0xFF, LED_FLAG_UNDERGLOW); break;
+ }
+ }
+ }
+}
+#endif
diff --git a/keyboards/keebio/iris/keymaps/drashna/keymap.c b/keyboards/keebio/iris/keymaps/drashna/keymap.c
index 95092cc521..44ffb59f6a 100644
--- a/keyboards/keebio/iris/keymaps/drashna/keymap.c
+++ b/keyboards/keebio/iris/keymaps/drashna/keymap.c
@@ -13,7 +13,7 @@
KC_TAB , K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, KC_BSLS, \
KC_C1R3, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, KC_QUOT, \
OS_LSFT, CTL_T(K21), K22, K23, K24, K25, OS_LALT, OS_RGUI, K26, K27, K28, K29, RCTL_T(K2A), OS_RSFT, \
- LT(_LOWER,KC_GRV), KC_SPC, KC_BSPC, KC_DEL, KC_ENT, RAISE \
+ KC_GRV, KC_SPC, LT(_LOWER,KC_BSPC), LT(_RAISE,KC_DEL), KC_ENT, RAISE \
)
#define LAYOUT_iris_base_wrapper(...) LAYOUT_iris_base(__VA_ARGS__)
diff --git a/layouts/community/ergodox/drashna/keymap.c b/layouts/community/ergodox/drashna/keymap.c
index fd867ede54..71ac549aeb 100644
--- a/layouts/community/ergodox/drashna/keymap.c
+++ b/layouts/community/ergodox/drashna/keymap.c
@@ -399,15 +399,6 @@ void suspend_wakeup_init_keymap(void) {
rgb_matrix_set_suspend_state(false);
}
-extern led_config_t g_led_config;
-void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue) {
- for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
- if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) {
- rgb_matrix_set_color( i, red, green, blue );
- }
- }
-}
-
void rgb_matrix_indicators_user(void) {
if ( userspace_config.rgb_layer_change &&
#ifdef RGB_DISABLE_WHEN_USB_SUSPENDED
@@ -421,9 +412,9 @@ void rgb_matrix_indicators_user(void) {
) {
switch (biton32(layer_state)) {
case _MODS:
- rgb_matrix_layer_helper(0xFF, 0xFF, 0x00); break;
+ rgb_matrix_layer_helper(0xFF, 0xFF, 0x00, LED_FLAG_MODIFIER); break;
case _GAMEPAD:
- rgb_matrix_layer_helper(0xFF, 0x80, 0x00);
+ rgb_matrix_layer_helper(0xFF, 0x80, 0x00, LED_FLAG_MODIFIER);
rgb_matrix_set_color(32, 0x00, 0xFF, 0x00); // Q
rgb_matrix_set_color(31, 0x00, 0xFF, 0xFF); // W
rgb_matrix_set_color(30, 0xFF, 0x00, 0x00); // E
@@ -439,31 +430,31 @@ void rgb_matrix_indicators_user(void) {
break;
case _DIABLO:
- rgb_matrix_layer_helper(0xFF, 0x00, 0x00); break;
+ rgb_matrix_layer_helper(0xFF, 0x00, 0x00, LED_FLAG_MODIFIER); break;
case _RAISE:
- rgb_matrix_layer_helper(0xFF, 0xFF, 0x00); break;
+ rgb_matrix_layer_helper(0xFF, 0xFF, 0x00, LED_FLAG_MODIFIER); break;
case _LOWER:
- rgb_matrix_layer_helper(0x00, 0xFF, 0x00); break;
+ rgb_matrix_layer_helper(0x00, 0xFF, 0x00, LED_FLAG_MODIFIER); break;
case _ADJUST:
- rgb_matrix_layer_helper(0xFF, 0x00, 0x00); break;
+ rgb_matrix_layer_helper(0xFF, 0x00, 0x00, LED_FLAG_MODIFIER); break;
default:
switch (biton32(default_layer_state)) {
case _QWERTY:
- rgb_matrix_layer_helper(0x00, 0xFF, 0xFF); break;
+ rgb_matrix_layer_helper(0x00, 0xFF, 0xFF, LED_FLAG_MODIFIER); break;
case _COLEMAK:
- rgb_matrix_layer_helper(0xFF, 0x00, 0xFF); break;
+ rgb_matrix_layer_helper(0xFF, 0x00, 0xFF, LED_FLAG_MODIFIER); break;
case _DVORAK:
- rgb_matrix_layer_helper(0x00, 0xFF, 0x00); break;
+ rgb_matrix_layer_helper(0x00, 0xFF, 0x00, LED_FLAG_MODIFIER); break;
case _WORKMAN:
- rgb_matrix_layer_helper(0xD9, 0xA5, 0x21); break;
+ rgb_matrix_layer_helper(0xD9, 0xA5, 0x21, LED_FLAG_MODIFIER); break;
case _NORMAN:
- rgb_matrix_layer_helper(0xFF, 0x7C, 0x4D); break;
+ rgb_matrix_layer_helper(0xFF, 0x7C, 0x4D, LED_FLAG_MODIFIER); break;
case _MALTRON:
- rgb_matrix_layer_helper(0xFF, 0xFF, 0x00); break;
+ rgb_matrix_layer_helper(0xFF, 0xFF, 0x00, LED_FLAG_MODIFIER); break;
case _EUCALYN:
- rgb_matrix_layer_helper(0xFF, 0x80, 0xBF); break;
+ rgb_matrix_layer_helper(0xFF, 0x80, 0xBF, LED_FLAG_MODIFIER); break;
case _CARPLAX:
- rgb_matrix_layer_helper(0x00, 0x00, 0xFF); break;
+ rgb_matrix_layer_helper(0x00, 0x00, 0xFF, LED_FLAG_MODIFIER); break;
}
}
}
diff --git a/layouts/community/ortho_4x12/drashna/keymap.c b/layouts/community/ortho_4x12/drashna/keymap.c
index 9b0c2d7949..3ebcd84a69 100644
--- a/layouts/community/ortho_4x12/drashna/keymap.c
+++ b/layouts/community/ortho_4x12/drashna/keymap.c
@@ -180,14 +180,6 @@ void suspend_wakeup_init_keymap(void) {
rgb_matrix_set_suspend_state(false);
}
-void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue) {
- for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
- if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) {
- rgb_matrix_set_color( i, red, green, blue );
- }
- }
-}
-
void rgb_matrix_indicators_user(void) {
uint8_t this_mod = get_mods();
uint8_t this_led = host_keyboard_leds();
@@ -209,29 +201,29 @@ void rgb_matrix_indicators_user(void) {
) {
switch (biton32(layer_state)) {
case _RAISE:
- rgb_matrix_layer_helper(0xFF, 0xFF, 0x00); break;
+ rgb_matrix_layer_helper(0xFF, 0xFF, 0x00, LED_FLAG_MODIFIER); break;
case _LOWER:
- rgb_matrix_layer_helper(0x00, 0xFF, 0x00); break;
+ rgb_matrix_layer_helper(0x00, 0xFF, 0x00, LED_FLAG_MODIFIER); break;
case _ADJUST:
- rgb_matrix_layer_helper(0xFF, 0x00, 0x00); break;
+ rgb_matrix_layer_helper(0xFF, 0x00, 0x00, LED_FLAG_MODIFIER); break;
default:
switch (biton32(default_layer_state)) {
case _QWERTY:
- rgb_matrix_layer_helper(0x00, 0xFF, 0xFF); break;
+ rgb_matrix_layer_helper(0x00, 0xFF, 0xFF, LED_FLAG_MODIFIER); break;
case _COLEMAK:
- rgb_matrix_layer_helper(0xFF, 0x00, 0xFF); break;
+ rgb_matrix_layer_helper(0xFF, 0x00, 0xFF, LED_FLAG_MODIFIER); break;
case _DVORAK:
- rgb_matrix_layer_helper(0x00, 0xFF, 0x00); break;
+ rgb_matrix_layer_helper(0x00, 0xFF, 0x00, LED_FLAG_MODIFIER); break;
case _WORKMAN:
- rgb_matrix_layer_helper(0xD9, 0xA5, 0x21); break;
+ rgb_matrix_layer_helper(0xD9, 0xA5, 0x21, LED_FLAG_MODIFIER); break;
case _NORMAN:
- rgb_matrix_layer_helper(0xFF, 0x7C, 0x4D); break;
+ rgb_matrix_layer_helper(0xFF, 0x7C, 0x4D, LED_FLAG_MODIFIER); break;
case _MALTRON:
- rgb_matrix_layer_helper(0xFF, 0xFF, 0x00); break;
+ rgb_matrix_layer_helper(0xFF, 0xFF, 0x00, LED_FLAG_MODIFIER); break;
case _EUCALYN:
- rgb_matrix_layer_helper(0xFF, 0x80, 0xBF); break;
+ rgb_matrix_layer_helper(0xFF, 0x80, 0xBF, LED_FLAG_MODIFIER); break;
case _CARPLAX:
- rgb_matrix_layer_helper(0x00, 0x00, 0xFF); break;
+ rgb_matrix_layer_helper(0x00, 0x00, 0xFF, LED_FLAG_MODIFIER); break;
}
}
}
diff --git a/users/drashna/rgb_stuff.c b/users/drashna/rgb_stuff.c
index 9e19747fa3..3421866170 100644
--- a/users/drashna/rgb_stuff.c
+++ b/users/drashna/rgb_stuff.c
@@ -334,3 +334,14 @@ uint32_t layer_state_set_rgb(uint32_t state) {
return state;
}
+
+#ifdef RGB_MATRIX_ENABLE
+extern led_config_t g_led_config;
+void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, uint8_t led_type) {
+ for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
+ if (HAS_FLAGS(g_led_config.flags[i], led_type)) {
+ rgb_matrix_set_color( i, red, green, blue );
+ }
+ }
+}
+#endif
diff --git a/users/drashna/rgb_stuff.h b/users/drashna/rgb_stuff.h
index 886f20ffcc..5721046127 100644
--- a/users/drashna/rgb_stuff.h
+++ b/users/drashna/rgb_stuff.h
@@ -19,3 +19,5 @@ uint32_t layer_state_set_rgb(uint32_t state);
uint32_t default_layer_state_set_rgb(uint32_t state);
void rgblight_sethsv_default_helper(uint8_t index);
void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue );
+
+void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, uint8_t led_type);