diff options
Diffstat (limited to 'keyboards/ploopyco/trackball_mini')
-rw-r--r-- | keyboards/ploopyco/trackball_mini/config.h | 2 | ||||
-rw-r--r-- | keyboards/ploopyco/trackball_mini/readme.md | 4 | ||||
-rw-r--r-- | keyboards/ploopyco/trackball_mini/rules.mk | 10 | ||||
-rw-r--r-- | keyboards/ploopyco/trackball_mini/trackball_mini.c | 58 | ||||
-rw-r--r-- | keyboards/ploopyco/trackball_mini/trackball_mini.h | 13 |
5 files changed, 51 insertions, 36 deletions
diff --git a/keyboards/ploopyco/trackball_mini/config.h b/keyboards/ploopyco/trackball_mini/config.h index 52d7390ca2..af1e63eb71 100644 --- a/keyboards/ploopyco/trackball_mini/config.h +++ b/keyboards/ploopyco/trackball_mini/config.h @@ -61,4 +61,4 @@ #define ADNS5050_SDIO_PIN C6 #define ADNS5050_CS_PIN B4 -#define POINTING_DEVICE_ROTATION_90 +#define POINTING_DEVICE_ROTATION_270 diff --git a/keyboards/ploopyco/trackball_mini/readme.md b/keyboards/ploopyco/trackball_mini/readme.md index a3aebb06e6..bc94482c71 100644 --- a/keyboards/ploopyco/trackball_mini/readme.md +++ b/keyboards/ploopyco/trackball_mini/readme.md @@ -1,7 +1,7 @@ # Ploopy Trackball Mini -![Ploopyco Trackball Mini](mini.jpg) +![Ploopyco Trackball Mini](https://ploopy.co/wp-content/uploads/2021/07/mini4.jpg) It's a DIY, QMK Powered Trackball...Mini! @@ -29,7 +29,7 @@ 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. -# Customzing your Ploopy Mini Trackball +# Customizing your Ploopy Mini Trackball While the defaults are designed so that it can be plugged in and used right away, there are a number of things that you may want to change, such as adding DPI control, or using the ball to scroll while holding a button. To allow for this sort of control, there is a callback for both the scroll wheel and the mouse sensor. diff --git a/keyboards/ploopyco/trackball_mini/rules.mk b/keyboards/ploopyco/trackball_mini/rules.mk index 8d76c9b3dc..f5e7935ee2 100644 --- a/keyboards/ploopyco/trackball_mini/rules.mk +++ b/keyboards/ploopyco/trackball_mini/rules.mk @@ -11,16 +11,16 @@ BOOTMAGIC_ENABLE = yes # 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 -# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend -# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -NKRO_ENABLE = no # USB Nkey Rollover +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 +MOUSEKEY_ENABLE = yes # Mouse keys + +ENCODER_ENABLE := no +OPTS_DEF += -DENCODER_ENABLE QUANTUM_LIB_SRC += analog.c SRC += opt_encoder.c diff --git a/keyboards/ploopyco/trackball_mini/trackball_mini.c b/keyboards/ploopyco/trackball_mini/trackball_mini.c index 2158a8f488..2b511c4eab 100644 --- a/keyboards/ploopyco/trackball_mini/trackball_mini.c +++ b/keyboards/ploopyco/trackball_mini/trackball_mini.c @@ -45,11 +45,11 @@ # define PLOOPY_DRAGSCROLL_DPI 375 // Fixed-DPI Drag Scroll #endif #ifndef PLOOPY_DRAGSCROLL_MULTIPLIER -# define PLOOPY_DRAGSCROLL_MULTIPLIER 0.75 // Variable-DPI Drag Scroll +# define PLOOPY_DRAGSCROLL_MULTIPLIER 0.75 // Variable-DPI Drag Scroll #endif keyboard_config_t keyboard_config; -uint16_t dpi_array[] = PLOOPY_DPI_OPTIONS; +uint16_t dpi_array[] = PLOOPY_DPI_OPTIONS; #define DPI_OPTION_SIZE (sizeof(dpi_array) / sizeof(uint16_t)) // TODO: Implement libinput profiles @@ -58,23 +58,38 @@ uint16_t dpi_array[] = PLOOPY_DPI_OPTIONS; // 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 -uint16_t lastScroll = 0; // Previous confirmed wheel event -uint16_t lastMidClick = 0; // Stops scrollwheel from being read if it was pressed -uint8_t OptLowPin = OPT_ENC1; -bool debug_encoder = false; +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 +uint16_t lastScroll = 0; // Previous confirmed wheel event +uint16_t lastMidClick = 0; // Stops scrollwheel from being read if it was pressed +uint8_t OptLowPin = OPT_ENC1; +bool debug_encoder = false; bool is_drag_scroll = false; -void process_wheel(report_mouse_t* mouse_report) { +__attribute__((weak)) bool encoder_update_user(uint8_t index, bool clockwise) { return true; } + +bool encoder_update_kb(uint8_t index, bool clockwise) { + if (!encoder_update_user(index, clockwise)) { + return false; + } +#ifdef MOUSEKEY_ENABLE + tap_code(clockwise ? KC_WH_U : KC_WH_D); +#else + mouse_report_t mouse_report = pointing_device_get_report(); + mouse_report.v = clockwise ? 1 : -1; + pointing_device_set_report(mouse_report); + pointing_device_send(); +#endif + return true; +} + +void process_wheel(void) { // If the mouse wheel was just released, do not scroll. - if (timer_elapsed(lastMidClick) < SCROLL_BUTT_DEBOUNCE) - return; + if (timer_elapsed(lastMidClick) < SCROLL_BUTT_DEBOUNCE) return; // Limit the number of scrolls per unit time. - if (timer_elapsed(lastScroll) < OPT_DEBOUNCE) - return; + if (timer_elapsed(lastScroll) < OPT_DEBOUNCE) return; // Don't scroll if the middle button is depressed. if (is_scroll_clicked) { @@ -87,15 +102,12 @@ void process_wheel(report_mouse_t* mouse_report) { uint16_t p1 = adc_read(OPT_ENC1_MUX); uint16_t p2 = adc_read(OPT_ENC2_MUX); - if (debug_encoder) - dprintf("OPT1: %d, OPT2: %d\n", p1, p2); + if (debug_encoder) dprintf("OPT1: %d, OPT2: %d\n", p1, p2); uint8_t dir = opt_encoder_handler(p1, p2); - if (dir == 0) - return; - - mouse_report->v = (int8_t)(dir * OPT_SCALE); + if (dir == 0) return; + encoder_update_kb(0, dir == 1); } void pointing_device_init_kb(void) { @@ -106,6 +118,7 @@ void pointing_device_init_kb(void) { } report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { + process_wheel(); if (is_drag_scroll) { mouse_report.h = mouse_report.x; @@ -127,12 +140,11 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) { // Update Timer to prevent accidental scrolls if ((record->event.key.col == 1) && (record->event.key.row == 0)) { - lastMidClick = timer_read(); + lastMidClick = timer_read(); is_scroll_clicked = record->event.pressed; } - if (!process_record_user(keycode, record)) - return false; + if (!process_record_user(keycode, record)) return false; if (keycode == DPI_CONFIG && record->event.pressed) { keyboard_config.dpi_config = (keyboard_config.dpi_config + 1) % DPI_OPTION_SIZE; diff --git a/keyboards/ploopyco/trackball_mini/trackball_mini.h b/keyboards/ploopyco/trackball_mini/trackball_mini.h index fc86fe776e..3af2a49b5e 100644 --- a/keyboards/ploopyco/trackball_mini/trackball_mini.h +++ b/keyboards/ploopyco/trackball_mini/trackball_mini.h @@ -29,16 +29,16 @@ #define OPT_ENC1_MUX 0 #define OPT_ENC2_MUX 4 -void process_wheel(report_mouse_t* mouse_report); +void process_wheel(void); #define LAYOUT(BL, BM, BR, BF, BB) \ { {BL, BM, BR, BF, BB}, } typedef union { - uint32_t raw; - struct { - uint8_t dpi_config; - }; + uint32_t raw; + struct { + uint8_t dpi_config; + }; } keyboard_config_t; extern keyboard_config_t keyboard_config; @@ -56,3 +56,6 @@ enum ploopy_keycodes { PLOOPY_SAFE_RANGE, #endif }; + +bool encoder_update_user(uint8_t index, bool clockwise); +bool encoder_update_kb(uint8_t index, bool clockwise); |