From e5b309a69f34d4e5a3a2a6b8732303c81cf5db01 Mon Sep 17 00:00:00 2001 From: Maddie O'Brien Date: Tue, 25 May 2021 23:42:29 -0700 Subject: [PATCH 1/5] Create readme.md --- keyboards/ploopyco/trackball_nano/keymaps/maddie/readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 keyboards/ploopyco/trackball_nano/keymaps/maddie/readme.md diff --git a/keyboards/ploopyco/trackball_nano/keymaps/maddie/readme.md b/keyboards/ploopyco/trackball_nano/keymaps/maddie/readme.md new file mode 100644 index 000000000000..3a597e38d812 --- /dev/null +++ b/keyboards/ploopyco/trackball_nano/keymaps/maddie/readme.md @@ -0,0 +1 @@ +toggles scroll mode when numlock is double-tapped within 25ms. add a macro or something, unless you have ungodly fast fingers. From d400640c866ba7c666ca4053804ae6e17bf35e65 Mon Sep 17 00:00:00 2001 From: Maddie O'Brien Date: Tue, 25 May 2021 23:45:42 -0700 Subject: [PATCH 2/5] Create keymap.c --- .../trackball_nano/keymaps/maddie/keymap.c | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c diff --git a/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c b/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c new file mode 100644 index 000000000000..6b844d6559a2 --- /dev/null +++ b/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c @@ -0,0 +1,84 @@ +/* Copyright 2021 Colin Lam (Ploopy Corporation) + * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) + * Copyright 2019 Sunjun Kim + * Copyright 2019 Hiroyuki Okada + * + * 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 . + */ +#include QMK_KEYBOARD_H + +// safe range starts at `PLOOPY_SAFE_RANGE` instead. +uint8_t scroll_enabled = 0; +uint8_t lock_state = 5; +int16_t delta_x = 0; +int16_t delta_y = 0; + +void process_mouse_user(report_mouse_t *mouse_report, int16_t x, int16_t y) { + if (scroll_enabled) { + mouse_report->x = 0; + mouse_report->y = 0; + delta_x += x; + delta_y += 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_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; + } +} + +void keyboard_post_init_user(void) { + lock_state = host_keyboard_led_state().num_lock; +} + +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) { + scroll_timer = timer_read(); + lock_count = 0; + } + + if (led_state.num_lock != lock_state) { + lock_count++; + + if (lock_count == 2) { + scroll_enabled = !scroll_enabled; + lock_count = 0; + delta_x = 0; + delta_y = 0; + } + } + + lock_state = led_state.num_lock; + return true; +} From f23110e7bf1ed849abe7879108963b4e3661177e Mon Sep 17 00:00:00 2001 From: Maddie O'Brien Date: Tue, 25 May 2021 23:50:55 -0700 Subject: [PATCH 3/5] revert debug --- keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c b/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c index 6b844d6559a2..5873c8249443 100644 --- a/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c +++ b/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c @@ -20,7 +20,7 @@ // safe range starts at `PLOOPY_SAFE_RANGE` instead. uint8_t scroll_enabled = 0; -uint8_t lock_state = 5; +uint8_t lock_state = 0; int16_t delta_x = 0; int16_t delta_y = 0; From adab1e458ca71730e71bb5b5038a88b27200fb14 Mon Sep 17 00:00:00 2001 From: Maddie O'Brien Date: Wed, 26 May 2021 00:14:30 -0700 Subject: [PATCH 4/5] keymap.c formatting --- .../ploopyco/trackball_nano/keymaps/maddie/keymap.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c b/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c index 5873c8249443..ed444ce5a69e 100644 --- a/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c +++ b/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c @@ -34,8 +34,7 @@ void process_mouse_user(report_mouse_t *mouse_report, int16_t x, int16_t y) { if (delta_x > 60) { mouse_report->h = 1; delta_x = 0; - } - else if (delta_x < -60) { + } else if (delta_x < -60) { mouse_report->h = -1; delta_x = 0; } @@ -43,13 +42,11 @@ void process_mouse_user(report_mouse_t *mouse_report, int16_t x, int16_t y) { if (delta_y > 15) { mouse_report->v = -1; delta_y = 0; - } - else if (delta_y < -15) { + } else if (delta_y < -15) { mouse_report->v = 1; delta_y = 0; } - } - else { + } else { mouse_report->x = x; mouse_report->y = y; } From b5b37c4d6f564b6b7c9a8be75b55a317e01b2dda Mon Sep 17 00:00:00 2001 From: Maddie O'Brien Date: Wed, 26 May 2021 20:53:17 -0700 Subject: [PATCH 5/5] Update keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c Co-authored-by: Drashna Jaelre --- keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c b/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c index ed444ce5a69e..6f568ecf5118 100644 --- a/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c +++ b/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c @@ -26,8 +26,6 @@ int16_t delta_y = 0; void process_mouse_user(report_mouse_t *mouse_report, int16_t x, int16_t y) { if (scroll_enabled) { - mouse_report->x = 0; - mouse_report->y = 0; delta_x += x; delta_y += y;