SDL: fixed d-pad support (or any joyhat device)

This commit is contained in:
punkrockguy318 2010-03-03 06:59:08 +00:00
parent 3e98bed606
commit 6b645249a1
1 changed files with 16 additions and 12 deletions

View File

@ -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,17 +65,10 @@ 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);
}