forked from mirrors/qmk_userspace
[Keymap] develop updates for Drashna Keymaps (#18472)
This commit is contained in:
parent
34490f098a
commit
5abb125b02
22 changed files with 84 additions and 1038 deletions
|
@ -3,10 +3,8 @@
|
|||
|
||||
#include "pointing.h"
|
||||
|
||||
static uint16_t mouse_timer = 0;
|
||||
static uint16_t mouse_debounce_timer = 0;
|
||||
static uint8_t mouse_keycode_tracker = 0;
|
||||
bool tap_toggling = false, enable_acceleration = false;
|
||||
static uint16_t mouse_debounce_timer = 0;
|
||||
bool enable_acceleration = false;
|
||||
|
||||
#ifdef TAPPING_TERM_PER_KEY
|
||||
# define TAP_CHECK get_tapping_term(KC_BTN1, NULL)
|
||||
|
@ -17,6 +15,15 @@ bool tap_toggling = false, enable_acceleration = false;
|
|||
# define TAP_CHECK TAPPING_TERM
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) void pointing_device_init_keymap(void) {}
|
||||
|
||||
void pointing_device_init_user(void) {
|
||||
set_auto_mouse_layer(_MOUSE);
|
||||
set_auto_mouse_enable(true);
|
||||
|
||||
pointing_device_init_keymap();
|
||||
}
|
||||
|
||||
__attribute__((weak)) report_mouse_t pointing_device_task_keymap(report_mouse_t mouse_report) {
|
||||
return mouse_report;
|
||||
}
|
||||
|
@ -26,28 +33,16 @@ report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) {
|
|||
mouse_report.x = 0;
|
||||
mouse_report.y = 0;
|
||||
|
||||
if (x != 0 && y != 0) {
|
||||
mouse_timer = timer_read();
|
||||
if (x != 0 && y != 0 && (timer_elapsed(mouse_debounce_timer) > TAP_CHECK)) {
|
||||
#ifdef OLED_ENABLE
|
||||
oled_timer_reset();
|
||||
#endif
|
||||
if (timer_elapsed(mouse_debounce_timer) > TAP_CHECK) {
|
||||
if (enable_acceleration) {
|
||||
x = (mouse_xy_report_t)(x > 0 ? x * x / 16 + x : -x * x / 16 + x);
|
||||
y = (mouse_xy_report_t)(y > 0 ? y * y / 16 + y : -y * y / 16 + y);
|
||||
}
|
||||
mouse_report.x = x;
|
||||
mouse_report.y = y;
|
||||
if (!layer_state_is(_MOUSE)) {
|
||||
layer_on(_MOUSE);
|
||||
}
|
||||
}
|
||||
} else if (timer_elapsed(mouse_timer) > 650 && layer_state_is(_MOUSE) && !mouse_keycode_tracker && !tap_toggling) {
|
||||
layer_off(_MOUSE);
|
||||
} else if (tap_toggling) {
|
||||
if (!layer_state_is(_MOUSE)) {
|
||||
layer_on(_MOUSE);
|
||||
if (enable_acceleration) {
|
||||
x = (mouse_xy_report_t)(x > 0 ? x * x / 16 + x : -x * x / 16 + x);
|
||||
y = (mouse_xy_report_t)(y > 0 ? y * y / 16 + y : -y * y / 16 + y);
|
||||
}
|
||||
mouse_report.x = x;
|
||||
mouse_report.y = y;
|
||||
}
|
||||
|
||||
return pointing_device_task_keymap(mouse_report);
|
||||
|
@ -55,64 +50,10 @@ report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) {
|
|||
|
||||
bool process_record_pointing(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 TG(_MOUSE):
|
||||
if (record->event.pressed) {
|
||||
tap_toggling ^= 1;
|
||||
}
|
||||
break;
|
||||
case MO(_MOUSE):
|
||||
#if defined(KEYBOARD_ploopy)
|
||||
case DPI_CONFIG:
|
||||
#elif (defined(KEYBOARD_bastardkb_charybdis) || defined(KEYBOARD_handwired_tractyl_manuform)) && !defined(NO_CHARYBDIS_KEYCODES)
|
||||
case SAFE_RANGE ... (CHARYBDIS_SAFE_RANGE-1):
|
||||
#endif
|
||||
case KC_MS_UP ... KC_MS_WH_RIGHT:
|
||||
record->event.pressed ? mouse_keycode_tracker++ : mouse_keycode_tracker--;
|
||||
mouse_timer = timer_read();
|
||||
break;
|
||||
case KC_ACCEL:
|
||||
enable_acceleration = record->event.pressed;
|
||||
record->event.pressed ? mouse_keycode_tracker++ : mouse_keycode_tracker--;
|
||||
mouse_timer = timer_read();
|
||||
break;
|
||||
#if 0
|
||||
case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX:
|
||||
break;
|
||||
#endif
|
||||
case QK_MOD_TAP ... QK_MOD_TAP_MAX:
|
||||
if (record->event.pressed || !record->tap.count) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (IS_NOEVENT(record->event)) break;
|
||||
if ((keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) && (((keycode >> 0x8) & 0xF) == _MOUSE)) {
|
||||
record->event.pressed ? mouse_keycode_tracker++ : mouse_keycode_tracker--;
|
||||
mouse_timer = timer_read();
|
||||
break;
|
||||
}
|
||||
if (layer_state_is(_MOUSE) && !mouse_keycode_tracker && !tap_toggling) {
|
||||
layer_off(_MOUSE);
|
||||
}
|
||||
mouse_keycode_tracker = 0;
|
||||
mouse_debounce_timer = timer_read();
|
||||
break;
|
||||
}
|
||||
|
@ -122,6 +63,32 @@ bool process_record_pointing(uint16_t keycode, keyrecord_t* record) {
|
|||
layer_state_t layer_state_set_pointing(layer_state_t state) {
|
||||
if (layer_state_cmp(state, _GAMEPAD) || layer_state_cmp(state, _DIABLO) || layer_state_cmp(state, _DIABLOII)) {
|
||||
state |= ((layer_state_t)1 << _MOUSE);
|
||||
set_auto_mouse_enable(false); // auto mouse can be disabled any time during run time
|
||||
} else {
|
||||
set_auto_mouse_enable(true);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
#if defined(POINTING_DEVICE_AUTO_MOUSE_ENABLE)
|
||||
__attribute__((weak)) bool is_mouse_record_keymap(uint16_t keycode, keyrecord_t *record) { return false; }
|
||||
|
||||
bool is_mouse_record_user(uint16_t keycode, keyrecord_t* record) {
|
||||
if (is_mouse_record_keymap(keycode, record)) {
|
||||
return true;
|
||||
}
|
||||
switch (keycode) {
|
||||
# if defined(KEYBOARD_ploopy)
|
||||
case DPI_CONFIG:
|
||||
# elif (defined(KEYBOARD_bastardkb_charybdis) || defined(KEYBOARD_handwired_tractyl_manuform)) && !defined(NO_CHARYBDIS_KEYCODES)
|
||||
case SAFE_RANGE ...(CHARYBDIS_SAFE_RANGE - 1):
|
||||
# elif (defined(KEYBOARD_bastardkb_dilemma) && !defined(NO_DILEMMA_KEYCODES))
|
||||
case SAFE_RANGE ...(DILEMMA_SAFE_RANGE - 1):
|
||||
# endif
|
||||
case KC_ACCEL:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue