SDL: fixed d-pad support (or any joyhat device)
This commit is contained in:
parent
3e98bed606
commit
6b645249a1
|
@ -43,8 +43,19 @@ DTestButtonJoy(ButtConfig *bc)
|
|||
{
|
||||
int x;
|
||||
|
||||
for(x = 0; x < bc->NumC; x++) {
|
||||
if(bc->ButtonNum[x] & 0x8000) {
|
||||
for(x = 0; x < bc->NumC; x++)
|
||||
{
|
||||
if(bc->ButtonNum[x] & 0x2000)
|
||||
{
|
||||
/* Hat "button" */
|
||||
if(SDL_JoystickGetHat(s_Joysticks[bc->DeviceNum[x]],
|
||||
((bc->ButtonNum[x] >> 8) & 0x1F)) &
|
||||
(bc->ButtonNum[x]&0xFF))
|
||||
return(1);
|
||||
|
||||
}
|
||||
else if(bc->ButtonNum[x] & 0x8000)
|
||||
{
|
||||
/* Axis "button" */
|
||||
int pos;
|
||||
pos = SDL_JoystickGetAxis(s_Joysticks[bc->DeviceNum[x]],
|
||||
|
@ -54,18 +65,11 @@ DTestButtonJoy(ButtConfig *bc)
|
|||
} else if (!(bc->ButtonNum[x] & 0x4000) && pos >= 16363) {
|
||||
return(1);
|
||||
}
|
||||
} else if(bc->ButtonNum[x] & 0x2000) {
|
||||
/* Hat "button" */
|
||||
if(SDL_JoystickGetHat(s_Joysticks[bc->DeviceNum[x]],
|
||||
(((bc->ButtonNum[x] >> 8) & 0x1F) &
|
||||
(bc->ButtonNum[x]&0xFF)))) {
|
||||
return(1);
|
||||
}
|
||||
} else if(SDL_JoystickGetButton(s_Joysticks[bc->DeviceNum[x]],
|
||||
bc->ButtonNum[x])) {
|
||||
else if(SDL_JoystickGetButton(s_Joysticks[bc->DeviceNum[x]],
|
||||
bc->ButtonNum[x]))
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue