diff options
Diffstat (limited to 'keyboards/ploopyco/mouse')
-rw-r--r-- | keyboards/ploopyco/mouse/keymaps/uqs/keymap.c | 36 | ||||
-rw-r--r-- | keyboards/ploopyco/mouse/keymaps/uqs/rules.mk | 1 | ||||
-rw-r--r-- | keyboards/ploopyco/mouse/mouse.c | 25 | ||||
-rw-r--r-- | keyboards/ploopyco/mouse/mouse.h | 13 | ||||
-rw-r--r-- | keyboards/ploopyco/mouse/readme.md | 4 | ||||
-rw-r--r-- | keyboards/ploopyco/mouse/rules.mk | 8 |
6 files changed, 72 insertions, 15 deletions
diff --git a/keyboards/ploopyco/mouse/keymaps/uqs/keymap.c b/keyboards/ploopyco/mouse/keymaps/uqs/keymap.c new file mode 100644 index 0000000000..564dad13df --- /dev/null +++ b/keyboards/ploopyco/mouse/keymaps/uqs/keymap.c @@ -0,0 +1,36 @@ +// Copyright 2022 Ulrich Spörlein (@uqs) +// SPDX-License-Identifier: GPL-2.0-or-later +// vi:et sw=4: + +#include QMK_KEYBOARD_H + +enum custom_keycodes { + DBL_CLK_NO = SAFE_RANGE, +}; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + // This works fine in xev(1) or a browser, but not in the game where I + // would want it. Maybe need to increase the delay? Also needs to be + // rewritten to use Deferred Execution. + case DBL_CLK_NO: + if (record->event.pressed) { + tap_code(KC_BTN2); + wait_ms(150); + tap_code(KC_BTN2); + wait_ms(300); + tap_code(KC_N); + } + return false; + } + return true; +} + + +// Layout is: +// left-most, M1, M3, M2, right-most, fwd, back (on side), tiny middle one + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = LAYOUT(KC_E, KC_BTN1, KC_BTN3, KC_BTN2, KC_LSFT, KC_BTN4, KC_BTN5, DF(1)), // shooters + [1] = LAYOUT(KC_1, KC_BTN1, KC_Y, KC_BTN2, DBL_CLK_NO, KC_N, KC_Y, DF(0)), // stardew valley, sword on 1 +}; diff --git a/keyboards/ploopyco/mouse/keymaps/uqs/rules.mk b/keyboards/ploopyco/mouse/keymaps/uqs/rules.mk new file mode 100644 index 0000000000..59222a688a --- /dev/null +++ b/keyboards/ploopyco/mouse/keymaps/uqs/rules.mk @@ -0,0 +1 @@ +#VIA_ENABLE = yes diff --git a/keyboards/ploopyco/mouse/mouse.c b/keyboards/ploopyco/mouse/mouse.c index 1b00ef3b71..25ebd1ee2d 100644 --- a/keyboards/ploopyco/mouse/mouse.c +++ b/keyboards/ploopyco/mouse/mouse.c @@ -66,7 +66,24 @@ 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) { // Lovingly ripped from the Ploopy Source // If the mouse wheel was just released, do not scroll. @@ -94,11 +111,11 @@ void process_wheel(report_mouse_t* mouse_report) { int dir = opt_encoder_handler(p1, p2); if (dir == 0) return; - mouse_report->v = (int8_t)(dir * OPT_SCALE); + encoder_update_kb(0, dir == 1); } -__attribute__((weak)) report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { - process_wheel(&mouse_report); +report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { + process_wheel(); if (is_drag_scroll) { mouse_report.h = mouse_report.x; diff --git a/keyboards/ploopyco/mouse/mouse.h b/keyboards/ploopyco/mouse/mouse.h index ee59827139..8383049aa5 100644 --- a/keyboards/ploopyco/mouse/mouse.h +++ b/keyboards/ploopyco/mouse/mouse.h @@ -28,16 +28,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(BLL, BL, BM, BR, BRR, BF, BB, BDPI) \ { {BL, BM, BR, BF, BB, BRR, BLL, BDPI}, } 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); diff --git a/keyboards/ploopyco/mouse/readme.md b/keyboards/ploopyco/mouse/readme.md index e9ad915a66..f7f072928b 100644 --- a/keyboards/ploopyco/mouse/readme.md +++ b/keyboards/ploopyco/mouse/readme.md @@ -1,6 +1,6 @@ # Ploopyco Mouse - + It's a DIY, QMK Powered Mouse!!!! @@ -17,7 +17,7 @@ To jump to the bootloader, hold down "Button 4" (the "forward" button on the lef See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). -# Customzing your PloopyCo Mouse +# Customizing your PloopyCo Mouse 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 to use 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/mouse/rules.mk b/keyboards/ploopyco/mouse/rules.mk index 45cb38901a..840b5eba39 100644 --- a/keyboards/ploopyco/mouse/rules.mk +++ b/keyboards/ploopyco/mouse/rules.mk @@ -14,10 +14,7 @@ BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = no # 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 @@ -25,5 +22,8 @@ POINTING_DEVICE_ENABLE = yes POINTING_DEVICE_DRIVER = pmw3360 MOUSEKEY_ENABLE = yes # Mouse keys +ENCODER_ENABLE := no +OPTS_DEF += -DENCODER_ENABLE + QUANTUM_LIB_SRC += analog.c SRC += opt_encoder.c |