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)];
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 __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__
MOUSEINFO
Definition: hidboot.h:39
hrNAK
#define hrNAK
Definition: max3421e.h:218
UHS_HID_BOOT_KEY_CAPS_LOCK
#define UHS_HID_BOOT_KEY_CAPS_LOCK
Definition: hidboot.h:25
USB_ENDPOINT_DESCRIPTOR::bInterval
uint8_t bInterval
Definition: usb_ch9.h:154
MouseReportParser::OnRightButtonDown
virtual void OnRightButtonDown(MOUSEINFO *mi)
Definition: hidboot.h:75
USB_HID_BOOT_PROTOCOL
#define USB_HID_BOOT_PROTOCOL
Definition: usbhid.h:82
HIDBoot::Poll
uint8_t Poll()
Definition: hidboot.h:578
AddressPool::GetUsbDevicePtr
virtual UsbDevice * GetUsbDevicePtr(uint8_t addr)=0
MODIFIERKEYS::bmLeftShift
uint8_t bmLeftShift
Definition: hidboot.h:87
MouseReportParser::OnMiddleButtonUp
virtual void OnMiddleButtonUp(MOUSEINFO *mi)
Definition: hidboot.h:78
USBHID::bAddress
uint8_t bAddress
Definition: usbhid.h:146
AddressPool
Definition: address.h:90
USB_DEVICE_DESCRIPTOR::bNumConfigurations
uint8_t bNumConfigurations
Definition: usb_ch9.h:119
MOUSEINFO::bmLeftButton
uint8_t bmLeftButton
Definition: hidboot.h:42
USB_HID_PROTOCOL_MOUSE
#define USB_HID_PROTOCOL_MOUSE
Definition: usbhid.h:94
NotifyFail
#define NotifyFail(...)
Definition: message.h:62
UsbDevice::lowspeed
bool lowspeed
Definition: address.h:86
USB_TRANSFER_TYPE_INTERRUPT
#define USB_TRANSFER_TYPE_INTERRUPT
Definition: usb_ch9.h:93
USB::RegisterDeviceClass
uint8_t RegisterDeviceClass(USBDeviceConfig *pdev)
Definition: UsbCore.h:230
MouseReportParser::OnLeftButtonDown
virtual void OnLeftButtonDown(MOUSEINFO *mi)
Definition: hidboot.h:69
AddressPool::AllocAddress
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub=false, uint8_t port=0)=0
KBDLEDS
Definition: hidboot.h:112
USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE
#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE
Definition: UsbCore.h:98
KeyboardReportParser::OemToAscii
uint8_t OemToAscii(uint8_t mod, uint8_t key)
Definition: hidboot.cpp:165
USBTRACE3
#define USBTRACE3(s, r, l)
Definition: macros.h:85
KBDLEDS::bmCompose
uint8_t bmCompose
Definition: hidboot.h:116
USB_ENDPOINT_DESCRIPTOR
Definition: usb_ch9.h:148
KBDINFO::bmLeftShift
uint8_t bmLeftShift
Definition: hidboot.h:100
CP_MASK_COMPARE_ALL
#define CP_MASK_COMPARE_ALL
Definition: confdescparser.h:42
KBDINFO
Definition: hidboot.h:96
MouseReportParser::mouseInfo
MOUSEINFO mouseInfo
Definition: hidboot.h:54
HIDBoot::Init
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
Definition: hidboot.h:285
UsbDEBUGlvl
int UsbDEBUGlvl
Definition: message.cpp:29
MODIFIERKEYS::bmLeftCtrl
uint8_t bmLeftCtrl
Definition: hidboot.h:86
KeyboardReportParser::OnKeyUp
virtual void OnKeyUp(uint8_t mod, uint8_t key)
Definition: hidboot.h:180
usbhid.h
MouseReportParser::OnMiddleButtonDown
virtual void OnMiddleButtonDown(MOUSEINFO *mi)
Definition: hidboot.h:81
HIDBoot::DEVCLASSOK
virtual bool DEVCLASSOK(uint8_t klass)
Definition: hidboot.h:246
MouseReportParser::bInfo
uint8_t bInfo[sizeof(MOUSEINFO)]
Definition: hidboot.h:55
KBDINFO::bmRightShift
uint8_t bmRightShift
Definition: hidboot.h:104
USBTRACE1
#define USBTRACE1(s, l)
Definition: macros.h:83
HID_BOOT_INTF_SUBCLASS
#define HID_BOOT_INTF_SUBCLASS
Definition: usbhid.h:89
KeyboardReportParser::getSymKeysUp
virtual const uint8_t * getSymKeysUp()
Definition: hidboot.h:187
UHS_HID_BOOT_KEY_SCROLL_LOCK
#define UHS_HID_BOOT_KEY_SCROLL_LOCK
Definition: hidboot.h:26
MOUSEINFO::dX
int8_t dX
Definition: hidboot.h:47
USBHID::SetReport
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
MOUSEINFO::bmRightButton
uint8_t bmRightButton
Definition: hidboot.h:43
NotifyFailGetDevDescr
#define NotifyFailGetDevDescr(...)
Definition: message.h:57
MODIFIERKEYS
Definition: hidboot.h:85
KBDLEDS::bmKana
uint8_t bmKana
Definition: hidboot.h:117
KeyboardReportParser::KeyboardReportParser
KeyboardReportParser()
Definition: hidboot.h:143
USB_DEVICE_DESCRIPTOR
Definition: usb_ch9.h:105
HIDBoot::HIDBoot
HIDBoot(USB *p, bool bRptProtoEnable=false)
Definition: hidboot.h:256
MODIFIERKEYS::bmLeftGUI
uint8_t bmLeftGUI
Definition: hidboot.h:89
HIDReportParser
Definition: usbhid.h:138
HIDBoot::EndpointXtract
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
Definition: hidboot.h:539
HID_RPT_PROTOCOL
#define HID_RPT_PROTOCOL
Definition: usbhid.h:83
KeyboardReportParser::Parse
void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
Definition: hidboot.cpp:127
USB_CLASS_HID
#define USB_CLASS_HID
Definition: UsbCore.h:72
USB_DEVICE_DESCRIPTOR::bMaxPacketSize0
uint8_t bMaxPacketSize0
Definition: usb_ch9.h:112
USB_NAK_MAX_POWER
#define USB_NAK_MAX_POWER
Definition: address.h:34
HIDBoot::SetReportParser
virtual bool SetReportParser(uint8_t id, HIDReportParser *prs)
Definition: hidboot.h:224
MODIFIERKEYS::bmRightGUI
uint8_t bmRightGUI
Definition: hidboot.h:93
bmUSB_TRANSFER_TYPE
#define bmUSB_TRANSFER_TYPE
Definition: usb_ch9.h:94
KBDINFO::bReserved
uint8_t bReserved
Definition: hidboot.h:108
KBDLEDS::bmCapsLock
uint8_t bmCapsLock
Definition: hidboot.h:114
EpInfo
Definition: address.h:39
epMUL
#define epMUL(p)
Definition: hidboot.h:34
MOUSEINFO::dY
int8_t dY
Definition: hidboot.h:48
USBHID::totalEndpoints
static const uint8_t totalEndpoints
Definition: usbhid.h:154
USB_ENDPOINT_DESCRIPTOR::bEndpointAddress
uint8_t bEndpointAddress
Definition: usb_ch9.h:151
USB_NAK_NOWAIT
#define USB_NAK_NOWAIT
Definition: address.h:36
KBDINFO::bmLeftCtrl
uint8_t bmLeftCtrl
Definition: hidboot.h:99
KeyboardReportParser::kbdLockingKeys
union KeyboardReportParser::@18 kbdLockingKeys
MouseReportParser
Definition: hidboot.h:51
USBHID::pUsb
USB * pUsb
Definition: usbhid.h:145
MouseReportParser::OnRightButtonUp
virtual void OnRightButtonUp(MOUSEINFO *mi)
Definition: hidboot.h:72
UHS_HID_BOOT_KEY_NUM_LOCK
#define UHS_HID_BOOT_KEY_NUM_LOCK
Definition: hidboot.h:27
USB_HID_PROTOCOL_KEYBOARD
#define USB_HID_PROTOCOL_KEYBOARD
Definition: usbhid.h:93
HIDBoot::GetAddress
virtual uint8_t GetAddress()
Definition: hidboot.h:234
USB
Definition: UsbCore.h:210
KeyboardReportParser::bInfo
uint8_t bInfo[sizeof(KBDINFO)]
Definition: hidboot.h:131
KeyboardReportParser::HandleLockingKeys
virtual uint8_t HandleLockingKeys(USBHID *hid, uint8_t key)
Definition: hidboot.h:151
totalEndpoints
#define totalEndpoints(p)
Definition: hidboot.h:33
KBDINFO::bmRightGUI
uint8_t bmRightGUI
Definition: hidboot.h:106
KeyboardReportParser::getNumKeys
virtual const uint8_t * getNumKeys()
Definition: hidboot.h:183
MODIFIERKEYS::bmRightCtrl
uint8_t bmRightCtrl
Definition: hidboot.h:90
L
@ L
Definition: controllerEnums.h:179
HIDBoot::isReady
virtual bool isReady()
Definition: hidboot.h:238
USB_ERROR_EPINFO_IS_NULL
#define USB_ERROR_EPINFO_IS_NULL
Definition: UsbCore.h:96
UsbDevice
Definition: address.h:82
KBDLEDS::bmNumLock
uint8_t bmNumLock
Definition: hidboot.h:113
HIDBoot::Release
uint8_t Release()
Definition: hidboot.h:564
KBDLEDS::bmReserved
uint8_t bmReserved
Definition: hidboot.h:118
MouseReportParser::Parse
void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
Definition: hidboot.cpp:19
SinkParser
Definition: sink_parser.h:35
HIDBoot
Definition: hidboot.h:201
KeyboardReportParser::kbdLeds
KBDLEDS kbdLeds
Definition: hidboot.h:135
USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL
#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL
Definition: UsbCore.h:95
ConfigDescParser
Definition: confdescparser.h:47
KBDLEDS::bmScrollLock
uint8_t bmScrollLock
Definition: hidboot.h:115
MouseReportParser::OnLeftButtonUp
virtual void OnLeftButtonUp(MOUSEINFO *mi)
Definition: hidboot.h:66
KBDINFO::bmLeftAlt
uint8_t bmLeftAlt
Definition: hidboot.h:101
USBTRACE
#define USBTRACE(s)
Definition: macros.h:82
MODIFIERKEYS::bmRightShift
uint8_t bmRightShift
Definition: hidboot.h:91
HIDBoot::DEVSUBCLASSOK
virtual bool DEVSUBCLASSOK(uint8_t subklass)
Definition: hidboot.h:250
USBTRACE2
#define USBTRACE2(s, r)
Definition: macros.h:84
MOUSEINFO::bmDummy
uint8_t bmDummy
Definition: hidboot.h:45
USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
Definition: UsbCore.h:93
NotifyFailSetConfDescr
#define NotifyFailSetConfDescr(...)
Definition: message.h:60
KBDINFO::Keys
uint8_t Keys[6]
Definition: hidboot.h:109
KBDINFO::bmLeftGUI
uint8_t bmLeftGUI
Definition: hidboot.h:102
AddressPool::FreeAddress
virtual void FreeAddress(uint8_t addr)=0
USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED
#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED
Definition: UsbCore.h:90
KeyboardReportParser::prevState
union KeyboardReportParser::@17 prevState
KeyboardReportParser::kbdInfo
KBDINFO kbdInfo
Definition: hidboot.h:130
USBHID
Definition: usbhid.h:143
KeyboardReportParser::OnControlKeysChanged
virtual void OnControlKeysChanged(uint8_t before, uint8_t after)
Definition: hidboot.h:174
KBDINFO::bmRightCtrl
uint8_t bmRightCtrl
Definition: hidboot.h:103
USB_ENDPOINT_DESCRIPTOR::bmAttributes
uint8_t bmAttributes
Definition: usb_ch9.h:152
KeyboardReportParser::getPadKeys
virtual const uint8_t * getPadKeys()
Definition: hidboot.h:195
MODIFIERKEYS::bmRightAlt
uint8_t bmRightAlt
Definition: hidboot.h:92
KeyboardReportParser::bLeds
uint8_t bLeds
Definition: hidboot.h:136
KeyboardReportParser::OnKeyDown
virtual void OnKeyDown(uint8_t mod, uint8_t key)
Definition: hidboot.h:177
KeyboardReportParser::getSymKeysLo
virtual const uint8_t * getSymKeysLo()
Definition: hidboot.h:191
MOUSEINFO::bmMiddleButton
uint8_t bmMiddleButton
Definition: hidboot.h:44
MODIFIERKEYS::bmLeftAlt
uint8_t bmLeftAlt
Definition: hidboot.h:88
USB_ENDPOINT_DESCRIPTOR::wMaxPacketSize
uint16_t wMaxPacketSize
Definition: usb_ch9.h:153
UsbDevice::epinfo
EpInfo * epinfo
Definition: address.h:83
MouseReportParser::OnMouseMove
virtual void OnMouseMove(MOUSEINFO *mi)
Definition: hidboot.h:63
KeyboardReportParser
Definition: hidboot.h:121
KBDINFO::bmRightAlt
uint8_t bmRightAlt
Definition: hidboot.h:105