aboutsummaryrefslogtreecommitdiffstats
path: root/tmk_core/protocol
diff options
context:
space:
mode:
authorzvecr2025-12-01 23:07:33 +0100
committerzvecr2025-12-01 23:07:33 +0100
commitb315b707e60f86d79d34bcb7a15084468117c1a1 (patch)
tree7bbdc5f5d703c28310b4751dd3db280d8f55a6bd /tmk_core/protocol
parente2bf515df4c51c4d2e3b442d23e52d6d43f7f726 (diff)
parente10429baae2a4b3ffec67fe31a5e1ac3212817f0 (diff)
Merge branch 'develop'
Diffstat (limited to 'tmk_core/protocol')
-rw-r--r--tmk_core/protocol/chibios/chibios.c3
-rw-r--r--tmk_core/protocol/host.c44
-rw-r--r--tmk_core/protocol/host.h3
-rw-r--r--tmk_core/protocol/lufa/lufa.c3
-rw-r--r--tmk_core/protocol/vusb/protocol.c3
5 files changed, 54 insertions, 2 deletions
diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c
index 5720bc3c4c..b8cded99fc 100644
--- a/tmk_core/protocol/chibios/chibios.c
+++ b/tmk_core/protocol/chibios/chibios.c
@@ -191,6 +191,9 @@ void protocol_pre_task(void) {
//
// Pause for a while to let things settle...
wait_ms(USB_SUSPEND_WAKEUP_DELAY);
+ // ...and then update the wakeup matrix again as the waking key
+ // might have been released during the delay
+ update_matrix_state_after_wakeup();
# endif
}
}
diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c
index 4874d7c1d3..f4fa9064e0 100644
--- a/tmk_core/protocol/host.c
+++ b/tmk_core/protocol/host.c
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdint.h>
#include "keyboard.h"
#include "keycode.h"
+#include "action.h"
#include "host.h"
#include "util.h"
#include "debug.h"
@@ -78,9 +79,48 @@ host_driver_t *host_get_driver(void) {
return driver;
}
+#ifdef CONNECTION_ENABLE
+static connection_host_t active_host = CONNECTION_HOST_NONE;
+
+__attribute__((weak)) void host_disconnect_active_driver_user(connection_host_t host) {}
+__attribute__((weak)) void host_disconnect_active_driver_kb(connection_host_t host) {}
+
+__attribute__((weak)) void host_connect_active_driver_user(connection_host_t host) {}
+__attribute__((weak)) void host_connect_active_driver_kb(connection_host_t host) {}
+
+// TODO: Additionally have host_driver_t handle swap
+static void host_update_active_driver(connection_host_t current, connection_host_t next) {
+ host_disconnect_active_driver_user(current);
+ host_disconnect_active_driver_kb(current);
+
+ if (current != CONNECTION_HOST_NONE) {
+ clear_keyboard();
+ }
+
+ host_connect_active_driver_user(next);
+ host_connect_active_driver_kb(next);
+}
+
+#endif
+
+void host_init(void) {
+ // currently do nothing
+}
+
+void host_task(void) {
+#ifdef CONNECTION_ENABLE
+ connection_host_t next_host = connection_get_host();
+ if (next_host != active_host) {
+ host_update_active_driver(active_host, next_host);
+
+ active_host = next_host;
+ }
+#endif
+}
+
static host_driver_t *host_get_active_driver(void) {
#ifdef CONNECTION_ENABLE
- switch (connection_get_host()) {
+ switch (active_host) {
# ifdef BLUETOOTH_ENABLE
case CONNECTION_HOST_BLUETOOTH:
return &bt_driver;
@@ -96,7 +136,7 @@ static host_driver_t *host_get_active_driver(void) {
bool host_can_send_nkro(void) {
#ifdef CONNECTION_ENABLE
- switch (connection_get_host()) {
+ switch (active_host) {
# ifdef BLUETOOTH_ENABLE
case CONNECTION_HOST_BLUETOOTH:
return bluetooth_can_send_nkro();
diff --git a/tmk_core/protocol/host.h b/tmk_core/protocol/host.h
index a0b1e73dcc..7ff6d0df08 100644
--- a/tmk_core/protocol/host.h
+++ b/tmk_core/protocol/host.h
@@ -27,6 +27,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
extern "C" {
#endif
+void host_init(void);
+void host_task(void);
+
/* host driver */
void host_set_driver(host_driver_t *driver);
host_driver_t *host_get_driver(void);
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index e13f4b548e..3e442ba033 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -826,6 +826,9 @@ void protocol_pre_task(void) {
//
// Pause for a while to let things settle...
wait_ms(USB_SUSPEND_WAKEUP_DELAY);
+ // ...and then update the wakeup matrix again as the waking key
+ // might have been released during the delay
+ update_matrix_state_after_wakeup();
# endif
}
}
diff --git a/tmk_core/protocol/vusb/protocol.c b/tmk_core/protocol/vusb/protocol.c
index e2d0c4112e..b95750306a 100644
--- a/tmk_core/protocol/vusb/protocol.c
+++ b/tmk_core/protocol/vusb/protocol.c
@@ -125,6 +125,9 @@ void protocol_pre_task(void) {
//
// Pause for a while to let things settle...
wait_ms(USB_SUSPEND_WAKEUP_DELAY);
+ // ...and then update the wakeup matrix again as the waking key
+ // might have been released during the delay
+ update_matrix_state_after_wakeup();
# endif
}
}