From c2ddd77e0d122b9b15d23486ed97280e8bc227f9 Mon Sep 17 00:00:00 2001 From: CoffeeIsLife <36961653+CoffeeIsLife87@users.noreply.github.com> Date: Wed, 31 May 2023 13:46:59 -0500 Subject: [Keymap] Cleanup coffeeislife87 keymap and remove features (#21061) Co-authored-by: Drashna Jaelre Co-authored-by: Fae --- .../kprepublic/bm40hsrgb/keymaps/coffee/config.h | 8 - .../kprepublic/bm40hsrgb/keymaps/coffee/keymap.c | 181 +++++++++------------ 2 files changed, 74 insertions(+), 115 deletions(-) (limited to 'keyboards/kprepublic/bm40hsrgb') diff --git a/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/config.h b/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/config.h index b5c19a31b8..e8f6fac120 100644 --- a/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/config.h +++ b/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/config.h @@ -52,14 +52,6 @@ # undef ENABLE_RGB_MATRIX_SOLID_MULTISPLASH #endif -// If RGBLight is enabled -#ifdef RGBLIGHT_ENABLE -# define RGBLED_NUM RGB_MATRIX_LED_COUNT - -# define RGBLIGHT_EFFECT_SNAKE -# define RGBLIGHT_EFFECT_STATIC_GRADIENT -#endif - // Feature disable #ifndef NO_PRINT # define NO_PRINT diff --git a/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/keymap.c b/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/keymap.c index a41020446d..ef7cfab5fe 100644 --- a/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/keymap.c +++ b/keyboards/kprepublic/bm40hsrgb/keymaps/coffee/keymap.c @@ -4,16 +4,11 @@ #include QMK_KEYBOARD_H enum custom_keycodes { - NULLKEY = SAFE_RANGE, // An empty key to start (and maybe end) the enum - #ifdef DYNAMIC_MACRO_ENABLE - MCR_PLY, // Macro play - MCR_REC, // Macro record - MCR_SWT, // Swap active macro - #endif - #ifdef MOUSEKEY_ENABLE - MS_ACL_U, - MS_ACL_D, - #endif + MCR_PLY = QK_USER, // Macro play + MCR_REC, // Macro record + MCR_SWT, // Swap active macro + MS_ACL_U, // Mouse speed up + MS_ACL_D, // Mouse speed down }; enum layout_names { @@ -35,25 +30,25 @@ static int current_accel = 0; #endif // MOUSEKEY_ENABLE #ifdef DYNAMIC_MACRO_ENABLE - // Macro 1 is = 1, Macro 2 = -1, No macro = 0 - static bool MACRO1 = true; - static bool RECORDING = false; - - static uint16_t REC = DM_REC1; - static uint16_t PLY = DM_PLY1; +// Macro 1 is = 1, Macro 2 = -1, No macro = 0 +static bool MACRO1 = true; // Determines whether or not we're using 1 or 2 +static bool RECORDING = false; +static uint16_t REC = DM_REC1; // Record either macro 1 or 2. Or stop recording +static uint16_t PLY = DM_PLY1; // Play either macro 1 or macro 2 + +void dynamic_macro_record_start_user(int8_t direction) { + REC = DM_RSTP; + RECORDING = true; +} - void dynamic_macro_record_start_user(int8_t direction) { - REC = DM_RSTP; - RECORDING = true; - } - void dynamic_macro_record_end_user(int8_t direction) { - RECORDING = false; - } +void dynamic_macro_record_end_user(int8_t direction) { + RECORDING = false; +} #else - #define MCR_PLY KC_NO - #define MCR_REC KC_NO - #define MCR_SWT KC_NO -#endif +#define MCR_PLY KC_NO +#define MCR_REC KC_NO +#define MCR_SWT KC_NO +#endif // DYNAMIC_MACRO_ENABLE const uint16_t PROGMEM keymaps[_END][MATRIX_ROWS][MATRIX_COLS] = { [_MAIN] = LAYOUT_planck_mit( @@ -84,73 +79,62 @@ const uint16_t PROGMEM keymaps[_END][MATRIX_ROWS][MATRIX_COLS] = { #endif // MOUSEKEY_ENABLE }; -#define LAYER (get_highest_layer(layer_state)) -#define LAYER_SIZE (MATRIX_ROWS * MATRIX_COLS) -#define CHECK_LED() \ - if ((i >= RGB_MATRIX_LED_COUNT) \ - || ((g_led_config.flags[pos] == LED_FLAG_NONE) || (g_led_config.flags[pos] == LED_FLAG_UNDERGLOW))) \ - continue - #ifdef RGB_MATRIX_ENABLE - #ifdef UNDERGLOW_DISABLE - void keyboard_pre_init_user(void) { +#define LAYER (get_highest_layer(layer_state)) +#define LAYER_SIZE (MATRIX_ROWS * MATRIX_COLS) +#define BRIGHTNESS rgb_matrix_get_val() - for (int key_id = 0; key_id < RGB_MATRIX_LED_COUNT; key_id++ ) { - if (g_led_config.flags[key_id] == LED_FLAG_UNDERGLOW) { - g_led_config.flags[key_id] = LED_FLAG_NONE; - } +#ifdef UNDERGLOW_DISABLE +void keyboard_pre_init_user(void) { + for (int key_id = 0; key_id < RGB_MATRIX_LED_COUNT; key_id++ ) { + if (g_led_config.flags[key_id] == LED_FLAG_UNDERGLOW) { + g_led_config.flags[key_id] = LED_FLAG_NONE; } } - #endif - - bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { - if (LAYER != _MAIN) { - - int DimmedMax = UINT8_MAX - (UINT8_MAX - rgb_matrix_config.hsv.v); - - for (uint8_t i = led_min; i <= led_max; i++) { +} +#endif // UNDERGLOW_DISABLE - uint8_t pos = ((uint8_t*)g_led_config.matrix_co)[i]; +bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { + if (LAYER == _MAIN) {return false;} - CHECK_LED(); // Check LED before moving on - uint16_t KC = pgm_read_word(&((uint16_t*)keymaps)[(LAYER_SIZE * LAYER) + i]); + for (uint8_t i = led_min; i <= led_max; i++) { + uint8_t pos = ((uint8_t*)g_led_config.matrix_co)[i]; + if (!HAS_ANY_FLAGS(g_led_config.flags[pos], (LED_FLAG_MODIFIER | LED_FLAG_KEYLIGHT))) {continue;} + uint16_t KC = pgm_read_word(&((uint16_t*)keymaps)[(LAYER_SIZE * LAYER) + i]); - if (KC == KC_NO) { - RGB_MATRIX_INDICATOR_SET_COLOR(pos, 0, 0, 0 ); - } + switch (KC) { + case KC_NO: + RGB_MATRIX_INDICATOR_SET_COLOR(pos, 0, 0, 0 ); + break; - #ifdef DYNAMIC_MACRO_ENABLE - else if (KC == MCR_SWT) { - if (!MACRO1) { - RGB_MATRIX_INDICATOR_SET_COLOR(pos, 0, DimmedMax, DimmedMax); - } - } else if (KC == MCR_REC) { - if (RECORDING) { - RGB_MATRIX_INDICATOR_SET_COLOR(pos, DimmedMax, 0, 0); - } - } - #endif + #ifdef DYNAMIC_MACRO_ENABLE + case MCR_SWT: + if (!MACRO1) { RGB_MATRIX_INDICATOR_SET_COLOR(pos, 0, BRIGHTNESS, BRIGHTNESS); } + break; - } + case MCR_REC: + if (RECORDING) { RGB_MATRIX_INDICATOR_SET_COLOR(pos, BRIGHTNESS, 0, 0); } + break; + #endif // DYNAMIC_MACRO_ENABLE } - return false; } + return false; +} #endif bool process_record_user(uint16_t keycode, keyrecord_t *record) { - #ifdef DYNAMIC_MACRO_ENABLE - if (keycode == MCR_REC) keycode = REC; - if (keycode == MCR_PLY) keycode = PLY; - if (!process_dynamic_macro(keycode, record)) { - REC = (MACRO1 ? DM_REC1 : DM_REC2); - return false; - } - #endif + if (keycode == MCR_REC) {keycode = REC;} + if (keycode == MCR_PLY) {keycode = PLY;} + if (!process_dynamic_macro(keycode, record)) { + REC = (MACRO1 ? DM_REC1 : DM_REC2); + return false; + } + #endif // DYNAMIC_MACRO_ENABLE #ifdef MOUSEKEY_ENABLE - if (keycode == MS_ACL_U || keycode == MS_ACL_D) { + if ((keycode == MS_ACL_U) || (keycode == MS_ACL_D)) { if (record->event.pressed) { if ( (keycode == MS_ACL_U) && (current_accel < 2) ) { current_accel += 1; } if ( (keycode == MS_ACL_D) && (current_accel > 0) ) { current_accel -= 1; } @@ -159,41 +143,24 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { action_t mousekey_action = action_for_keycode(keycode); process_action(record, mousekey_action); } - #endif + #endif // MOUSEKEY_ENABLE switch (keycode) { #ifdef DYNAMIC_MACRO_ENABLE - case MCR_SWT: - if (!RECORDING && record->event.pressed) { - // if the button is pressed and we're not recording - MACRO1 = !MACRO1; - if (MACRO1) { - REC = DM_REC1; - PLY = DM_PLY1; - } else { - REC = DM_REC2; - PLY = DM_PLY2; - } - } - return false; - #endif - - #if defined(RGB_MATRIX_ENABLE) && defined(RGBLIGHT_ENABLE) // this only needs to be defined if both are enabled - case RGB_TOG: // We can intercept this keycode ig? Cool :) - if (record->event.pressed) { - if (rgb_matrix_is_enabled()) { - rgb_matrix_disable/*_noeeprom*/(); - rgblight_enable/*_noeeprom*/(); - } else if (rgblight_is_enabled()) { - rgb_matrix_disable/*_noeeprom*/(); - rgblight_disable/*_noeeprom*/(); - } else { - rgb_matrix_enable/*_noeeprom*/(); - rgblight_disable/*_noeeprom*/(); - } + case MCR_SWT: + if (!RECORDING && record->event.pressed) { + // if the button is pressed and we're not recording + MACRO1 = !MACRO1; + if (MACRO1) { + REC = DM_REC1; + PLY = DM_PLY1; + } else { + REC = DM_REC2; + PLY = DM_PLY2; } - return false; - #endif + } + return false; + #endif // DYNAMIC_MACRO_ENABLE default: return true; //Process all other keycodes normally -- cgit v1.2.3