!B (Physics) temp constraint buffer reallocation problem if too many ragdolls
[CRYENGINE.git] / Code / CryEngine / CryInput / SDLPad.h
blob17568d52e8dcf3a33f4874783b67f4aef9c17c00
1 // Copyright 2001-2017 Crytek GmbH / Crytek Group. All rights reserved.
3 /*************************************************************************
4 -------------------------------------------------------------------------
5 $Id$
6 $DateTime$
7 Description: GamePad Input implementation for Linux using SDL
8 -------------------------------------------------------------------------
9 History:
10 - Jan 20,2014: Created by Leander Beernaert
12 *************************************************************************/
14 #pragma once
16 #if defined(USE_LINUXINPUT)
18 #include <SDL.h>
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
26 public:
28 CSDLPad(CLinuxInput& input, int device);
30 virtual ~CSDLPad();
32 // IInputDevice overrides
33 virtual int GetDeviceIndex() const { return m_deviceNo; }
34 virtual bool Init();
35 virtual void Update(bool bFocus);
36 virtual void ClearAnalogKeyState(TInputSymbols& clearedSymbols);
37 virtual void ClearKeyState();
38 virtual bool SetForceFeedback(IFFParams params);
39 // ~IInputDevice
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);
50 private:
51 static float DeadZoneFilter(int input);
53 bool OpenDevice();
55 void CloseDevice();
57 private:
58 SDL_Joystick* m_pSDLDevice;
59 SDL_Haptic* m_pHapticDevice;
60 int m_curHapticEffect;
61 int m_deviceNo;
62 int m_handle;
63 bool m_connected;
64 bool m_supportsFeedback;
65 float m_vibrateTime;
68 class CSDLPadManager
70 public:
72 CSDLPadManager(CLinuxInput& input);
74 ~CSDLPadManager();
76 bool Init();
78 void Update(bool bFocus);
80 private:
81 bool AddGamePad(int deviceIndex);
83 bool RemovGamePad(int instanceId);
85 CSDLPad* FindPadByInstanceId(int instanceId);
86 CSDLPad* FindPadByDeviceIndex(int deviceIndex);
87 private:
89 typedef std::vector<CSDLPad*> GamePadVector;
91 CLinuxInput& m_rLinuxInput;
92 GamePadVector m_gamePads;
95 #endif