Initial commit.

This commit is contained in:
Anna Rose Wiggins 2015-11-04 22:02:09 -05:00
commit 1a0ecea44a
3 changed files with 100 additions and 0 deletions

39
Joystick.h Normal file
View file

@ -0,0 +1,39 @@
#ifndef _JOYSTICK_H_
#define _JOYSTICK_H_
#include <Arduino.h>
// 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