summaryrefslogtreecommitdiff
path: root/keyboards/handwired/tractyl_manuform/tm_sync.c
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2021-09-08 16:52:43 -0700
committerGitHub <noreply@github.com>2021-09-08 16:52:43 -0700
commit4294aa0f1ee546c74a72bad3e556d7ee4e020a88 (patch)
tree1e7bf4d90c9f154f333985cc22103a361d4dc545 /keyboards/handwired/tractyl_manuform/tm_sync.c
parent8f8411a98a60ffe9e8410e892bff946d9122d3a9 (diff)
downloadqmk_firmware-4294aa0f1ee546c74a72bad3e556d7ee4e020a88.tar.gz
qmk_firmware-4294aa0f1ee546c74a72bad3e556d7ee4e020a88.zip
[Keyboard] Tractyl Manuform - configuration updates (#14314)
* [Keyboard] Tractyl Manuform - configuration updates * Update readmes * Add more details * Fix issues with encoder pins * Additional fixes for pin config * Fix up some comments
Diffstat (limited to 'keyboards/handwired/tractyl_manuform/tm_sync.c')
-rw-r--r--keyboards/handwired/tractyl_manuform/tm_sync.c66
1 files changed, 17 insertions, 49 deletions
diff --git a/keyboards/handwired/tractyl_manuform/tm_sync.c b/keyboards/handwired/tractyl_manuform/tm_sync.c
index 2a8847b3ef..1cb3549469 100644
--- a/keyboards/handwired/tractyl_manuform/tm_sync.c
+++ b/keyboards/handwired/tractyl_manuform/tm_sync.c
@@ -20,43 +20,40 @@
#include "drivers/sensors/pmw3360.h"
kb_config_data_t kb_config;
-kb_pointer_data_t kb_pointer;
+kb_mouse_report_t sync_mouse_report;
+
+void kb_pointer_sync_handler(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) {
+ if (target2initiator_buffer_size == sizeof(sync_mouse_report)) {
+ memcpy(target2initiator_buffer, &sync_mouse_report, sizeof(sync_mouse_report));
+ }
+ sync_mouse_report.x = 0;
+ sync_mouse_report.y = 0;
+}
void kb_config_sync_handler(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) {
if (initiator2target_buffer_size == sizeof(kb_config)) {
memcpy(&kb_config, initiator2target_buffer, sizeof(kb_config));
}
-}
-void kb_pointer_sync_handler(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) {
- if (target2initiator_buffer_size == sizeof(kb_pointer)) {
- memcpy(target2initiator_buffer, &kb_pointer, sizeof(kb_pointer));
+
+ static uint16_t cpi = 0;
+ // Check if the state values are different
+ if (cpi != kb_config.device_cpi) {
+ cpi = kb_config.device_cpi;
}
}
void keyboard_pre_init_sync(void) {
memset(&kb_config, 0, sizeof(kb_config));
- memset(&kb_pointer, 0, sizeof(kb_pointer));
+ memset(&sync_mouse_report, 0, sizeof(sync_mouse_report));
}
-void keyboard_post_init_kb(void) {
+void keyboard_post_init_sync(void) {
// Register keyboard state sync split transaction
transaction_register_rpc(RPC_ID_KB_CONFIG_SYNC, kb_config_sync_handler);
transaction_register_rpc(RPC_ID_POINTER_STATE_SYNC, kb_pointer_sync_handler);
-
- keyboard_post_init_user();
}
-void kb_config_update(void) {
- if (is_keyboard_master()) {
- static uint16_t cpi = 0;
- if (cpi != kb_config.device_cpi) {
- cpi = kb_config.device_cpi;
- pmw_set_cpi(cpi);
- }
- }
-}
-
-void kb_config_sync(void) {
+void housekeeping_task_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 kb_config_data_t last_kb_config;
@@ -82,35 +79,6 @@ void kb_config_sync(void) {
}
}
-void kb_pointer_sync(void) {
- if (is_keyboard_master() && is_keyboard_left()) {
- // Keep track of the last state, so that we can tell if we need to propagate to slave
- static uint32_t last_sync = 0;
-
- // Perform the sync if requested
- if (timer_elapsed32(last_sync) >= 5) {
- if (transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(kb_pointer), &kb_pointer)) {
- last_sync = timer_read32();
- }
- }
- }
-}
-
-void housekeeping_task_kb(void) {
- // Update kb_config so we can send to slave
- kb_config_update();
- // Data sync from master to slave
- kb_config_sync();
- kb_pointer_sync();
-}
-
-void kb_pointer_sync_send(int8_t x, int8_t y) {
- kb_pointer.mouse_x = x;
- kb_pointer.mouse_y = y;
-}
-
-kb_pointer_data_t kb_pointer_sync_get(void) { return (kb_pointer_data_t){.mouse_x = kb_pointer.mouse_x, .mouse_y = kb_pointer.mouse_y}; }
-
void trackball_set_cpi(uint16_t cpi) {
kb_config.device_cpi = cpi;
if (!is_keyboard_left()) {