A fully-Android-compatible two joysticks USB driver for LPC1768. The joysticks have 1 hat, 6 buttons, and there are 1P, 2P buttons.
Fork of app-board-Joystick by
usbhid.h@2:84ea6e2fb4b6, 2016-12-17 (annotated)
- Committer:
- Alberto_Wino
- Date:
- Sat Dec 17 13:13:59 2016 +0000
- Revision:
- 2:84ea6e2fb4b6
- Parent:
- 1:76c47d2ba442
- Child:
- 3:f1a8ec4659f8
Added 2nd-pad-as-buttons configuration.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Alberto_Wino | 1:76c47d2ba442 | 1 | /* usbhid.h */ |
Alberto_Wino | 1:76c47d2ba442 | 2 | /* USB HID class device */ |
Alberto_Wino | 1:76c47d2ba442 | 3 | /* Copyright (c) Phil Wright 2008 */ |
Alberto_Wino | 1:76c47d2ba442 | 4 | |
Alberto_Wino | 1:76c47d2ba442 | 5 | #ifndef USBHID_H |
Alberto_Wino | 1:76c47d2ba442 | 6 | #define USBHID_H |
Alberto_Wino | 1:76c47d2ba442 | 7 | |
Alberto_Wino | 1:76c47d2ba442 | 8 | #include "usbdevice.h" |
Alberto_Wino | 1:76c47d2ba442 | 9 | |
Alberto_Wino | 1:76c47d2ba442 | 10 | class usbhid : public usbdevice |
Alberto_Wino | 1:76c47d2ba442 | 11 | { |
Alberto_Wino | 1:76c47d2ba442 | 12 | public: |
Alberto_Wino | 1:76c47d2ba442 | 13 | usbhid(); |
Alberto_Wino | 1:76c47d2ba442 | 14 | |
Alberto_Wino | 1:76c47d2ba442 | 15 | protected: |
Alberto_Wino | 1:76c47d2ba442 | 16 | virtual void deviceEventReset(); |
Alberto_Wino | 1:76c47d2ba442 | 17 | virtual void endpointEventEP1In(); |
Alberto_Wino | 1:76c47d2ba442 | 18 | virtual bool requestGetDescriptor(); |
Alberto_Wino | 1:76c47d2ba442 | 19 | virtual bool requestSetConfiguration(); |
Alberto_Wino | 1:76c47d2ba442 | 20 | }; |
Alberto_Wino | 1:76c47d2ba442 | 21 | |
Alberto_Wino | 1:76c47d2ba442 | 22 | #define JOYSTICK_UP (1<<0) |
Alberto_Wino | 1:76c47d2ba442 | 23 | #define JOYSTICK_DOWN (1<<1) |
Alberto_Wino | 1:76c47d2ba442 | 24 | #define JOYSTICK_LEFT (1<<2) |
Alberto_Wino | 1:76c47d2ba442 | 25 | #define JOYSTICK_RIGHT (1<<3) |
Alberto_Wino | 1:76c47d2ba442 | 26 | |
Alberto_Wino | 1:76c47d2ba442 | 27 | class USBJoystick : public usbhid |
Alberto_Wino | 1:76c47d2ba442 | 28 | { |
Alberto_Wino | 1:76c47d2ba442 | 29 | public: |
Alberto_Wino | 1:76c47d2ba442 | 30 | USBJoystick(); |
Alberto_Wino | 2:84ea6e2fb4b6 | 31 | bool update(uint8_t gamepad_id, uint8_t stick, uint32_t buttons); |
Alberto_Wino | 1:76c47d2ba442 | 32 | protected: |
Alberto_Wino | 1:76c47d2ba442 | 33 | virtual bool requestGetDescriptor(); |
Alberto_Wino | 1:76c47d2ba442 | 34 | }; |
Alberto_Wino | 1:76c47d2ba442 | 35 | |
Alberto_Wino | 1:76c47d2ba442 | 36 | #endif /* USBHID_H */ |