|
Lines 199-207
Link Here
|
| 199 |
*/ |
199 |
*/ |
| 200 |
static bool Joy_ReadJoystick(int nSdlJoyID, JOYREADING *pJoyReading) |
200 |
static bool Joy_ReadJoystick(int nSdlJoyID, JOYREADING *pJoyReading) |
| 201 |
{ |
201 |
{ |
|
|
202 |
unsigned hat = SDL_JoystickGetHat(sdlJoystick[nSdlJoyID], 0); |
| 203 |
|
| 202 |
/* Joystick is OK, read position from the configured joystick axis */ |
204 |
/* Joystick is OK, read position from the configured joystick axis */ |
| 203 |
pJoyReading->XPos = SDL_JoystickGetAxis(sdlJoystick[nSdlJoyID], pJoyReading->XAxisID); |
205 |
pJoyReading->XPos = SDL_JoystickGetAxis(sdlJoystick[nSdlJoyID], pJoyReading->XAxisID); |
| 204 |
pJoyReading->YPos = SDL_JoystickGetAxis(sdlJoystick[nSdlJoyID], pJoyReading->YAxisID); |
206 |
pJoyReading->YPos = SDL_JoystickGetAxis(sdlJoystick[nSdlJoyID], pJoyReading->YAxisID); |
|
|
207 |
/* Similarly to other emulators that support hats, override axis readings with hats */ |
| 208 |
if (hat & SDL_HAT_LEFT) |
| 209 |
pJoyReading->XPos = -32768; |
| 210 |
if (hat & SDL_HAT_RIGHT) |
| 211 |
pJoyReading->XPos = 32767; |
| 212 |
if (hat & SDL_HAT_UP) |
| 213 |
pJoyReading->YPos = -32768; |
| 214 |
if (hat & SDL_HAT_DOWN) |
| 215 |
pJoyReading->YPos = 32767; |
| 205 |
/* Sets bit #0 if button #1 is pressed: */ |
216 |
/* Sets bit #0 if button #1 is pressed: */ |
| 206 |
pJoyReading->Buttons = SDL_JoystickGetButton(sdlJoystick[nSdlJoyID], 0); |
217 |
pJoyReading->Buttons = SDL_JoystickGetButton(sdlJoystick[nSdlJoyID], 0); |
| 207 |
/* Sets bit #1 if button #2 is pressed: */ |
218 |
/* Sets bit #1 if button #2 is pressed: */ |