summaryrefslogtreecommitdiff
path: root/lib/usbhost/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h
diff options
context:
space:
mode:
authorDrashna Jael're <drashna@live.com>2021-10-11 20:36:47 -0700
committerDrashna Jael're <drashna@live.com>2021-10-11 20:36:47 -0700
commitb34675555cbd9a71a797a7ebc2148cbf2e8f0efc (patch)
tree2d701310ccd3fc2c603d63536ab4a3c1d9b9381b /lib/usbhost/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h
parentbcddde8738dbba48c548f1e3f12a10bbf60a65d8 (diff)
parentd9e077468ab3446cbd7306a453a73dad2c1403e8 (diff)
Merge commit 'd9e077468ab3446cbd7306a453a73dad2c1403e8' into firmware_21
Diffstat (limited to 'lib/usbhost/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h')
-rw-r--r--lib/usbhost/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/usbhost/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h b/lib/usbhost/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h
new file mode 100644
index 0000000000..733b8f8da8
--- /dev/null
+++ b/lib/usbhost/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h
@@ -0,0 +1,33 @@
+#if !defined(__HIDJOYSTICKRPTPARSER_H__)
+#define __HIDJOYSTICKRPTPARSER_H__
+
+#include <hid.h>
+
+struct GamePadEventData {
+ uint8_t X, Y, Z1, Z2, Rz;
+};
+
+class JoystickEvents {
+public:
+ 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);
+};
+
+#define RPT_GEMEPAD_LEN 5
+
+class JoystickReportParser : public HIDReportParser {
+ JoystickEvents *joyEvents;
+
+ uint8_t oldPad[RPT_GEMEPAD_LEN];
+ uint8_t oldHat;
+ uint16_t oldButtons;
+
+public:
+ JoystickReportParser(JoystickEvents *evt);
+
+ virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
+};
+
+#endif // __HIDJOYSTICKRPTPARSER_H__