diff options
author | Drashna Jael're <drashna@live.com> | 2021-02-23 13:57:26 -0800 |
---|---|---|
committer | Drashna Jael're <drashna@live.com> | 2021-02-23 13:57:26 -0800 |
commit | 146b042514569acac33b616aa278d293af594f49 (patch) | |
tree | f169aef071affe58195f3bc992ceb89e615de633 /keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/drashna/keymap.c | |
parent | 2abfa624c90df49fe4f0639a54961fd54a1255ac (diff) | |
parent | 0b69e4df818c2515cf4eee3d8b6fd4a07775b887 (diff) |
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/drashna/keymap.c')
-rw-r--r-- | keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/drashna/keymap.c | 66 |
1 files changed, 49 insertions, 17 deletions
diff --git a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/drashna/keymap.c b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/drashna/keymap.c index f8803edb9c..5a1bb79fe2 100644 --- a/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/drashna/keymap.c +++ b/keyboards/handwired/dactyl_manuform/5x6_right_trackball/keymaps/drashna/keymap.c @@ -16,24 +16,21 @@ #include "drashna.h" -#define TG_DBLO TG(_DIABLO) - - // clang-format off #define LAYOUT_5x6_right_trackball_wrapper(...) LAYOUT_5x6_right_trackball(__VA_ARGS__) #define LAYOUT_5x6_right_trackball_base( \ K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, \ - K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, \ + K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \ K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A \ ) \ LAYOUT_5x6_right_trackball_wrapper( \ - KC_GRV, ________________NUMBER_LEFT________________, ________________NUMBER_RIGHT_______________, KC_MINS, \ - KC_ESC, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, KC_BSLS, \ - LALT_T(KC_TAB), K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, RALT_T(KC_QUOT), \ + KC_ESC, ________________NUMBER_LEFT________________, ________________NUMBER_RIGHT_______________, KC_MINS, \ + SH_TT, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, SH_TT, \ + LALT_T(KC_TAB), K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, RALT_T(K1B), \ OS_LSFT, CTL_T(K21), K22, K23, K24, K25, K26, K27, K28, K29, RCTL_T(K2A), OS_RSFT, \ OS_LALT, OS_LGUI, TG_GAME, TG_DBLO, \ OS_LGUI, KC_GRV, OS_RGUI, \ - KC_SPC, _______, KC_ENT, \ + KC_SPC, TT(_MOUSE), KC_ENT, \ BK_LWER, MO(_MOUSE), MO(_MOUSE), DL_RAIS \ ) #define LAYOUT_5x6_right_trackball_base_wrapper(...) LAYOUT_5x6_right_trackball_base(__VA_ARGS__) @@ -149,13 +146,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, KC_NUKE, _______ ), }; -// clang-format off - +// clang-format on #ifdef POINTING_DEVICE_ENABLE -static uint16_t mouse_timer = 0; -static uint16_t mouse_debounce_timer = 0; +static uint16_t mouse_timer = 0; +static uint16_t mouse_debounce_timer = 0; static uint8_t mouse_keycode_tracker = 0; +bool tap_toggling = false; void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y) { if ((x || y) && timer_elapsed(mouse_timer) > 125) { @@ -164,29 +161,64 @@ void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y) { layer_on(_MOUSE); } } - if (timer_elapsed(mouse_debounce_timer) > 125 || layer_state_is(_GAMEPAD) ) { + +# ifdef TAPPING_TERM_PER_KEY + if (timer_elapsed(mouse_debounce_timer) > get_tapping_term(KC_BTN1, NULL) +# else + if (timer_elapsed(mouse_debounce_timer) > TAPPING_TERM +# endif + || layer_state_is(_GAMEPAD)) { mouse_report->x = x; mouse_report->y = y; } +# ifdef OLED_DRIVER_ENABLE + if (x || y) oled_timer = timer_read32(); +# endif } void matrix_scan_keymap(void) { - if (timer_elapsed(mouse_timer) > 650 && layer_state_is(_MOUSE) && !mouse_keycode_tracker) { + if (timer_elapsed(mouse_timer) > 650 && layer_state_is(_MOUSE) && !mouse_keycode_tracker && !tap_toggling) { layer_off(_MOUSE); } + if (tap_toggling) { + if (!layer_state_is(_MOUSE)) { + layer_on(_MOUSE); + } + } } -bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { - switch(keycode){ +bool process_record_keymap(uint16_t keycode, keyrecord_t* record) { + switch (keycode) { + case TT(_MOUSE): { + if (record->event.pressed) { + mouse_keycode_tracker++; + } else { +# if TAPPING_TOGGLE != 0 + if (record->tap.count == TAPPING_TOGGLE) { + tap_toggling ^= 1; +# if TAPPING_TOGGLE == 1 + if (!tap_toggling) mouse_keycode_tracker -= record->tap.count + 1; +# else + if (!tap_toggling) mouse_keycode_tracker -= record->tap.count; +# endif + } else { + mouse_keycode_tracker--; + } +# endif + } + mouse_timer = timer_read(); + break; + } case MO(_MOUSE): case DPI_CONFIG: - case KC_MS_UP...KC_MS_WH_RIGHT: + case KC_MS_UP ... KC_MS_WH_RIGHT: record->event.pressed ? mouse_keycode_tracker++ : mouse_keycode_tracker--; mouse_timer = timer_read(); break; default: if (layer_state_is(_MOUSE) && !mouse_keycode_tracker) { layer_off(_MOUSE); + mouse_keycode_tracker = 0; } mouse_debounce_timer = timer_read(); break; |