summaryrefslogtreecommitdiff
path: root/users/drashna/pointing
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2022-09-25 13:04:00 -0700
committerGitHub <noreply@github.com>2022-09-25 13:04:00 -0700
commit5abb125b025750d7015d1a9cafc5a861cedfa9b3 (patch)
treeda18da9141a0efcd3e3ca099742af0da4fa78903 /users/drashna/pointing
parent34490f098ae1e556ceeaa6a684b3f0deb8b75cfb (diff)
[Keymap] develop updates for Drashna Keymaps (#18472)
Diffstat (limited to 'users/drashna/pointing')
-rw-r--r--users/drashna/pointing/pointing.c119
-rw-r--r--users/drashna/pointing/pointing.h2
2 files changed, 44 insertions, 77 deletions
diff --git a/users/drashna/pointing/pointing.c b/users/drashna/pointing/pointing.c
index c9a7945a84..1b64502ed3 100644
--- a/users/drashna/pointing/pointing.c
+++ b/users/drashna/pointing/pointing.c
@@ -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
diff --git a/users/drashna/pointing/pointing.h b/users/drashna/pointing/pointing.h
index 8b00ffc0ec..28d8610148 100644
--- a/users/drashna/pointing/pointing.h
+++ b/users/drashna/pointing/pointing.h
@@ -3,8 +3,8 @@
#include "drashna.h"
+void pointing_device_init_keymap(void);
report_mouse_t pointing_device_task_keymap(report_mouse_t mouse_report);
void matrix_scan_pointing(void);
bool process_record_pointing(uint16_t keycode, keyrecord_t* record);
layer_state_t layer_state_set_pointing(layer_state_t state);
-extern bool tap_toggling, enable_acceleration;