erjiang / huion-keys

Linux program to create custom bindings for Huion tablet hotkeys
GNU General Public License v3.0
13 stars 4 forks source link

Switchable keybinding sets #6

Closed erjiang closed 3 years ago

erjiang commented 3 years ago

@NeoTheFox reports that the official drivers have a feature for certain buttons that change the mapping of other buttons.

original description removed

NeoTheFox commented 3 years ago

I think you misunderstood the feature a bit. The cycling isn't happening on consecutive presses. One button in the center of the dial (Button 9, currently mappable) cycles between 3 possible sets of the dial clockwise/counter-clockwise bindings. The Button 9 itself is not mappable and works exclusively to toggle between dial sets.

erjiang commented 3 years ago

@NeoTheFox Ah, you're right; I did misunderstand it. I'll go ahead and change the text.

erjiang commented 3 years ago

One idea could be to have separate ini sections in the config file:

9=next_mode

[Mode 1]
dial_cw=a

[Mode 2]
dial_cw=b

but I don't know if we'd also need to redefine all other buttons in each mode or have each mode be an "overlay" on the base bindings.

NeoTheFox commented 3 years ago

I think overlay is good, or it could only apply specifically to the dial. I wonder how the dial works on KD200, and if it also switches between 3 modes - this dial mode switching is probably the behavior we would want. From what I can tell from your HID dump - Huion devices seem to have the same code sequences for similar functionality, and so KD200 could get this feature "for free" even. I think performance-wise it would be best to pre-generate a dictionary for all the modes at the time of config parsing and just populate the missing keys in each mode with the ones outside the "Mode" section. This way while it's actually running it would only have to use something like Map[Mode][Key], and not do any additional checks.

erjiang commented 3 years ago

Implemented by #9