1 #ifndef __USBKEYBOARD_H__
2 #define __USBKEYBOARD_H__
6 #endif /* __cplusplus */
8 #define DEVLIST_MAXSIZE 0x08
9 #define CBEVENT_MAXNUM 0x08
11 #define USB_CLASS_HID 0x03
12 #define USB_SUBCLASS_BOOT 0x01
13 #define USB_PROTOCOL_KEYBOARD 0x01
15 #define USB_ENPOINT_INTERRUPT 0x03
17 #define USB_DT_HID 0x21
18 #define USB_DT_HID_SIZE 0x09
19 #define USB_DT_REPORT 0x22
21 #define USB_REQ_GETPROTOCOL 0x03
22 #define USB_REQ_SETPROTOCOL 0x0B
23 #define USB_REQ_GETREPORT 0x01
24 #define USB_REQ_SETREPORT 0x09
26 #define USB_REPTYPE_INPUT 0x01
27 #define USB_REPTYPE_OUTPUT 0x02
28 #define USB_REPTYPE_FEATURE 0x03
30 #define USB_REQTYPE_GET 0xA1
31 #define USB_REQTYPE_SET 0x21
35 USBKEYBOARD_PRESSED
= 0,
37 USBKEYBOARD_DISCONNECTED
39 }USBKeyboard_eventType
;
48 typedef struct _USBKeyboard_event
50 USBKeyboard_eventType type
;
55 typedef s32 (*eventcallback
)(USBKeyboard_event event
,void *usrdata
);
57 typedef struct _device
62 #define DEVNULL (device){0,0}
64 typedef struct _keyboard
78 eventcallback cb
[CBEVENT_MAXNUM
];
79 void* cbData
[CBEVENT_MAXNUM
];
91 bool devEqual(device dev1
,device dev2
);
93 s32
USBKeyboard_Initialize();
94 s32
USBKeyboard_Deinitialize();
96 s32
USBKeyboard_Find(device (*devs
)[DEVLIST_MAXSIZE
]);
98 s32
USBKeyboard_Open(keyboard
*key
,device dev
);
99 s32
USBKeyboard_Close(keyboard
*key
);
101 s32
USBKeyboard_Get_Protocol(keyboard
*key
);
102 s32
USBKeyboard_Set_Protocol(keyboard
*key
, u8 protocol
);
104 s32
USBKeyboard_Get_OutputReport_Ctrl(keyboard
*key
,u8
*leds
);
105 s32
USBKeyboard_Set_OutputReport_Ctrl(keyboard
*key
);
107 s32
USBKeyboard_Get_InputReport_Intr(keyboard
*key
);
109 s32
USBKeyboard_GetState(keyboard
*key
);
111 s32
USBKeyboard_PutOnLed(keyboard
*key
,USBKeyboard_led led
);
112 s32
USBKeyboard_PutOffLed(keyboard
*key
,USBKeyboard_led led
);
113 s32
USBKeyboard_SwitchLed(keyboard
*key
,USBKeyboard_led led
);
115 s32
USBKeyboard_Add_EventCB(keyboard
* key
,eventcallback cb
, void* data
);
116 s32
USBKeyboard_Remove_EventCB(keyboard
* key
,u8 n
);
120 #endif /* __cplusplus */
122 #endif /* __USBKEYBOARD_H__ */