summaryrefslogtreecommitdiff
path: root/keyboards/ploopyco/trackball_nano/keymaps/maddie
diff options
context:
space:
mode:
authorAidan Gauland <aidalgol@users.noreply.github.com>2022-06-03 04:37:28 +1200
committerGitHub <noreply@github.com>2022-06-02 09:37:28 -0700
commit7c3cb9916465c69655343e0e4294741588658140 (patch)
tree4532919100477e16440cd4d57b2a1f0a0406c9b0 /keyboards/ploopyco/trackball_nano/keymaps/maddie
parent7ff666340ca4de2447141b5327f758d52b4417cd (diff)
[Keymap] Fix maddie layout for ploopy/trackball_nano (#17213)
Diffstat (limited to 'keyboards/ploopyco/trackball_nano/keymaps/maddie')
-rw-r--r--keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c b/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c
index 2e3e1136bf..14a7804cc2 100644
--- a/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c
+++ b/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c
@@ -18,39 +18,42 @@
*/
#include QMK_KEYBOARD_H
+// Configuration options
+#define SCROLL_TIMEOUT 25
+#define DELTA_X_THRESHOLD 60
+#define DELTA_Y_THRESHOLD 15
+
// safe range starts at `PLOOPY_SAFE_RANGE` instead.
-uint8_t scroll_enabled = 0;
-uint8_t lock_state = 0;
-int8_t delta_x = 0;
-int8_t delta_y = 0;
+bool scroll_enabled = false;
+bool lock_state = false;
// Dummy
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {{{ KC_NO }}};
-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) {
if (scroll_enabled) {
- delta_x += x;
- delta_y += y;
+ delta_x += mouse_report.x;
+ delta_y += mouse_report.y;
- if (delta_x > 60) {
- mouse_report->h = 1;
- delta_x = 0;
- } else if (delta_x < -60) {
- mouse_report->h = -1;
- delta_x = 0;
- }
+ if (delta_x > DELTA_X_THRESHOLD) {
+ mouse_report.h = 1;
+ delta_x = 0;
+ } else if (delta_x < -DELTA_X_THRESHOLD) {
+ mouse_report.h = -1;
+ delta_x = 0;
+ }
- if (delta_y > 15) {
- mouse_report->v = -1;
- delta_y = 0;
- } else if (delta_y < -15) {
- mouse_report->v = 1;
- delta_y = 0;
- }
- } else {
- mouse_report->x = x;
- mouse_report->y = y;
+ if (delta_y > DELTA_Y_THRESHOLD) {
+ mouse_report.v = -1;
+ delta_y = 0;
+ } else if (delta_y < -DELTA_Y_THRESHOLD) {
+ mouse_report.v = 1;
+ delta_y = 0;
+ }
+ mouse_report.x = 0;
+ mouse_report.y = 0;
}
+ return mouse_report;
}
void keyboard_post_init_user(void) {
@@ -61,7 +64,7 @@ bool led_update_user(led_t led_state) {
static uint8_t lock_count = 0;
static uint16_t scroll_timer = 0;
- if (timer_elapsed(scroll_timer) > 25) {
+ if (timer_elapsed(scroll_timer) > SCROLL_TIMEOUT) {
scroll_timer = timer_read();
lock_count = 0;
}
@@ -72,8 +75,6 @@ bool led_update_user(led_t led_state) {
if (lock_count == 2) {
scroll_enabled = !scroll_enabled;
lock_count = 0;
- delta_x = 0;
- delta_y = 0;
}
}