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);
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));
174 virtual void OnControlKeysChanged(uint8_t before __attribute__((unused)), uint8_t after __attribute__((unused))) {
177 virtual void OnKeyDown(uint8_t mod __attribute__((unused)), uint8_t key __attribute__((unused))) {
180 virtual void OnKeyUp(uint8_t mod __attribute__((unused)), uint8_t key __attribute__((unused))) {
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];
332 len = (buf[0] > constBufSize) ? constBufSize : buf[0];
340 goto FailGetDevDescr;
382 goto FailGetDevDescr;
390 USBTRACE(
"HID_PROTOCOL_KEYBOARD AND MOUSE\r\n");
396 confDescrParser.SetOR();
397 for(uint8_t i = 0; i < num_of_conf; i++) {
405 USBTRACE(
"HID_PROTOCOL_KEYBOARD\r\n");
406 for(uint8_t i = 0; i < num_of_conf; i++) {
422 for(uint8_t i = 0; i < num_of_conf; i++) {
454 goto FailSetConfDescr;
462 for(uint8_t i = 0; i <
epMUL(BOOT_PROTOCOL); i++) {
465 if(rcode)
goto FailSetProtocol;
466 USBTRACE2(
"PROTOCOL SET HID_BOOT rcode:", rcode);
495 #ifdef DEBUG_USB_HOST 513 #ifdef DEBUG_USB_HOST 519 #ifdef DEBUG_USB_HOST 530 #ifdef DEBUG_USB_HOST 538 template <const u
int8_t BOOT_PROTOCOL>
563 template <const u
int8_t BOOT_PROTOCOL>
577 template <const u
int8_t BOOT_PROTOCOL>
581 if(bPollEnable && ((int32_t)((uint32_t)millis() - qNextPollTime) >= 0
L)) {
584 for(
int i = 0; i <
epMUL(BOOT_PROTOCOL); i++) {
585 const uint16_t const_buff_len = 16;
586 uint8_t buf[const_buff_len];
596 if(!rcode && read > 2) {
598 pRptParser[i]->
Parse((
USBHID*)
this, 0, (uint8_t)read, buf);
599 #ifdef DEBUG_USB_HOST 603 USBTRACE3(
"(hidboot.h) Poll:", rcode, 0x81);
606 USBTRACE3(
"(hidboot.h) Strange read count: ", read, 0x80);
607 USBTRACE3(
"(hidboot.h) Interface:", i, 0x80);
612 for(uint8_t i = 0; i < read; i++) {
613 PrintHex<uint8_t > (buf[i], 0x80);
622 qNextPollTime = (uint32_t)millis() + bInterval;
627 #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 USB_TRANSFER_TYPE_INTERRUPT
#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)
#define bmUSB_TRANSFER_TYPE
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()
uint8_t bNumConfigurations
#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)