diff options
Diffstat (limited to 'keyboards/ploopyco/mouse/keymaps/drag_scroll/keymap.c')
-rw-r--r-- | keyboards/ploopyco/mouse/keymaps/drag_scroll/keymap.c | 43 |
1 files changed, 4 insertions, 39 deletions
diff --git a/keyboards/ploopyco/mouse/keymaps/drag_scroll/keymap.c b/keyboards/ploopyco/mouse/keymaps/drag_scroll/keymap.c index 438e2406f..da328fff0 100644 --- a/keyboards/ploopyco/mouse/keymaps/drag_scroll/keymap.c +++ b/keyboards/ploopyco/mouse/keymaps/drag_scroll/keymap.c | |||
@@ -17,46 +17,11 @@ | |||
17 | */ | 17 | */ |
18 | #include QMK_KEYBOARD_H | 18 | #include QMK_KEYBOARD_H |
19 | 19 | ||
20 | // used for tracking the state | ||
21 | bool is_drag_scroll = false; | ||
22 | |||
23 | enum custom_keycodes { | ||
24 | DRAG_SCROLL = PLOOPY_SAFE_RANGE, | ||
25 | }; | ||
26 | |||
27 | 20 | ||
28 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | 21 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { |
29 | [0] = LAYOUT(/* Base */ | 22 | [0] = LAYOUT(/* Base */ |
30 | C(KC_C), KC_BTN1, KC_BTN3, KC_BTN2, C(KC_V), KC_BTN4, KC_BTN5, DPI_CONFIG) | 23 | C(KC_C), KC_BTN1, KC_BTN3, LT(1, KC_BTN2), C(KC_V), KC_BTN4, KC_BTN5, DPI_CONFIG), |
31 | }; | 24 | [1] = LAYOUT(/* Base */ |
25 | _______, DRAG_SCROLL, _______, _______, _______, _______, _______, RESET), | ||
32 | 26 | ||
33 | 27 | }; | |
34 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
35 | switch (keycode) { | ||
36 | case DRAG_SCROLL: | ||
37 | if (record->event.pressed) { | ||
38 | // this toggles the state each time you tap it | ||
39 | is_drag_scroll ^= 1; | ||
40 | } | ||
41 | break; | ||
42 | } | ||
43 | return true; | ||
44 | } | ||
45 | |||
46 | // The real magic is here. | ||
47 | // This function is called to translate the processed sensor movement | ||
48 | // from the mouse sensor and translates it into x and y movement for | ||
49 | // the mouse report. Normally. So if "drag scroll" is toggled on, | ||
50 | // moving the ball scrolls instead. You could remove the x or y here | ||
51 | // to only scroll in one direction, if you wanted, as well. In fact, | ||
52 | // there is no reason that you need to send this to the mouse report. | ||
53 | // You could have it register a key, instead. | ||
54 | void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y) { | ||
55 | if (is_drag_scroll) { | ||
56 | mouse_report->h = x; | ||
57 | mouse_report->v = y; | ||
58 | } else { | ||
59 | mouse_report->x = x; | ||
60 | mouse_report->y = y; | ||
61 | } | ||
62 | } | ||