![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
N64 to USB HID interface
USBHID/usbhid.h@5:eb93a4f91396, 2014-12-10 (annotated)
- Committer:
- igor_m
- Date:
- Wed Dec 10 14:22:30 2014 +0000
- Revision:
- 5:eb93a4f91396
- Parent:
- 0:547c5459faa6
Initial Release
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
igor_m |
0:547c5459faa6 | 1 | /* usbhid.h */ |
igor_m |
0:547c5459faa6 | 2 | /* USB HID class device */ |
igor_m |
0:547c5459faa6 | 3 | /* Copyright (c) Phil Wright 2008 */ |
igor_m |
0:547c5459faa6 | 4 | |
igor_m |
0:547c5459faa6 | 5 | /* modified by Shinichiro Oba <http://mbed.org/users/bricklife/> */ |
igor_m |
0:547c5459faa6 | 6 | |
igor_m |
0:547c5459faa6 | 7 | #ifndef USBHID_H |
igor_m |
0:547c5459faa6 | 8 | #define USBHID_H |
igor_m |
0:547c5459faa6 | 9 | |
igor_m |
0:547c5459faa6 | 10 | #include "usbdevice.h" |
igor_m |
0:547c5459faa6 | 11 | |
igor_m |
0:547c5459faa6 | 12 | /* Mouse buttons */ |
igor_m |
0:547c5459faa6 | 13 | #define MOUSE_L (1<<0) |
igor_m |
0:547c5459faa6 | 14 | #define MOUSE_M (1<<1) |
igor_m |
0:547c5459faa6 | 15 | #define MOUSE_R (1<<2) |
igor_m |
0:547c5459faa6 | 16 | |
igor_m |
0:547c5459faa6 | 17 | class usbhid : public usbdevice |
igor_m |
0:547c5459faa6 | 18 | { |
igor_m |
0:547c5459faa6 | 19 | public: |
igor_m |
0:547c5459faa6 | 20 | usbhid(); |
igor_m |
0:547c5459faa6 | 21 | bool keyboard(char c); |
igor_m |
0:547c5459faa6 | 22 | bool keyboard(char *string); |
igor_m |
0:547c5459faa6 | 23 | bool mouse(signed char x, signed char y, unsigned char buttons=0, signed char wheel=0); |
igor_m |
0:547c5459faa6 | 24 | protected: |
igor_m |
0:547c5459faa6 | 25 | virtual bool requestSetConfiguration(); |
igor_m |
0:547c5459faa6 | 26 | virtual void endpointEventEP1In(void); |
igor_m |
0:547c5459faa6 | 27 | virtual void deviceEventReset(void); |
igor_m |
0:547c5459faa6 | 28 | virtual bool requestGetDescriptor(void); |
igor_m |
0:547c5459faa6 | 29 | virtual bool requestSetup(void); |
igor_m |
0:547c5459faa6 | 30 | private: |
igor_m |
0:547c5459faa6 | 31 | bool sendInputReport(unsigned char id, unsigned char *data, unsigned char size); |
igor_m |
0:547c5459faa6 | 32 | }; |
igor_m |
0:547c5459faa6 | 33 | |
igor_m |
0:547c5459faa6 | 34 | |
igor_m |
0:547c5459faa6 | 35 | // |
igor_m |
0:547c5459faa6 | 36 | // USBJoystick |
igor_m |
0:547c5459faa6 | 37 | // |
igor_m |
0:547c5459faa6 | 38 | |
igor_m |
0:547c5459faa6 | 39 | #define JOYSTICK_UP (1<<0) |
igor_m |
0:547c5459faa6 | 40 | #define JOYSTICK_DOWN (1<<1) |
igor_m |
0:547c5459faa6 | 41 | #define JOYSTICK_LEFT (1<<2) |
igor_m |
0:547c5459faa6 | 42 | #define JOYSTICK_RIGHT (1<<3) |
igor_m |
0:547c5459faa6 | 43 | |
igor_m |
0:547c5459faa6 | 44 | class USBJoystick : public usbhid |
igor_m |
0:547c5459faa6 | 45 | { |
igor_m |
0:547c5459faa6 | 46 | public: |
igor_m |
0:547c5459faa6 | 47 | USBJoystick(); |
igor_m | 5:eb93a4f91396 | 48 | bool joystick(unsigned char buttons1, unsigned short buttons2, signed char x, signed char y, signed char cx, signed char cy, unsigned char L, unsigned char R); |
igor_m |
0:547c5459faa6 | 49 | protected: |
igor_m |
0:547c5459faa6 | 50 | virtual bool requestGetDescriptor(void); |
igor_m |
0:547c5459faa6 | 51 | private: |
igor_m |
0:547c5459faa6 | 52 | bool sendInputReport(unsigned char *data, unsigned char size); |
igor_m |
0:547c5459faa6 | 53 | }; |
igor_m |
0:547c5459faa6 | 54 | |
igor_m |
0:547c5459faa6 | 55 | #endif |