You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

le3dp_rptparser.h 813B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #if !defined(__HIDJOYSTICKRPTPARSER_H__)
  2. #define __HIDJOYSTICKRPTPARSER_H__
  3. #include <hid.h>
  4. struct GamePadEventData
  5. {
  6. union { //axes and hut switch
  7. uint32_t axes;
  8. struct {
  9. uint32_t x : 10;
  10. uint32_t y : 10;
  11. uint32_t hat : 4;
  12. uint32_t twist : 8;
  13. };
  14. };
  15. uint8_t buttons_a;
  16. uint8_t slider;
  17. uint8_t buttons_b;
  18. };
  19. class JoystickEvents
  20. {
  21. public:
  22. virtual void OnGamePadChanged(const GamePadEventData *evt);
  23. };
  24. #define RPT_GAMEPAD_LEN sizeof(GamePadEventData)/sizeof(uint8_t)
  25. class JoystickReportParser : public HIDReportParser
  26. {
  27. JoystickEvents *joyEvents;
  28. uint8_t oldPad[RPT_GAMEPAD_LEN];
  29. public:
  30. JoystickReportParser(JoystickEvents *evt);
  31. virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
  32. };
  33. #endif // __HIDJOYSTICKRPTPARSER_H__