Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches

4. Joystick driver fuckery

Of course, joystick drivers have many quirks that greatly complicate things. So much so that they deserve their own chapter. Here's a list of some of the quirks I've encountered:

Combined triggers

DirectInput combines left and right triggers into a single axis. They are combined using the strategy in Chapter 4: Dimension Reduction.

Kodi solves this by splitting the axis into two semiaxes, as explained in Chapter 2: Joystick drivers. Each semiaxis is mapped to its own trigger.

Anomalous triggers

Not all triggers start at 0.0 and travel to 1.0 (or -1.0 in DirectInput). Some triggers start at 1.0 or -1.0, and travel to 0.0 or to the opposite unit. These are called anomalous triggers. These triggers have two properties: Center - The theory here is that initial perturbations are minimal. This means that the center is determined by rounding the first value to the closest int. Range - The range can be half range (assumed) or full range (detected when a value has the opposite sign)

Discrete D-pads

Instead of four buttons or a hat enum, D-pads can sometimes be reported as floats that use the discrete values -1.0, 0.0 and 1.0. Fortunately, because analog sticks can emulate D-pads, we can simply treat the discrete D-pad as an analog stick.

Repeated input

Some buttons generate two input events. For example, some hats operate as four digital buttons AND as a discrete D-pad. This is solved via a "cooldown" while mapping, which ignores any input for around 50ms after a button is mapped.

Hat enums

I consider hat enums a quirk because it just makes so much more sense to represent them using four buttons. It doesn't even guarantee mutual exclusion between opposite directions, as this can be violated by a flag with the improper bits set.

Pressure-sensitive buttons

Pressure-sensitive buttons can be reported as an analog axis instead of a digital value.

Incomplete information

Pertinent info (name, USB VID and PID, etc) might be missing, making it hard to identify the correct button map.