diff options
| author | QMK Bot <hello@qmk.fm> | 2021-02-15 04:09:53 +0000 |
|---|---|---|
| committer | QMK Bot <hello@qmk.fm> | 2021-02-15 04:09:53 +0000 |
| commit | 26ee9360bfbab3bd6b1f9dc5ac5a13f10b454e16 (patch) | |
| tree | fc14e5a51dcb778a44e930762ed59617d73fa5dd /keyboards/ploopyco/mouse/keymaps/drag_scroll/keymap.c | |
| parent | 0b63fb5e819495f4515001cd367a279eaf9eaaa2 (diff) | |
| parent | e768fb83bdf1bc292cefc9f3f70cb1597c3108fc (diff) | |
| download | qmk_firmware-26ee9360bfbab3bd6b1f9dc5ac5a13f10b454e16.tar.gz qmk_firmware-26ee9360bfbab3bd6b1f9dc5ac5a13f10b454e16.zip | |
Merge remote-tracking branch 'origin/master' into develop
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 | } | ||
