Advertisement
Al99

InputHandler.h

Nov 11th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #ifndef __InputHandler__
  2. #define __InputHandler__
  3.  
  4. #include <iostream>
  5. #include <vector>
  6. #include <SDL2/SDL.h>
  7.  
  8. class InputHandler
  9. {
  10.     public:
  11.    
  12.     static InputHandler* Instance()
  13.     {
  14.         if(s_pInstance == 0)
  15.         {
  16.             s_pInstance = new InputHandler();
  17.         }
  18.         return s_pInstance;
  19.     }
  20.    
  21.     void update();
  22.     void clean();
  23.    
  24.     void initialiseJoysticks();
  25.     bool joystickInitialised() {
  26.         return m_bjoysticksInitialised; }
  27.        
  28.         int xvalue(int joy, int stick);
  29.         int yvalue(int joy, int stick);
  30.    
  31.     private:
  32.    
  33.     InputHandler() {}
  34.    
  35.     static InputHandler* s_pInstance;
  36.  
  37.     std::vector<SDL_Joystick*> m_joysticks;
  38.     bool m_bjoysticksInitialised;
  39.    
  40.     const int m_joystickDeadZone = 10000;
  41. };
  42.  
  43. typedef InputHandler TheInputHandler;
  44.  
  45. #endif /*defined (InputHandler) */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement