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