Align use of keymap level _kb callbacks (#25774)

This commit is contained in:
Joel Challis 2025-11-11 22:00:28 +00:00 committed by GitHub
parent 8ec3de0f92
commit 98504424b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 46 additions and 80 deletions

View file

@ -72,14 +72,7 @@ __attribute__((weak)) void trackball_check_click(bool pressed, report_mouse_t* m
} }
} }
bool process_record_kb(uint16_t keycode, keyrecord_t* record) { bool process_record_user(uint16_t keycode, keyrecord_t* record) {
if (true) {
xprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed);
}
if (!process_record_user(keycode, record)) { return false; }
/* If Mousekeys is disabled, then use handle the mouse button /* If Mousekeys is disabled, then use handle the mouse button
* keycodes. This makes things simpler, and allows usage of * keycodes. This makes things simpler, and allows usage of
* the keycodes in a consistent manner. But only do this if * the keycodes in a consistent manner. But only do this if
@ -95,6 +88,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
} }
pointing_device_set_report(currentReport); pointing_device_set_report(currentReport);
pointing_device_send(); pointing_device_send();
return false;
} }
#endif #endif

View file

@ -176,7 +176,6 @@ void dilemma_set_pointer_dragscroll_enabled(bool enable) {
void pointing_device_init_kb(void) { void pointing_device_init_kb(void) {
maybe_update_pointing_device_cpi(&g_dilemma_config); maybe_update_pointing_device_cpi(&g_dilemma_config);
pointing_device_init_user();
} }
/** /**

View file

@ -87,7 +87,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
float tone_qwerty[][2] = TONE_QWERTY; float tone_qwerty[][2] = TONE_QWERTY;
float tone_numpad[][2] = TONE_NUMPAD; float tone_numpad[][2] = TONE_NUMPAD;
layer_state_t default_layer_state_set_kb(layer_state_t state) { layer_state_t default_layer_state_set_user(layer_state_t state) {
if (state == 1UL<<_QWERTY) { if (state == 1UL<<_QWERTY) {
PLAY_SONG(tone_qwerty); PLAY_SONG(tone_qwerty);
} else if (state == 1UL<<_NUMPAD) { } else if (state == 1UL<<_NUMPAD) {

View file

@ -172,7 +172,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
# endif # endif
/* Joystick + Encoder fix */ /* Joystick + Encoder fix */
void keyboard_post_init_kb(void) { void keyboard_post_init_user(void) {
if (is_keyboard_master()) { if (is_keyboard_master()) {
gpio_write_pin_low(JOYSTICK_X_PIN); gpio_write_pin_low(JOYSTICK_X_PIN);
gpio_write_pin_low(JOYSTICK_Y_PIN); gpio_write_pin_low(JOYSTICK_Y_PIN);

View file

@ -76,15 +76,13 @@ layer_state_t layer_state_set_user(layer_state_t state) {
} }
return state; return state;
} }
void suspend_power_down_kb(void) { void suspend_power_down_user(void) {
// code will run multiple times while keyboard is suspended // code will run multiple times while keyboard is suspended
gpio_write_pin_high(GP23); gpio_write_pin_high(GP23);
gpio_write_pin_high(GP24); gpio_write_pin_high(GP24);
gpio_write_pin_high(GP25); gpio_write_pin_high(GP25);
suspend_power_down_user();
} }
void suspend_wakeup_init_kb(void) { void suspend_wakeup_init_user(void) {
layer_state_set_kb(layer_state); layer_state_set_kb(layer_state);
suspend_wakeup_init_user();
} }

View file

@ -42,25 +42,19 @@ const rgblight_segment_t PROGMEM ll_sl[] = RGBLIGHT_LAYER_SEGMENTS(
const rgblight_segment_t* const PROGMEM rgb_layers[] = RGBLIGHT_LAYERS_LIST(ll_none, ll_cl, ll_sl); const rgblight_segment_t* const PROGMEM rgb_layers[] = RGBLIGHT_LAYERS_LIST(ll_none, ll_cl, ll_sl);
void keyboard_post_init_kb(void) { void keyboard_post_init_user(void) {
rgblight_layers = rgb_layers; rgblight_layers = rgb_layers;
keyboard_post_init_user();
} }
bool led_update_kb(led_t led_state) { bool led_update_user(led_t led_state) {
bool res = led_update_user(led_state); uint8_t lock_bits = led_state.scroll_lock << 1 | led_state.caps_lock;
for (uint8_t i=0; i<3; i++) {
if (res) { rgblight_set_layer_state(i, false);
uint8_t lock_bits = led_state.scroll_lock << 1 | led_state.caps_lock; }
for (uint8_t i=0; i<3; i++) { if (lock_bits < 3) {
rgblight_set_layer_state(i, false); rgblight_set_layer_state(lock_bits, true);
}
if (lock_bits < 3) {
rgblight_set_layer_state(lock_bits, true);
}
} }
return res; return false;
} }
#endif #endif

View file

@ -42,25 +42,19 @@ const rgblight_segment_t PROGMEM ll_sl[] = RGBLIGHT_LAYER_SEGMENTS(
const rgblight_segment_t* const PROGMEM rgb_layers[] = RGBLIGHT_LAYERS_LIST(ll_none, ll_cl, ll_sl); const rgblight_segment_t* const PROGMEM rgb_layers[] = RGBLIGHT_LAYERS_LIST(ll_none, ll_cl, ll_sl);
void keyboard_post_init_kb(void) { void keyboard_post_init_user(void) {
rgblight_layers = rgb_layers; rgblight_layers = rgb_layers;
keyboard_post_init_user();
} }
bool led_update_kb(led_t led_state) { bool led_update_user(led_t led_state) {
bool res = led_update_user(led_state); uint8_t lock_bits = led_state.scroll_lock << 1 | led_state.caps_lock;
for (uint8_t i=0; i<3; i++) {
if (res) { rgblight_set_layer_state(i, false);
uint8_t lock_bits = led_state.scroll_lock << 1 | led_state.caps_lock; }
for (uint8_t i=0; i<3; i++) { if (lock_bits < 3) {
rgblight_set_layer_state(i, false); rgblight_set_layer_state(lock_bits, true);
}
if (lock_bits < 3) {
rgblight_set_layer_state(lock_bits, true);
}
} }
return res; return false;
} }
#endif #endif

View file

@ -73,25 +73,19 @@ const rgblight_segment_t* const PROGMEM rgb_layers[] = RGBLIGHT_LAYERS_LIST(
ll_slcl ll_slcl
); );
void keyboard_post_init_kb(void) { void keyboard_post_init_user(void) {
rgblight_layers = rgb_layers; rgblight_layers = rgb_layers;
keyboard_post_init_user();
} }
bool led_update_kb (led_t led_state) { bool led_update_user (led_t led_state) {
bool res = led_update_user(led_state); uint8_t lock_bits = led_state.scroll_lock << 2 | led_state.caps_lock << 1 | led_state.num_lock;
for (uint8_t i=0; i<7; i++) {
if (res) { rgblight_set_layer_state(i, false);
uint8_t lock_bits = led_state.scroll_lock << 2 | led_state.caps_lock << 1 | led_state.num_lock; }
for (uint8_t i=0; i<7; i++) { if (lock_bits < 7) {
rgblight_set_layer_state(i, false); rgblight_set_layer_state(lock_bits, true);
}
if (lock_bits < 7) {
rgblight_set_layer_state(lock_bits, true);
}
} }
return res; return false;
} }
#endif #endif

View file

@ -73,25 +73,19 @@ const rgblight_segment_t* const PROGMEM rgb_layers[] = RGBLIGHT_LAYERS_LIST(
ll_slcl ll_slcl
); );
void keyboard_post_init_kb(void) { void keyboard_post_init_user(void) {
rgblight_layers = rgb_layers; rgblight_layers = rgb_layers;
keyboard_post_init_user();
} }
bool led_update_kb (led_t led_state) { bool led_update_user (led_t led_state) {
bool res = led_update_user(led_state); uint8_t lock_bits = led_state.scroll_lock << 2 | led_state.caps_lock << 1 | led_state.num_lock;
for (uint8_t i=0; i<7; i++) {
if (res) { rgblight_set_layer_state(i, false);
uint8_t lock_bits = led_state.scroll_lock << 2 | led_state.caps_lock << 1 | led_state.num_lock; }
for (uint8_t i=0; i<7; i++) { if (lock_bits < 7) {
rgblight_set_layer_state(i, false); rgblight_set_layer_state(lock_bits, true);
}
if (lock_bits < 7) {
rgblight_set_layer_state(lock_bits, true);
}
} }
return res; return false;
} }
#endif #endif

View file

@ -283,7 +283,6 @@ void pointing_device_init_kb(void) {
cirque_pinnacle_enable_cursor_glide(false); cirque_pinnacle_enable_cursor_glide(false);
set_auto_mouse_enable(true); set_auto_mouse_enable(true);
pointing_device_init_user();
} }
/** /**

View file

@ -18,7 +18,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
}; };
// clang-format on // clang-format on
void pointing_device_init_kb(void) { void pointing_device_init_user(void) {
pointing_device_set_cpi(1600); pointing_device_set_cpi(1600);
} }

View file

@ -18,7 +18,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
}; };
// clang-format on // clang-format on
void pointing_device_init_kb(void) { void pointing_device_init_user(void) {
pointing_device_set_cpi(1600); pointing_device_set_cpi(1600);
} }

View file

@ -20,11 +20,11 @@ joystick_config_t joystick_axes[JOYSTICK_AXIS_COUNT] = {
[0] = JOYSTICK_AXIS_VIRTUAL [0] = JOYSTICK_AXIS_VIRTUAL
}; };
bool encoder_update_kb(uint8_t index, bool clockwise) { bool encoder_update_user(uint8_t index, bool clockwise) {
joystick_position += (clockwise ? 2 : -2) * (full_joystick_value / pulses_per_revolution); // +2 and -2 are used, since +1.0 and -1.0 axis output refers to positions at half of a full rotation joystick_position += (clockwise ? 2 : -2) * (full_joystick_value / pulses_per_revolution); // +2 and -2 are used, since +1.0 and -1.0 axis output refers to positions at half of a full rotation
joystick_set_axis(0, joystick_position); joystick_set_axis(0, joystick_position);
return true; return false;
} }
#endif #endif