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.

60 lines
1.5 KiB

  1. /* Gamepad.h
  2. *
  3. * Based on the advanced HID library for Arduino:
  4. * https://github.com/NicoHood/HID
  5. * Copyright (c) 2014-2015 NicoHood
  6. *
  7. * Copyright (c) 2020 Mikael Norrgård <http://daemonbite.com>
  8. *
  9. * GNU GENERAL PUBLIC LICENSE
  10. * Version 3, 29 June 2007
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation, either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  24. *
  25. */
  26. #pragma once
  27. #include "HID.h"
  28. extern const char* gp_serial;
  29. typedef struct {
  30. uint8_t buttons;
  31. int8_t X;
  32. int8_t Y;
  33. } GamepadReport;
  34. class Gamepad_ : public PluggableUSBModule
  35. {
  36. private:
  37. uint8_t reportId;
  38. protected:
  39. int getInterface(uint8_t* interfaceCount);
  40. int getDescriptor(USBSetup& setup);
  41. uint8_t getShortName(char *name);
  42. bool setup(USBSetup& setup);
  43. uint8_t epType[1];
  44. uint8_t protocol;
  45. uint8_t idle;
  46. public:
  47. GamepadReport _GamepadReport;
  48. Gamepad_(void);
  49. void reset(void);
  50. void send();
  51. };