You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.7 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __SDL_JOYSICK_WRAPPER_HEADER__
  2. #define __SDL_JOYSICK_WRAPPER_HEADER__
  3. #include "core/coreWidget.h"
  4. #include "core/coreLabel.h"
  5. #include "../components/object/objectFlyHunter.h"
  6. #define ANIMATION_DELAY 50
  7. #define JOYSTICK_MAX_BUTTONS 32
  8. #define JOYSTICK_MAX_USED_BUTTONS 12
  9. #define JOYSTICK_MAX_AXIS 9
  10. #define JOYSTICK_MAX_HATS 2
  11. #define JOYSTICK_MAX_BALLS 2
  12. class sdlJoystickWrapper: public sdlCoreWidget {
  13. private:
  14. basicLogCollection * m_pLog;
  15. SDL_Joystick * m_pJoystick;
  16. SDL_mutex * m_pProtector;
  17. sdlLabel * m_pJoyNameLabel;
  18. sdlLabel * m_pButtonLabels[JOYSTICK_MAX_BUTTONS];
  19. objectFlyHunter * m_pFlyHunter;
  20. uint8_t m_bNumAxes;
  21. uint8_t m_bNumBalls;
  22. uint8_t m_bNumButtons;
  23. uint8_t m_bNumHats;
  24. uint8_t m_bAnimationStage;
  25. uint64_t m_nNextAnimationStage;
  26. TEXTURE_HEAP_ITEM * m_pHatTexture;
  27. //------------------------------------------------//
  28. bool m_aButtons[JOYSTICK_MAX_BUTTONS];
  29. int16_t m_aAxis[JOYSTICK_MAX_AXIS];
  30. int m_aBall_x[JOYSTICK_MAX_BALLS];
  31. int m_aBall_y[JOYSTICK_MAX_BALLS];
  32. uint8_t m_hat[JOYSTICK_MAX_HATS];
  33. protected:
  34. virtual void drawBefore(SDL_Renderer* pRenderer);
  35. virtual void drawAfter(SDL_Renderer* pRenderer);
  36. virtual void dispatch(SDL_Event* pEvt);
  37. virtual bool create(void);
  38. public:
  39. explicit sdlJoystickWrapper(int x, int y, /*int w, int h,*/ sdlCoreWidget *parent=NULL);
  40. virtual ~sdlJoystickWrapper();
  41. void setController(int id);
  42. void setController(SDL_Joystick* joystick);
  43. void setFlyHunter(objectFlyHunter* ptr) { m_pFlyHunter; };
  44. /*emitters*/
  45. void (*Roll)(int16_t) = NULL;
  46. void (*Pitch)(int16_t) = NULL;
  47. void (*Yaw)(int16_t) = NULL;
  48. void (*Throttle)(int16_t) = NULL;
  49. };
  50. #endif