Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intelligently ignore mouse devices in autodiscovery based on defsrc, and allow configurability #1279

Closed
Kommynct opened this issue Oct 9, 2024 Discussed in #1273 · 17 comments · Fixed by #1289
Closed
Labels
linux Issue pertains to Linux only

Comments

@Kommynct
Copy link

Kommynct commented Oct 9, 2024

Discussed in #1273

Originally posted by Kommynct October 5, 2024
Right now I have a very high DPI mouse that i've configured with hyprland like so:

device {
name = logitech-usb-receiver
sensitivity = -0.85
accel_profile = flat
}

If I startup kanata, I need to add

device {
name = kanata-1
sensitivity = -0.85
accel_profile = flat
}

However, that means that the mouse isn't properly matched anymore, if i have two mice and another is plugged in, they may alternate between kanata-1 and kanata-2 etc... i'd like to just disable mouse support all together since i'm not using kanata to control the mouse at all, i'm just using it for chording.

@jtroo
Copy link
Owner

jtroo commented Oct 9, 2024

Here is the relevant code if you want to give it a shot. Not sure when I'll get around to it.

pub fn is_input_device(device: &Device) -> bool {

I don't use autodetection on Linux; upon re-reviewing the code here apparently mice are explicitly looked for and grabbed 🤔.

@Kommynct
Copy link
Author

Kommynct commented Oct 9, 2024

Are mice even useful to this software?

i'll take a crack at it on friday, I'm terrible at programming so no promises, thanks for looking into it though, really appreciate it!

I am of the opinion that mouse support should be manually enabled, would you be fine with a patch that does that?

@wis
Copy link
Contributor

wis commented Oct 9, 2024

Are mice even useful to this software?

Yes. I do not use a mouse, I use the keyboard to move the mouse (HJKL keys), scroll (YUIO keys), left click (C key), right click (, Comma key) , middle click (d key), using a mouse layer, and I've seen the configs of multiple people who have a similar setup.

I am of the opinion that mouse support should be manually enabled, would you be fine with a patch that does that?

I think rather the existing default behavior should be (remain) with mouse support, and mouse support should be manually disabled in the config. this also would avoid breaking people's configs.

@Kommynct
Copy link
Author

Kommynct commented Oct 9, 2024

I don't think what you're describing requires the mouse to be grabbed, I don't think mouse grabbing in particular is useful, correct me if I'm wrong, but moving the mouse with keys isn't the same as interpreting all input from the mouse.

I suggest disabling it by default because there are no usecases I can think of and it breaks setups. the only use I can think of is the mouse back key switching to a layer

@wis
Copy link
Contributor

wis commented Oct 9, 2024

I don't think what you're describing requires the mouse to be grabbed, I don't think mouse grabbing in particular is useful, correct me if I'm wrong, but moving the mouse with keys isn't the same as interpreting all input from the mouse.

Oh you only meant mouse key input (remapping) support, it wasn't clear to me from the way you described it.

I suggest disabling it by default because there are no usecases I can think of and it breaks setups. the only use I can think of is the mouse back key switching to a layer

You can't know how people use Kanata, there may be many people who map the mouse keys in a way that's useful to them.
In general, I always suggest not to change the existing default behavior in a breaking manner. Just my 2 cents.

@Kommynct
Copy link
Author

Kommynct commented Oct 9, 2024

In general, I always suggest not to change the existing default behavior in a breaking manner. Just my 2 cents.

I generally agree with this, but I think settings that lead to buggy behaviors in particular should be disabled by default, and thus an exception, and this does.

@jtroo your preference?

#1235
#1270

and all future reports like this would be solved by disabling this, at the cost of having people change one line in their configs. It'd probably be worth it in the long run.

@jtroo
Copy link
Owner

jtroo commented Oct 9, 2024

Some users do remap mice but I think we should have a breaking change here; I doubt most users remap mice and this sounds worth disabling by default.

@Kommynct
Copy link
Author

Kommynct commented Oct 9, 2024

I have tried fucking around with it, I ended up with some time today, and I can safely say I am in over my head and need to take a rust course to do any of this haha, sorry!

https://github.com/Kommynct/kanata/tree/patch-1 you can see what I tried here, i doubt it will be of any help at all.

@jtroo
Copy link
Owner

jtroo commented Oct 11, 2024

A thought: we could avoid a breaking change by having the presence of mouse actions in defsrc determine the config value when not explicitly defined in defcfg.

@Kommynct
Copy link
Author

Makes sense, devices that aren't being modified by kanata should just never be grabbed by it just generally

@jtroo jtroo added the linux Issue pertains to Linux only label Oct 14, 2024
@jtroo jtroo changed the title Disable mouse support completely Intelligently ignore mouse devices in autodiscovery based and allow configurability Oct 14, 2024
@jtroo
Copy link
Owner

jtroo commented Oct 15, 2024

Can you test if #1289 works

@Kommynct
Copy link
Author

I'm in no position to this week, I just recently switched to nixos and have no idea how to test pull requests with everything being different, and I'm swamped with work anyway.

If nobody else can this week I'll figure it out next week

@jtroo jtroo changed the title Intelligently ignore mouse devices in autodiscovery based and allow configurability Intelligently ignore mouse devices in autodiscovery based on defsrc, and allow configurability Oct 15, 2024
@Kommynct
Copy link
Author

1.7.0 shipped to nixos and i'm unfortunately still facing this issue on all the mice i've tested.

@jtroo
Copy link
Owner

jtroo commented Nov 24, 2024

You set the autodetect setting explicitly? What does the log print with the --debug flag set on Kanata startup?

@jtroo jtroo reopened this Nov 24, 2024
@Kommynct
Copy link
Author

			extraDefCfg = ''
				process-unmapped-keys false
				concurrent-tap-hold yes
				linux-device-detect-mode keyboard-only
				linux-dev-names-exclude (
					"Logitech USB Receiver"
					"ZSA Technology Labs Ergodox EZ"
					"Paris Commune Keyboard"
				)
			'';

^^is in my nixos files, logitech usb receiver is my mouse, i've also tried it with another logitech mouse that's wired, for testing i removed the dev-names-exclude and ran kanata with --debug, these are the results:

06:24:49.6910 �[0m�[34m[INFO] �[0mkanata v1.7.0 starting
06:24:49.6913 �[0m�[34m[INFO] �[0mprocess unmapped keys: false
06:24:49.6913 �[0m�[34m[INFO] �[0mNOTE: kanata was compiled to never allow cmd
06:24:49.6913 �[0m�[36m[DEBUG] �[0m(1) kanata_parser::cfg::alloc: freeing allocations of length 0
06:24:49.6915 �[0m�[34m[INFO] �[0mconfig file is valid
06:24:49.6920 �[0m�[34m[INFO] �[0mCreated device "/dev/input/event15"
06:24:49.6920 �[0m�[34m[INFO] �[0mSleeping for 2s. Please release all keys and don't press additional ones. Run kanata with --help to see how understand more and how to disable this sleep.
06:24:51.6921 �[0m�[34m[INFO] �[0mentering the processing loop
06:24:51.6922 �[0m�[34m[INFO] �[0mentering the event loop
06:24:51.6922 �[0m�[34m[INFO] �[0mlooking for devices in /dev/input
06:24:51.6923 �[0m�[36m[DEBUG] �[0m(1) kanata_state_machine::oskbd::linux: Use for input: false. Non-input device: Creative Technology Ltd Sound Blaster X4
06:24:51.6923 �[0m�[34m[INFO] �[0mInit: catching only releases and sending immediately
06:24:51.6923 �[0m�[36m[DEBUG] �[0m(1) kanata_state_machine::oskbd::linux: Use for input: false. detect type KeyboardOnly; device type Mouse, device name: Logitech USB Receiver
06:24:51.6923 �[0m�[36m[DEBUG] �[0m(1) kanata_state_machine::oskbd::linux: Use for input: true. detect type KeyboardOnly; device type Keyboard, device name: Logitech USB Receiver Keyboard
06:24:51.6923 �[0m�[36m[DEBUG] �[0m(1) kanata_state_machine::oskbd::linux: Use for input: true. detect type KeyboardOnly; device type Keyboard, device name: ZSA Technology Labs Ergodox EZ
06:24:51.6924 �[0m�[36m[DEBUG] �[0m(1) kanata_state_machine::oskbd::linux: Use for input: false. Non-input device: ZSA Technology Labs Ergodox EZ System Control
06:24:51.6924 �[0m�[36m[DEBUG] �[0m(1) kanata_state_machine::oskbd::linux: Use for input: true. detect type KeyboardOnly; device type Keyboard, device name: ZSA Technology Labs Ergodox EZ Consumer Control
06:24:51.6924 �[0m�[36m[DEBUG] �[0m(1) kanata_state_machine::oskbd::linux: Use for input: true. detect type KeyboardOnly; device type Keyboard, device name: ZSA Technology Labs Ergodox EZ Keyboard
06:24:51.6924 �[0m�[36m[DEBUG] �[0m(1) kanata_state_machine::oskbd::linux: Use for input: false. Non-input device: Power Button
06:24:51.6924 �[0m�[36m[DEBUG] �[0m(1) kanata_state_machine::oskbd::linux: Use for input: false. Non-input device: Power Button
06:24:51.6924 �[0m�[36m[DEBUG] �[0m(1) kanata_state_machine::oskbd::linux: Use for input: false. Non-input device: Eee PC WMI hotkeys
06:24:51.6925 �[0m�[36m[DEBUG] �[0m(1) kanata_state_machine::oskbd::linux: Use for input: false. Non-input device: HDA ATI HDMI HDMI/DP,pcm=3
06:24:51.7029 �[0m�[36m[DEBUG] �[0m(1) kanata_state_machine::oskbd::linux: Use for input: false. Non-input device: HDA ATI HDMI HDMI/DP,pcm=7
06:24:51.7129 �[0m�[36m[DEBUG] �[0m(1) kanata_state_machine::oskbd::linux: Use for input: false. Non-input device: HDA ATI HDMI HDMI/DP,pcm=8
06:24:51.7229 �[0m�[36m[DEBUG] �[0m(1) kanata_state_machine::oskbd::linux: Use for input: false. Non-input device: HDA ATI HDMI HDMI/DP,pcm=9
06:24:51.7329 �[0m�[36m[DEBUG] �[0m(1) kanata_state_machine::oskbd::linux: Use for input: false. Non-input device: HDA ATI HDMI HDMI/DP,pcm=10
06:24:51.7389 �[0m�[36m[DEBUG] �[0m(1) kanata_state_machine::oskbd::linux: Use for input: true. detect type KeyboardOnly; device type Keyboard, device name: Kathakali's S21+ Keyboard
06:24:51.7389 �[0m�[36m[DEBUG] �[0m(1) kanata_state_machine::oskbd::linux: Use for input: false. detect type KeyboardOnly; device type Mouse, device name: Kathakali's S21+ Mouse
06:24:51.7390 �[0m�[36m[DEBUG] �[0m(1) kanata_state_machine::oskbd::linux: Use for input: true. detect type KeyboardOnly; device type Keyboard, device name: Paris Commune Keyboard
06:24:51.7390 �[0m�[36m[DEBUG] �[0m(1) kanata_state_machine::oskbd::linux: Use for input: false. detect type KeyboardOnly; device type Mouse, device name: Paris Commune Mouse
06:24:51.7390 �[0m�[34m[INFO] �[0mregistering /dev/input/event1: "Logitech USB Receiver"
06:24:51.7589 �[0m�[34m[INFO] �[0mregistering /dev/input/event2: "Logitech USB Receiver Keyboard"
06:24:51.7779 �[0m�[34m[INFO] �[0mregistering /dev/input/event3: "ZSA Technology Labs Ergodox EZ"
06:24:51.7979 �[0m�[34m[INFO] �[0mregistering /dev/input/event5: "ZSA Technology Labs Ergodox EZ Consumer Control"
06:24:51.8139 �[0m�[34m[INFO] �[0mregistering /dev/input/event6: "ZSA Technology Labs Ergodox EZ Keyboard"
06:24:51.8349 �[0m�[34m[INFO] �[0mregistering /dev/input/event18: "Kathakali's S21+ Keyboard"
06:24:51.8519 �[0m�[34m[INFO] �[0mregistering /dev/input/event19: "Kathakali's S21+ Mouse"
06:24:51.8729 �[0m�[34m[INFO] �[0mregistering /dev/input/event21: "Paris Commune Keyboard"
06:24:51.9059 �[0m�[34m[INFO] �[0mregistering /dev/input/event22: "Paris Commune Mouse"
06:24:52.2196 �[0m�[34m[INFO] �[0mStarting kanata proper
06:24:52.2196 �[0m�[34m[INFO] �[0mYou may forcefully exit kanata by pressing lctl+spc+esc at any time. These keys refer to defsrc input, meaning BEFORE kanata remaps keys.
06:25:05.0836 �[0m�[36m[DEBUG] �[0m(3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_LEFTCTRL (29), value: Press }
06:25:05.0837 �[0m�[36m[DEBUG] �[0m(3) kanata_state_machine::kanata: key press     LCtrl
06:25:05.0837 �[0m�[36m[DEBUG] �[0m(3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTCTRL), value: 1 }
06:25:05.0846 �[0m�[36m[DEBUG] �[0m(3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_C (46), value: Press }
06:25:05.0846 �[0m�[36m[DEBUG] �[0m(3) kanata_state_machine::kanata: key press     C
06:25:05.0846 �[0m�[36m[DEBUG] �[0m(3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_C), value: 1 }

@jtroo
Copy link
Owner

jtroo commented Nov 25, 2024

Ah, the log message is correct but the return value is wrong.

@jtroo
Copy link
Owner

jtroo commented Nov 25, 2024

89235ac

@jtroo jtroo closed this as completed Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linux Issue pertains to Linux only
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants