Initial for Condor Simulator
Dependents: USBJoystick_2 USBJoystick_NEW
Fork of USBJoystick by
Diff: USBJoystick.h
- Revision:
- 4:71835900760f
- Parent:
- 3:550cca870c98
- Child:
- 5:fa0a30d0ef3d
diff -r 550cca870c98 -r 71835900760f USBJoystick.h --- a/USBJoystick.h Sun Sep 16 09:56:23 2018 +0000 +++ b/USBJoystick.h Sat Sep 29 09:27:44 2018 +0000 @@ -31,8 +31,10 @@ #define REPORT_ID_JOYSTICK 4 //Configure Joystick Slider Resolution -#define SBYTE 1 // 1 Byte, 8 Bit Resolution -#define SWORD 0 // 2 Byte, 16 Bit Resolution +/* +#define SBYTE 0 // 1 Byte, 8 Bit Resolution +#define SWORD 1 // 2 Byte, 16 Bit Resolution +*/ //Configure Joystick Hat Buttons #define HAT4 1 // 4 Hat Buttons; 4 Positions if HAT4_8 = 0 #define HAT4_8 1 // 4 Hat Buttons giving 8 Positions if 1; DO NOT USE WITH HAT8! @@ -75,16 +77,17 @@ }; #endif -/* X, Y and T limits */ +/* Limits */ /* These values do not directly map to screen pixels */ /* Zero may be interpreted as meaning 'no movement' */ -#define JX_MIN_ABS (-127) /*!< The maximum value that we can move to the left on the x-axis */ -#define JY_MIN_ABS (-127) /*!< The maximum value that we can move up on the y-axis */ -#define JT_MIN_ABS (-127) /*!< The minimum value for the throttle */ -#define JX_MAX_ABS (127) /*!< The maximum value that we can move to the right on the x-axis */ -#define JY_MAX_ABS (127) /*!< The maximum value that we can move down on the y-axis */ -#define JT_MAX_ABS (127) /*!< The maximum value for the throttle */ - +#if (SBYTE == 1) + #define MIN_ABS (-127) /*!< The maximum value */ + #define MAX_ABS (127) /*!< The maximum value */ +#endif +#if (SWORD == 1) + #define MIN_ABS (-32767) /*!< The maximum value */ + #define MAX_ABS (32767) /*!< The maximum value */ +#endif /** * * USBJoystick example @@ -166,15 +169,17 @@ /** * Write state of the joystick * - * @param t throttle position - * @param r rudder position * @param x x-axis position * @param y y-axis position + * @param b break position + * @param f flaps position + * @param r rudder position + * @param t throttle position + * @param hat hat state 0 (up), 1 (up right), 2 (right), 3 (down right), 4 (down), 5 (down left), 6 (left), 7 (up left) or 8 (neutral) * @param buttons buttons state - * @param hat hat state 0 (up), 1 (right, 2 (down), 3 (left) or 4 (neutral) * @returns true if there is no error, false otherwise */ - bool update(int16_t t, int16_t r, int16_t d, int16_t w, int16_t x, int16_t y, uint32_t buttons, uint8_t hat); + bool update(uint16_t x, uint16_t y, uint16_t b, uint16_t f, uint16_t r, uint16_t t, uint8_t hat, uint32_t buttons); /** * Write state of the joystick @@ -189,7 +194,7 @@ * @param t throttle position * @returns true if there is no error, false otherwise */ - bool throttle(int16_t t); + bool throttle(uint16_t t); /** * Move the rudder position @@ -197,23 +202,23 @@ * @param r rudder position * @returns true if there is no error, false otherwise */ - bool rudder(int16_t r); + bool rudder(uint16_t r); /** * Move the dive break position * - * @param d dive break position + * @param b break position * @returns true if there is no error, false otherwise */ - bool diveBreak(int16_t d); + bool diveBreak(uint16_t b); /** * Move the flaps position * - * @param w wing flaps position + * @param f flaps position * @returns true if there is no error, false otherwise */ - bool flaps(int16_t w); + bool flaps(uint16_t f); /** @@ -223,7 +228,7 @@ * @param y-axis position * @returns true if there is no error, false otherwise */ - bool move(int16_t x, int16_t y); + bool move(uint16_t x, uint16_t y); /** * Press one or several buttons @@ -249,14 +254,14 @@ virtual uint8_t * reportDesc(); private: - int16_t _t; - int16_t _r; - int16_t _d; - int16_t _w; - int16_t _x; - int16_t _y; + uint16_t _x; + uint16_t _y; + uint16_t _b; + uint16_t _f; + uint16_t _r; + uint16_t _t; + uint8_t _hat; uint32_t _buttons; - uint8_t _hat; void _init(); };