summaryrefslogtreecommitdiff
path: root/users/drashna/split
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2022-01-21 19:36:52 -0800
committerGitHub <noreply@github.com>2022-01-21 19:36:52 -0800
commitb090ff03ed4391f27e8e3d9a843f529bedd08e19 (patch)
treee734aa4541f05ed4f919f86ff36d85cbd17f795a /users/drashna/split
parent8901c9eca1db8d10b06f544553a5fc941eda51ae (diff)
[Keymap] Drashna's OLED rewrite (#15981)
Diffstat (limited to 'users/drashna/split')
-rw-r--r--users/drashna/split/transport_sync.c65
-rw-r--r--users/drashna/split/transport_sync.h4
2 files changed, 56 insertions, 13 deletions
diff --git a/users/drashna/split/transport_sync.c b/users/drashna/split/transport_sync.c
index 794664293c..2509e448cb 100644
--- a/users/drashna/split/transport_sync.c
+++ b/users/drashna/split/transport_sync.c
@@ -9,7 +9,7 @@
#endif
#ifdef CUSTOM_UNICODE_ENABLE
-#include "process_unicode_common.h"
+# include "process_unicode_common.h"
extern unicode_config_t unicode_config;
#endif
#ifdef AUDIO_ENABLE
@@ -24,8 +24,10 @@ extern bool tap_toggling;
extern bool swap_hands;
#endif
-static bool watchdog_ping_done = false;
-static uint32_t watchdog_timer = 0;
+#if defined(SPLIT_WATCHDOG_TIMEOUT)
+static bool watchdog_ping_done = false;
+static uint32_t watchdog_timer = 0;
+#endif
extern userspace_config_t userspace_config;
extern bool host_driver_disabled;
@@ -51,20 +53,35 @@ void user_config_sync(uint8_t initiator2target_buffer_size, const void* initiato
}
}
+#if defined(SPLIT_WATCHDOG_TIMEOUT)
void watchdog_handler(uint8_t in_buflen, const void* in_data, uint8_t out_buflen, void* out_data) { watchdog_ping_done = true; }
+#endif
+#ifdef OLED_ENABLE
+#include "oled/oled_stuff.h"
+void keylogger_string_sync(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) {
+ if (initiator2target_buffer_size == OLED_KEYLOGGER_LENGTH) {
+ memcpy(&keylog_str, initiator2target_buffer, initiator2target_buffer_size);
+ }
+}
+#endif
void keyboard_post_init_transport_sync(void) {
// Register keyboard state sync split transaction
transaction_register_rpc(RPC_ID_USER_STATE_SYNC, user_state_sync);
transaction_register_rpc(RPC_ID_USER_KEYMAP_SYNC, user_keymap_sync);
transaction_register_rpc(RPC_ID_USER_CONFIG_SYNC, user_config_sync);
+#ifdef OLED_ENABLE
+ transaction_register_rpc(RPC_ID_USER_KEYLOG_STR, keylogger_string_sync);
+#endif
-#ifdef __AVR__
+#if defined(SPLIT_WATCHDOG_TIMEOUT)
+# if defined(PROTOCOL_LUFA)
wdt_disable();
-#endif
+# endif
transaction_register_rpc(RPC_ID_USER_WATCHDOG_SYNC, watchdog_handler);
watchdog_timer = timer_read32();
+#endif
}
void user_transport_update(void) {
@@ -107,9 +124,12 @@ void user_transport_update(void) {
void user_transport_sync(void) {
if (is_keyboard_master()) {
// Keep track of the last state, so that we can tell if we need to propagate to slave
- static uint16_t last_keymap = 0;
- static uint32_t last_config = 0, last_sync[3], last_user_state = 0;
- bool needs_sync = false;
+ static uint16_t last_keymap = 0;
+ static uint32_t last_config = 0, last_sync[4], last_user_state = 0;
+ bool needs_sync = false;
+#ifdef OLED_ENABLE
+ static char keylog_temp[OLED_KEYLOGGER_LENGTH] = { 0 };
+#endif
// Check if the state values are different
if (memcmp(&transport_user_state, &last_user_state, sizeof(transport_user_state))) {
@@ -164,9 +184,30 @@ void user_transport_sync(void) {
if (transaction_rpc_send(RPC_ID_USER_CONFIG_SYNC, sizeof(transport_userspace_config), &transport_userspace_config)) {
last_sync[2] = timer_read32();
}
+ needs_sync = false;
+ }
+
+#ifdef OLED_ENABLE
+ // Check if the state values are different
+ if (memcmp(&keylog_str, &keylog_temp, OLED_KEYLOGGER_LENGTH)) {
+ needs_sync = true;
+ memcpy(&keylog_temp, &keylog_str, OLED_KEYLOGGER_LENGTH);
+ }
+ if (timer_elapsed32(last_sync[3]) > 250) {
+ needs_sync = true;
+ }
+
+ // Perform the sync if requested
+ if (needs_sync) {
+ if (transaction_rpc_send(RPC_ID_USER_KEYLOG_STR, OLED_KEYLOGGER_LENGTH, &keylog_str)) {
+ last_sync[3] = timer_read32();
+ }
+ needs_sync = false;
}
+#endif
}
+#if defined(SPLIT_WATCHDOG_TIMEOUT)
if (!watchdog_ping_done) {
if (is_keyboard_master()) {
if (timer_elapsed32(watchdog_timer) > 100) {
@@ -180,16 +221,14 @@ void user_transport_sync(void) {
}
} else {
if (timer_elapsed32(watchdog_timer) > 3500) {
-#ifdef __AVR__
- wdt_enable(WDTO_250MS);
-#else
- NVIC_SystemReset();
-#endif
+ software_reset();
while (1) {
}
}
}
}
+#endif
+
}
void housekeeping_task_user(void) {
diff --git a/users/drashna/split/transport_sync.h b/users/drashna/split/transport_sync.h
index 6b6f0c388b..884586dfdd 100644
--- a/users/drashna/split/transport_sync.h
+++ b/users/drashna/split/transport_sync.h
@@ -4,6 +4,10 @@
#pragma once
#include "drashna.h"
+#ifdef OLED_ENABLE
+# include "oled/oled_stuff.h"
+extern char keylog_str[OLED_KEYLOGGER_LENGTH];
+#endif
typedef union {
uint32_t raw;