1
0
mirror of https://github.com/gdsports/USBHost_t36 synced 2024-11-15 21:55:01 -05:00

reorganize header file

This commit is contained in:
PaulStoffregen 2017-10-21 11:52:26 -07:00
parent 8a0a5802c2
commit bd5f7d9486

View File

@ -557,6 +557,7 @@ private:
static volatile bool reset_busy; static volatile bool reset_busy;
}; };
//--------------------------------------------------------------------------
class USBHIDParser : public USBDriver { class USBHIDParser : public USBDriver {
public: public:
@ -595,7 +596,7 @@ private:
strbuf_t mystring_bufs[1]; strbuf_t mystring_bufs[1];
}; };
//--------------------------------------------------------------------------
class KeyboardController : public USBDriver /* , public USBHIDInput */ { class KeyboardController : public USBDriver /* , public USBHIDInput */ {
public: public:
@ -658,6 +659,89 @@ private:
strbuf_t mystring_bufs[1]; strbuf_t mystring_bufs[1];
}; };
//--------------------------------------------------------------------------
class KeyboardHIDExtrasController : public USBHIDInput {
public:
KeyboardHIDExtrasController(USBHost &host) { USBHIDParser::driver_ready_for_hid_collection(this); }
void clear() { event_ = false;}
bool available() { return event_; }
void attachPress(void (*f)(uint32_t top, uint16_t code)) { keyPressedFunction = f; }
void attachRelease(void (*f)(uint32_t top, uint16_t code)) { keyReleasedFunction = f; }
enum {MAX_KEYS_DOWN=4};
// uint32_t buttons() { return buttons_; }
protected:
virtual bool claim_collection(Device_t *dev, uint32_t topusage);
virtual void hid_input_begin(uint32_t topusage, uint32_t type, int lgmin, int lgmax);
virtual void hid_input_data(uint32_t usage, int32_t value);
virtual void hid_input_end();
virtual void disconnect_collection(Device_t *dev);
private:
void (*keyPressedFunction)(uint32_t top, uint16_t code);
void (*keyReleasedFunction)(uint32_t top, uint16_t code);
uint32_t topusage_ = 0; // What top report am I processing?
uint8_t collections_claimed_ = 0;
volatile bool event_ = false;
volatile bool hid_input_begin_ = false;
volatile bool hid_input_data_ = false; // did we receive any valid data with report?
uint8_t count_keys_down_ = 0;
uint16_t keys_down[MAX_KEYS_DOWN];
};
//--------------------------------------------------------------------------
class MouseController : public USBHIDInput {
public:
MouseController(USBHost &host) { USBHIDParser::driver_ready_for_hid_collection(this); }
bool available() { return mouseEvent; }
void mouseDataClear();
uint8_t getButtons() { return buttons; }
int getMouseX() { return mouseX; }
int getMouseY() { return mouseY; }
int getWheel() { return wheel; }
int getWheelH() { return wheelH; }
protected:
virtual bool claim_collection(Device_t *dev, uint32_t topusage);
virtual void hid_input_begin(uint32_t topusage, uint32_t type, int lgmin, int lgmax);
virtual void hid_input_data(uint32_t usage, int32_t value);
virtual void hid_input_end();
virtual void disconnect_collection(Device_t *dev);
private:
uint8_t collections_claimed = 0;
volatile bool mouseEvent = false;
volatile bool hid_input_begin_ = false;
uint8_t buttons = 0;
int mouseX = 0;
int mouseY = 0;
int wheel = 0;
int wheelH = 0;
};
//--------------------------------------------------------------------------
class JoystickController : public USBHIDInput {
public:
JoystickController(USBHost &host) { USBHIDParser::driver_ready_for_hid_collection(this); }
bool available() { return joystickEvent; }
void joystickDataClear();
uint32_t getButtons() { return buttons; }
int getAxis(uint32_t index) { return (index < (sizeof(axis)/sizeof(axis[0]))) ? axis[index] : 0; }
protected:
virtual bool claim_collection(Device_t *dev, uint32_t topusage);
virtual void hid_input_begin(uint32_t topusage, uint32_t type, int lgmin, int lgmax);
virtual void hid_input_data(uint32_t usage, int32_t value);
virtual void hid_input_end();
virtual void disconnect_collection(Device_t *dev);
private:
uint8_t collections_claimed = 0;
bool anychange = false;
volatile bool joystickEvent = false;
uint32_t buttons = 0;
int16_t axis[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
};
//--------------------------------------------------------------------------
class MIDIDevice : public USBDriver { class MIDIDevice : public USBDriver {
public: public:
enum { SYSEX_MAX_LEN = 60 }; enum { SYSEX_MAX_LEN = 60 };
@ -802,6 +886,7 @@ private:
strbuf_t mystring_bufs[1]; strbuf_t mystring_bufs[1];
}; };
//--------------------------------------------------------------------------
class USBSerial: public USBDriver, public Stream { class USBSerial: public USBDriver, public Stream {
public: public:
@ -860,8 +945,11 @@ private:
enum { CDCACM, FTDI, PL2303, CH341 } sertype; enum { CDCACM, FTDI, PL2303, CH341 } sertype;
}; };
//--------------------------------------------------------------------------
class AntPlus: public USBDriver { class AntPlus: public USBDriver {
// Please post any AntPlus feedback or contributions on this forum thread:
// https://forum.pjrc.com/threads/43110-Ant-libarary-and-USB-driver-for-Teensy-3-5-6
public: public:
AntPlus(USBHost &host) : /* txtimer(this),*/ updatetimer(this) { init(); } AntPlus(USBHost &host) : /* txtimer(this),*/ updatetimer(this) { init(); }
void begin(const uint8_t key=0); void begin(const uint8_t key=0);
@ -1079,82 +1167,4 @@ private:
}; };
class MouseController : public USBHIDInput {
public:
MouseController(USBHost &host) { USBHIDParser::driver_ready_for_hid_collection(this); }
bool available() { return mouseEvent; }
void mouseDataClear();
uint8_t getButtons() { return buttons; }
int getMouseX() { return mouseX; }
int getMouseY() { return mouseY; }
int getWheel() { return wheel; }
int getWheelH() { return wheelH; }
protected:
virtual bool claim_collection(Device_t *dev, uint32_t topusage);
virtual void hid_input_begin(uint32_t topusage, uint32_t type, int lgmin, int lgmax);
virtual void hid_input_data(uint32_t usage, int32_t value);
virtual void hid_input_end();
virtual void disconnect_collection(Device_t *dev);
private:
uint8_t collections_claimed = 0;
volatile bool mouseEvent = false;
volatile bool hid_input_begin_ = false;
uint8_t buttons = 0;
int mouseX = 0;
int mouseY = 0;
int wheel = 0;
int wheelH = 0;
};
class JoystickController : public USBHIDInput {
public:
JoystickController(USBHost &host) { USBHIDParser::driver_ready_for_hid_collection(this); }
bool available() { return joystickEvent; }
void joystickDataClear();
uint32_t getButtons() { return buttons; }
int getAxis(uint32_t index) { return (index < (sizeof(axis)/sizeof(axis[0]))) ? axis[index] : 0; }
protected:
virtual bool claim_collection(Device_t *dev, uint32_t topusage);
virtual void hid_input_begin(uint32_t topusage, uint32_t type, int lgmin, int lgmax);
virtual void hid_input_data(uint32_t usage, int32_t value);
virtual void hid_input_end();
virtual void disconnect_collection(Device_t *dev);
private:
uint8_t collections_claimed = 0;
bool anychange = false;
volatile bool joystickEvent = false;
uint32_t buttons = 0;
int16_t axis[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
};
class KeyboardHIDExtrasController : public USBHIDInput {
public:
KeyboardHIDExtrasController(USBHost &host) { USBHIDParser::driver_ready_for_hid_collection(this); }
void clear() { event_ = false;}
bool available() { return event_; }
void attachPress(void (*f)(uint32_t top, uint16_t code)) { keyPressedFunction = f; }
void attachRelease(void (*f)(uint32_t top, uint16_t code)) { keyReleasedFunction = f; }
enum {MAX_KEYS_DOWN=4};
// uint32_t buttons() { return buttons_; }
protected:
virtual bool claim_collection(Device_t *dev, uint32_t topusage);
virtual void hid_input_begin(uint32_t topusage, uint32_t type, int lgmin, int lgmax);
virtual void hid_input_data(uint32_t usage, int32_t value);
virtual void hid_input_end();
virtual void disconnect_collection(Device_t *dev);
private:
void (*keyPressedFunction)(uint32_t top, uint16_t code);
void (*keyReleasedFunction)(uint32_t top, uint16_t code);
uint32_t topusage_ = 0; // What top report am I processing?
uint8_t collections_claimed_ = 0;
volatile bool event_ = false;
volatile bool hid_input_begin_ = false;
volatile bool hid_input_data_ = false; // did we receive any valid data with report?
uint8_t count_keys_down_ = 0;
uint16_t keys_down[MAX_KEYS_DOWN];
};
#endif #endif