Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
QMK Bot 2023-05-31 18:47:46 +00:00
commit 6a2de56aaf
2 changed files with 73 additions and 114 deletions

View File

@ -52,14 +52,6 @@
# undef ENABLE_RGB_MATRIX_SOLID_MULTISPLASH # undef ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
#endif #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 // Feature disable
#ifndef NO_PRINT #ifndef NO_PRINT
# define NO_PRINT # define NO_PRINT

View File

@ -4,16 +4,11 @@
#include QMK_KEYBOARD_H #include QMK_KEYBOARD_H
enum custom_keycodes { enum custom_keycodes {
NULLKEY = SAFE_RANGE, // An empty key to start (and maybe end) the enum MCR_PLY = QK_USER, // Macro play
#ifdef DYNAMIC_MACRO_ENABLE MCR_REC, // Macro record
MCR_PLY, // Macro play MCR_SWT, // Swap active macro
MCR_REC, // Macro record MS_ACL_U, // Mouse speed up
MCR_SWT, // Swap active macro MS_ACL_D, // Mouse speed down
#endif
#ifdef MOUSEKEY_ENABLE
MS_ACL_U,
MS_ACL_D,
#endif
}; };
enum layout_names { enum layout_names {
@ -35,25 +30,25 @@ static int current_accel = 0;
#endif // MOUSEKEY_ENABLE #endif // MOUSEKEY_ENABLE
#ifdef DYNAMIC_MACRO_ENABLE #ifdef DYNAMIC_MACRO_ENABLE
// Macro 1 is = 1, Macro 2 = -1, No macro = 0 // Macro 1 is = 1, Macro 2 = -1, No macro = 0
static bool MACRO1 = true; static bool MACRO1 = true; // Determines whether or not we're using 1 or 2
static bool RECORDING = false; 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
static uint16_t REC = DM_REC1; void dynamic_macro_record_start_user(int8_t direction) {
static uint16_t PLY = DM_PLY1; REC = DM_RSTP;
RECORDING = true;
}
void dynamic_macro_record_start_user(int8_t direction) { void dynamic_macro_record_end_user(int8_t direction) {
REC = DM_RSTP; RECORDING = false;
RECORDING = true; }
}
void dynamic_macro_record_end_user(int8_t direction) {
RECORDING = false;
}
#else #else
#define MCR_PLY KC_NO #define MCR_PLY KC_NO
#define MCR_REC KC_NO #define MCR_REC KC_NO
#define MCR_SWT KC_NO #define MCR_SWT KC_NO
#endif #endif // DYNAMIC_MACRO_ENABLE
const uint16_t PROGMEM keymaps[_END][MATRIX_ROWS][MATRIX_COLS] = { const uint16_t PROGMEM keymaps[_END][MATRIX_ROWS][MATRIX_COLS] = {
[_MAIN] = LAYOUT_planck_mit( [_MAIN] = LAYOUT_planck_mit(
@ -84,73 +79,62 @@ const uint16_t PROGMEM keymaps[_END][MATRIX_ROWS][MATRIX_COLS] = {
#endif // MOUSEKEY_ENABLE #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 RGB_MATRIX_ENABLE
#ifdef UNDERGLOW_DISABLE #define LAYER (get_highest_layer(layer_state))
void keyboard_pre_init_user(void) { #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++ ) { #ifdef UNDERGLOW_DISABLE
if (g_led_config.flags[key_id] == LED_FLAG_UNDERGLOW) { void keyboard_pre_init_user(void) {
g_led_config.flags[key_id] = LED_FLAG_NONE; 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 }
#endif // UNDERGLOW_DISABLE
bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
if (LAYER != _MAIN) { if (LAYER == _MAIN) {return false;}
int DimmedMax = UINT8_MAX - (UINT8_MAX - rgb_matrix_config.hsv.v); 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]);
for (uint8_t i = led_min; i <= led_max; i++) { switch (KC) {
case KC_NO:
RGB_MATRIX_INDICATOR_SET_COLOR(pos, 0, 0, 0 );
break;
uint8_t pos = ((uint8_t*)g_led_config.matrix_co)[i]; #ifdef DYNAMIC_MACRO_ENABLE
case MCR_SWT:
if (!MACRO1) { RGB_MATRIX_INDICATOR_SET_COLOR(pos, 0, BRIGHTNESS, BRIGHTNESS); }
break;
CHECK_LED(); // Check LED before moving on case MCR_REC:
uint16_t KC = pgm_read_word(&((uint16_t*)keymaps)[(LAYER_SIZE * LAYER) + i]); if (RECORDING) { RGB_MATRIX_INDICATOR_SET_COLOR(pos, BRIGHTNESS, 0, 0); }
break;
if (KC == KC_NO) { #endif // DYNAMIC_MACRO_ENABLE
RGB_MATRIX_INDICATOR_SET_COLOR(pos, 0, 0, 0 );
}
#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
}
} }
}
return false; return false;
} }
#endif #endif
bool process_record_user(uint16_t keycode, keyrecord_t *record) { bool process_record_user(uint16_t keycode, keyrecord_t *record) {
#ifdef DYNAMIC_MACRO_ENABLE #ifdef DYNAMIC_MACRO_ENABLE
if (keycode == MCR_REC) keycode = REC; if (keycode == MCR_REC) {keycode = REC;}
if (keycode == MCR_PLY) keycode = PLY; if (keycode == MCR_PLY) {keycode = PLY;}
if (!process_dynamic_macro(keycode, record)) { if (!process_dynamic_macro(keycode, record)) {
REC = (MACRO1 ? DM_REC1 : DM_REC2); REC = (MACRO1 ? DM_REC1 : DM_REC2);
return false; return false;
} }
#endif #endif // DYNAMIC_MACRO_ENABLE
#ifdef MOUSEKEY_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 (record->event.pressed) {
if ( (keycode == MS_ACL_U) && (current_accel < 2) ) { current_accel += 1; } if ( (keycode == MS_ACL_U) && (current_accel < 2) ) { current_accel += 1; }
if ( (keycode == MS_ACL_D) && (current_accel > 0) ) { 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); action_t mousekey_action = action_for_keycode(keycode);
process_action(record, mousekey_action); process_action(record, mousekey_action);
} }
#endif #endif // MOUSEKEY_ENABLE
switch (keycode) { switch (keycode) {
#ifdef DYNAMIC_MACRO_ENABLE #ifdef DYNAMIC_MACRO_ENABLE
case MCR_SWT: case MCR_SWT:
if (!RECORDING && record->event.pressed) { if (!RECORDING && record->event.pressed) {
// if the button is pressed and we're not recording // if the button is pressed and we're not recording
MACRO1 = !MACRO1; MACRO1 = !MACRO1;
if (MACRO1) { if (MACRO1) {
REC = DM_REC1; REC = DM_REC1;
PLY = DM_PLY1; PLY = DM_PLY1;
} else { } else {
REC = DM_REC2; REC = DM_REC2;
PLY = DM_PLY2; PLY = DM_PLY2;
}
} }
return false; }
#endif return false;
#endif // DYNAMIC_MACRO_ENABLE
#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*/();
}
}
return false;
#endif
default: default:
return true; //Process all other keycodes normally return true; //Process all other keycodes normally