summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboards/handwired/tractyl_manuform/5x6_right/config.h1
-rw-r--r--keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c2
-rw-r--r--keyboards/handwired/tractyl_manuform/5x6_right/rules.mk2
-rw-r--r--keyboards/handwired/tractyl_manuform/config.h5
-rw-r--r--keyboards/handwired/tractyl_manuform/tm_sync.c180
-rw-r--r--keyboards/handwired/tractyl_manuform/tractyl_manuform.c56
-rw-r--r--keyboards/handwired/tractyl_manuform/tractyl_manuform.h15
-rw-r--r--users/drashna/oled/oled_stuff.c13
-rw-r--r--users/drashna/oled/oled_stuff.h2
9 files changed, 65 insertions, 211 deletions
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/config.h b/keyboards/handwired/tractyl_manuform/5x6_right/config.h
index d7618912f7..b9d8e86c09 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/config.h
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/config.h
@@ -52,5 +52,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define OLED_DISPLAY_128X64
-#define POINTING_DEVICE_TASK_THROTTLE
#define POINTING_DEVICE_RIGHT
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c b/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c
index 958f694172..65f8a5260d 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c
@@ -301,7 +301,7 @@ void oled_driver_render_logo_left(void) {
# endif
oled_set_cursor(6, 3);
# if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right)
- render_pointing_dpi_status(0);
+ render_pointing_dpi_status(kb_config_data.device_cpi, 0);
# endif
oled_set_cursor(0, 4);
}
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/rules.mk b/keyboards/handwired/tractyl_manuform/5x6_right/rules.mk
index 37bbbb4dae..a689be3dd5 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/rules.mk
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/rules.mk
@@ -18,6 +18,4 @@ MOUSE_SHARED_EP = yes
SPLIT_KEYBOARD = yes
-QUANTUM_LIB_SRC += tm_sync.c
-
DEFAULT_FOLDER = handwired/tractyl_manuform/5x6_right/teensy2pp
diff --git a/keyboards/handwired/tractyl_manuform/config.h b/keyboards/handwired/tractyl_manuform/config.h
index cc8a7546f4..15c8102b8f 100644
--- a/keyboards/handwired/tractyl_manuform/config.h
+++ b/keyboards/handwired/tractyl_manuform/config.h
@@ -39,4 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define NO_ACTION_MACRO
#define NO_ACTION_FUNCTION
-#define SPLIT_TRANSACTION_IDS_KB RPC_ID_KB_CONFIG_SYNC, RPC_ID_POINTER_STATE_SYNC
+#define SPLIT_POINTING_ENABLE
+#define POINTING_DEVICE_TASK_THROTTLE_MS 1
+
+#define SPLIT_TRANSACTION_IDS_KB RPC_ID_KB_CONFIG_SYNC
diff --git a/keyboards/handwired/tractyl_manuform/tm_sync.c b/keyboards/handwired/tractyl_manuform/tm_sync.c
deleted file mode 100644
index 549a17a22f..0000000000
--- a/keyboards/handwired/tractyl_manuform/tm_sync.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
- * Copyright 2021 Dasky (@daskygit)
-
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include QMK_KEYBOARD_H
-#include "pointing_device.h"
-#include "transactions.h"
-#include <string.h>
-#ifdef MOUSEKEY_ENABLE
-# include "mousekey.h"
-#endif
-
-// typedef struct {
-// uint16_t device_cpi;
-// } kb_config_data_t;
-
-kb_config_data_t kb_config;
-static report_mouse_t shared_mouse_report;
-extern const pointing_device_driver_t pointing_device_driver;
-
-void kb_pointer_sync_handler(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) {
- shared_mouse_report = pointing_device_driver.get_report(shared_mouse_report);
- memcpy(target2initiator_buffer, &shared_mouse_report, sizeof(report_mouse_t));
- shared_mouse_report.x = 0;
- shared_mouse_report.y = 0;
- shared_mouse_report.h = 0;
- shared_mouse_report.v = 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));
- }
-
- static uint16_t cpi = 0;
- // Check if the state values are different
- if (cpi != kb_config.device_cpi) {
- cpi = kb_config.device_cpi;
- if (!is_keyboard_left()) {
- pointing_device_set_cpi(cpi);
- }
- }
-}
-
-void keyboard_pre_init_sync(void) {
- memset(&kb_config, 0, sizeof(kb_config));
- memset(&shared_mouse_report, 0, sizeof(shared_mouse_report));
-}
-
-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);
-}
-
-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;
- static uint32_t last_sync = 0;
- bool needs_sync = false;
-
- // Check if the state values are different
- if (memcmp(&kb_config, &last_kb_config, sizeof(kb_config))) {
- needs_sync = true;
- memcpy(&last_kb_config, &kb_config, sizeof(kb_config));
- }
- // Send to slave every 500ms regardless of state change
- if (timer_elapsed32(last_sync) > 500) {
- needs_sync = true;
- }
-
- // Perform the sync if requested
- if (needs_sync) {
- if (transaction_rpc_send(RPC_ID_KB_CONFIG_SYNC, sizeof(kb_config), &kb_config)) {
- last_sync = timer_read32();
- }
- }
- }
-}
-
-void trackball_set_cpi(uint16_t cpi) {
- kb_config.device_cpi = cpi;
- if (!is_keyboard_left()) {
- pointing_device_set_cpi(cpi);
- }
-}
-
-void pointing_device_task(void) {
- if (!is_keyboard_master()) {
- return;
- }
-
-#if defined(POINTING_DEVICE_TASK_THROTTLE)
- static uint32_t last_exec = 0;
- if (timer_elapsed32(last_exec) < 1) {
- return;
- }
- last_exec = timer_read32();
-#endif
-
- report_mouse_t local_report = pointing_device_get_report();
-
- // Gather report info
-#ifdef POINTING_DEVICE_MOTION_PIN
- if (!readPin(POINTING_DEVICE_MOTION_PIN))
-#endif
-#if defined(POINTING_DEVICE_COMBINED)
- local_report = pointing_device_driver.get_report(local_report);
- transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(report_mouse_t), &shared_mouse_report);
- local_report.x = local_report.x | shared_mouse_report.x;
- local_report.y = local_report.y | shared_mouse_report.y;
- local_report.h = local_report.h | shared_mouse_report.h;
- local_report.v = local_report.v | shared_mouse_report.v;
-#elif defined(POINTING_DEVICE_LEFT)
- if (is_keyboard_left()) {
- local_report = pointing_device_driver.get_report(local_report);
- } else {
- transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(report_mouse_t), &local_report);
- }
-#elif defined(POINTING_DEVICE_RIGHT)
- if (!is_keyboard_left()) {
- local_report = pointing_device_driver.get_report(local_report);
- } else {
- transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(report_mouse_t), &local_report);
- }
-#else
-# error "You need to define the side(s) the pointing device is on. POINTING_DEVICE_COMBINED / POINTING_DEVICE_LEFT / POINTING_DEVICE_RIGHT"
-#endif
-
- // Support rotation of the sensor data
-#if defined(POINTING_DEVICE_ROTATION_90) || defined(POINTING_DEVICE_ROTATION_180) || defined(POINTING_DEVICE_ROTATION_270)
- int8_t x = local_report.x, y = local_report.y;
-# if defined(POINTING_DEVICE_ROTATION_90)
- local_report.x = y;
- local_report.y = -x;
-# elif defined(POINTING_DEVICE_ROTATION_180)
- local_report.x = -x;
- local_report.y = -y;
-# elif defined(POINTING_DEVICE_ROTATION_270)
- local_report.x = -y;
- local_report.y = x;
-# else
-# error "How the heck did you get here?!"
-# endif
-#endif
- // Support Inverting the X and Y Axises
-#if defined(POINTING_DEVICE_INVERT_X)
- local_report.x = -local_report.x;
-#endif
-#if defined(POINTING_DEVICE_INVERT_Y)
- local_report.y = -local_report.y;
-#endif
-
- // allow kb to intercept and modify report
- local_report = pointing_device_task_kb(local_report);
- // combine with mouse report to ensure that the combined is sent correctly
-#ifdef MOUSEKEY_ENABLE
- report_mouse_t mousekey_report = mousekey_get_report();
- local_report.buttons = local_report.buttons | mousekey_report.buttons;
-#endif
-#if defined(POINTING_DEVICE_COMBINED)
- local_report.buttons = local_report.buttons | shared_mouse_report.buttons;
-#endif
- pointing_device_set_report(local_report);
- pointing_device_send();
-}
diff --git a/keyboards/handwired/tractyl_manuform/tractyl_manuform.c b/keyboards/handwired/tractyl_manuform/tractyl_manuform.c
index 6095bfb7e2..5bdc57ca09 100644
--- a/keyboards/handwired/tractyl_manuform/tractyl_manuform.c
+++ b/keyboards/handwired/tractyl_manuform/tractyl_manuform.c
@@ -17,7 +17,6 @@
#include "tractyl_manuform.h"
#include "transactions.h"
#include <string.h>
-#include "drivers/sensors/pmw3360.h"
#ifndef TRACKBALL_DPI_OPTIONS
# define TRACKBALL_DPI_OPTIONS \
@@ -31,11 +30,10 @@
#endif
keyboard_config_t keyboard_config;
+kb_config_data_t kb_config_data;
uint16_t dpi_array[] = TRACKBALL_DPI_OPTIONS;
#define DPI_OPTION_SIZE (sizeof(dpi_array) / sizeof(uint16_t))
-
-
bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
if (!process_record_user(keycode, record)) {
return false;
@@ -49,7 +47,8 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
keyboard_config.dpi_config = (keyboard_config.dpi_config + 1) % DPI_OPTION_SIZE;
}
eeconfig_update_kb(keyboard_config.raw);
- trackball_set_cpi(dpi_array[keyboard_config.dpi_config]);
+ kb_config_data.device_cpi = dpi_array[keyboard_config.dpi_config];
+ pointing_device_set_cpi(kb_config_data.device_cpi);
}
#endif
@@ -69,7 +68,6 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
return true;
}
-__attribute__((weak)) void keyboard_pre_init_sync(void) {}
__attribute__((weak)) void keyboard_pre_init_sub(void) {}
void keyboard_pre_init_kb(void) {
// debug_enable = true;
@@ -83,20 +81,22 @@ void keyboard_pre_init_kb(void) {
writePin(DEBUG_LED_PIN, !debug_enable);
#endif
+ memset(&kb_config_data, 0, sizeof(kb_config_data));
+
keyboard_pre_init_sub();
- keyboard_pre_init_sync();
keyboard_pre_init_user();
}
-__attribute__((weak)) void keyboard_post_init_sync(void) {}
-void keyboard_post_init_kb(void) {
- keyboard_post_init_sync();
+void keyboard_post_init_kb(void) {
+ transaction_register_rpc(RPC_ID_KB_CONFIG_SYNC, kb_config_sync_handler);
+
keyboard_post_init_user();
}
#ifdef POINTING_DEVICE_ENABLE
void pointing_device_init_kb(void) {
- trackball_set_cpi(dpi_array[keyboard_config.dpi_config]);
+ kb_config_data.device_cpi = dpi_array[keyboard_config.dpi_config];
+ pointing_device_set_cpi(kb_config_data.device_cpi);
pointing_device_init_user();
}
@@ -111,7 +111,8 @@ report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) {
void eeconfig_init_kb(void) {
keyboard_config.dpi_config = TRACKBALL_DPI_DEFAULT;
#ifdef POINTING_DEVICE_ENABLE
- trackball_set_cpi(dpi_array[keyboard_config.dpi_config]);
+ kb_config_data.device_cpi = dpi_array[keyboard_config.dpi_config];
+ pointing_device_set_cpi(kb_config_data.device_cpi);
#endif
eeconfig_update_kb(keyboard_config.raw);
eeconfig_init_user();
@@ -135,12 +136,39 @@ void matrix_scan_kb(void) {
matrix_scan_user();
}
-__attribute__((weak)) void housekeeping_task_sync(void) {}
-void housekeeping_task_kb(void) {
- housekeeping_task_sync();
+void housekeeping_task_kb(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;
+ static uint32_t last_sync = 0;
+ bool needs_sync = false;
+
+ // Check if the state values are different
+ if (memcmp(&kb_config_data, &last_kb_config, sizeof(kb_config_data))) {
+ needs_sync = true;
+ memcpy(&last_kb_config, &kb_config_data, sizeof(kb_config_data));
+ }
+ // Send to slave every 500ms regardless of state change
+ if (timer_elapsed32(last_sync) > 500) {
+ needs_sync = true;
+ }
+
+ // Perform the sync if requested
+ if (needs_sync) {
+ if (transaction_rpc_send(RPC_ID_KB_CONFIG_SYNC, sizeof(kb_config_data), &kb_config_data)) {
+ last_sync = timer_read32();
+ }
+ }
+ }
// no need for user function, is called already
}
+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_data)) {
+ memcpy(&kb_config_data, initiator2target_buffer, sizeof(kb_config_data));
+ }
+}
+
#ifdef POINTING_DEVICE_ENABLE
void matrix_power_up(void) { pointing_device_task(); }
#endif
diff --git a/keyboards/handwired/tractyl_manuform/tractyl_manuform.h b/keyboards/handwired/tractyl_manuform/tractyl_manuform.h
index 6aa40fc18b..3f8aca4551 100644
--- a/keyboards/handwired/tractyl_manuform/tractyl_manuform.h
+++ b/keyboards/handwired/tractyl_manuform/tractyl_manuform.h
@@ -32,21 +32,26 @@ typedef union {
};
} keyboard_config_t;
+typedef union {
+ uint32_t raw;
+ struct {
+ uint16_t device_cpi;
+ };
+} kb_config_data_t;
+
extern keyboard_config_t keyboard_config;
+extern kb_config_data_t kb_config_data;
enum ploopy_keycodes {
DPI_CONFIG = SAFE_RANGE,
KEYMAP_SAFE_RANGE,
};
-typedef struct {
- uint16_t device_cpi;
-} kb_config_data_t;
-
-void trackball_set_cpi(uint16_t cpi);
void matrix_init_sub_kb(void);
void matrix_scan_sub_kb(void);
void keyboard_pre_init_sync(void);
void keyboard_post_init_sync(void);
void housekeeping_task_sync(void);
+
+void kb_config_sync_handler(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer);
diff --git a/users/drashna/oled/oled_stuff.c b/users/drashna/oled/oled_stuff.c
index 9ee2cbfed8..8894814985 100644
--- a/users/drashna/oled/oled_stuff.c
+++ b/users/drashna/oled/oled_stuff.c
@@ -348,9 +348,8 @@ void render_wpm(uint8_t padding) {
#endif
}
-#if defined(KEYBOARD_handwired_tractyl_manuform) || defined(KEYBOARD_bastardkb_charybdis)
-extern kb_config_data_t kb_config;
-void render_pointing_dpi_status(uint8_t padding) {
+#if defined(POINTING_DEVICE_ENABLE)
+void render_pointing_dpi_status(uint16_t cpi, uint8_t padding) {
oled_write_P(PSTR("CPI:"), false);
if (padding) {
for (uint8_t n = padding - 1; n > 0; n--) {
@@ -358,7 +357,7 @@ void render_pointing_dpi_status(uint8_t padding) {
}
}
- oled_write(get_u16_str(kb_config.device_cpi, ' '), false);
+ oled_write(get_u16_str(cpi, ' '), false);
}
#endif
@@ -381,8 +380,10 @@ __attribute__((weak)) void oled_driver_render_logo_left(void) {
render_wpm(0);
# endif
oled_write_P(PSTR(" "), false);
-# if defined(KEYBOARD_handwired_tractyl_manuform) || defined(KEYBOARD_bastardkb_charybdis)
- render_pointing_dpi_status(1);
+# if defined(KEYBOARD_handwired_tractyl_manuform)
+ render_pointing_dpi_status(kb_config_data.device_cpi, 1);
+# elif defined(KEYBOARD_bastardkb_charybdis)
+ render_pointing_dpi_status(, 1);
# endif
oled_set_cursor(0, 4);
#else
diff --git a/users/drashna/oled/oled_stuff.h b/users/drashna/oled/oled_stuff.h
index 8795684d6a..fd64b50874 100644
--- a/users/drashna/oled/oled_stuff.h
+++ b/users/drashna/oled/oled_stuff.h
@@ -33,7 +33,7 @@ void render_bootmagic_status(void);
void render_user_status(void);
void oled_driver_render_logo(void);
void render_wpm(uint8_t padding);
-void render_pointing_dpi_status(uint8_t padding);
+void render_pointing_dpi_status(uint16_t cpi, uint8_t padding);
void oled_driver_render_logo_left(void);
void oled_driver_render_logo_right(void);