kanata icon indicating copy to clipboard operation
kanata copied to clipboard

Feature request: add `setmouse`

Open lelazsq opened this issue 2 years ago • 8 comments

currently, I can only move the mouse pointer with the movemouse and movemouse-accel actions, which which move the pointer relative to its current position. but i wanna make a mouse layer which moves the pointer to a specific position on the screen.

the only way i could think of doing it in the current version of kanata is by creating a macro which moves the mouse pointer to one of the corners of the screen and then move it to the position i want, but that's pretty tedious.

i'd like if there was a setmouse action which would take in an x and y value and then set the position of the mouse pointer to those coordinates, for example (setmouse 540 960) would move the mouse pointer to the center of a 1080p screen. this would help out my workflow a ton.

lelazsq avatar Apr 04 '23 14:04 lelazsq

Implementation notes in case someone wants to try their hand at this:

SendInput: MOUSEEVENTF_ABSOLUTE in https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-mouseinput

Interception: https://docs.rs/interception/latest/interception/struct.MouseFlags.html#associatedconstant.MOVE_ABSOLUTE

Linux: https://docs.rs/evdev/0.12.1/evdev/struct.AbsoluteAxisType.html https://docs.rs/evdev/0.12.1/evdev/uinput/struct.VirtualDeviceBuilder.html#method.with_absolute_axis

jtroo avatar Apr 05 '23 04:04 jtroo

Hmm looks like on Linux at least, the absolute axis is not usable for moving the mouse cursor.

https://stackoverflow.com/questions/5190921/simulating-absolute-mouse-movements-in-linux-using-uinput

On Linux there's already a pretty good keyboard-mouse solution in warpd though, so could use that instead. https://github.com/rvaiya/warpd

jtroo avatar Apr 08 '23 20:04 jtroo

Implemented in Windows in #373.

Looks like to do this properly in Linux, need to work with X and Wayland instead of using uinput, which is a bit unfortunate. Or one could use warpd as suggested in the previous comment.

jtroo avatar Apr 09 '23 03:04 jtroo

yeah i wanted setmouse so i could create something like warpd on windows (just without the visual guides) lol, looks pretty good.

lelazsq avatar Apr 12 '23 02:04 lelazsq

didn't realize i accidentally closed this issue, my bad.

lelazsq avatar Apr 16 '23 03:04 lelazsq