diff --git a/quantum/haptic.c b/quantum/haptic.c index 81bad469b3..211d0814a0 100644 --- a/quantum/haptic.c +++ b/quantum/haptic.c @@ -335,18 +335,27 @@ void haptic_play(void) { uint8_t play_eff = 0; play_eff = haptic_config.mode; drv2605l_pulse(play_eff); -# if defined(SPLIT_KEYBOARD) && defined(SPLIT_HAPTIC_ENABLE) - split_haptic_play = haptic_config.mode; -# endif #endif #ifdef HAPTIC_SOLENOID solenoid_fire_handler(); -# if defined(SPLIT_KEYBOARD) && defined(SPLIT_HAPTIC_ENABLE) - split_haptic_play = 1; -# endif #endif } +#if defined(SPLIT_KEYBOARD) && defined(SPLIT_HAPTIC_ENABLE) +void set_haptic_split_play(uint8_t mode) { + split_haptic_play = mode; +} + +void split_haptic_play_effect(uint8_t mode) { +#ifdef HAPTIC_DRV2605L + drv2605l_pulse(mode); +#endif // HAPTIC_DRV2605L +#ifdef HAPTIC_SOLENOID + solenoid_fire_handler(); +#endif // HAPTIC_SOLENOID +} +#endif + void haptic_shutdown(void) { #ifdef HAPTIC_SOLENOID solenoid_shutdown(); diff --git a/quantum/haptic.h b/quantum/haptic.h index b283d5d268..00f02a1782 100644 --- a/quantum/haptic.h +++ b/quantum/haptic.h @@ -77,6 +77,11 @@ void haptic_cont_increase(void); void haptic_cont_decrease(void); void haptic_play(void); +#if defined(SPLIT_KEYBOARD) && defined(SPLIT_HAPTIC_ENABLE) +void set_haptic_split_play(uint8_t mode); +void split_haptic_play_effect(uint8_t mode); +#endif + void haptic_shutdown(void); void haptic_notify_usb_device_state_change(void); diff --git a/quantum/keyboard.c b/quantum/keyboard.c index 56c79298cf..9552c6d4cd 100644 --- a/quantum/keyboard.c +++ b/quantum/keyboard.c @@ -506,6 +506,10 @@ void switch_events(uint8_t row, uint8_t col, bool pressed) { #if defined(RGB_MATRIX_ENABLE) rgb_matrix_handle_key_event(row, col, pressed); #endif +#if defined(HAPTIC_ENABLE) && defined(SPLIT_HAPTIC_ENABLE) + void haptic_handle_key_event(uint8_t row, uint8_t col, bool pressed); + haptic_handle_key_event(row, col, pressed); +#endif // HAPTIC_ENABLE && SPLIT_HAPTIC_ENABLE } /** diff --git a/quantum/process_keycode/process_haptic.c b/quantum/process_keycode/process_haptic.c index 54cd7b817e..2382eb925e 100644 --- a/quantum/process_keycode/process_haptic.c +++ b/quantum/process_keycode/process_haptic.c @@ -129,19 +129,28 @@ bool process_haptic(uint16_t keycode, keyrecord_t *record) { } } + return true; +} + + + +void haptic_handle_key_event(uint8_t row, uint8_t col, bool pressed) { + keyevent_t event = MAKE_KEYEVENT(row, col, pressed); + keyrecord_t record = {.event = event}; + uint16_t keycode = get_event_keycode(event, false); + if (haptic_get_enable() && ((!HAPTIC_OFF_IN_LOW_POWER) || (usb_device_state_get_configure_state() == USB_DEVICE_STATE_CONFIGURED))) { - if (record->event.pressed) { + if (record.event.pressed) { // keypress - if (haptic_get_feedback() < 2 && get_haptic_enabled_key(keycode, record)) { + if (haptic_get_feedback() < 2 && get_haptic_enabled_key(keycode, &record)) { haptic_play(); } } else { // keyrelease - if (haptic_get_feedback() > 0 && get_haptic_enabled_key(keycode, record)) { + if (haptic_get_feedback() > 0 && get_haptic_enabled_key(keycode, &record)) { haptic_play(); } } } - return true; } diff --git a/quantum/split_common/transactions.c b/quantum/split_common/transactions.c index f66b2ad89f..14c1ca5df9 100644 --- a/quantum/split_common/transactions.c +++ b/quantum/split_common/transactions.c @@ -838,8 +838,7 @@ static void haptic_handlers_slave(matrix_row_t master_matrix[], matrix_row_t sla memcpy(&haptic_config, &split_shmem->haptic_sync.haptic_config, sizeof(haptic_config_t)); if (split_shmem->haptic_sync.haptic_play != 0xFF) { - haptic_set_mode(split_shmem->haptic_sync.haptic_play); - haptic_play(); + split_haptic_play_effect(split_shmem->haptic_sync.haptic_play); } }