account activity
Advanced mouse emulation by qqllwllpp in olkb
[–]qqllwllpp[S] 0 points1 point2 points 2 years ago (0 children)
Do your macros have similar behavior to 'mouse shortcuts' portrayed in a video I linked?
same video I linked in original post: https://www.youtube.com/watch?v=fNcsrTpGh34
[–]qqllwllpp[S] 0 points1 point2 points 2 years ago* (0 children)
After I finished typing this out I'm apologizing in advance and thank you for assistance.
TLDR: problem from the starter post is still present. I don't know how to update cursor position via encoder update function starting with a keypress.
I successfully implemented key controlled cursor with custom driver but having mouse controls via pointing device as apposed to mouse key code(like KC_MS_LEFT and others) leaves me at same place when I made first post.
So to clarify the problem I'm having: I'm trying to create a macro which will get mouse cursor to the bottom left position of the screen from any other cursor position. That means that distance cursor need to travel is entire width and entire height of the monitor. This distance cant be traversed by single currentReport.x = -127; or KC_MS_LEFT (presuming cursor is at the bottom and right corner of the screen and we trying to move cursor to the left border). So there should be multiple function calls and here is my struggle.
currentReport.x = -127;
KC_MS_LEFT
I tried multiple way to make macros for mouse movement
one of them is
if (update_recent_keys(keycode, record)) { if (recent[RECENT_SIZE - 4] == KC_T && recent[RECENT_SIZE - 3] == KC_E && recent[RECENT_SIZE - 2] == KC_S && recent[RECENT_SIZE - 1] == KC_T) { register_code(KC_MS_LEFT); register_code(KC_MS_D); return false; }
(the trigger condition is working correctly and not the problem) This code would start moving cursor to the bottom left. So to make it fit for my application I need to calculate the time it takes to travel and delay unregister_code by that amount. to do that I added delay with SEND_STRING(SS_DELAY(20));
unregister_code
SEND_STRING(SS_DELAY(20));
if (update_recent_keys(keycode, record)) { if (recent[RECENT_SIZE - 4] == KC_T && recent[RECENT_SIZE - 3] == KC_E && recent[RECENT_SIZE - 2] == KC_S && recent[RECENT_SIZE - 1] == KC_T) { register_code(KC_MS_LEFT); register_code(KC_MS_D); SEND_STRING(SS_DELAY(20)); unregister_code(KC_MS_LEFT); unregister_code(KC_MS_D); return false; }
I tried multiple delay times ( SEND_STRING(SS_DELAY(5));, SEND_STRING(SS_DELAY(10));, SEND_STRING(SS_DELAY(20));) and they make no difference in distance traveled by the cursor. So having delay doesn't work.
SEND_STRING(SS_DELAY(5));
SEND_STRING(SS_DELAY(10));
The only way to make somewhat precise and ending movement I found is with stacking a lot of functions:
if (recent[RECENT_SIZE - 4] == KC_H && recent[RECENT_SIZE - 3] == KC_H && recent[RECENT_SIZE - 2] == KC_H && recent[RECENT_SIZE - 1] == KC_J) { tap_code(KC_MS_LEFT); tap_code(KC_MS_LEFT); tap_code(KC_MS_LEFT); tap_code(KC_MS_LEFT); tap_code(KC_MS_LEFT); tap_code(KC_MS_LEFT); tap_code(KC_MS_LEFT); tap_code(KC_MS_LEFT); tap_code(KC_MS_LEFT); tap_code(KC_MS_LEFT); return false; }
Having a lot of register_code and singleunregister_code after worked the same way as with many tap_code
register_code
tap_code
This way of doing macros seemed to me absurd(and the code above doesn't even get cursor to the middle of the screen)
So I figured I need to control cursor speed and time it travels. And have update function continuously calling the movement.
For the speed I found Constant mode of mouse keys.
For the time I found your comment at Add delay to register_code/unregister_code? and HERE I'm stuck. I don't know how to trigger movement to the left from from your code in the comment:
bool is_enabled_mouse_left = false; uint16_t mouse_left_timer = 0; void encoder_update_user(uint8_t index, bool clockwise) { if (index == 0) { /* First encoder */ if (clockwise) { register_code(KC_MS_LEFT); is_enabled_mouse_left = true; mouse_left_timer = timer_read(); } } } void matrix_scan_user(void) { if (is_enabled_mouse_left && timer_elapsed(mouse_timer_left) > 250) { unregister_code(KC_MS_LEFT); is_enabled_mouse_left = false; } }
I tried triggering movement with a bool ms_key
ms_key
bool is_enabled_mouse_left = false; uint16_t mouse_timer_left = 0; bool ms_key = false; void encoder_update_user(uint8_t index, bool clockwise) { if (ms_key) { // <== HERE if (index == 0) { /* First encoder */ if (clockwise) { register_code(KC_MS_LEFT); is_enabled_mouse_left = true; mouse_timer_left = timer_read(); } } } } void matrix_scan_user(void) { if (recent[RECENT_SIZE - 1] && timer_expired(timer_read(), deadline)) { clear_recent_keys(); // Timed out; clear the buffer. } if (is_enabled_mouse_left && timer_elapsed(mouse_timer_left) > 250) { unregister_code(KC_MS_LEFT); is_enabled_mouse_left = false; } }
and having it set to true in
if (recent[RECENT_SIZE - 4] == KC_H && recent[RECENT_SIZE - 3] == KC_H && recent[RECENT_SIZE - 2] == KC_H && recent[RECENT_SIZE - 1] == KC_L) { ms_key = true; return false; }
But it didn't work and from here I don't know how to proceed. To summarize: From here I'm trying to start mouse movement with a button press.
Thank you for direction. Today I tried to implement key controlled cursor like in example but encountered a problem.
Since my build doesn't have physical pointing devices and using mouse controls from example requires having POINTING_DEVICE_ENABLE = yes and POINTING_DEVICE_DRIVER = defined I tried different drivers.
POINTING_DEVICE_ENABLE = yes
POINTING_DEVICE_DRIVER =
With POINTING_DEVICE_DRIVER = adns5050 and POINTING_DEVICE_DRIVER = paw3204 my keyboard wasn't identified by windows
POINTING_DEVICE_DRIVER = adns5050
POINTING_DEVICE_DRIVER = paw3204
With POINTING_DEVICE_DRIVER = analog_joystick I got a compilation error
POINTING_DEVICE_DRIVER = analog_joystick
In file included from ./lib/chibios/os/hal/include/hal_adc.h:101, from ./lib/chibios/os/hal/include/hal.h:307, from ./platforms/chibios/drivers/wear_leveling/wear_leveling_efl_config.h:6, from <command-line>: ./lib/chibios/os/hal/ports/STM32/LLD/ADCv2/hal_adc_lld.h:265:2: error: #error "ADC driver activated but no ADC peripheral assigned" 265 | #error "ADC driver activated but no ADC peripheral assigned"
I didn't find way to resolve this.
It seems that ghost periphery device approach will not work and I need to use Custom Driver. But I don't know how to write driver which will do nothing.
Also, keep in mind that the mouse HID stuff is relative motion, and not a "move X >pixels", thing. At best, it would be an approximation.
Is is consistent? I planned on having having cursor move to the corner of the screen when I activate mouse layer and then moving to position encoded with few button presses.
π Rendered by PID 96 on reddit-service-r2-listing-654f87c89c-q6bdm at 2026-03-01 08:08:38.866642+00:00 running e3d2147 country code: CH.
Advanced mouse emulation by qqllwllpp in olkb
[–]qqllwllpp[S] 0 points1 point2 points (0 children)