File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -287,6 +287,12 @@ PROFILE_START_SLICE("ENGINE_Pump");
287287 break ;
288288 CheckJoystickMotion (event);
289289 break ;
290+ // joystick hat (it the crosspad on a Xbox360 joystick)
291+ case SDL_JOYHATMOTION:
292+ if (!bJoystickSupported)
293+ break ;
294+ CheckJoystickHat (event);
295+ break ;
290296
291297 case SDL_QUIT:
292298 bQuit = true ;
@@ -472,6 +478,18 @@ void Engine::CheckJoystickMotion(SDL_Event event)
472478 }
473479// gLog.OutPut("CheckJoystick END\n");
474480}
481+
482+ void Engine::CheckJoystickHat (SDL_Event event)
483+ {
484+ // gLog.OutPut("CheckJoystickHat START\n");
485+ Uint8 hat = event.jhat .hat ;
486+ KeyStateAlltered (JOYSTICK_LEFT, hat & SDL_HAT_LEFT);
487+ KeyStateAlltered (JOYSTICK_RIGHT, hat & SDL_HAT_RIGHT);
488+ KeyStateAlltered (JOYSTICK_UP, hat & SDL_HAT_UP);
489+ KeyStateAlltered (JOYSTICK_DOWN, hat & SDL_HAT_DOWN);
490+ // gLog.OutPut("CheckJoystickHat END\n");
491+ }
492+
475493// ================================================================================================//
476494 /* ************************
477495 ** Keystate has changed **
Original file line number Diff line number Diff line change @@ -162,6 +162,7 @@ class Engine
162162
163163 void InitializeKeys ();
164164 void CheckJoystickMotion (SDL_Event e);
165+ void CheckJoystickHat (SDL_Event e);
165166 void ConfigureKey (int keyIndex, bool set, int keyPressed);
166167 void KeyStateAlltered (int key,bool state);
167168 void KeysPostUpdate ();
You can’t perform that action at this time.
0 commit comments