#ifndef _JOYSTICK_H_ #define _JOYSTICK_H_ #include // If you're using the arduino-big-joystick firmware, these numbers can't be // changed. If you're writing your own Report Descriptor, tune these to match. // TODO: Pass these in to the constructor, with the same caveats. Shouldn't need // to edit the header file to make something work in a library. :( #define JOYSTICK_NUM_AXES 8 #define JOYSTICK_NUM_BUTTONS 40 #define JOYSTICK_NUM_BYTES (JOYSTICK_NUM_BUTTONS+7)/8 typedef struct JoyReport { int16_t axis[JOYSTICK_NUM_AXES]; uint8_t button[JOYSTICK_NUM_BYTES]; } ; class Joystick { public: Joystick(bool debug=false); void Init(); void SetAxis(uint8_t axis, int16_t value); void PressButton(uint8_t button); void ReleaseButton(uint8_t button); void ReleaseAllButtons(); // This actually sends the commands. You *must* call this for the // joystick to do anything! void Write(); private: JoyReport _joyReport; bool _debug; }; #endif