jtroo / kanata

Improve keyboard comfort and usability with advanced customization
GNU Lesser General Public License v3.0
2.88k stars 124 forks source link

Kanata disables the mouse portion of KeyMouse on Mac #708

Open rchybicki opened 9 months ago

rchybicki commented 9 months ago

Requirements

Describe the bug

I know I'll probably be the only person with this problem, but after seeing how great home row modifiers work on kanata I'd love bo get this to work :-).

On mac, no matter how simple the config, kanata works but completely disables the mouse in my keymouse (https://keymouse.com/)

The keymouse shows up as a single device in kanata -l: kanata -l Apple Internal Keyboard / Trackpad TouchBarUserDevice USB Receiver KeyMouse Alpha - Left

Any pointers on what I could try / where to look?

Relevant kanata config

No response

To Reproduce

Run kanata on MacOS using a keymouse

Expected behavior

mouse should work

Kanata version

1.5.0

Debug logs

No response

Operating system

MacOS Sonoma

Additional context

No response

rszyma commented 9 months ago

Have you tried mapping it in Karabiner? And if you did, does it have the same problem?

rchybicki commented 9 months ago

Yes, works in karabiner out of the box, I didn't have to do anything to get it to work. Just finished moving the home row mods to it. Mouse works, and while home row mods are also working, there's a perceptible lag for every letter when typing. Definitely worse than kanata, but better than nothing.

In case it helps, kmonad also didn't work, they keymouse were causing "Cannot translate from mac keycode" errors. I added the missing keycodes to the kmonad KeyMaps, but then I started getting "Cannot interpret mac switch: 18446744073709551615" errors and didn't how to fix those.

rszyma commented 9 months ago

Looking at the driverkit source (https://github.com/psych3r/driverkit/blob/1b552cc9a0d60003605f2a69f2c2c3b46cacfc71/c_src/driverkit.cpp#L9), it uses post_keyboard_input_report for sending all input events, but it seems like there's a method specifically for sending mouse events: post_pointing_input_report.

So probably calling send_key in kanata fails, also the error message is ignored, so if it's error indded it won't get logged: https://github.com/jtroo/kanata/blob/41214665947364e877def5a374881621ed18e94a/src/oskbd/macos.rs#L160C8-L160C43

Edit: actually post_keyboard_input_report is used only for kext, for dext client->async_post_report is used instead, but it either way it doesn't seem to handle pointing device inputs.

cc @psych3r

rchybicki commented 9 months ago

Thanks for taking a look @rszyma. I added logging in macos.rs and it is erroring out there, but no details on why. It seems mouse passthrough is missing in the driverkit and would need to be added, but that would be too much for me to tackle right now.

rchybicki commented 9 months ago

I tested on Windows and kanata is working correctly, but also the keymouse shows up in the device manager as a mouse and keyboard separately, so now I'm not sure if it's working because of different kanata OS implementations or different drivers. I'm learning Rust basics and getting to know kanata and karabiner codebases to figure out what's missing, but I'd expect the answer to that will be obvious to @psych3r - any pointers appreciated.

psych3r commented 9 months ago

I don't have any answers, but one thing you can try to do is get the details of the mouse events emitted by your keyboard. Running Kanata in debug mode should produce output like: "Attempting to write "

gkstlr202 commented 8 months ago

I tested on Windows and kanata is working correctly, but also the keymouse shows up in the device manager as a mouse and keyboard separately, so now I'm not sure if it's working because of different kanata OS implementations or different drivers. I'm learning Rust basics and getting to know kanata and karabiner codebases to figure out what's missing, but I'd expect the answer to that will be obvious to @psych3r - any pointers appreciated.

While requesting a feature for Kanata, I happened to come across a Keymouse user. I'm a Windows user, and in my case, everything is working fine. I haven't posted the post, but I'm experiencing the same issue, so I need a 3D file. Do you have it? The Keymouse administrator isn't responding anymore, so I thought I'd ask you. https://www.keymouse.com/forum/is-there-nobody-who-has-the-3d-case-file-for-keymouse-alpha-small-size

rchybicki commented 8 months ago

I tested on Windows and kanata is working correctly, but also the keymouse shows up in the device manager as a mouse and keyboard separately, so now I'm not sure if it's working because of different kanata OS implementations or different drivers. I'm learning Rust basics and getting to know kanata and karabiner codebases to figure out what's missing, but I'd expect the answer to that will be obvious to @psych3r - any pointers appreciated.

While requesting a feature for Kanata, I happened to come across a Keymouse user. I'm a Windows user, and in my case, everything is working fine. I haven't posted the post, but I'm experiencing the same issue, so I need a 3D file. Do you have it? The Keymouse administrator isn't responding anymore, so I thought I'd ask you. https://www.keymouse.com/forum/is-there-nobody-who-has-the-3d-case-file-for-keymouse-alpha-small-size

Sorry, I don't have the 3D files for them, I bought the pre-built versions.