Trackball: changing button behaviour

I’m having trouble finding the right part of the firmware that defines the trackball buttons. It seems not to be as straight forward as changing the keyboard fimeware by modifing the keycode matrix.
Could anyone help by pointing me to the corresponding lines in the code?

Starting from this line you can see GPIO lines polling which assigns buttons behaviour corresponding to the GPIO Port D state:

  • D3 & D4 are setting mouse buttons 1 & 2
  • D1 is setting button 4 at line 303
  • D0 & D2 are setting wheel mode at line 310 and translating ball movement into H & V wheel movement.

These GPIO lines are initialized at line 170 but this is GPIO port initialisation, not mouse button assignment. So as long as you want to keep the same GPIO lines attached to buttons (any buttons) the same init sequence applies.
So if you want to remap key functions - you need to do it at GPIO Polling code. Note though it’s not a KeyboardMouse HID device, so you cannot assign arbitrary kbd keys. But you can add one more mouse button (g instead of second wheel button). And then you can remap functions using evdev/udev/hwid

4 Likes

Thank you really much for the great answer!
The trackball not being a KeyboardMouse HID device explains a lot. I will experiment a bit and document anything usefull that happens as a result of it :smile:.