[hi] autoselect device to focus on?

Joe Kaplan's icon

I'm discovering some challenges with [hi].

I have 4 identical gamepads attached to my system. An instance of it appears in the [hi] menu as "twokey." when I populate the [hi] menu on my MacBook Pro it lists 12 version of the device. So the menu shows "twokey", "twokey 2," "twokey 3"... "twokey 12" in addition to a bunch of other devices.

Through trial and error I can identify which four of those twelve devices are real. And everything is fine. But if I unplug my USB hub and plug it back in, or if I restart my computer, the devices shuffle around. Of the 12 devices in the menu, the active ones appear to be a random 4 devices each session.

This means I have to go through the trial and error exercise and manually set my [hi] objects every time I start the patch in a new location. This is not ideal. It's the kind of cumbersome setup susceptible to human error that's good to avoid in performance situations.

I know [hi] has to focus on a device to report output. But is there any other solution or workaround that can tell me which device an input is coming from? Ideally I could create an initialization routine, where the UI can say "press a button on device 1" and then the patch can identify that the device and focus the [hi] objects accordingly.

Curious if the hivemind has any input here. Thanks!

Source Audio's icon

I was quite sure that you will get this problem, that's why I suggested arduino.
Could you rename USB descriptor of each twokey device to define itself with different name and Product ID ?

I don't know that firmware, and have no time to digg into it, but believe that reason you see it tripple for each device is because of the firmware not being reduced to a single type USB descriptor.
The screenshot you posted in another thread shows it :

Means you need not only to flash each device with different product ID, (PID)
but also to reduce descriptor to gamepad device.

If you can't manage that ...
one hardware instance of that twokey units should show up
in consecutive order, , like 4 5 6, out of 12, and one of them will be usable,
1st, 2nd or 3rd, in each of them.
If 1st one would be the one that transmits, then twokey 1, twokey 4, twokey 7 etc.
maybe ... ?

Joe Kaplan's icon

Thanks again Source Audio!

I don't know the QMK firmware very well either. But I was able to change the USB descriptor for each device. They now register as "Red Button," "Blue Button," "Green Button," and "Black Button." I was also able to reduce the descriptor so that two instances of each appear instead of three instances. But the first one is always the real one. This lets me make it work exactly how I thought it would!


On Mac, at least. Windows must be looking somewhere else for the descriptor. Each button still appears as one instance of "twokey." I don't know why.

I agree that building a button hub myself with an arduino is probably a better solution. I'm looking forward to setting up my arduino workshop next time I need to do something like this.

Source Audio's icon

Did you change PID as well, not only product name ?
On Mac you can see all infos in USB info pane in
system profiler

Joe Kaplan's icon

Hey, it worked! I incremented the PID on each device so they all have a unique Product ID that is different from the original ID the board shipped with. Now Windows is identifying them properly as well. Very exciting.

Thanks again for everything! I will probably have a bunch more questions come Arduino time. :)

Source Audio's icon

feel free to ask them