USB Host Shield 2.0
hidboot.h
Go to the documentation of this file.
1 /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2 
3 This software may be distributed and modified under the terms of the GNU
4 General Public License version 2 (GPL2) as published by the Free Software
5 Foundation and appearing in the file GPL2.TXT included in the packaging of
6 this file. Please note that GPL2 Section 2[b] requires that all works based
7 on this software must also be made publicly available under the terms of
8 the GPL2 ("Copyleft").
9 
10 Contact information
11 -------------------
12 
13 Circuits At Home, LTD
14 Web : http://www.circuitsathome.com
15 e-mail : support@circuitsathome.com
16  */
17 #if !defined(__HIDBOOT_H__)
18 #define __HIDBOOT_H__
19 
20 #include "usbhid.h"
21 
22 #define UHS_HID_BOOT_KEY_ZERO 0x27
23 #define UHS_HID_BOOT_KEY_ENTER 0x28
24 #define UHS_HID_BOOT_KEY_SPACE 0x2c
25 #define UHS_HID_BOOT_KEY_CAPS_LOCK 0x39
26 #define UHS_HID_BOOT_KEY_SCROLL_LOCK 0x47
27 #define UHS_HID_BOOT_KEY_NUM_LOCK 0x53
28 #define UHS_HID_BOOT_KEY_ZERO2 0x62
29 #define UHS_HID_BOOT_KEY_PERIOD 0x63
30 
31 // Don't worry, GCC will optimize the result to a final value.
32 #define bitsEndpoints(p) ((((p) & USB_HID_PROTOCOL_KEYBOARD)? 2 : 0) | (((p) & USB_HID_PROTOCOL_MOUSE)? 1 : 0))
33 #define totalEndpoints(p) ((bitsEndpoints(p) == 3) ? 3 : 2)
34 #define epMUL(p) ((((p) & USB_HID_PROTOCOL_KEYBOARD)? 1 : 0) + (((p) & USB_HID_PROTOCOL_MOUSE)? 1 : 0))
35 
36 // Already defined in hid.h
37 // #define HID_MAX_HID_CLASS_DESCRIPTORS 5
38 
39 struct MOUSEINFO {
40 
41  struct {
42  uint8_t bmLeftButton : 1;
43  uint8_t bmRightButton : 1;
44  uint8_t bmMiddleButton : 1;
45  uint8_t bmDummy : 5;
46  };
47  int8_t dX;
48  int8_t dY;
49 };
50 
52 
53  union {
55  uint8_t bInfo[sizeof (MOUSEINFO)];
56  } prevState;
57 
58 public:
59  void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
60 
61 protected:
62 
63  virtual void OnMouseMove(MOUSEINFO *mi __attribute__((unused))) {
64  };
65 
66  virtual void OnLeftButtonUp(MOUSEINFO *mi __attribute__((unused))) {
67  };
68 
69  virtual void OnLeftButtonDown(MOUSEINFO *mi __attribute__((unused))) {
70  };
71 
72  virtual void OnRightButtonUp(MOUSEINFO *mi __attribute__((unused))) {
73  };
74 
75  virtual void OnRightButtonDown(MOUSEINFO *mi __attribute__((unused))) {
76  };
77 
78  virtual void OnMiddleButtonUp(MOUSEINFO *mi __attribute__((unused))) {
79  };
80 
81  virtual void OnMiddleButtonDown(MOUSEINFO *mi __attribute__((unused))) {
82  };
83 };
84 
85 struct MODIFIERKEYS {
86  uint8_t bmLeftCtrl : 1;
87  uint8_t bmLeftShift : 1;
88  uint8_t bmLeftAlt : 1;
89  uint8_t bmLeftGUI : 1;
90  uint8_t bmRightCtrl : 1;
91  uint8_t bmRightShift : 1;
92  uint8_t bmRightAlt : 1;
93  uint8_t bmRightGUI : 1;
94 };
95 
96 struct KBDINFO {
97 
98  struct {
99  uint8_t bmLeftCtrl : 1;
100  uint8_t bmLeftShift : 1;
101  uint8_t bmLeftAlt : 1;
102  uint8_t bmLeftGUI : 1;
103  uint8_t bmRightCtrl : 1;
104  uint8_t bmRightShift : 1;
105  uint8_t bmRightAlt : 1;
106  uint8_t bmRightGUI : 1;
107  };
108  uint8_t bReserved;
109  uint8_t Keys[6];
110 };
111 
112 struct KBDLEDS {
113  uint8_t bmNumLock : 1;
114  uint8_t bmCapsLock : 1;
115  uint8_t bmScrollLock : 1;
116  uint8_t bmCompose : 1;
117  uint8_t bmKana : 1;
118  uint8_t bmReserved : 3;
119 };
120 
122  static const uint8_t numKeys[10];
123  static const uint8_t symKeysUp[12];
124  static const uint8_t symKeysLo[12];
125  static const uint8_t padKeys[5];
126 
127 protected:
128 
129  union {
131  uint8_t bInfo[sizeof (KBDINFO)];
133 
134  union {
136  uint8_t bLeds;
138 
139  uint8_t OemToAscii(uint8_t mod, uint8_t key);
140 
141 public:
142 
144  kbdLockingKeys.bLeds = 0;
145  };
146 
147  void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
148 
149 protected:
150 
151  virtual uint8_t HandleLockingKeys(USBHID* hid, uint8_t key) {
152  uint8_t old_keys = kbdLockingKeys.bLeds;
153 
154  switch(key) {
156  kbdLockingKeys.kbdLeds.bmNumLock = ~kbdLockingKeys.kbdLeds.bmNumLock;
157  break;
159  kbdLockingKeys.kbdLeds.bmCapsLock = ~kbdLockingKeys.kbdLeds.bmCapsLock;
160  break;
162  kbdLockingKeys.kbdLeds.bmScrollLock = ~kbdLockingKeys.kbdLeds.bmScrollLock;
163  break;
164  }
165 
166  if(old_keys != kbdLockingKeys.bLeds && hid) {
167  uint8_t lockLeds = kbdLockingKeys.bLeds;
168  return (hid->SetReport(0, 0/*hid->GetIface()*/, 2, 0, 1, &lockLeds));
169  }
170 
171  return 0;
172  };
173 
174  virtual void OnControlKeysChanged(uint8_t before __attribute__((unused)), uint8_t after __attribute__((unused))) {
175  };
176 
177  virtual void OnKeyDown(uint8_t mod __attribute__((unused)), uint8_t key __attribute__((unused))) {
178  };
179 
180  virtual void OnKeyUp(uint8_t mod __attribute__((unused)), uint8_t key __attribute__((unused))) {
181  };
182 
183  virtual const uint8_t *getNumKeys() {
184  return numKeys;
185  };
186 
187  virtual const uint8_t *getSymKeysUp() {
188  return symKeysUp;
189  };
190 
191  virtual const uint8_t *getSymKeysLo() {
192  return symKeysLo;
193  };
194 
195  virtual const uint8_t *getPadKeys() {
196  return padKeys;
197  };
198 };
199 
200 template <const uint8_t BOOT_PROTOCOL>
201 class HIDBoot : public USBHID //public USBDeviceConfig, public UsbConfigXtracter
202 {
203  EpInfo epInfo[totalEndpoints(BOOT_PROTOCOL)];
204  HIDReportParser *pRptParser[epMUL(BOOT_PROTOCOL)];
205 
206  uint8_t bConfNum; // configuration number
207  uint8_t bIfaceNum; // Interface Number
208  uint8_t bNumIface; // number of interfaces in the configuration
209  uint8_t bNumEP; // total number of EP in the configuration
210  uint32_t qNextPollTime; // next poll time
211  bool bPollEnable; // poll enable flag
212  uint8_t bInterval; // largest interval
213  bool bRptProtoEnable; // Report Protocol enable flag
214 
215  void Initialize();
216 
217  virtual HIDReportParser* GetReportParser(uint8_t id) {
218  return pRptParser[id];
219  };
220 
221 public:
222  HIDBoot(USB *p, bool bRptProtoEnable = false);
223 
224  virtual bool SetReportParser(uint8_t id, HIDReportParser *prs) {
225  pRptParser[id] = prs;
226  return true;
227  };
228 
229  // USBDeviceConfig implementation
230  uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
231  uint8_t Release();
232  uint8_t Poll();
233 
234  virtual uint8_t GetAddress() {
235  return bAddress;
236  };
237 
238  virtual bool isReady() {
239  return bPollEnable;
240  };
241 
242  // UsbConfigXtracter implementation
243  // Method should be defined here if virtual.
244  virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep);
245 
246  virtual bool DEVCLASSOK(uint8_t klass) {
247  return (klass == USB_CLASS_HID);
248  }
249 
250  virtual bool DEVSUBCLASSOK(uint8_t subklass) {
251  return (subklass == BOOT_PROTOCOL);
252  }
253 };
254 
255 template <const uint8_t BOOT_PROTOCOL>
256 HIDBoot<BOOT_PROTOCOL>::HIDBoot(USB *p, bool bRptProtoEnable/* = false*/) :
257 USBHID(p),
258 qNextPollTime(0),
259 bPollEnable(false),
260 bRptProtoEnable(bRptProtoEnable) {
261  Initialize();
262 
263  for(int i = 0; i < epMUL(BOOT_PROTOCOL); i++) {
264  pRptParser[i] = NULL;
265  }
266  if(pUsb)
267  pUsb->RegisterDeviceClass(this);
268 }
269 
270 template <const uint8_t BOOT_PROTOCOL>
272  for(int i = 0; i < totalEndpoints(BOOT_PROTOCOL); i++) {
273  epInfo[i].epAddr = 0;
274  epInfo[i].maxPktSize = (i) ? 0 : 8;
275  epInfo[i].bmSndToggle = 0;
276  epInfo[i].bmRcvToggle = 0;
277  epInfo[i].bmNakPower = (i) ? USB_NAK_NOWAIT : USB_NAK_MAX_POWER;
278  }
279  bNumEP = 1;
280  bNumIface = 0;
281  bConfNum = 0;
282 }
283 
284 template <const uint8_t BOOT_PROTOCOL>
285 uint8_t HIDBoot<BOOT_PROTOCOL>::Init(uint8_t parent, uint8_t port, bool lowspeed) {
286  const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR);
287 
288  uint8_t buf[constBufSize];
289  USB_DEVICE_DESCRIPTOR* device;
290  uint8_t rcode;
291  UsbDevice *p = NULL;
292  EpInfo *oldep_ptr = NULL;
293  uint8_t len = 0;
294  //uint16_t cd_len = 0;
295 
296  uint8_t num_of_conf; // number of configurations
297  //uint8_t num_of_intf; // number of interfaces
298 
299  AddressPool &addrPool = pUsb->GetAddressPool();
300 
301  USBTRACE("BM Init\r\n");
302  //USBTRACE2("totalEndpoints:", (uint8_t) (totalEndpoints(BOOT_PROTOCOL)));
303  //USBTRACE2("epMUL:", epMUL(BOOT_PROTOCOL));
304 
305  if(bAddress)
307 
308  bInterval = 0;
309  // Get pointer to pseudo device with address 0 assigned
310  p = addrPool.GetUsbDevicePtr(0);
311 
312  if(!p)
314 
315  if(!p->epinfo) {
316  USBTRACE("epinfo\r\n");
318  }
319 
320  // Save old pointer to EP_RECORD of address 0
321  oldep_ptr = p->epinfo;
322 
323  // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence
324  p->epinfo = epInfo;
325 
326  p->lowspeed = lowspeed;
327 
328  // Get device descriptor
329  rcode = pUsb->getDevDescr(0, 0, 8, (uint8_t*)buf);
330 
331  if(!rcode)
332  len = (buf[0] > constBufSize) ? constBufSize : buf[0];
333 
334  device = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
335 
336  if(rcode) {
337  // Restore p->epinfo
338  p->epinfo = oldep_ptr;
339 
340  goto FailGetDevDescr;
341  }
342 
343  // Restore p->epinfo
344  p->epinfo = oldep_ptr;
345 
346  // Allocate new address according to device class
347  bAddress = addrPool.AllocAddress(parent, false, port);
348 
349  if(!bAddress)
351 
352  // Extract Max Packet Size from the device descriptor
353  epInfo[0].maxPktSize = (uint8_t)(device->bMaxPacketSize0);
354 
355  // Assign new address to the device
356  rcode = pUsb->setAddr(0, 0, bAddress);
357 
358  if(rcode) {
359  p->lowspeed = false;
360  addrPool.FreeAddress(bAddress);
361  bAddress = 0;
362  USBTRACE2("setAddr:", rcode);
363  return rcode;
364  }
365  //delay(2); //per USB 2.0 sect.9.2.6.3
366 
367  USBTRACE2("Addr:", bAddress);
368 
369  p->lowspeed = false;
370 
371  p = addrPool.GetUsbDevicePtr(bAddress);
372 
373  if(!p)
375 
376  p->lowspeed = lowspeed;
377 
378  if(len)
379  rcode = pUsb->getDevDescr(bAddress, 0, len, (uint8_t*)buf);
380 
381  if(rcode)
382  goto FailGetDevDescr;
383 
384  num_of_conf = device->bNumConfigurations;
385 
386  USBTRACE2("NC:", num_of_conf);
387 
388  // GCC will optimize unused stuff away.
390  USBTRACE("HID_PROTOCOL_KEYBOARD AND MOUSE\r\n");
395  CP_MASK_COMPARE_ALL > confDescrParser(this);
396  confDescrParser.SetOR(); // Use the OR variant.
397  for(uint8_t i = 0; i < num_of_conf; i++) {
398  pUsb->getConfDescr(bAddress, 0, i, &confDescrParser);
399  if(bNumEP == (uint8_t)(totalEndpoints(BOOT_PROTOCOL)))
400  break;
401  }
402  } else {
403  // GCC will optimize unused stuff away.
404  if(BOOT_PROTOCOL & USB_HID_PROTOCOL_KEYBOARD) {
405  USBTRACE("HID_PROTOCOL_KEYBOARD\r\n");
406  for(uint8_t i = 0; i < num_of_conf; i++) {
411  CP_MASK_COMPARE_ALL> confDescrParserA(this);
412 
413  pUsb->getConfDescr(bAddress, 0, i, &confDescrParserA);
414  if(bNumEP == (uint8_t)(totalEndpoints(BOOT_PROTOCOL)))
415  break;
416  }
417  }
418 
419  // GCC will optimize unused stuff away.
420  if(BOOT_PROTOCOL & USB_HID_PROTOCOL_MOUSE) {
421  USBTRACE("HID_PROTOCOL_MOUSE\r\n");
422  for(uint8_t i = 0; i < num_of_conf; i++) {
427  CP_MASK_COMPARE_ALL> confDescrParserB(this);
428 
429  pUsb->getConfDescr(bAddress, 0, i, &confDescrParserB);
430  if(bNumEP == ((uint8_t)(totalEndpoints(BOOT_PROTOCOL))))
431  break;
432 
433  }
434  }
435  }
436  USBTRACE2("bNumEP:", bNumEP);
437 
438  if(bNumEP != (uint8_t)(totalEndpoints(BOOT_PROTOCOL))) {
440  goto Fail;
441  }
442 
443  // Assign epInfo to epinfo pointer
444  rcode = pUsb->setEpInfoEntry(bAddress, bNumEP, epInfo);
445  //USBTRACE2("setEpInfoEntry returned ", rcode);
446  USBTRACE2("Cnf:", bConfNum);
447 
448  delay(1000);
449 
450  // Set Configuration Value
451  rcode = pUsb->setConf(bAddress, 0, bConfNum);
452 
453  if(rcode)
454  goto FailSetConfDescr;
455 
456  delay(1000);
457 
458  USBTRACE2("bIfaceNum:", bIfaceNum);
459  USBTRACE2("bNumIface:", bNumIface);
460 
461  // Yes, mouse wants SetProtocol and SetIdle too!
462  for(uint8_t i = 0; i < epMUL(BOOT_PROTOCOL); i++) {
463  USBTRACE2("\r\nInterface:", i);
464  rcode = SetProtocol(i, bRptProtoEnable ? HID_RPT_PROTOCOL : USB_HID_BOOT_PROTOCOL);
465  if(rcode) goto FailSetProtocol;
466  USBTRACE2("PROTOCOL SET HID_BOOT rcode:", rcode);
467  rcode = SetIdle(i, 0, 0);
468  USBTRACE2("SET_IDLE rcode:", rcode);
469  // if(rcode) goto FailSetIdle; This can fail.
470  // Get the RPIPE and just throw it away.
472  rcode = GetReportDescr(i, &sink);
473  USBTRACE2("RPIPE rcode:", rcode);
474  }
475 
476  // Get RPIPE and throw it away.
477 
478  if(BOOT_PROTOCOL & USB_HID_PROTOCOL_KEYBOARD) {
479  // Wake keyboard interface by twinkling up to 5 LEDs that are in the spec.
480  // kana, compose, scroll, caps, num
481  rcode = 0x20; // Reuse rcode.
482  while(rcode) {
483  rcode >>= 1;
484  // Ignore any error returned, we don't care if LED is not supported
485  SetReport(0, 0, 2, 0, 1, &rcode); // Eventually becomes zero (All off)
486  delay(25);
487  }
488  }
489  USBTRACE("BM configured\r\n");
490 
491  bPollEnable = true;
492  return 0;
493 
494 FailGetDevDescr:
495 #ifdef DEBUG_USB_HOST
497  goto Fail;
498 #endif
499 
500  //FailSetDevTblEntry:
501  //#ifdef DEBUG_USB_HOST
502  // NotifyFailSetDevTblEntry();
503  // goto Fail;
504  //#endif
505 
506  //FailGetConfDescr:
507  //#ifdef DEBUG_USB_HOST
508  // NotifyFailGetConfDescr();
509  // goto Fail;
510  //#endif
511 
512 FailSetConfDescr:
513 #ifdef DEBUG_USB_HOST
515  goto Fail;
516 #endif
517 
518 FailSetProtocol:
519 #ifdef DEBUG_USB_HOST
520  USBTRACE("SetProto:");
521  goto Fail;
522 #endif
523 
524  //FailSetIdle:
525  //#ifdef DEBUG_USB_HOST
526  // USBTRACE("SetIdle:");
527  //#endif
528 
529 Fail:
530 #ifdef DEBUG_USB_HOST
531  NotifyFail(rcode);
532 #endif
533  Release();
534 
535  return rcode;
536 }
537 
538 template <const uint8_t BOOT_PROTOCOL>
539 void HIDBoot<BOOT_PROTOCOL>::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *pep) {
540 
541  // If the first configuration satisfies, the others are not considered.
542  //if(bNumEP > 1 && conf != bConfNum)
543  if(bNumEP == totalEndpoints(BOOT_PROTOCOL))
544  return;
545 
546  bConfNum = conf;
547  bIfaceNum = iface;
548 
549  if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_INTERRUPT && (pep->bEndpointAddress & 0x80) == 0x80) {
550  if(pep->bInterval > bInterval) bInterval = pep->bInterval;
551 
552  // Fill in the endpoint info structure
553  epInfo[bNumEP].epAddr = (pep->bEndpointAddress & 0x0F);
554  epInfo[bNumEP].maxPktSize = (uint8_t)pep->wMaxPacketSize;
555  epInfo[bNumEP].bmSndToggle = 0;
556  epInfo[bNumEP].bmRcvToggle = 0;
557  epInfo[bNumEP].bmNakPower = USB_NAK_NOWAIT;
558  bNumEP++;
559 
560  }
561 }
562 
563 template <const uint8_t BOOT_PROTOCOL>
565  pUsb->GetAddressPool().FreeAddress(bAddress);
566 
567  bConfNum = 0;
568  bIfaceNum = 0;
569  bNumEP = 1;
570  bAddress = 0;
571  qNextPollTime = 0;
572  bPollEnable = false;
573 
574  return 0;
575 }
576 
577 template <const uint8_t BOOT_PROTOCOL>
579  uint8_t rcode = 0;
580 
581  if(bPollEnable && ((int32_t)((uint32_t)millis() - qNextPollTime) >= 0L)) {
582 
583  // To-do: optimize manually, using the for loop only if needed.
584  for(int i = 0; i < epMUL(BOOT_PROTOCOL); i++) {
585  const uint16_t const_buff_len = 64;
586 
587  USBTRACE3("(hidboot.h) i=", i, 0x81);
588  USBTRACE3("(hidboot.h) epInfo[epInterruptInIndex + i].epAddr=", epInfo[epInterruptInIndex + i].epAddr, 0x81);
589  USBTRACE3("(hidboot.h) epInfo[epInterruptInIndex + i].maxPktSize=", epInfo[epInterruptInIndex + i].maxPktSize, 0x81);
590  uint16_t read = (uint16_t)epInfo[epInterruptInIndex + i].maxPktSize;
591 
592  if (read > const_buff_len)
593  read = const_buff_len;
594 
595  uint8_t buf[read];
596 
597  rcode = pUsb->inTransfer(bAddress, epInfo[epInterruptInIndex + i].epAddr, &read, buf);
598  // SOME buggy dongles report extra keys (like sleep) using a 2 byte packet on the wrong endpoint.
599  // Since keyboard and mice must report at least 3 bytes, we ignore the extra data.
600  if(!rcode && read > 2) {
601  if(pRptParser[i])
602  pRptParser[i]->Parse((USBHID*)this, 0, (uint8_t)read, buf);
603 #ifdef DEBUG_USB_HOST
604  // We really don't care about errors and anomalies unless we are debugging.
605  } else {
606  if(rcode != hrNAK) {
607  USBTRACE3("(hidboot.h) Poll:", rcode, 0x81);
608  }
609  if(!rcode && read) {
610  USBTRACE3("(hidboot.h) Strange read count: ", read, 0x80);
611  USBTRACE3("(hidboot.h) Interface:", i, 0x80);
612  }
613  }
614 
615  if(!rcode && read && (UsbDEBUGlvl > 0x7f)) {
616  for(uint8_t i = 0; i < read; i++) {
617  PrintHex<uint8_t > (buf[i], 0x80);
618  USBTRACE1(" ", 0x80);
619  }
620  if(read)
621  USBTRACE1("\r\n", 0x80);
622 #endif
623  }
624 
625  }
626  qNextPollTime = (uint32_t)millis() + bInterval;
627  }
628  return rcode;
629 }
630 
631 #endif // __HIDBOOTMOUSE_H__
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
Definition: UsbCore.h:95
#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE
Definition: UsbCore.h:100
#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED
Definition: UsbCore.h:92
#define USB_CLASS_HID
Definition: UsbCore.h:74
#define USB_ERROR_EPINFO_IS_NULL
Definition: UsbCore.h:98
#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL
Definition: UsbCore.h:97
#define USB_NAK_MAX_POWER
Definition: address.h:34
#define USB_NAK_NOWAIT
Definition: address.h:36
virtual void FreeAddress(uint8_t addr)=0
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub=false, uint8_t port=0)=0
virtual UsbDevice * GetUsbDevicePtr(uint8_t addr)=0
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
Definition: hidboot.h:539
virtual bool SetReportParser(uint8_t id, HIDReportParser *prs)
Definition: hidboot.h:224
virtual uint8_t GetAddress()
Definition: hidboot.h:234
virtual bool isReady()
Definition: hidboot.h:238
virtual bool DEVCLASSOK(uint8_t klass)
Definition: hidboot.h:246
uint8_t Release()
Definition: hidboot.h:564
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
Definition: hidboot.h:285
uint8_t Poll()
Definition: hidboot.h:578
HIDBoot(USB *p, bool bRptProtoEnable=false)
Definition: hidboot.h:256
virtual bool DEVSUBCLASSOK(uint8_t subklass)
Definition: hidboot.h:250
void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
Definition: hidboot.cpp:127
virtual const uint8_t * getSymKeysLo()
Definition: hidboot.h:191
union KeyboardReportParser::@17 prevState
virtual const uint8_t * getSymKeysUp()
Definition: hidboot.h:187
virtual void OnKeyUp(uint8_t mod, uint8_t key)
Definition: hidboot.h:180
uint8_t bInfo[sizeof(KBDINFO)]
Definition: hidboot.h:131
union KeyboardReportParser::@18 kbdLockingKeys
virtual const uint8_t * getNumKeys()
Definition: hidboot.h:183
uint8_t OemToAscii(uint8_t mod, uint8_t key)
Definition: hidboot.cpp:165
virtual void OnControlKeysChanged(uint8_t before, uint8_t after)
Definition: hidboot.h:174
virtual void OnKeyDown(uint8_t mod, uint8_t key)
Definition: hidboot.h:177
virtual const uint8_t * getPadKeys()
Definition: hidboot.h:195
virtual uint8_t HandleLockingKeys(USBHID *hid, uint8_t key)
Definition: hidboot.h:151
virtual void OnRightButtonUp(MOUSEINFO *mi)
Definition: hidboot.h:72
virtual void OnMouseMove(MOUSEINFO *mi)
Definition: hidboot.h:63
virtual void OnRightButtonDown(MOUSEINFO *mi)
Definition: hidboot.h:75
virtual void OnLeftButtonUp(MOUSEINFO *mi)
Definition: hidboot.h:66
virtual void OnMiddleButtonUp(MOUSEINFO *mi)
Definition: hidboot.h:78
MOUSEINFO mouseInfo
Definition: hidboot.h:54
uint8_t bInfo[sizeof(MOUSEINFO)]
Definition: hidboot.h:55
virtual void OnLeftButtonDown(MOUSEINFO *mi)
Definition: hidboot.h:69
virtual void OnMiddleButtonDown(MOUSEINFO *mi)
Definition: hidboot.h:81
void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
Definition: hidboot.cpp:19
Definition: usbhid.h:143
static const uint8_t totalEndpoints
Definition: usbhid.h:154
uint8_t bAddress
Definition: usbhid.h:146
uint8_t SetReport(uint8_t ep, uint8_t iface, uint8_t report_type, uint8_t report_id, uint16_t nbytes, uint8_t *dataptr)
Definition: usbhid.cpp:50
USB * pUsb
Definition: usbhid.h:145
Definition: UsbCore.h:212
uint8_t RegisterDeviceClass(USBDeviceConfig *pdev)
Definition: UsbCore.h:232
#define CP_MASK_COMPARE_ALL
@ L
int UsbDEBUGlvl
Definition: message.cpp:29
#define UHS_HID_BOOT_KEY_CAPS_LOCK
Definition: hidboot.h:25
#define totalEndpoints(p)
Definition: hidboot.h:33
#define epMUL(p)
Definition: hidboot.h:34
#define UHS_HID_BOOT_KEY_NUM_LOCK
Definition: hidboot.h:27
#define UHS_HID_BOOT_KEY_SCROLL_LOCK
Definition: hidboot.h:26
#define USBTRACE3(s, r, l)
Definition: macros.h:85
#define USBTRACE1(s, l)
Definition: macros.h:83
#define USBTRACE2(s, r)
Definition: macros.h:84
#define USBTRACE(s)
Definition: macros.h:82
#define hrNAK
Definition: max3421e.h:218
#define NotifyFailSetConfDescr(...)
Definition: message.h:60
#define NotifyFail(...)
Definition: message.h:62
#define NotifyFailGetDevDescr(...)
Definition: message.h:57
Definition: address.h:39
uint8_t bmLeftCtrl
Definition: hidboot.h:99
uint8_t bmLeftGUI
Definition: hidboot.h:102
uint8_t bmRightGUI
Definition: hidboot.h:106
uint8_t bmLeftShift
Definition: hidboot.h:100
uint8_t bmLeftAlt
Definition: hidboot.h:101
uint8_t bReserved
Definition: hidboot.h:108
uint8_t Keys[6]
Definition: hidboot.h:109
uint8_t bmRightCtrl
Definition: hidboot.h:103
uint8_t bmRightShift
Definition: hidboot.h:104
uint8_t bmRightAlt
Definition: hidboot.h:105
uint8_t bmNumLock
Definition: hidboot.h:113
uint8_t bmCompose
Definition: hidboot.h:116
uint8_t bmCapsLock
Definition: hidboot.h:114
uint8_t bmReserved
Definition: hidboot.h:118
uint8_t bmKana
Definition: hidboot.h:117
uint8_t bmScrollLock
Definition: hidboot.h:115
uint8_t bmRightGUI
Definition: hidboot.h:93
uint8_t bmRightCtrl
Definition: hidboot.h:90
uint8_t bmLeftCtrl
Definition: hidboot.h:86
uint8_t bmLeftAlt
Definition: hidboot.h:88
uint8_t bmRightShift
Definition: hidboot.h:91
uint8_t bmLeftGUI
Definition: hidboot.h:89
uint8_t bmLeftShift
Definition: hidboot.h:87
uint8_t bmRightAlt
Definition: hidboot.h:92
uint8_t bmRightButton
Definition: hidboot.h:43
uint8_t bmDummy
Definition: hidboot.h:45
uint8_t bmMiddleButton
Definition: hidboot.h:44
uint8_t bmLeftButton
Definition: hidboot.h:42
int8_t dX
Definition: hidboot.h:47
int8_t dY
Definition: hidboot.h:48
uint8_t bMaxPacketSize0
Definition: usb_ch9.h:112
uint8_t bNumConfigurations
Definition: usb_ch9.h:119
uint8_t bEndpointAddress
Definition: usb_ch9.h:151
uint16_t wMaxPacketSize
Definition: usb_ch9.h:153
EpInfo * epinfo
Definition: address.h:83
bool lowspeed
Definition: address.h:86
#define bmUSB_TRANSFER_TYPE
Definition: usb_ch9.h:94
#define USB_TRANSFER_TYPE_INTERRUPT
Definition: usb_ch9.h:93
#define HID_RPT_PROTOCOL
Definition: usbhid.h:83
#define USB_HID_PROTOCOL_MOUSE
Definition: usbhid.h:94
#define USB_HID_BOOT_PROTOCOL
Definition: usbhid.h:82
#define USB_HID_PROTOCOL_KEYBOARD
Definition: usbhid.h:93
#define HID_BOOT_INTF_SUBCLASS
Definition: usbhid.h:89