summaryrefslogtreecommitdiffstats
path: root/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h
diff options
context:
space:
mode:
authortmk <hasu@tmk-kbd.com>2015-05-13 04:13:10 +0200
committertmk <hasu@tmk-kbd.com>2015-05-13 04:13:10 +0200
commitf1f2066657f4a0998adc016c95d7e541b436e09f (patch)
treed056cb656b538c4f3a3c205363e0070976655e2e /tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h
parent1c73e574f109a17566db99e399bdf86007488d2a (diff)
parentf6d56675f9f981c5464f0ca7a1fbb0162154e8c5 (diff)
downloadqmk_firmware-f1f2066657f4a0998adc016c95d7e541b436e09f.tar.gz
qmk_firmware-f1f2066657f4a0998adc016c95d7e541b436e09f.tar.xz
Diffstat (limited to 'tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h')
-rw-r--r--tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h b/tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h
new file mode 100644
index 000000000..733b8f8da
--- /dev/null
+++ b/tmk_core/protocol/usb_hid/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__