diff options
Diffstat (limited to 'keyboards/ploopyco/trackball_nano')
-rw-r--r-- | keyboards/ploopyco/trackball_nano/info.json | 3 | ||||
-rw-r--r-- | keyboards/ploopyco/trackball_nano/keymaps/lkbm/keymap.c | 167 | ||||
-rw-r--r-- | keyboards/ploopyco/trackball_nano/keymaps/lkbm/readme.md | 2 | ||||
-rw-r--r-- | keyboards/ploopyco/trackball_nano/keymaps/lkbm/rules.mk | 1 | ||||
-rw-r--r-- | keyboards/ploopyco/trackball_nano/readme.md | 19 | ||||
-rw-r--r-- | keyboards/ploopyco/trackball_nano/rev1_001/keyboard.json (renamed from keyboards/ploopyco/trackball_nano/rev1_001/info.json) | 0 | ||||
-rw-r--r-- | keyboards/ploopyco/trackball_nano/rev1_001/rules.mk | 0 | ||||
-rw-r--r-- | keyboards/ploopyco/trackball_nano/rules.mk | 13 | ||||
-rw-r--r-- | keyboards/ploopyco/trackball_nano/trackball_nano.c | 115 | ||||
-rw-r--r-- | keyboards/ploopyco/trackball_nano/trackball_nano.h | 37 |
10 files changed, 7 insertions, 350 deletions
diff --git a/keyboards/ploopyco/trackball_nano/info.json b/keyboards/ploopyco/trackball_nano/info.json index c1309ad270..e73b480d70 100644 --- a/keyboards/ploopyco/trackball_nano/info.json +++ b/keyboards/ploopyco/trackball_nano/info.json @@ -9,6 +9,9 @@ "device_version": "0.0.1", "max_power": 100 }, + "features": { + "pointing_device": true + }, "processor": "atmega32u4", "bootloader": "atmel-dfu", "debounce": 0, diff --git a/keyboards/ploopyco/trackball_nano/keymaps/lkbm/keymap.c b/keyboards/ploopyco/trackball_nano/keymaps/lkbm/keymap.c deleted file mode 100644 index 6c3a38d127..0000000000 --- a/keyboards/ploopyco/trackball_nano/keymaps/lkbm/keymap.c +++ /dev/null @@ -1,167 +0,0 @@ -/* Copyright 2022 Aidan Gauland - * Copyright 2021 Colin Lam (Ploopy Corporation) - * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <[email protected]> - * 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 <http://www.gnu.org/licenses/>. - */ -#include QMK_KEYBOARD_H -#include "print.h" - -#define NUM_LOCK_BITMASK 0b01 -#define CAPS_LOCK_BITMASK 0b10 - -// World record for fastest index finger tapping is 1092 taps per minute, which -// is 55ms for a single tap. -// https://recordsetter.com/world-record/index-finger-taps-minute/46066 -#define LED_CMD_TIMEOUT 25 -#define DELTA_X_THRESHOLD 60 -#define DELTA_Y_THRESHOLD 15 - -typedef enum { - // You could theoretically define 0b00 and send it by having a macro send - // the second tap after LED_CMD_TIMEOUT has elapsed. - // CMD_EXTRA = 0b00, - TG_SCROLL = 0b01, - CYC_DPI = 0b10, - CMD_RESET = 0b11 // CMD_ prefix to avoid clash with QMK macro -} led_cmd_t; - -// State -static bool scroll_enabled = false; -static bool num_lock_state = false; -static bool caps_lock_state = false; -static bool in_cmd_window = false; -static int8_t delta_x = 0; -static int8_t delta_y = 0; - -typedef struct { - led_cmd_t led_cmd; - uint8_t num_lock_count; - uint8_t caps_lock_count; -} cmd_window_state_t; - -// Dummy -const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {{{KC_NO}}}; - -report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) { - if (scroll_enabled) { - delta_x += mouse_report.x; - delta_y += mouse_report.y; - - 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 > 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) { - num_lock_state = host_keyboard_led_state().num_lock; - caps_lock_state = host_keyboard_led_state().caps_lock; -} - -uint32_t command_timeout(uint32_t trigger_time, void *cb_arg) { - cmd_window_state_t *cmd_window_state = (cmd_window_state_t *)cb_arg; -# ifdef CONSOLE_ENABLE - uprintf("Received command 0b%02b (", cmd_window_state->led_cmd); -# endif - switch (cmd_window_state->led_cmd) { - case TG_SCROLL: -# ifdef CONSOLE_ENABLE - uprint("TG_SCROLL)\n"); -# endif - scroll_enabled = !scroll_enabled; - break; - case CYC_DPI: -# ifdef CONSOLE_ENABLE - uprint("CYC_DPI)\n"); -# endif - cycle_dpi(); - break; - case CMD_RESET: -# ifdef CONSOLE_ENABLE - uprint("QK_BOOT)\n"); -# endif - reset_keyboard(); - break; - default: -# ifdef CONSOLE_ENABLE - uprint("unknown)\n"); -# endif - // Ignore unrecognised commands. - break; - } - cmd_window_state->led_cmd = 0; - cmd_window_state->num_lock_count = 0; - cmd_window_state->caps_lock_count = 0; - in_cmd_window = false; - - return 0; // Don't repeat -} - -bool led_update_user(led_t led_state) { - static cmd_window_state_t cmd_window_state = { - .led_cmd = 0b00, - .num_lock_count = 0, - .caps_lock_count = 0 - }; - - // Start timer to end command window if we are not already in the middle of - // one. - if (!in_cmd_window) { - in_cmd_window = true; - defer_exec(LED_CMD_TIMEOUT, command_timeout, &cmd_window_state); - } - - // Set num lock and caps lock bits when each is toggled on and off within - // the window. - if (led_state.num_lock != num_lock_state) { - cmd_window_state.num_lock_count++; - - if (cmd_window_state.num_lock_count == 2) { - cmd_window_state.led_cmd |= NUM_LOCK_BITMASK; - cmd_window_state.num_lock_count = 0; - } - } - - if (led_state.caps_lock != caps_lock_state) { - cmd_window_state.caps_lock_count++; - - if (cmd_window_state.caps_lock_count == 2) { - cmd_window_state.led_cmd |= CAPS_LOCK_BITMASK; - cmd_window_state.caps_lock_count = 0; - } - } - - // Keep our copy of the LED states in sync with the host. - num_lock_state = led_state.num_lock; - caps_lock_state = led_state.caps_lock; - return true; -} diff --git a/keyboards/ploopyco/trackball_nano/keymaps/lkbm/readme.md b/keyboards/ploopyco/trackball_nano/keymaps/lkbm/readme.md deleted file mode 100644 index 3b2f698e52..0000000000 --- a/keyboards/ploopyco/trackball_nano/keymaps/lkbm/readme.md +++ /dev/null @@ -1,2 +0,0 @@ -# The keymap that takes commands as LED-Key BitMasks (lkbm) -Based on [maddie](../maddie), this keymap lets you send a 2-bit command by having a macro on your keyboard tap `KC_NUM_LOCK` and `KC_CAPS_LOCK` on and off within a very short window (25ms by default) to represent bits 1 and 2 respectively. The keymap uses this to allow toggling between sending mouse-movement events and scrolling events; cycling DPI presets, and resetting to the bootloader, so you can reflash without having to unscrew your Ploopy Nano. diff --git a/keyboards/ploopyco/trackball_nano/keymaps/lkbm/rules.mk b/keyboards/ploopyco/trackball_nano/keymaps/lkbm/rules.mk deleted file mode 100644 index 199bad85f3..0000000000 --- a/keyboards/ploopyco/trackball_nano/keymaps/lkbm/rules.mk +++ /dev/null @@ -1 +0,0 @@ -DEFERRED_EXEC_ENABLE = yes diff --git a/keyboards/ploopyco/trackball_nano/readme.md b/keyboards/ploopyco/trackball_nano/readme.md index 0d427bfb55..a3ef878bdf 100644 --- a/keyboards/ploopyco/trackball_nano/readme.md +++ b/keyboards/ploopyco/trackball_nano/readme.md @@ -28,21 +28,6 @@ Occasionally, new revisions of the PCB will be released. Every board comes with Match the firmware that you flash onto the board with the designator on the board. -# Customizing your Ploopy Nano Trackball - -You can change the DPI/CPI or speed of the trackball by calling `adns_set_cpi` at any time. Additionally, there is a `DPI_CONFIG` macro that will cycle through an array of options for the DPI. This is set to 375, 750, and 1375, but can be changed. 750 is the default. - -To configure/set your own array, there are two defines to use, `PLOOPY_DPI_OPTIONS` to set the array, and `PLOOPY_DPI_DEFAULT`. - -```c -#define PLOOPY_DPI_OPTIONS { 375, 750, 1375} -#define PLOOPY_DPI_DEFAULT 1 -``` - -The `PLOOPY_DPI_OPTIONS` array sets the values that you want to be able to cycle through, and the order they are in. The "default" define lets the firmware know which of these options is the default and should be loaded by default. - -The `DPI_CONFIG` macro will cycle through the values in the array, each time you hit it. It stores this value in persistent memory, so it will load it the next time the device powers up. - ## Fuse settings When flashing the bootloader, use the following fuse settings: @@ -52,3 +37,7 @@ When flashing the bootloader, use the following fuse settings: | Low | `0x5E` | | High | `0x99` | | Extended | `0xC3` | + +# Customizing your PloopyCo Trackball Nano + +You can find customziation options [here](../readme.md). diff --git a/keyboards/ploopyco/trackball_nano/rev1_001/info.json b/keyboards/ploopyco/trackball_nano/rev1_001/keyboard.json index abf5f9fe74..abf5f9fe74 100644 --- a/keyboards/ploopyco/trackball_nano/rev1_001/info.json +++ b/keyboards/ploopyco/trackball_nano/rev1_001/keyboard.json diff --git a/keyboards/ploopyco/trackball_nano/rev1_001/rules.mk b/keyboards/ploopyco/trackball_nano/rev1_001/rules.mk deleted file mode 100644 index e69de29bb2..0000000000 --- a/keyboards/ploopyco/trackball_nano/rev1_001/rules.mk +++ /dev/null diff --git a/keyboards/ploopyco/trackball_nano/rules.mk b/keyboards/ploopyco/trackball_nano/rules.mk index 7a1052a4fa..df29dfbc07 100644 --- a/keyboards/ploopyco/trackball_nano/rules.mk +++ b/keyboards/ploopyco/trackball_nano/rules.mk @@ -1,16 +1,3 @@ -# Build Options -# change yes to no to disable -# -BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite -EXTRAKEY_ENABLE = yes # Audio control and System control -CONSOLE_ENABLE = yes # Console for debug -COMMAND_ENABLE = no # Commands for debug and configuration -NKRO_ENABLE = no # Enable N-Key Rollover -BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality -RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow -AUDIO_ENABLE = no # Audio output -POINTING_DEVICE_ENABLE = yes POINTING_DEVICE_DRIVER = adns5050 -MOUSEKEY_ENABLE = no # Mouse keys DEFAULT_FOLDER = ploopyco/trackball_nano/rev1_001 diff --git a/keyboards/ploopyco/trackball_nano/trackball_nano.c b/keyboards/ploopyco/trackball_nano/trackball_nano.c deleted file mode 100644 index 366918e134..0000000000 --- a/keyboards/ploopyco/trackball_nano/trackball_nano.c +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright 2021 Colin Lam (Ploopy Corporation) - * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <[email protected]> - * 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 <http://www.gnu.org/licenses/>. - */ - -#include "trackball_nano.h" -#include "wait.h" - -#ifndef OPT_DEBOUNCE -# define OPT_DEBOUNCE 5 // (ms) Time between scroll events -#endif - -#ifndef SCROLL_BUTT_DEBOUNCE -# define SCROLL_BUTT_DEBOUNCE 100 // (ms) Time between scroll events -#endif - -#ifndef OPT_THRES -# define OPT_THRES 150 // (0-1024) Threshold for actication -#endif - -#ifndef OPT_SCALE -# define OPT_SCALE 1 // Multiplier for wheel -#endif - -#ifndef PLOOPY_DPI_OPTIONS -# define PLOOPY_DPI_OPTIONS \ - { 375, 750, 1375 } -# ifndef PLOOPY_DPI_DEFAULT -# define PLOOPY_DPI_DEFAULT 2 -# endif -#endif - -#ifndef PLOOPY_DPI_DEFAULT -# define PLOOPY_DPI_DEFAULT 2 -#endif - -keyboard_config_t keyboard_config; -uint16_t dpi_array[] = PLOOPY_DPI_OPTIONS; -#define DPI_OPTION_SIZE ARRAY_SIZE(dpi_array) - -void cycle_dpi(void) { - keyboard_config.dpi_config = (keyboard_config.dpi_config + 1) % DPI_OPTION_SIZE; - pointing_device_set_cpi(dpi_array[keyboard_config.dpi_config]); -#ifdef CONSOLE_ENABLE - uprintf("DPI is now %d\n", dpi_array[keyboard_config.dpi_config]); -#endif -} - -// TODO: Implement libinput profiles -// https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html -// Compile time accel selection -// Valid options are ACC_NONE, ACC_LINEAR, ACC_CUSTOM, ACC_QUADRATIC - -// Trackball State -bool is_scroll_clicked = false; -bool BurstState = false; // init burst state for Trackball module -uint16_t MotionStart = 0; // Timer for accel, 0 is resting state - -void pointing_device_init_kb(void) { - // set the DPI. - pointing_device_set_cpi(dpi_array[keyboard_config.dpi_config]); -} - -// Hardware Setup -void keyboard_pre_init_kb(void) { - // debug_enable = true; - // debug_matrix = true; - // debug_mouse = true; - // debug_encoder = true; - - /* Ground all output pins connected to ground. This provides additional - * pathways to ground. If you're messing with this, know this: driving ANY - * of these pins high will cause a short. On the MCU. Ka-blooey. - */ -#ifdef UNUSABLE_PINS - const pin_t unused_pins[] = UNUSABLE_PINS; - - for (uint8_t i = 0; i < ARRAY_SIZE(unused_pins); i++) { - setPinOutput(unused_pins[i]); - writePinLow(unused_pins[i]); - } -#endif - - keyboard_pre_init_user(); -} - -void eeconfig_init_kb(void) { - keyboard_config.dpi_config = PLOOPY_DPI_DEFAULT; - eeconfig_update_kb(keyboard_config.raw); - eeconfig_init_user(); -} - -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_user(); -} diff --git a/keyboards/ploopyco/trackball_nano/trackball_nano.h b/keyboards/ploopyco/trackball_nano/trackball_nano.h deleted file mode 100644 index e3bd0cb351..0000000000 --- a/keyboards/ploopyco/trackball_nano/trackball_nano.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright 2021 Colin Lam (Ploopy Corporation) - * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <[email protected]> - * 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 <http://www.gnu.org/licenses/>. - */ - -#pragma once - -#include "quantum.h" - -typedef union { - uint32_t raw; - struct { - uint8_t dpi_config; - }; -} keyboard_config_t; - -extern keyboard_config_t keyboard_config; - -enum ploopy_keycodes { - DPI_CONFIG = QK_KB_0, -}; - -void cycle_dpi(void); |