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) {
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(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, uint8_t after) {
175  };
176 
177  virtual void OnKeyDown(uint8_t mod, uint8_t key) {
178  };
179 
180  virtual void OnKeyUp(uint8_t mod, uint8_t key) {
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  uint8_t rcode;
290  UsbDevice *p = NULL;
291  EpInfo *oldep_ptr = NULL;
292  uint8_t len = 0;
293  //uint16_t cd_len = 0;
294 
295  uint8_t num_of_conf; // number of configurations
296  //uint8_t num_of_intf; // number of interfaces
297 
298  AddressPool &addrPool = pUsb->GetAddressPool();
299 
300  USBTRACE("BM Init\r\n");
301  //USBTRACE2("totalEndpoints:", (uint8_t) (totalEndpoints(BOOT_PROTOCOL)));
302  //USBTRACE2("epMUL:", epMUL(BOOT_PROTOCOL));
303 
304  if(bAddress)
306 
307  bInterval = 0;
308  // Get pointer to pseudo device with address 0 assigned
309  p = addrPool.GetUsbDevicePtr(0);
310 
311  if(!p)
313 
314  if(!p->epinfo) {
315  USBTRACE("epinfo\r\n");
317  }
318 
319  // Save old pointer to EP_RECORD of address 0
320  oldep_ptr = p->epinfo;
321 
322  // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence
323  p->epinfo = epInfo;
324 
325  p->lowspeed = lowspeed;
326 
327  // Get device descriptor
328  rcode = pUsb->getDevDescr(0, 0, 8, (uint8_t*)buf);
329 
330  if(!rcode)
331  len = (buf[0] > constBufSize) ? constBufSize : buf[0];
332 
333  if(rcode) {
334  // Restore p->epinfo
335  p->epinfo = oldep_ptr;
336 
337  goto FailGetDevDescr;
338  }
339 
340  // Restore p->epinfo
341  p->epinfo = oldep_ptr;
342 
343  // Allocate new address according to device class
344  bAddress = addrPool.AllocAddress(parent, false, port);
345 
346  if(!bAddress)
348 
349  // Extract Max Packet Size from the device descriptor
350  epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0;
351 
352  // Assign new address to the device
353  rcode = pUsb->setAddr(0, 0, bAddress);
354 
355  if(rcode) {
356  p->lowspeed = false;
357  addrPool.FreeAddress(bAddress);
358  bAddress = 0;
359  USBTRACE2("setAddr:", rcode);
360  return rcode;
361  }
362  //delay(2); //per USB 2.0 sect.9.2.6.3
363 
364  USBTRACE2("Addr:", bAddress);
365 
366  p->lowspeed = false;
367 
368  p = addrPool.GetUsbDevicePtr(bAddress);
369 
370  if(!p)
372 
373  p->lowspeed = lowspeed;
374 
375  if(len)
376  rcode = pUsb->getDevDescr(bAddress, 0, len, (uint8_t*)buf);
377 
378  if(rcode)
379  goto FailGetDevDescr;
380 
381  num_of_conf = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations;
382 
383  USBTRACE2("NC:", num_of_conf);
384 
385  // GCC will optimize unused stuff away.
387  USBTRACE("HID_PROTOCOL_KEYBOARD AND MOUSE\r\n");
392  CP_MASK_COMPARE_ALL > confDescrParser(this);
393  confDescrParser.SetOR(); // Use the OR variant.
394  for(uint8_t i = 0; i < num_of_conf; i++) {
395  pUsb->getConfDescr(bAddress, 0, i, &confDescrParser);
396  if(bNumEP == (uint8_t)(totalEndpoints(BOOT_PROTOCOL)))
397  break;
398  }
399  } else {
400  // GCC will optimize unused stuff away.
401  if(BOOT_PROTOCOL & USB_HID_PROTOCOL_KEYBOARD) {
402  USBTRACE("HID_PROTOCOL_KEYBOARD\r\n");
403  for(uint8_t i = 0; i < num_of_conf; i++) {
408  CP_MASK_COMPARE_ALL> confDescrParserA(this);
409 
410  pUsb->getConfDescr(bAddress, 0, i, &confDescrParserA);
411  if(bNumEP == (uint8_t)(totalEndpoints(BOOT_PROTOCOL)))
412  break;
413  }
414  }
415 
416  // GCC will optimize unused stuff away.
417  if(BOOT_PROTOCOL & USB_HID_PROTOCOL_MOUSE) {
418  USBTRACE("HID_PROTOCOL_MOUSE\r\n");
419  for(uint8_t i = 0; i < num_of_conf; i++) {
424  CP_MASK_COMPARE_ALL> confDescrParserB(this);
425 
426  pUsb->getConfDescr(bAddress, 0, i, &confDescrParserB);
427  if(bNumEP == ((uint8_t)(totalEndpoints(BOOT_PROTOCOL))))
428  break;
429 
430  }
431  }
432  }
433  USBTRACE2("bNumEP:", bNumEP);
434 
435  if(bNumEP != (uint8_t)(totalEndpoints(BOOT_PROTOCOL))) {
437  goto Fail;
438  }
439 
440  // Assign epInfo to epinfo pointer
441  rcode = pUsb->setEpInfoEntry(bAddress, bNumEP, epInfo);
442  //USBTRACE2("setEpInfoEntry returned ", rcode);
443  USBTRACE2("Cnf:", bConfNum);
444 
445  delay(1000);
446 
447  // Set Configuration Value
448  rcode = pUsb->setConf(bAddress, 0, bConfNum);
449 
450  if(rcode)
451  goto FailSetConfDescr;
452 
453  delay(1000);
454 
455  USBTRACE2("bIfaceNum:", bIfaceNum);
456  USBTRACE2("bNumIface:", bNumIface);
457 
458  // Yes, mouse wants SetProtocol and SetIdle too!
459  for(uint8_t i = 0; i < epMUL(BOOT_PROTOCOL); i++) {
460  USBTRACE2("\r\nInterface:", i);
461  rcode = SetProtocol(i, bRptProtoEnable ? HID_RPT_PROTOCOL : USB_HID_BOOT_PROTOCOL);
462  if(rcode) goto FailSetProtocol;
463  USBTRACE2("PROTOCOL SET HID_BOOT rcode:", rcode);
464  rcode = SetIdle(i, 0, 0);
465  USBTRACE2("SET_IDLE rcode:", rcode);
466  // if(rcode) goto FailSetIdle; This can fail.
467  // Get the RPIPE and just throw it away.
469  rcode = GetReportDescr(i, &sink);
470  USBTRACE2("RPIPE rcode:", rcode);
471  }
472 
473  // Get RPIPE and throw it away.
474 
475  if(BOOT_PROTOCOL & USB_HID_PROTOCOL_KEYBOARD) {
476  // Wake keyboard interface by twinkling up to 5 LEDs that are in the spec.
477  // kana, compose, scroll, caps, num
478  rcode = 0x20; // Reuse rcode.
479  while(rcode) {
480  rcode >>= 1;
481  // Ignore any error returned, we don't care if LED is not supported
482  SetReport(0, 0, 2, 0, 1, &rcode); // Eventually becomes zero (All off)
483  delay(25);
484  }
485  }
486  USBTRACE("BM configured\r\n");
487 
488  bPollEnable = true;
489  return 0;
490 
491 FailGetDevDescr:
492 #ifdef DEBUG_USB_HOST
494  goto Fail;
495 #endif
496 
497  //FailSetDevTblEntry:
498  //#ifdef DEBUG_USB_HOST
499  // NotifyFailSetDevTblEntry();
500  // goto Fail;
501  //#endif
502 
503  //FailGetConfDescr:
504  //#ifdef DEBUG_USB_HOST
505  // NotifyFailGetConfDescr();
506  // goto Fail;
507  //#endif
508 
509 FailSetConfDescr:
510 #ifdef DEBUG_USB_HOST
512  goto Fail;
513 #endif
514 
515 FailSetProtocol:
516 #ifdef DEBUG_USB_HOST
517  USBTRACE("SetProto:");
518  goto Fail;
519 #endif
520 
521  //FailSetIdle:
522  //#ifdef DEBUG_USB_HOST
523  // USBTRACE("SetIdle:");
524  //#endif
525 
526 Fail:
527 #ifdef DEBUG_USB_HOST
528  NotifyFail(rcode);
529 #endif
530  Release();
531 
532  return rcode;
533 }
534 
535 template <const uint8_t BOOT_PROTOCOL>
536 void HIDBoot<BOOT_PROTOCOL>::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *pep) {
537 
538  // If the first configuration satisfies, the others are not considered.
539  //if(bNumEP > 1 && conf != bConfNum)
540  if(bNumEP == totalEndpoints(BOOT_PROTOCOL))
541  return;
542 
543  bConfNum = conf;
544  bIfaceNum = iface;
545 
546  if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) {
547  if(pep->bInterval > bInterval) bInterval = pep->bInterval;
548 
549  // Fill in the endpoint info structure
550  epInfo[bNumEP].epAddr = (pep->bEndpointAddress & 0x0F);
551  epInfo[bNumEP].maxPktSize = (uint8_t)pep->wMaxPacketSize;
552  epInfo[bNumEP].bmSndToggle = 0;
553  epInfo[bNumEP].bmRcvToggle = 0;
554  epInfo[bNumEP].bmNakPower = USB_NAK_NOWAIT;
555  bNumEP++;
556 
557  }
558 }
559 
560 template <const uint8_t BOOT_PROTOCOL>
563 
564  bConfNum = 0;
565  bIfaceNum = 0;
566  bNumEP = 1;
567  bAddress = 0;
568  qNextPollTime = 0;
569  bPollEnable = false;
570 
571  return 0;
572 }
573 
574 template <const uint8_t BOOT_PROTOCOL>
576  uint8_t rcode = 0;
577 
578  if(bPollEnable && ((long)(millis() - qNextPollTime) >= 0L)) {
579 
580  // To-do: optimize manually, using the for loop only if needed.
581  for(int i = 0; i < epMUL(BOOT_PROTOCOL); i++) {
582  const uint16_t const_buff_len = 16;
583  uint8_t buf[const_buff_len];
584 
585  USBTRACE3("(hidboot.h) i=", i, 0x81);
586  USBTRACE3("(hidboot.h) epInfo[epInterruptInIndex + i].epAddr=", epInfo[epInterruptInIndex + i].epAddr, 0x81);
587  USBTRACE3("(hidboot.h) epInfo[epInterruptInIndex + i].maxPktSize=", epInfo[epInterruptInIndex + i].maxPktSize, 0x81);
588  uint16_t read = (uint16_t)epInfo[epInterruptInIndex + i].maxPktSize;
589 
590  rcode = pUsb->inTransfer(bAddress, epInfo[epInterruptInIndex + i].epAddr, &read, buf);
591  // SOME buggy dongles report extra keys (like sleep) using a 2 byte packet on the wrong endpoint.
592  // Since keyboard and mice must report at least 3 bytes, we ignore the extra data.
593  if(!rcode && read > 2) {
594  if(pRptParser[i])
595  pRptParser[i]->Parse((USBHID*)this, 0, (uint8_t)read, buf);
596 #ifdef DEBUG_USB_HOST
597  // We really don't care about errors and anomalies unless we are debugging.
598  } else {
599  if(rcode != hrNAK) {
600  USBTRACE3("(hidboot.h) Poll:", rcode, 0x81);
601  }
602  if(!rcode && read) {
603  USBTRACE3("(hidboot.h) Strange read count: ", read, 0x80);
604  USBTRACE3("(hidboot.h) Interface:", i, 0x80);
605  }
606  }
607 
608  if(!rcode && read && (UsbDEBUGlvl > 0x7f)) {
609  for(uint8_t i = 0; i < read; i++) {
610  PrintHex<uint8_t > (buf[i], 0x80);
611  USBTRACE1(" ", 0x80);
612  }
613  if(read)
614  USBTRACE1("\r\n", 0x80);
615 #endif
616  }
617 
618  }
619  qNextPollTime = millis() + bInterval;
620  }
621  return rcode;
622 }
623 
624 #endif // __HIDBOOTMOUSE_H__
uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr)
Definition: Usb.cpp:771
uint8_t bmRcvToggle
Definition: address.h:41
#define CP_MASK_COMPARE_ALL
Definition: usbhid.h:143
USB * pUsb
Definition: usbhid.h:145
EpInfo * epinfo
Definition: address.h:76
#define HID_BOOT_INTF_SUBCLASS
Definition: usbhid.h:89
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:191
virtual void OnRightButtonDown(MOUSEINFO *mi)
Definition: hidboot.h:75
virtual void OnKeyDown(uint8_t mod, uint8_t key)
Definition: hidboot.h:177
uint8_t bmNakPower
Definition: address.h:42
uint8_t GetReportDescr(uint16_t wIndex, USBReadParser *parser=NULL)
Definition: usbhid.cpp:34
uint8_t Poll()
Definition: hidboot.h:575
#define NotifyFail(...)
Definition: message.h:55
virtual void OnMiddleButtonUp(MOUSEINFO *mi)
Definition: hidboot.h:78
MOUSEINFO mouseInfo
Definition: hidboot.h:54
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
Definition: Usb.cpp:810
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
Definition: hidboot.h:536
virtual bool DEVCLASSOK(uint8_t klass)
Definition: hidboot.h:246
#define UHS_HID_BOOT_KEY_SCROLL_LOCK
Definition: hidboot.h:26
#define NotifyFailGetDevDescr(...)
Definition: message.h:50
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
Definition: Usb.cpp:64
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
Definition: hidboot.h:285
virtual bool SetReportParser(uint8_t id, HIDReportParser *prs)
Definition: hidboot.h:224
virtual void OnKeyUp(uint8_t mod, uint8_t key)
Definition: hidboot.h:180
int UsbDEBUGlvl
Definition: message.cpp:22
#define USB_CLASS_HID
Definition: UsbCore.h:59
virtual void FreeAddress(uint8_t addr)=0
virtual UsbDevice * GetUsbDevicePtr(uint8_t addr)=0
uint8_t SetIdle(uint8_t iface, uint8_t reportID, uint8_t duration)
Definition: usbhid.cpp:62
virtual const uint8_t * getSymKeysUp()
Definition: hidboot.h:187
#define USBTRACE2(s, r)
Definition: macros.h:77
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
Definition: Usb.cpp:801
uint8_t bmMiddleButton
Definition: hidboot.h:44
virtual void OnLeftButtonUp(MOUSEINFO *mi)
Definition: hidboot.h:66
uint8_t epAddr
Definition: address.h:33
uint8_t bmDummy
Definition: hidboot.h:45
virtual uint8_t GetAddress()
Definition: hidboot.h:234
#define USB_NAK_MAX_POWER
Definition: address.h:27
HIDBoot(USB *p, bool bRptProtoEnable=false)
Definition: hidboot.h:256
virtual uint8_t HandleLockingKeys(USBHID *hid, uint8_t key)
Definition: hidboot.h:151
#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 bAddress
Definition: usbhid.h:146
uint16_t wMaxPacketSize
Definition: usb_ch9.h:146
virtual void OnMiddleButtonDown(MOUSEINFO *mi)
Definition: hidboot.h:81
static const uint8_t epInterruptInIndex
Definition: usbhid.h:149
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub=false, uint8_t port=0)=0
uint8_t bEndpointAddress
Definition: usb_ch9.h:144
#define UHS_HID_BOOT_KEY_NUM_LOCK
Definition: hidboot.h:27
uint8_t bmSndToggle
Definition: address.h:40
#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE
Definition: UsbCore.h:85
#define USB_HID_PROTOCOL_KEYBOARD
Definition: usbhid.h:93
#define totalEndpoints(p)
Definition: hidboot.h:33
#define USBTRACE1(s, l)
Definition: macros.h:76
#define USB_NAK_NOWAIT
Definition: address.h:29
uint8_t SetProtocol(uint8_t iface, uint8_t protocol)
Definition: usbhid.cpp:66
#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL
Definition: UsbCore.h:82
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:174
static const uint8_t totalEndpoints
Definition: usbhid.h:154
uint8_t Release()
Definition: hidboot.h:561
virtual void OnLeftButtonDown(MOUSEINFO *mi)
Definition: hidboot.h:69
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval=0)
Definition: Usb.cpp:206
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
virtual const uint8_t * getNumKeys()
Definition: hidboot.h:183
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
Definition: UsbCore.h:80
virtual bool isReady()
Definition: hidboot.h:238
#define USB_HID_BOOT_PROTOCOL
Definition: usbhid.h:82
virtual const uint8_t * getPadKeys()
Definition: hidboot.h:195
uint8_t maxPktSize
Definition: address.h:34
AddressPool & GetAddressPool()
Definition: UsbCore.h:213
int8_t dY
Definition: hidboot.h:48
Definition: UsbCore.h:197
virtual bool DEVSUBCLASSOK(uint8_t subklass)
Definition: hidboot.h:250
#define USB_HID_PROTOCOL_MOUSE
Definition: usbhid.h:94
#define USBTRACE3(s, r, l)
Definition: macros.h:78
uint8_t RegisterDeviceClass(USBDeviceConfig *pdev)
Definition: UsbCore.h:217
#define NotifyFailSetConfDescr(...)
Definition: message.h:53
virtual void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)=0
uint8_t bmLeftButton
Definition: hidboot.h:42
uint8_t bReserved
Definition: hidboot.h:108
#define HID_RPT_PROTOCOL
Definition: usbhid.h:83
#define UHS_HID_BOOT_KEY_CAPS_LOCK
Definition: hidboot.h:25
#define USBTRACE(s)
Definition: macros.h:75
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)
Definition: Usb.cpp:766