necroware / gameport-adapter

GamePort adapter to connect old DB15 joysticks to USB port
GNU General Public License v3.0
274 stars 54 forks source link

Dynamic Hat padding #73

Closed schuellerf closed 8 months ago

schuellerf commented 8 months ago

I don't know the specification but that seems to fix all my problems (see discussion in #70 )

necroware commented 8 months ago

This works accidentally and some joystick will stop working using this code. For example some Logitech devices. This code makes padding dependent on the amount of hat directions and the number of buttons followed by that. With 0 used as no direction, you'd need 4 bits in total to encode 8 directions (9 values) or 3 bits to encode 4 directions (5 values). If the amount of buttons followed is let's say 4 and you use 4 bits, than you don't need to pad, because you'd get 4 directions and 4 buttons with one bit for each one. In such case this code would work accidentally (example CH Flight Stick, Thrustmaster) but if you have it's let's say 5,7 or 9 buttons (Logitech), the padding will not fit anymore. You can't map the amount of hat directions directly to the amount of bits, which you need to encode that values. It can work accidentally in cases where you have 4 or 8 buttons.

We have to find a proper padding, which windows is so strict about.