1 // Copyright 2001-2019 Crytek GmbH / Crytek Group. All rights reserved.
3 /*************************************************************************
4 -------------------------------------------------------------------------
7 Description: GamePad Input implementation for Linux using SDL
8 -------------------------------------------------------------------------
10 - Jan 20,2014: Created by Leander Beernaert
12 *************************************************************************/
16 #if defined(USE_LINUXINPUT)
19 #include "LinuxInput.h"
20 // We need a manager, since all the input for each Game Pad is collected
21 // in the same queue. If we were to update the game pads seperately
22 // they would consume each other's events.
24 class CSDLPad
: public CLinuxInputDevice
28 CSDLPad(CLinuxInput
& input
, int device
);
32 // IInputDevice overrides
33 virtual int GetDeviceIndex() const { return m_deviceNo
; }
35 virtual void Update(bool bFocus
);
36 virtual void ClearAnalogKeyState(TInputSymbols
& clearedSymbols
);
37 virtual void ClearKeyState();
38 virtual bool SetForceFeedback(IFFParams params
);
41 int GetInstanceId() const;
43 void HandleAxisEvent(const SDL_JoyAxisEvent
& evt
);
45 void HandleHatEvent(const SDL_JoyHatEvent
& evt
);
47 void HandleButtonEvent(const SDL_JoyButtonEvent
& evt
);
49 void HandleConnectionState(const bool connected
);
51 static float DeadZoneFilter(int input
);
58 SDL_Joystick
* m_pSDLDevice
;
59 SDL_Haptic
* m_pHapticDevice
;
60 int m_curHapticEffect
;
64 bool m_supportsFeedback
;
72 CSDLPadManager(CLinuxInput
& input
);
78 void Update(bool bFocus
);
81 bool AddGamePad(int deviceIndex
);
83 bool RemovGamePad(int instanceId
);
85 CSDLPad
* FindPadByInstanceId(int instanceId
);
86 CSDLPad
* FindPadByDeviceIndex(int deviceIndex
);
89 typedef std::vector
<CSDLPad
*> GamePadVector
;
91 CLinuxInput
& m_rLinuxInput
;
92 GamePadVector m_gamePads
;