summaryrefslogtreecommitdiff
path: root/keyboards/handwired
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2021-11-14 22:03:24 -0800
committerGitHub <noreply@github.com>2021-11-14 22:03:24 -0800
commit56e3f06a26851976e559aacf7a096c61403304be (patch)
tree1e9ec98ad239fdd241e77ac4c4822fc2721a9cea /keyboards/handwired
parent462c3a615113e84ac3ca837a5caeb928c0ec8505 (diff)
Rework and expand Pointing Device support (#14343)
Co-authored-by: Dasky <32983009+daskygit@users.noreply.github.com>
Diffstat (limited to 'keyboards/handwired')
-rw-r--r--keyboards/handwired/tractyl_manuform/5x6_right/config.h1
-rw-r--r--keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c11
-rw-r--r--keyboards/handwired/tractyl_manuform/5x6_right/rules.mk4
-rw-r--r--keyboards/handwired/tractyl_manuform/tm_sync.c3
-rw-r--r--keyboards/handwired/tractyl_manuform/tractyl_manuform.c81
5 files changed, 24 insertions, 76 deletions
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/config.h b/keyboards/handwired/tractyl_manuform/5x6_right/config.h
index ce35197f71..6f702bd59e 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/config.h
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/config.h
@@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DIODE_DIRECTION COL2ROW
#define ROTATIONAL_TRANSFORM_ANGLE -25
+#define POINTING_DEVICE_INVERT_X
/* Bootmagic Lite key configuration */
#define BOOTMAGIC_LITE_ROW 0
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 5bfc21fd14..1275950766 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/keymaps/drashna/keymap.c
@@ -174,7 +174,11 @@ bool tap_toggling = false;
# define TAP_CHECK TAPPING_TERM
# endif
-void process_mouse_user(report_mouse_t* mouse_report, int8_t x, int8_t y) {
+report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) {
+ int8_t x = mouse_report.x, y = mouse_report.y;
+ mouse_report.x = 0;
+ mouse_report.y = 0;
+
if (x != 0 && y != 0) {
mouse_timer = timer_read();
# ifdef OLED_ENABLE
@@ -185,13 +189,14 @@ void process_mouse_user(report_mouse_t* mouse_report, int8_t x, int8_t y) {
x = (x > 0 ? x * x / 16 + x : -x * x / 16 + x);
y = (y > 0 ? y * y / 16 + y : -y * y / 16 + y);
}
- mouse_report->x = x;
- mouse_report->y = y;
+ mouse_report.x = x;
+ mouse_report.y = y;
if (!layer_state_is(_MOUSE)) {
layer_on(_MOUSE);
}
}
}
+ return mouse_report;
}
void matrix_scan_keymap(void) {
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/rules.mk b/keyboards/handwired/tractyl_manuform/5x6_right/rules.mk
index c9bc2dbb99..699e826485 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/rules.mk
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/rules.mk
@@ -16,11 +16,11 @@ AUDIO_ENABLE = no # Audio output
SWAP_HANDS_ENABLE = yes
POINTING_DEVICE_ENABLE = yes
+POINTING_DEVICE_DRIVER = pmw3360
MOUSE_SHARED_EP = no
SPLIT_KEYBOARD = yes
-SRC += drivers/sensors/pmw3360.c
-QUANTUM_LIB_SRC += spi_master.c tm_sync.c
+QUANTUM_LIB_SRC += tm_sync.c
DEFAULT_FOLDER = handwired/tractyl_manuform/5x6_right/teensy2pp
diff --git a/keyboards/handwired/tractyl_manuform/tm_sync.c b/keyboards/handwired/tractyl_manuform/tm_sync.c
index 1cb3549469..4739af1e76 100644
--- a/keyboards/handwired/tractyl_manuform/tm_sync.c
+++ b/keyboards/handwired/tractyl_manuform/tm_sync.c
@@ -17,7 +17,6 @@
#include "tractyl_manuform.h"
#include "transactions.h"
#include <string.h>
-#include "drivers/sensors/pmw3360.h"
kb_config_data_t kb_config;
kb_mouse_report_t sync_mouse_report;
@@ -82,6 +81,6 @@ void housekeeping_task_sync(void) {
void trackball_set_cpi(uint16_t cpi) {
kb_config.device_cpi = cpi;
if (!is_keyboard_left()) {
- pmw_set_cpi(cpi);
+ pointing_device_set_cpi(cpi);
}
}
diff --git a/keyboards/handwired/tractyl_manuform/tractyl_manuform.c b/keyboards/handwired/tractyl_manuform/tractyl_manuform.c
index d851528ffb..5f476fcc98 100644
--- a/keyboards/handwired/tractyl_manuform/tractyl_manuform.c
+++ b/keyboards/handwired/tractyl_manuform/tractyl_manuform.c
@@ -34,55 +34,7 @@ keyboard_config_t keyboard_config;
uint16_t dpi_array[] = TRACKBALL_DPI_OPTIONS;
#define DPI_OPTION_SIZE (sizeof(dpi_array) / sizeof(uint16_t))
-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, int8_t x, int8_t y) {
- mouse_report->x = x;
- mouse_report->y = y;
-}
-
-__attribute__((weak)) void process_mouse(void) {
- report_pmw_t data = pmw_read_burst();
- // Reset timer if stopped moving
- if (!data.isMotion) {
- if (MotionStart != 0) MotionStart = 0;
- return;
- }
-
- if (data.isOnSurface) {
- // Set timer if new motion
- if (MotionStart == 0) {
- if (debug_mouse) dprintf("Starting motion.\n");
- MotionStart = timer_read();
- }
-
- if (debug_mouse) {
- dprintf("Delt] d: %d t: %u\n", abs(data.dx) + abs(data.dy), MotionStart);
- }
- if (debug_mouse) {
- dprintf("Pre ] X: %d, Y: %d\n", data.dx, data.dy);
- }
-#if defined(PROFILE_LINEAR)
- float scale = float(timer_elaspsed(MotionStart)) / 1000.0;
- data.dx *= scale;
- data.dy *= scale;
-#elif defined(PROFILE_INVERSE)
- // TODO
-#else
- // no post processing
-#endif
-
- // Wrap to HID size
- data.dx = constrain(data.dx, -127, 127);
- data.dy = constrain(data.dy, -127, 127);
- 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));
-
- sync_mouse_report.x = -data.dx;
- sync_mouse_report.y = data.dy;
- }
-}
bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
if (!process_record_user(keycode, record)) {
@@ -109,11 +61,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
#ifndef MOUSEKEY_ENABLE
if (IS_MOUSEKEY_BUTTON(keycode)) {
report_mouse_t currentReport = pointing_device_get_report();
- if (record->event.pressed) {
- currentReport.buttons |= 1 << (keycode - KC_MS_BTN1);
- } else {
- currentReport.buttons &= ~(1 << (keycode - KC_MS_BTN1));
- }
+ currentReport.buttons = pointing_device_handle_buttons(currentReport.buttons, record->event.pressed, keycode - KC_MS_BTN1);
pointing_device_set_report(currentReport);
pointing_device_send();
}
@@ -145,33 +93,28 @@ void keyboard_post_init_kb(void) {
}
#ifdef POINTING_DEVICE_ENABLE
-void pointing_device_init(void) {
- if (!is_keyboard_left()) {
- // initialize ball sensor
- pmw_spi_init();
- }
+void pointing_device_init_kb(void) {
trackball_set_cpi(dpi_array[keyboard_config.dpi_config]);
+ pointing_device_init_user();
}
-void pointing_device_task(void) {
- report_mouse_t mouse_report = pointing_device_get_report();
-
+report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) {
if (is_keyboard_left()) {
if (is_keyboard_master()) {
transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(sync_mouse_report), &sync_mouse_report);
- process_mouse_user(&mouse_report, sync_mouse_report.x, sync_mouse_report.y);
+ mouse_report.x = sync_mouse_report.x;
+ mouse_report.y = sync_mouse_report.y;
+ pointing_device_task_user(mouse_report);
}
} else {
- process_mouse();
if (is_keyboard_master()) {
- process_mouse_user(&mouse_report, sync_mouse_report.x, sync_mouse_report.y);
- sync_mouse_report.x = 0;
- sync_mouse_report.y = 0;
+ pointing_device_task_user(mouse_report);
+ } else {
+ sync_mouse_report.x = mouse_report.x;
+ sync_mouse_report.y = mouse_report.y;
}
}
-
- pointing_device_set_report(mouse_report);
- pointing_device_send();
+ return mouse_report;
}
#endif