diff options
| author | Maddie O'Brien <hexadecatrienoic@users.noreply.github.com> | 2021-05-26 22:11:38 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-26 22:11:38 -0700 |
| commit | 6750733cda3b93213ef91e6653d615a054f7de90 (patch) | |
| tree | f89208b0fbfb94f22e0b19793a21358fd63ec0cc /keyboards/ploopyco | |
| parent | 975e42ed3c18311d8da4abd11deb42d504b1a8c5 (diff) | |
| download | qmk_firmware-6750733cda3b93213ef91e6653d615a054f7de90.tar.gz qmk_firmware-6750733cda3b93213ef91e6653d615a054f7de90.zip | |
Add keymap with scrolling mode for the Ploopy Nano trackball (#13013)
Co-authored-by: Drashna Jaelre <drashna@live.com>
Diffstat (limited to 'keyboards/ploopyco')
| -rw-r--r-- | keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c | 79 | ||||
| -rw-r--r-- | keyboards/ploopyco/trackball_nano/keymaps/maddie/readme.md | 1 |
2 files changed, 80 insertions, 0 deletions
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 000000000..6f568ecf5 --- /dev/null +++ b/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c | |||
| @@ -0,0 +1,79 @@ | |||
| 1 | /* Copyright 2021 Colin Lam (Ploopy Corporation) | ||
| 2 | * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> | ||
| 3 | * Copyright 2019 Sunjun Kim | ||
| 4 | * Copyright 2019 Hiroyuki Okada | ||
| 5 | * | ||
| 6 | * This program is free software: you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation, either version 2 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | */ | ||
| 19 | #include QMK_KEYBOARD_H | ||
| 20 | |||
| 21 | // safe range starts at `PLOOPY_SAFE_RANGE` instead. | ||
| 22 | uint8_t scroll_enabled = 0; | ||
| 23 | uint8_t lock_state = 0; | ||
| 24 | int16_t delta_x = 0; | ||
| 25 | int16_t delta_y = 0; | ||
| 26 | |||
| 27 | void process_mouse_user(report_mouse_t *mouse_report, int16_t x, int16_t y) { | ||
| 28 | if (scroll_enabled) { | ||
| 29 | delta_x += x; | ||
| 30 | delta_y += y; | ||
| 31 | |||
| 32 | if (delta_x > 60) { | ||
| 33 | mouse_report->h = 1; | ||
| 34 | delta_x = 0; | ||
| 35 | } else if (delta_x < -60) { | ||
| 36 | mouse_report->h = -1; | ||
| 37 | delta_x = 0; | ||
| 38 | } | ||
| 39 | |||
| 40 | if (delta_y > 15) { | ||
| 41 | mouse_report->v = -1; | ||
| 42 | delta_y = 0; | ||
| 43 | } else if (delta_y < -15) { | ||
| 44 | mouse_report->v = 1; | ||
| 45 | delta_y = 0; | ||
| 46 | } | ||
| 47 | } else { | ||
| 48 | mouse_report->x = x; | ||
| 49 | mouse_report->y = y; | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | void keyboard_post_init_user(void) { | ||
| 54 | lock_state = host_keyboard_led_state().num_lock; | ||
| 55 | } | ||
| 56 | |||
| 57 | bool led_update_user(led_t led_state) { | ||
| 58 | static uint8_t lock_count = 0; | ||
| 59 | static uint16_t scroll_timer = 0; | ||
| 60 | |||
| 61 | if (timer_elapsed(scroll_timer) > 25) { | ||
| 62 | scroll_timer = timer_read(); | ||
| 63 | lock_count = 0; | ||
| 64 | } | ||
| 65 | |||
| 66 | if (led_state.num_lock != lock_state) { | ||
| 67 | lock_count++; | ||
| 68 | |||
| 69 | if (lock_count == 2) { | ||
| 70 | scroll_enabled = !scroll_enabled; | ||
| 71 | lock_count = 0; | ||
| 72 | delta_x = 0; | ||
| 73 | delta_y = 0; | ||
| 74 | } | ||
| 75 | } | ||
| 76 | |||
| 77 | lock_state = led_state.num_lock; | ||
| 78 | return true; | ||
| 79 | } | ||
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 000000000..3a597e38d --- /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. | |||
