Control drones with a proper joystick
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.

hid_parser.h 993B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Saitek X52 Arduino USB Host Shield Library.
  3. * Copyright 2016 by Thomas Buck <xythobuz@xythobuz.de>
  4. *
  5. * Based on the USB Host Library HID Joystick example
  6. * https://www.circuitsathome.com/mcu/hid-joystick-code-sample
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation, version 2.
  11. */
  12. #ifndef __HID_PARSER_H__
  13. #define __HID_PARSER_H__
  14. #include <hid.h>
  15. #include "joystick_events.h"
  16. #define RPT_GEMEPAD_LEN 8
  17. #define BUFFER_SIZE 16
  18. class JoystickReportParser : public HIDReportParser {
  19. JoystickEvents* joyEvents;
  20. uint8_t buf[BUFFER_SIZE];
  21. uint8_t oldPad[RPT_GEMEPAD_LEN];
  22. uint8_t oldHat;
  23. uint64_t oldButtons;
  24. uint8_t oldMouse;
  25. GamePadEventData buffer;
  26. public:
  27. JoystickReportParser(JoystickEvents* evt);
  28. virtual void Parse(HID* hid, bool is_rpt_id, uint8_t len, uint8_t* bufPart);
  29. };
  30. #endif // __HID_PARSER_H__