66 #ifndef AZERTY_KEYBOARD 67 #define QWERTY_KEYBOARD 69 #define KBD_LEFT_CTRL 0x01 70 #define KBD_LEFT_SHIFT 0x02 71 #define KBD_LEFT_ALT 0x04 72 #define KBD_LEFT_GUI 0x08 73 #define KBD_RIGHT_CTRL 0x10 74 #define KBD_RIGHT_SHIFT 0x20 75 #define KBD_RIGHT_ALT 0x40 76 #define KBD_RIGHT_GUI 0x80 77 #define KBR_MAX_NBR_PRESSED 6 211 #ifdef QWERTY_KEYBOARD 212 static const int8_t HID_KEYBRD_Key[] = {
213 '\0',
'`',
'1',
'2',
'3',
'4',
'5',
'6',
214 '7',
'8',
'9',
'0',
'-',
'=',
'\0',
'\r',
215 '\t',
'q',
'w',
'e',
'r',
't',
'y',
'u',
216 'i',
'o',
'p',
'[',
']',
'\\',
217 '\0',
'a',
's',
'd',
'f',
'g',
'h',
'j',
218 'k',
'l',
';',
'\'',
'\0',
'\n',
219 '\0',
'\0',
'z',
'x',
'c',
'v',
'b',
'n',
220 'm',
',',
'.',
'/',
'\0',
'\0',
221 '\0',
'\0',
'\0',
' ',
'\0',
'\0',
'\0',
'\0',
222 '\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
223 '\0',
'\0',
'\0',
'\0',
'\0',
'\r',
'\0',
'\0',
224 '\0',
'\0',
'\0',
'\0',
'\0',
'\0',
225 '\0',
'\0',
'7',
'4',
'1',
226 '\0',
'/',
'8',
'5',
'2',
227 '0',
'*',
'9',
'6',
'3',
228 '.',
'-',
'+',
'\0',
'\n',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
229 '\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
230 '\0',
'\0',
'\0',
'\0' 233 static const int8_t HID_KEYBRD_ShiftKey[] = {
234 '\0',
'~',
'!',
'@',
'#',
'$',
'%',
'^',
'&',
'*',
'(',
')',
235 '_',
'+',
'\0',
'\0',
'\0',
'Q',
'W',
'E',
'R',
'T',
'Y',
'U',
236 'I',
'O',
'P',
'{',
'}',
'|',
'\0',
'A',
'S',
'D',
'F',
'G',
237 'H',
'J',
'K',
'L',
':',
'"',
'\0',
'\n',
'\0',
'\0',
'Z',
'X',
238 'C',
'V',
'B',
'N',
'M',
'<',
'>',
'?',
'\0',
'\0',
'\0',
'\0',
239 '\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
240 '\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
241 '\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
242 '\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
243 '\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
244 '\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0' 249 static const int8_t HID_KEYBRD_Key[] = {
250 '\0',
'`',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'0',
251 '-',
'=',
'\0',
'\r',
'\t',
'a',
'z',
'e',
'r',
't',
'y',
'u',
252 'i',
'o',
'p',
'[',
']',
'\\',
'\0',
'q',
's',
'd',
'f',
'g',
253 'h',
'j',
'k',
'l',
'm',
'\0',
'\0',
'\n',
'\0',
'\0',
'w',
'x',
254 'c',
'v',
'b',
'n',
',',
';',
':',
'!',
'\0',
'\0',
'\0',
'\0',
255 '\0',
' ',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
256 '\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\r',
'\0',
'\0',
'\0',
257 '\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'7',
'4',
'1',
'\0',
'/',
258 '8',
'5',
'2',
'0',
'*',
'9',
'6',
'3',
'.',
'-',
'+',
'\0',
259 '\n',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
260 '\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0' 263 static const int8_t HID_KEYBRD_ShiftKey[] = {
264 '\0',
'~',
'!',
'@',
'#',
'$',
'%',
'^',
'&',
'*',
'(',
')',
'_',
265 '+',
'\0',
'\0',
'\0',
'A',
'Z',
'E',
'R',
'T',
'Y',
'U',
'I',
'O',
266 'P',
'{',
'}',
'*',
'\0',
'Q',
'S',
'D',
'F',
'G',
'H',
'J',
'K',
267 'L',
'M',
'%',
'\0',
'\n',
'\0',
'\0',
'W',
'X',
'C',
'V',
'B',
'N',
268 '?',
'.',
'/',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
269 '\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
270 '\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
271 '\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
272 '\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
273 '\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0' 277 static const uint8_t HID_KEYBRD_Codes[] = {
278 0, 0, 0, 0, 31, 50, 48, 33,
279 19, 34, 35, 36, 24, 37, 38, 39,
280 52, 51, 25, 26, 17, 20, 32, 21,
281 23, 49, 18, 47, 22, 46, 2, 3,
282 4, 5, 6, 7, 8, 9, 10, 11,
283 43, 110, 15, 16, 61, 12, 13, 27,
284 28, 29, 42, 40, 41, 1, 53, 54,
285 55, 30, 112, 113, 114, 115, 116, 117,
286 118, 119, 120, 121, 122, 123, 124, 125,
287 126, 75, 80, 85, 76, 81, 86, 89,
288 79, 84, 83, 90, 95, 100, 105, 106,
289 108, 93, 98, 103, 92, 97, 102, 91,
290 96, 101, 99, 104, 45, 129, 0, 0,
291 0, 0, 0, 0, 0, 0, 0, 0,
292 0, 0, 0, 0, 0, 0, 0, 0,
293 0, 0, 0, 0, 0, 0, 0, 0,
294 0, 0, 0, 0, 0, 107, 0, 56,
295 0, 0, 0, 0, 0, 0, 0, 0,
296 0, 0, 0, 0, 0, 0, 0, 0,
297 0, 0, 0, 0, 0, 0, 0, 0,
298 0, 0, 0, 0, 0, 0, 0, 0,
299 0, 0, 0, 0, 0, 0, 0, 0,
300 0, 0, 0, 0, 0, 0, 0, 0,
301 0, 0, 0, 0, 0, 0, 0, 0,
302 0, 0, 0, 0, 0, 0, 0, 0,
303 0, 0, 0, 0, 0, 0, 0, 0,
304 0, 0, 0, 0, 0, 0, 0, 0,
305 0, 0, 0, 0, 0, 0, 0, 0,
306 58, 44, 60, 127, 64, 57, 62, 128
349 if(USBH_HID_KeybdDecode(phost) ==
USBH_OK)
370 if(HID_Handle->
length == 0)
387 for(x=0; x <
sizeof(keybd_info.
keys); x++)
409 output = HID_KEYBRD_ShiftKey[HID_KEYBRD_Codes[info->
keys[0]]];
413 output = HID_KEYBRD_Key[HID_KEYBRD_Codes[info->
keys[0]]];
USBH_DeviceTypeDef device
This file contains all the prototypes for the usbh_hid_keybd.c.
uint8_t USBH_HID_GetASCIICode(HID_KEYBD_Info_TypeDef *info)
USBH_HID_GetASCIICode The function decode keyboard data into ASCII characters.
HID_KEYBD_Info_TypeDef keybd_info
USBH_StatusTypeDef USBH_HID_KeybdInit(USBH_HandleTypeDef *phost)
USBH_HID_KeybdInit The function init the HID keyboard.
HID_KEYBD_Info_TypeDef * USBH_HID_GetKeybdInfo(USBH_HandleTypeDef *phost)
USBH_HID_GetKeybdInfo The function return keyboard information.
uint32_t keybd_report_data[2]
uint16_t fifo_read(FIFO_TypeDef *f, void *buf, uint16_t nbytes)
fifo_read Read from FIFO.
uint8_t Data[USBH_MAX_DATA_BUFFER]
USBH_ClassTypeDef * pActiveClass
void fifo_init(FIFO_TypeDef *f, uint8_t *buf, uint16_t size)
fifo_init Initialize FIFO.
uint32_t HID_ReadItem(HID_Report_ItemTypedef *ri, uint8_t ndx)
HID_ReadItem The function read a report item.