17 #if !defined(__HIDBOOT_H__) 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 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)) 59 void Parse(
USBHID *hid,
bool is_rpt_id, uint8_t len, uint8_t *buf);
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;
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;
113 uint8_t bmNumLock : 1;
114 uint8_t bmCapsLock : 1;
115 uint8_t bmScrollLock : 1;
116 uint8_t bmCompose : 1;
118 uint8_t bmReserved : 3;
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];
139 uint8_t OemToAscii(uint8_t mod, uint8_t key);
144 kbdLockingKeys.bLeds = 0;
147 void Parse(
USBHID *hid,
bool is_rpt_id, uint8_t len, uint8_t *buf);
152 uint8_t old_keys = kbdLockingKeys.bLeds;
156 kbdLockingKeys.kbdLeds.bmNumLock = ~kbdLockingKeys.kbdLeds.bmNumLock;
159 kbdLockingKeys.kbdLeds.bmCapsLock = ~kbdLockingKeys.kbdLeds.bmCapsLock;
162 kbdLockingKeys.kbdLeds.bmScrollLock = ~kbdLockingKeys.kbdLeds.bmScrollLock;
166 if(old_keys != kbdLockingKeys.bLeds && hid) {
167 uint8_t lockLeds = kbdLockingKeys.bLeds;
168 return (hid->
SetReport(0, 0, 2, 0, 1, &lockLeds));
180 virtual void OnKeyUp(uint8_t mod, uint8_t key) {
200 template <const u
int8_t BOOT_PROTOCOL>
210 uint32_t qNextPollTime;
213 bool bRptProtoEnable;
218 return pRptParser[id];
222 HIDBoot(
USB *p,
bool bRptProtoEnable =
false);
225 pRptParser[id] = prs;
230 uint8_t Init(uint8_t parent, uint8_t port,
bool lowspeed);
244 virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto,
const USB_ENDPOINT_DESCRIPTOR *ep);
251 return (subklass == BOOT_PROTOCOL);
255 template <const u
int8_t BOOT_PROTOCOL>
260 bRptProtoEnable(bRptProtoEnable) {
263 for(
int i = 0; i <
epMUL(BOOT_PROTOCOL); i++) {
264 pRptParser[i] = NULL;
270 template <const u
int8_t BOOT_PROTOCOL>
284 template <const u
int8_t BOOT_PROTOCOL>
288 uint8_t buf[constBufSize];
331 len = (buf[0] > constBufSize) ? constBufSize : buf[0];
337 goto FailGetDevDescr;
379 goto FailGetDevDescr;
387 USBTRACE(
"HID_PROTOCOL_KEYBOARD AND MOUSE\r\n");
393 confDescrParser.SetOR();
394 for(uint8_t i = 0; i < num_of_conf; i++) {
402 USBTRACE(
"HID_PROTOCOL_KEYBOARD\r\n");
403 for(uint8_t i = 0; i < num_of_conf; i++) {
419 for(uint8_t i = 0; i < num_of_conf; i++) {
451 goto FailSetConfDescr;
459 for(uint8_t i = 0; i <
epMUL(BOOT_PROTOCOL); i++) {
462 if(rcode)
goto FailSetProtocol;
463 USBTRACE2(
"PROTOCOL SET HID_BOOT rcode:", rcode);
492 #ifdef DEBUG_USB_HOST 510 #ifdef DEBUG_USB_HOST 516 #ifdef DEBUG_USB_HOST 527 #ifdef DEBUG_USB_HOST 535 template <const u
int8_t BOOT_PROTOCOL>
560 template <const u
int8_t BOOT_PROTOCOL>
574 template <const u
int8_t BOOT_PROTOCOL>
578 if(bPollEnable && ((
long)(millis() - qNextPollTime) >= 0
L)) {
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];
593 if(!rcode && read > 2) {
595 pRptParser[i]->
Parse((
USBHID*)
this, 0, (uint8_t)read, buf);
596 #ifdef DEBUG_USB_HOST 600 USBTRACE3(
"(hidboot.h) Poll:", rcode, 0x81);
603 USBTRACE3(
"(hidboot.h) Strange read count: ", read, 0x80);
604 USBTRACE3(
"(hidboot.h) Interface:", i, 0x80);
609 for(uint8_t i = 0; i < read; i++) {
610 PrintHex<uint8_t > (buf[i], 0x80);
619 qNextPollTime = millis() + bInterval;
624 #endif // __HIDBOOTMOUSE_H__ uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr)
#define CP_MASK_COMPARE_ALL
#define HID_BOOT_INTF_SUBCLASS
#define USB_ERROR_EPINFO_IS_NULL
virtual const uint8_t * getSymKeysLo()
virtual void OnRightButtonDown(MOUSEINFO *mi)
virtual void OnKeyDown(uint8_t mod, uint8_t key)
uint8_t GetReportDescr(uint16_t wIndex, USBReadParser *parser=NULL)
virtual void OnMiddleButtonUp(MOUSEINFO *mi)
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
virtual bool DEVCLASSOK(uint8_t klass)
#define UHS_HID_BOOT_KEY_SCROLL_LOCK
#define NotifyFailGetDevDescr(...)
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
virtual bool SetReportParser(uint8_t id, HIDReportParser *prs)
virtual void OnKeyUp(uint8_t mod, uint8_t key)
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)
virtual const uint8_t * getSymKeysUp()
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
virtual void OnLeftButtonUp(MOUSEINFO *mi)
virtual uint8_t GetAddress()
#define USB_NAK_MAX_POWER
HIDBoot(USB *p, bool bRptProtoEnable=false)
virtual uint8_t HandleLockingKeys(USBHID *hid, uint8_t key)
virtual void OnMouseMove(MOUSEINFO *mi)
virtual void OnRightButtonUp(MOUSEINFO *mi)
virtual void OnMiddleButtonDown(MOUSEINFO *mi)
static const uint8_t epInterruptInIndex
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub=false, uint8_t port=0)=0
#define UHS_HID_BOOT_KEY_NUM_LOCK
#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE
#define USB_HID_PROTOCOL_KEYBOARD
#define totalEndpoints(p)
uint8_t SetProtocol(uint8_t iface, uint8_t protocol)
#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL
#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED
virtual void OnControlKeysChanged(uint8_t before, uint8_t after)
static const uint8_t totalEndpoints
virtual void OnLeftButtonDown(MOUSEINFO *mi)
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval=0)
uint8_t SetReport(uint8_t ep, uint8_t iface, uint8_t report_type, uint8_t report_id, uint16_t nbytes, uint8_t *dataptr)
virtual const uint8_t * getNumKeys()
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
#define USB_HID_BOOT_PROTOCOL
virtual const uint8_t * getPadKeys()
AddressPool & GetAddressPool()
virtual bool DEVSUBCLASSOK(uint8_t subklass)
#define USB_HID_PROTOCOL_MOUSE
#define USBTRACE3(s, r, l)
uint8_t RegisterDeviceClass(USBDeviceConfig *pdev)
#define NotifyFailSetConfDescr(...)
virtual void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)=0
#define UHS_HID_BOOT_KEY_CAPS_LOCK
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)