I’d like to have the UHK60 switch layouts automatically based on the currently focused window.
I could use autohotkey to detect the window. Ahk should be able to talk to the firmware via USB to actually switch the layout (or even change any settings)
But how do I do that? There has to be some kind of interface. Is there any documentation about that?
So that should be only one call with the correct bytes to change a layout for example?
Yes, once you know which hid interface to use.
#!/bin/bash
# find the first hid belonging to UHK 60
hidraw="hidraw`grep 'UHK 60' /sys/class/hidraw/hidraw*/device/uevent | sed -nE 's/.*hidraw([0-9]+)\/.*/\1/p' | sort -rn | head -n 1`"
# now send the command to uhk. `\x14` is the macro command. The rest is a normal string taken from the argument.
echo -e "\x14$*" > "/dev/$hidraw"
I there’s even a script for setting layouts. I guess I have to just get the bytes from there and some of the usb classes.
Yes. usb_protocol_handler will tell you what the bytes are.
agent/uhk-operations leaves me to believe the command for switching keymap should be something like echo -e "\x11 3 71 65 77" > "/dev/$hidraw" (tried also echo -e "\x113 71 65 77" > "/dev/$hidraw")
for a “GAM” keymap:
I suspect the first byte needs to be something like interface id. Not sure if it is constant though - it used to be, but there was couple of changes in the last year.
I.e., try to prefix the message by a small integer (1 byte, less than 10).
Sorry, forgotten about this detail.
edit: eeeh, the echo syntax is wrong. This sends a string, not a list of bytes. Anyways, will look into it later.