From 7a08b9d374dfcf9d872738af44b231862064b96f Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 22 Jan 2021 08:23:03 -0800 Subject: [Keymap] Cleanup and updating of drashna keymap code (#11516) * Update other keyboards for rgb matrix changes * Remove customized bootmagic code * Fix corne layout compilation error * Fix compiler errors with all keymaps * Add Simple Visualizer for ergodox infinity * Fix compile issue with Corne * Fix keymap stuff * Add alias for mouse layer * Add Halmak Keyboard layout * Updates for Kyria * Add support for oled interval * Change RGB stuff [CHANGE] Fix coexistence issues * Fix rgb_stuff * Add custom ploopyco mouse keymap * Decrease default dwell time * Updates based on last breaking changes update * Disable command on dactyl * Update ergodox to use proper commands for rgb matrix indicators * Update all rgb matrix indicator functions * Update rules for dactyl-manuform * Reduce wait time for mouse layer off event * Add more info to logger * Add wrappers for get_tapping term * Move version.h include into only file that actually needs it * Update rgb sleep stuff * Update key print function * Change DM keymap settings * Change pin for DM Manuform * Add Proton C stuff for Corne keymap * more arm corne tinkering * Even more arm stuff for corne * Cleanup corne stuff * redirect default keymap to drashna because I am a very bad man * change corne rgb priority * Update tractyl manuform to not conflict * Add more secret stuff * more dactyl tweaks * Add more options to split transport * Changes of oled support * Change split settings * Improve keylogger formatting more * tweak oled stuff * Oled and such tweaks * Reduce brightness due to leds * Decrease brightness more * Only run layer code if master --- layouts/community/split_3x6_3/drashna/keymap.c | 81 ++++++++++---------------- 1 file changed, 31 insertions(+), 50 deletions(-) (limited to 'layouts/community/split_3x6_3/drashna/keymap.c') diff --git a/layouts/community/split_3x6_3/drashna/keymap.c b/layouts/community/split_3x6_3/drashna/keymap.c index e53d053973..513cc7f7dc 100644 --- a/layouts/community/split_3x6_3/drashna/keymap.c +++ b/layouts/community/split_3x6_3/drashna/keymap.c @@ -16,11 +16,6 @@ #include "drashna.h" -#ifdef RGBLIGHT_ENABLE -// Following line allows macro to read current RGB settings -extern rgblight_config_t rgblight_config; -#endif - enum crkbd_keycodes { RGBRST = NEW_SAFE_RANGE }; /* @@ -31,6 +26,7 @@ enum crkbd_keycodes { RGBRST = NEW_SAFE_RANGE }; * of use. K## is a placeholder to pass through the individual keycodes */ +// clang-format off #define LAYOUT_split_3x6_3_base( \ K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, \ K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, \ @@ -40,7 +36,7 @@ enum crkbd_keycodes { RGBRST = NEW_SAFE_RANGE }; KC_ESC, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, KC_MINS, \ ALT_T(KC_TAB), K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, RALT_T(KC_QUOT), \ OS_LSFT, CTL_T(K21), K22, K23, K24, K25, K26, K27, K28, K29, RCTL_T(K2A), OS_RSFT, \ - KC_GRV, KC_SPC, BK_LWER, DL_RAIS, KC_ENT, OS_RGUI \ + RGB_MOD, KC_SPC, BK_LWER, DL_RAIS, KC_ENT, OS_RGUI \ ) #define LAYOUT_split_3x6_3_base_wrapper(...) LAYOUT_split_3x6_3_base(__VA_ARGS__) @@ -123,31 +119,17 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { }; // clang-format on -bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { - if (record->event.pressed) { -#ifndef SPLIT_KEYBOARD - if (keycode == RESET && !is_master) { - return false; - } -#endif - } - return true; -} - #ifdef OLED_DRIVER_ENABLE oled_rotation_t oled_init_user(oled_rotation_t rotation) { -# ifndef SPLIT_KEYBOARD - if (is_master) { -# endif + if (is_keyboard_master()) { return OLED_ROTATION_270; -# ifndef SPLIT_KEYBOARD - } else { + } else { return rotation; } -# endif } #endif +#ifdef TAPPING_TERM_PER_KEY uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case ALT_T(KC_A): @@ -156,75 +138,74 @@ uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) { return TAPPING_TERM; } } +#endif + +void matrix_slave_scan_user(void) { #ifdef RGB_MATRIX_ENABLE + rgb_matrix_task(); +#endif +} +#ifdef RGB_MATRIX_ENABLE void suspend_power_down_keymap(void) { rgb_matrix_set_suspend_state(true); } void suspend_wakeup_init_keymap(void) { rgb_matrix_set_suspend_state(false); } -void check_default_layer(uint8_t mode, uint8_t type) { +void check_default_layer(uint8_t mode, uint8_t type, uint8_t led_min, uint8_t led_max) { switch (get_highest_layer(default_layer_state)) { case _QWERTY: - rgb_matrix_layer_helper(HSV_CYAN, mode, rgb_matrix_config.speed, type); + rgb_matrix_layer_helper(HSV_CYAN, mode, rgb_matrix_config.speed, type, led_min, led_max); break; case _COLEMAK: - rgb_matrix_layer_helper(HSV_MAGENTA, mode, rgb_matrix_config.speed, type); + rgb_matrix_layer_helper(HSV_MAGENTA, mode, rgb_matrix_config.speed, type, led_min, led_max); break; case _DVORAK: - rgb_matrix_layer_helper(HSV_SPRINGGREEN, mode, rgb_matrix_config.speed, type); + rgb_matrix_layer_helper(HSV_SPRINGGREEN, mode, rgb_matrix_config.speed, type, led_min, led_max); break; case _WORKMAN: - rgb_matrix_layer_helper(HSV_GOLDENROD, mode, rgb_matrix_config.speed, type); + rgb_matrix_layer_helper(HSV_GOLDENROD, mode, rgb_matrix_config.speed, type, led_min, led_max); break; case _NORMAN: - rgb_matrix_layer_helper(HSV_CORAL, mode, rgb_matrix_config.speed, type); + rgb_matrix_layer_helper(HSV_CORAL, mode, rgb_matrix_config.speed, type, led_min, led_max); break; case _MALTRON: - rgb_matrix_layer_helper(HSV_YELLOW, mode, rgb_matrix_config.speed, type); + rgb_matrix_layer_helper(HSV_YELLOW, mode, rgb_matrix_config.speed, type, led_min, led_max); break; case _EUCALYN: - rgb_matrix_layer_helper(HSV_PINK, mode, rgb_matrix_config.speed, type); + rgb_matrix_layer_helper(HSV_PINK, mode, rgb_matrix_config.speed, type, led_min, led_max); break; case _CARPLAX: - rgb_matrix_layer_helper(HSV_BLUE, mode, rgb_matrix_config.speed, type); + rgb_matrix_layer_helper(HSV_BLUE, mode, rgb_matrix_config.speed, type, led_min, led_max); break; } } -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 - ) { +void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { + if (!is_keyboard_master()) return; + if (userspace_config.rgb_layer_change) { switch (get_highest_layer(layer_state)) { case _GAMEPAD: - rgb_matrix_layer_helper(HSV_ORANGE, 0, rgb_matrix_config.speed, LED_FLAG_UNDERGLOW); + rgb_matrix_layer_helper(HSV_ORANGE, 0, rgb_matrix_config.speed, LED_FLAG_UNDERGLOW, led_min, led_max); break; case _DIABLO: - rgb_matrix_layer_helper(HSV_RED, 0, rgb_matrix_config.speed, LED_FLAG_UNDERGLOW); + rgb_matrix_layer_helper(HSV_RED, 0, rgb_matrix_config.speed, LED_FLAG_UNDERGLOW, led_min, led_max); break; case _RAISE: - rgb_matrix_layer_helper(HSV_YELLOW, 0, rgb_matrix_config.speed, LED_FLAG_UNDERGLOW); + rgb_matrix_layer_helper(HSV_YELLOW, 0, rgb_matrix_config.speed, LED_FLAG_UNDERGLOW, led_min, led_max); break; case _LOWER: - rgb_matrix_layer_helper(HSV_GREEN, 0, rgb_matrix_config.speed, LED_FLAG_UNDERGLOW); + rgb_matrix_layer_helper(HSV_GREEN, 0, rgb_matrix_config.speed, LED_FLAG_UNDERGLOW, led_min, led_max); break; case _ADJUST: - rgb_matrix_layer_helper(HSV_RED, 0, rgb_matrix_config.speed, LED_FLAG_UNDERGLOW); + rgb_matrix_layer_helper(HSV_RED, 0, rgb_matrix_config.speed, LED_FLAG_UNDERGLOW, led_min, led_max); break; default: { - check_default_layer(IS_LAYER_ON(_MODS), LED_FLAG_UNDERGLOW); + check_default_layer(IS_LAYER_ON(_MODS), LED_FLAG_UNDERGLOW, led_min, led_max); break; } } - check_default_layer(0, LED_FLAG_MODIFIER); + check_default_layer(0, LED_FLAG_MODIFIER, led_min, led_max); } } #endif -- cgit v1.2.3