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@3:f1a8ec4659f8, 2016-12-17 (annotated)
- Committer:
- Alberto_Wino
- Date:
- Sat Dec 17 15:10:12 2016 +0000
- Revision:
- 3:f1a8ec4659f8
- Parent:
- 2:84ea6e2fb4b6
Added a two-interface configuration, which fully works on Android.
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 | 3:f1a8ec4659f8 | 5 | /* Modified by yours truly. */ |
Alberto_Wino | 3:f1a8ec4659f8 | 6 | |
Alberto_Wino | 3:f1a8ec4659f8 | 7 | #pragma once |
Alberto_Wino | 1:76c47d2ba442 | 8 | |
Alberto_Wino | 1:76c47d2ba442 | 9 | #include "usbdevice.h" |
Alberto_Wino | 1:76c47d2ba442 | 10 | |
Alberto_Wino | 1:76c47d2ba442 | 11 | class usbhid : public usbdevice |
Alberto_Wino | 1:76c47d2ba442 | 12 | { |
Alberto_Wino | 1:76c47d2ba442 | 13 | public: |
Alberto_Wino | 1:76c47d2ba442 | 14 | usbhid(); |
Alberto_Wino | 1:76c47d2ba442 | 15 | |
Alberto_Wino | 1:76c47d2ba442 | 16 | protected: |
Alberto_Wino | 1:76c47d2ba442 | 17 | virtual void deviceEventReset(); |
Alberto_Wino | 1:76c47d2ba442 | 18 | virtual void endpointEventEP1In(); |
Alberto_Wino | 3:f1a8ec4659f8 | 19 | virtual void endpointEventEP2In(); |
Alberto_Wino | 1:76c47d2ba442 | 20 | virtual bool requestGetDescriptor(); |
Alberto_Wino | 1:76c47d2ba442 | 21 | virtual bool requestSetConfiguration(); |
Alberto_Wino | 1:76c47d2ba442 | 22 | }; |
Alberto_Wino | 1:76c47d2ba442 | 23 | |
Alberto_Wino | 1:76c47d2ba442 | 24 | #define JOYSTICK_UP (1<<0) |
Alberto_Wino | 1:76c47d2ba442 | 25 | #define JOYSTICK_DOWN (1<<1) |
Alberto_Wino | 1:76c47d2ba442 | 26 | #define JOYSTICK_LEFT (1<<2) |
Alberto_Wino | 1:76c47d2ba442 | 27 | #define JOYSTICK_RIGHT (1<<3) |
Alberto_Wino | 1:76c47d2ba442 | 28 | |
Alberto_Wino | 1:76c47d2ba442 | 29 | class USBJoystick : public usbhid |
Alberto_Wino | 1:76c47d2ba442 | 30 | { |
Alberto_Wino | 1:76c47d2ba442 | 31 | public: |
Alberto_Wino | 1:76c47d2ba442 | 32 | USBJoystick(); |
Alberto_Wino | 2:84ea6e2fb4b6 | 33 | bool update(uint8_t gamepad_id, uint8_t stick, uint32_t buttons); |
Alberto_Wino | 1:76c47d2ba442 | 34 | protected: |
Alberto_Wino | 1:76c47d2ba442 | 35 | virtual bool requestGetDescriptor(); |
Alberto_Wino | 1:76c47d2ba442 | 36 | }; |