Properly handle Linux event device button numbers
Old code would, by coincidence, map 1->16 to 1->16, then 17->32 to 1->32, leaving 1 and 17 on the same button number. We still map 33->56 to 1->24, creating some overlap. But at least that's because StepMania will have run out of buttons. THIS PATCH WILL CHANGE THE CODES OF JOYSTICK BUTTONS 17 AND UP.
This commit is contained in:
@@ -386,9 +386,18 @@ void InputHandler_Linux_Event::InputThread()
|
||||
|
||||
switch (event.type) {
|
||||
case EV_KEY: {
|
||||
int iNum = event.code;
|
||||
// In 2.6.11 using an EMS USB2, the event number for P1 Tri (the first button)
|
||||
// is being reported as 32 instead of 0. Correct for this.
|
||||
int iNum;
|
||||
if (event.code >= BTN_JOYSTICK && event.code <= BTN_JOYSTICK + 0xf) {
|
||||
// These guys have arbitrary names, but the kernel code in hid-input.c maps exactly 0xf of them.
|
||||
iNum = event.code - BTN_JOYSTICK;
|
||||
} else if (event.code >= BTN_TRIGGER_HAPPY1 && event.code <= BTN_TRIGGER_HAPPY40) {
|
||||
// Actually, we only have 32 buttons defined.
|
||||
iNum = event.code - BTN_TRIGGER_HAPPY1 + 0x10;
|
||||
} else {
|
||||
// If the button number is >40+0xf, it gets mapped to a code with no #define.
|
||||
// I don't know if this is appropriate at all, but what else to do?
|
||||
iNum = event.code;
|
||||
}
|
||||
wrap( iNum, 32 ); // max number of joystick buttons. Make this a constant?
|
||||
ButtonPressed( DeviceInput(g_apEventDevices[i]->m_Dev, enum_add2(JOY_BUTTON_1, iNum), event.value != 0, now) );
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user