From a786fbe35bc92b353b7002b5c1a505afa66677e0 Mon Sep 17 00:00:00 2001 From: Ryan C Date: Wed, 27 Apr 2022 20:12:06 -0500 Subject: [PATCH 1/2] Small fix for setups with only a slave touch bar. --- keyboards/rgbkb/common/touch_encoder.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/keyboards/rgbkb/common/touch_encoder.c b/keyboards/rgbkb/common/touch_encoder.c index 1e6c54e8ebf4..3c2324c9faa0 100644 --- a/keyboards/rgbkb/common/touch_encoder.c +++ b/keyboards/rgbkb/common/touch_encoder.c @@ -244,6 +244,14 @@ void touch_encoder_update_slave(slave_touch_status_t slave_state) { } void touch_encoder_update(int8_t transaction_id) { + if (is_keyboard_master()) { + slave_touch_status_t slave_state; + if (transaction_rpc_exec(transaction_id, sizeof(bool), &touch_disabled, sizeof(slave_touch_status_t), &slave_state)) { + if (memcmp(&touch_slave_state, &slave_state, sizeof(slave_touch_status_t))) + touch_encoder_update_slave(slave_state); + } + } + if (!touch_initialized) return; #if TOUCH_UPDATE_INTERVAL > 0 if (!timer_expired(timer_read(), touch_update_timer)) return; @@ -277,14 +285,6 @@ void touch_encoder_update(int8_t transaction_id) { if ((touch_raw[0] & SLIDER_BIT) && touch_processed[3] != touch_raw[3]) { touch_encoder_update_position(); } - - if (is_keyboard_master()) { - slave_touch_status_t slave_state; - if (transaction_rpc_exec(transaction_id, sizeof(bool), &touch_disabled, sizeof(slave_touch_status_t), &slave_state)) { - if (memcmp(&touch_slave_state, &slave_state, sizeof(slave_touch_status_t))) - touch_encoder_update_slave(slave_state); - } - } } void touch_encoder_calibrate(void) { From f62bda807817c481aa81a2320d4ef31aac641dd0 Mon Sep 17 00:00:00 2001 From: Ryan C Date: Wed, 27 Apr 2022 21:31:42 -0500 Subject: [PATCH 2/2] Readded throttling --- keyboards/rgbkb/common/touch_encoder.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/keyboards/rgbkb/common/touch_encoder.c b/keyboards/rgbkb/common/touch_encoder.c index 3c2324c9faa0..5f0e4f0ccad0 100644 --- a/keyboards/rgbkb/common/touch_encoder.c +++ b/keyboards/rgbkb/common/touch_encoder.c @@ -244,6 +244,11 @@ void touch_encoder_update_slave(slave_touch_status_t slave_state) { } void touch_encoder_update(int8_t transaction_id) { +#if TOUCH_UPDATE_INTERVAL > 0 + if (!timer_expired(timer_read(), touch_update_timer)) return; + touch_update_timer = timer_read() + TOUCH_UPDATE_INTERVAL; +#endif + if (is_keyboard_master()) { slave_touch_status_t slave_state; if (transaction_rpc_exec(transaction_id, sizeof(bool), &touch_disabled, sizeof(slave_touch_status_t), &slave_state)) { @@ -253,10 +258,6 @@ void touch_encoder_update(int8_t transaction_id) { } if (!touch_initialized) return; -#if TOUCH_UPDATE_INTERVAL > 0 - if (!timer_expired(timer_read(), touch_update_timer)) return; - touch_update_timer = timer_read() + TOUCH_UPDATE_INTERVAL; -#endif read_register(QT_DETECTION_STATUS, &touch_raw[0], sizeof(touch_raw)); touch_processed[1] = touch_raw[1];