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

distinguish between two deskhop on one computer #212

Closed
chri2 opened this issue Jan 23, 2025 · 9 comments
Closed

distinguish between two deskhop on one computer #212

chri2 opened this issue Jan 23, 2025 · 9 comments

Comments

@chri2
Copy link

chri2 commented Jan 23, 2025

I have two desks I'm working on, each of the desks having its own deskhop.

Keyboard and mouse are different in both places and I'd like to setup my OS to use different settings for each of the keyboard/mouse on the different two deskhops.

The deskhop connected to my computer looks in both places the same - I can't distinguish between deskhop1 (keyboard a and mouse b) and deskhop2 (keyboard c and mouse d).

Therefore I can't e.g. (re-)map keys on the OS-side for each of the keyboards differently.

A possible solution would be to allow to setup a deskhop with a different from the default usb id or maybe allow setting of a serial number that on other devices can be recognized by e.g. udevd.

@AJolly
Copy link

AJolly commented Jan 25, 2025

You may be able to track based on which USB port you are connected to,?

When you say two desks are both desks being run from the same computer?

@hrvach hrvach closed this as completed in cf842f8 Jan 27, 2025
@hrvach
Copy link
Owner

hrvach commented Jan 27, 2025

Patched in cf842f8, would this help you use udev rules or something else to match the two devices?

@chri2
Copy link
Author

chri2 commented Jan 28, 2025

@AJolly

When you say two desks are both desks being run from the same computer?

Yes and on both desks the deskhop is connected to the same port ;-) - but yes, thanks, great idea! I didn't think about it that way, yet.

@hrvach

Patched in cf842f8, would this help you use udev rules or something else to match the two devices?

Yes, great! I'm no programmer, but the diff looks like it adds a serial that can be set in the .h file during compiling. Excellent - thank you! I'll test it later and report back.

@hrvach
Copy link
Owner

hrvach commented Jan 28, 2025

It's not actually set in the .h file (just the placeholder) but uses the unique ID gathered from the SPI flash which is the standard way these boards determine serial number. Each board should have an unique ID and ideally you'll be able to differentiate based on that.

@chri2
Copy link
Author

chri2 commented Jan 29, 2025

Thanks for clarifying!

@chri2
Copy link
Author

chri2 commented Jan 30, 2025

Just tested and it works. I had to struggle a bit with udev on linux. Here's my solution (Debian Bookworm):

Make udev ask the hardware database using deskhops serial number

On my system the default udev rules do not include the information about the serial number when asking the hardware database for extra information about a device.

/etc/udev/rules.d/59-evdev.rules:

ACTION=="remove", GOTO="evdev_end"
KERNEL!="event*", GOTO="evdev_end"

# Device matching the input device name and the S/N (used for Deskhop)
KERNELS=="input*", \
  IMPORT{builtin}="hwdb 'evdev:sn:$attr{name}:$attr{uniq}'", \
  ENV{.HAVE_HWDB_PROPERTIES}="1"

LABEL="evdev_end"

The filename is chosen, so that this rule would run before my default rule for evdev named /lib/udev.d/rules/60-evdev.rules. You might need to change the filename for your system accordingly. /lib/udev.d/rules/60-evdev.rules contains IMPORT{builtin}="keyboard" which should run after the new rule.

Add extra information for the keyboard attached to deskhop

The device match above will lookup the hardware database for a section evdev:sn:<deskhop name>:<deskhop s/n>. I added it to the database:

/etc/udev/hwdb.d/59-keyboard.hwdb:

# deskhop with S/N
evdev:sn:Hrvoje Cavrak DeskHop Switch Keyboard:xxxxxxxxxxxxxxxxx
 KEYBOARD_KEY_7004a=insert
 KEYBOARD_KEY_70049=home

To get the xxxxxxxxxxxxxxxxx part (serial number) I used lsusb -d2e8a:107c -v | grep -i serial which outputs something like

# lsusb -d2e8a:107c -v | grep -i serial
  iSerial                 3 xxxxxxxxxxxxxxxxx

The first digit seperated by space from the S/N is not part of the number - in my example the 3.

@hrvach
Copy link
Owner

hrvach commented Jan 30, 2025

That's great, since you were kind enough to write this down, care to put it in a Wiki format and I'll add it to the project docs?

@chri2
Copy link
Author

chri2 commented Jan 31, 2025

I believe the wiki will accept md? The comment has already been written in md, but I guess it's only possible to extract those via the api in md again. If it could help anybody, please go ahead and put it onto the wiki!

Thanks for the great project!

comment.md

@hrvach
Copy link
Owner

hrvach commented Feb 2, 2025

I believe the wiki will accept md? The comment has already been written in md, but I guess it's only possible to extract those via the api in md again. If it could help anybody, please go ahead and put it onto the wiki!

Thanks for the great project!

comment.md

Added, thank you again for being helpful and sharing!

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

No branches or pull requests

3 participants