summaryrefslogtreecommitdiff
path: root/keyboards/handwired/tractyl_manuform/tractyl_manuform.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/handwired/tractyl_manuform/tractyl_manuform.c')
-rw-r--r--keyboards/handwired/tractyl_manuform/tractyl_manuform.c78
1 files changed, 30 insertions, 48 deletions
diff --git a/keyboards/handwired/tractyl_manuform/tractyl_manuform.c b/keyboards/handwired/tractyl_manuform/tractyl_manuform.c
index e992c446cb..61a6740a2d 100644
--- a/keyboards/handwired/tractyl_manuform/tractyl_manuform.c
+++ b/keyboards/handwired/tractyl_manuform/tractyl_manuform.c
@@ -30,9 +30,6 @@
# define TRACKBALL_DPI_DEFAULT 0
#endif
-extern kb_runtime_config_t kb_state;
-extern kb_slave_data_t kb_slave;
-
keyboard_config_t keyboard_config;
uint16_t dpi_array[] = TRACKBALL_DPI_OPTIONS;
#define DPI_OPTION_SIZE (sizeof(dpi_array) / sizeof(uint16_t))
@@ -40,18 +37,20 @@ uint16_t dpi_array[] = TRACKBALL_DPI_OPTIONS;
bool BurstState = false; // init burst state for Trackball module
uint16_t MotionStart = 0; // Timer for accel, 0 is resting state
-__attribute__((weak)) void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y) {
+__attribute__((weak)) void process_mouse_user(report_mouse_t* mouse_report, int8_t x, int8_t y) {
mouse_report->x = x;
mouse_report->y = y;
}
-__attribute__((weak)) void process_mouse(report_mouse_t* mouse_report) {
+__attribute__((weak)) kb_pointer_data_t process_mouse(void) {
+ kb_pointer_data_t temp_data = {.mouse_x = 0, .mouse_y = 0};
+
report_pmw_t data = pmw_read_burst();
if (data.isOnSurface && data.isMotion) {
// Reset timer if stopped moving
if (!data.isMotion) {
if (MotionStart != 0) MotionStart = 0;
- return;
+ return temp_data;
}
// Set timer if new motion
@@ -78,9 +77,10 @@ __attribute__((weak)) void process_mouse(report_mouse_t* mouse_report) {
if (debug_mouse) dprintf("Cons] X: %d, Y: %d\n", data.dx, data.dy);
// dprintf("Elapsed:%u, X: %f Y: %\n", i, pgm_read_byte(firmware_data+i));
- mouse_report->x = -data.dx;
- mouse_report->y = data.dy;
+ temp_data.mouse_x = -data.dx;
+ temp_data.mouse_y = data.dy;
}
+ return temp_data;
}
bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
@@ -118,6 +118,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
return true;
}
+__attribute__((weak)) void keyboard_pre_init_sync(void) {}
// Hardware Setup
void keyboard_pre_init_kb(void) {
@@ -137,6 +138,7 @@ void keyboard_pre_init_kb(void) {
writePin(DEBUG_LED_PIN, debug_enable);
#endif
+ keyboard_pre_init_sync();
keyboard_pre_init_user();
}
@@ -149,11 +151,22 @@ void pointing_device_init(void) {
trackball_set_cpi(dpi_array[keyboard_config.dpi_config]);
}
-static bool has_report_changed(report_mouse_t new, report_mouse_t old) { return (new.buttons != old.buttons) || (new.x&& new.x != old.x) || (new.y&& new.y != old.y) || (new.h&& new.h != old.h) || (new.v&& new.v != old.v); }
-
void pointing_device_task(void) {
report_mouse_t mouse_report = pointing_device_get_report();
- if (!is_keyboard_left()) { process_mouse(&mouse_report); }
+ kb_pointer_data_t data = {.mouse_x = mouse_report.x, .mouse_y = mouse_report.y};
+ if (is_keyboard_left()) {
+ if (is_keyboard_master()) {
+ data = kb_pointer_sync_get();
+ process_mouse_user(&mouse_report, data.mouse_x, data.mouse_y);
+ }
+ } else {
+ data = process_mouse();
+ if (!is_keyboard_master()) {
+ kb_pointer_sync_send(data.mouse_x, data.mouse_y);
+ } else {
+ process_mouse_user(&mouse_report, data.mouse_x, data.mouse_y);
+ }
+ }
pointing_device_set_report(mouse_report);
pointing_device_send();
@@ -169,49 +182,18 @@ void eeconfig_init_kb(void) {
eeconfig_init_user();
}
+__attribute__((weak)) void matrix_init_sub_kb(void) {}
void matrix_init_kb(void) {
// is safe to just read DPI setting since matrix init
// comes before pointing device init.
keyboard_config.raw = eeconfig_read_kb();
if (keyboard_config.dpi_config > DPI_OPTION_SIZE) { eeconfig_init_kb(); }
+ matrix_init_sub_kb();
matrix_init_user();
}
-#ifdef POINTING_DEVICE_ENABLE
-void pointing_device_send(void) {
- static report_mouse_t old_report = {};
- report_mouse_t mouseReport = pointing_device_get_report();
- if (is_keyboard_master()) {
- int8_t x = mouseReport.x, y = mouseReport.y;
- mouseReport.x = 0;
- mouseReport.y = 0;
- process_mouse_user(&mouseReport, x, y);
- if (has_report_changed(mouseReport, old_report)) { host_mouse_send(&mouseReport); }
- } else {
- master_mouse_send(mouseReport.x, mouseReport.y);
- }
- mouseReport.x = 0;
- mouseReport.y = 0;
- mouseReport.v = 0;
- mouseReport.h = 0;
- old_report = mouseReport;
- pointing_device_set_report(mouseReport);
+__attribute__((weak)) void matrix_scan_sub_kb(void) {}
+void matrix_scan_kb(void) {
+ matrix_scan_sub_kb();
+ matrix_scan_user();
}
-#endif
-
-#ifdef POINTING_DEVICE_ENABLE
-void master_mouse_send(int8_t x, int8_t y) {
-#ifdef SPLIT_TRANSACTION_IDS_KB
- kb_slave.mouse_x += x;
- kb_slave.mouse_y += y;
-#endif
-}
-void trackball_set_cpi(uint16_t cpi) {
-#ifdef SPLIT_TRANSACTION_IDS_KB
- kb_state.device_cpi = cpi;
-#endif
- if (!is_keyboard_left()) {
- pmw_set_cpi(cpi);
- }
-}
-#endif