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

Multiple defcfg linux-dev #62

Closed
br-lemes opened this issue Jul 23, 2022 · 5 comments
Closed

Multiple defcfg linux-dev #62

br-lemes opened this issue Jul 23, 2022 · 5 comments
Labels
enhancement New feature or request linux Issue pertains to Linux only

Comments

@br-lemes
Copy link
Contributor

I use two of these 6x4 keypad as a split keyboard. As they are two independent keyboards, normally I can't setup layers which works across the "halves" (a key in one keypad which activates a layer in the other one). To solve this I currently use evsieve to fake one device out of these two. This way:

# evsieve --input /dev/input/by-id/usb-BlackC_Sayobot.cn_L-event-kbd grab --input /dev/input/by-id/usb-BlackC_Sayobot.cn_R-event-kbd grab --output create-link=/dev/input/by-id/sayo

It would be nice if kanata could use multiple devices this way out of the box.

H80454abdae6b4f8c9749ffbb733055a5D

@jtroo jtroo added this to the v1.0.6 milestone Jul 23, 2022
@jtroo
Copy link
Owner

jtroo commented Jul 23, 2022

That's a cool use case, thanks for sharing it! 👍

@jtroo jtroo added enhancement New feature or request linux Issue pertains to Linux only labels Jul 23, 2022
@jtroo
Copy link
Owner

jtroo commented Jul 23, 2022

You've probably found this already, but for reference, the input reading is done in:
https://github.com/jtroo/kanata/blob/main/src/oskbd/linux.rs

Currently, the event loop does blocking calls to fetch_events for a single device, so would need to rearchitect the input event handling to be able to handle multiple devices. It would be good to dig into evsieve's source as inspiration for how they do it.


Edit:

Browsing through evsieve's source, it uses C style code using epoll and raw file descriptors. Quite efficient, but a lot more complicated than what kanata's doing.

@jtroo
Copy link
Owner

jtroo commented Jul 24, 2022

I've added a kanata-evsieve crate exposing the evsieve functionality as a library. Not sure yet if using it is a viable strategy, but seems like it should work out okay.

@jtroo jtroo modified the milestone: v1.0.6 Jul 25, 2022
@jtroo
Copy link
Owner

jtroo commented Jul 30, 2022

@br-lemes please test the code in the new PR at your leisure. I haven't actually tested it on multiple keyboards myself since I don't have a convenient way to do so, but I think it should work.

Config change:

  ;; If you want to read from multiple devices, separate them by `:`.
  ;; linux-dev /dev/input/<dev1>:/dev/input/<dev2>

@br-lemes
Copy link
Contributor Author

Yes, it works. I'm typing using the PR version right now!

It's great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request linux Issue pertains to Linux only
Projects
None yet
Development

No branches or pull requests

2 participants