USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h

34 lines
808 B
C
Raw Normal View History

2012-04-03 22:09:04 +02:00
#if !defined(__HIDJOYSTICKRPTPARSER_H__)
#define __HIDJOYSTICKRPTPARSER_H__
#include <usbhid.h>
2013-10-01 20:50:09 +02:00
struct GamePadEventData {
uint8_t X, Y, Z1, Z2, Rz;
2012-04-03 22:09:04 +02:00
};
2013-10-01 20:50:09 +02:00
class JoystickEvents {
2012-04-03 22:09:04 +02:00
public:
2013-10-01 20:50:09 +02:00
virtual void OnGamePadChanged(const GamePadEventData *evt);
virtual void OnHatSwitch(uint8_t hat);
virtual void OnButtonUp(uint8_t but_id);
virtual void OnButtonDn(uint8_t but_id);
2012-04-03 22:09:04 +02:00
};
#define RPT_GEMEPAD_LEN 5
2013-10-01 20:50:09 +02:00
class JoystickReportParser : public HIDReportParser {
JoystickEvents *joyEvents;
2012-04-03 22:09:04 +02:00
2013-10-01 20:50:09 +02:00
uint8_t oldPad[RPT_GEMEPAD_LEN];
uint8_t oldHat;
uint16_t oldButtons;
2012-04-03 22:09:04 +02:00
public:
2013-10-01 20:50:09 +02:00
JoystickReportParser(JoystickEvents *evt);
2012-04-03 22:09:04 +02:00
virtual void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
2012-04-03 22:09:04 +02:00
};
2013-04-03 21:14:25 +02:00
#endif // __HIDJOYSTICKRPTPARSER_H__