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.
53 lines
1.7 KiB
53 lines
1.7 KiB
#ifndef __SDL_JOYSICK_WRAPPER_HEADER__
|
|
#define __SDL_JOYSICK_WRAPPER_HEADER__
|
|
#include "core/coreWidget.h"
|
|
#include "core/coreLabel.h"
|
|
#include "../components/object/objectFlyHunter.h"
|
|
#define ANIMATION_DELAY 50
|
|
#define JOYSTICK_MAX_BUTTONS 32
|
|
#define JOYSTICK_MAX_USED_BUTTONS 12
|
|
#define JOYSTICK_MAX_AXIS 9
|
|
#define JOYSTICK_MAX_HATS 2
|
|
#define JOYSTICK_MAX_BALLS 2
|
|
class sdlJoystickWrapper: public sdlCoreWidget {
|
|
private:
|
|
basicLogCollection * m_pLog;
|
|
SDL_Joystick * m_pJoystick;
|
|
SDL_mutex * m_pProtector;
|
|
sdlLabel * m_pJoyNameLabel;
|
|
sdlLabel * m_pButtonLabels[JOYSTICK_MAX_BUTTONS];
|
|
objectFlyHunter * m_pFlyHunter;
|
|
|
|
uint8_t m_bNumAxes;
|
|
uint8_t m_bNumBalls;
|
|
uint8_t m_bNumButtons;
|
|
uint8_t m_bNumHats;
|
|
|
|
uint8_t m_bAnimationStage;
|
|
uint64_t m_nNextAnimationStage;
|
|
TEXTURE_HEAP_ITEM * m_pHatTexture;
|
|
//------------------------------------------------//
|
|
bool m_aButtons[JOYSTICK_MAX_BUTTONS];
|
|
int16_t m_aAxis[JOYSTICK_MAX_AXIS];
|
|
int m_aBall_x[JOYSTICK_MAX_BALLS];
|
|
int m_aBall_y[JOYSTICK_MAX_BALLS];
|
|
uint8_t m_hat[JOYSTICK_MAX_HATS];
|
|
protected:
|
|
virtual void drawBefore(SDL_Renderer* pRenderer);
|
|
virtual void drawAfter(SDL_Renderer* pRenderer);
|
|
virtual void dispatch(SDL_Event* pEvt);
|
|
virtual bool create(void);
|
|
public:
|
|
explicit sdlJoystickWrapper(int x, int y, /*int w, int h,*/ sdlCoreWidget *parent=NULL);
|
|
virtual ~sdlJoystickWrapper();
|
|
void setController(int id);
|
|
void setController(SDL_Joystick* joystick);
|
|
void setFlyHunter(objectFlyHunter* ptr) { m_pFlyHunter; };
|
|
/*emitters*/
|
|
void (*Roll)(int16_t) = NULL;
|
|
void (*Pitch)(int16_t) = NULL;
|
|
void (*Yaw)(int16_t) = NULL;
|
|
void (*Throttle)(int16_t) = NULL;
|
|
};
|
|
|
|
#endif
|