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

feat(linux): add device names options #415

Merged
merged 2 commits into from
May 23, 2023
Merged

Conversation

jtroo
Copy link
Owner

@jtroo jtroo commented May 22, 2023

Implements #376, #378

@jtroo jtroo force-pushed the linux-better-device-handling branch from 6a38c6c to ce7e4e4 Compare May 22, 2023 06:28
@jtroo
Copy link
Owner Author

jtroo commented May 22, 2023

Note: I haven't tested the functionality by unplugging or replugging devices since I typically only use Linux via Virtual Machines or WSL2, and I don't ever attach the USB keyboard device to the VM directly. But I think it should work.

@rszyma
Copy link
Contributor

rszyma commented May 22, 2023

Note: I haven't tested the functionality by unplugging or replugging devices since I typically only use Linux via Virtual Machines or WSL2, and I don't ever attach the USB keyboard device to the VM directly. But I think it should work.

I don't see any issues with linux-dev-names-exclude

However, I think there's a problem with linux-dev-names-include:

11:28:19 [INFO] kanata v1.4.0-prerelease-1 starting
11:28:19 [INFO] process unmapped keys: false
11:28:19 [INFO] NOTE: kanata was compiled to never allow cmd
11:28:19 [INFO] config parsed
11:28:19 [INFO] Created device "/sys/devices/virtual/input/input129/event18"
11:28:19 [INFO] Sleeping for 2s. Please release all keys and don't press additional ones.
11:28:21 [INFO] entering the processing loop
11:28:21 [INFO] entering the event loop
11:28:21 [INFO] looking for devices in /dev/input
11:28:21 [INFO] Init: catching only releases and sending immediately
11:28:21 [INFO] device [/dev/input/event16:ROYUAN Akko Multi-modes Keyboard-B Mouse] is ignored
11:28:21 [INFO] device [/dev/input/event15:ROYUAN Akko Multi-modes Keyboard-B Keyboard] is ignored
11:28:21 [INFO] device [/dev/input/event13:ROYUAN Akko Multi-modes Keyboard-B Consumer Control] is ignored
11:28:21 [INFO] device [/dev/input/event12:ROYUAN Akko Multi-modes Keyboard-B] is included
11:28:21 [INFO] device [/dev/input/event4:ELAN071A:00 04F3:30FD Mouse] is ignored
11:28:21 [INFO] device [/dev/input/event2:AT Translated Set 2 keyboard] is ignored
11:28:21 [INFO] registering /dev/input/event12: "ROYUAN Akko Multi-modes Keyboard-B"
11:28:22 [INFO] Starting kanata proper
11:28:24 [WARN] removing kbd device: /dev/input/event12
11:28:33 [INFO] watch found file changes, looking for new devices
11:28:33 [INFO] looking for devices in /dev/input
11:28:34 [INFO] device [/dev/input/event4:ELAN071A:00 04F3:30FD Mouse] is ignored
11:28:34 [INFO] device [/dev/input/event2:AT Translated Set 2 keyboard] is ignored
11:28:34 [ERROR] failed read: Could not auto detect any keyboard devices

Press enter to exit
11:28:34 [ERROR] channel disconnected

Error: failed read: Could not auto detect any keyboard devices
  1. I started kanata with the keyboard I want to remap specified in linux-dev-names-include
  2. at 11:28:24 I plugged out the keyboard
  3. at 11:28:33 I plugged in the keyboard back

@rszyma
Copy link
Contributor

rszyma commented May 22, 2023

Adding 200 ms sleep here no longer throws an error.

log::info!("watch found file changes, looking for new devices");

@jtroo
Copy link
Owner Author

jtroo commented May 22, 2023

Thanks for testing!

Added a sleep, though in a different line of code, to be more targeted. A single hard-coded longer sleep feels a little unclean, as opposed to shorter retry-sleeps, but I think in practice it doesn't matter since this only happens when plugging in a new keyboard.

@jtroo jtroo merged commit 5e9474f into main May 23, 2023
3 checks passed
@jtroo jtroo deleted the linux-better-device-handling branch May 23, 2023 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow specifying devices *not* to handle Allow specifying device by name
2 participants