How to make 2 keyboards emit different key-codes for the same key?

The title may not be the exact description of my "wants", but I think it highlights the best possible (and universal) approach.

I have a regular keyboard. Then I have a small USB device with merely 4 buttons or keys on it. It is identified as a keyboard in /dev both as kbd8 and ums3 - those appear to be the same devices or maybe buses. I do not know that subject very well.

In any case, pressing keys on a small "keyboard" prints "a", "b", "c", "d" respectively, with correct key-codes and exactly the same ones my regular keyboard would print if I pressed those keys on it. Of course, I want very different key-codes from this small device -- preferably the ones that are hard to find on any other keyboard-like devices. Not something too fancy for now, but, say, for now: if instead of those letters I'd be getting back F17, F18, F19 and F20 that would satisfy me.

I read man for setxkbmap and experimented with layouts, symbols, etc. - and all I could find in the /usr/local/share/X11/xkb/ directory. I then tried constructing my own layouts, symbols... ah! Too much. And then, of course, attempting to assign it all to this particular device only.

It almost worked, actually, when I made this device print "fr" instead of "us" characters upon pressing the keys. This worked by trial and error: I figured out the necessary device number requried, so I could say "setxkbmap -device N ..." and the rest would apply only to this device, but not my main keyboard. However, French isn't exactly what I had in mind, nor is it particularly convenient when it comes to assigning keys for various purposes.

Does anyone have any specific instruction on how to achieve this simple goal? I had spent some considerable time on it and, I figured, asking now would be a good time to ask, because I cannot be obsessing over such an puny issue any longer.

Thank you.
 
I actually have no idea. I checked with various utilities: this device is from a no-name vendor, very cheap, very simple - but it's exactly what I need. Is there a way to check if it's an HID device?

Btw, I've set uhid_load="YES" in /boot/loader.conf prior to my my attempts to tweak it. In fact I started with kbdcontrol(1), but got no luck there. But then I realized, I didn't need this to work outside of Xorg, and it seemed like setxkbmap got me somewhat closer to a solution.

If you can tell me exactly how can I accomplish my goal in any way (with or without Xorg's tools, so long as it works in Xorg too and does not interfere with the other keyboard) - and tell me how to not waste more than 20 minutes on it... that would be a wonderful advice!

I heard years ago people were having similar issues, specifically on Linux, but I never found any solution for it back then. I'm sure someone searching for a similar problem in the future would also be very greateful if we crack this case. It's just that it is now that I decided to finally put the device to its intended use, years after I purchased it.
 
Back
Top