mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
969eabb8d7
The following collisions resolved: hid.h -> usbhid.h hid.cpp -> usbhid.cpp HID -> USBHID HID_BOOT_PROTOCOL -> USB_HID_BOOT_PROTOCOL HID_PROTOCOL_NONE -> USB_HID_PROTOCOL_NONE HID_PROTOCOL_KEYBOARD -> USB_HID_PROTOCOL_KEYBOARD HID_PROTOCOL_MOUSE -> USB_HID_PROTOCOL_MOUSE As a result, it's possible to use the library together with Arduino's bundled HID / Mouse / Keyboard libraries (Leonardo, Micro, or Due). https://www.arduino.cc/en/Reference/MouseKeyboard
33 lines
808 B
C++
33 lines
808 B
C++
#if !defined(__HIDJOYSTICKRPTPARSER_H__)
|
|
#define __HIDJOYSTICKRPTPARSER_H__
|
|
|
|
#include <usbhid.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(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
|
|
};
|
|
|
|
#endif // __HIDJOYSTICKRPTPARSER_H__
|