mirror of
				https://github.com/mfulz/qmk_firmware.git
				synced 2025-11-04 07:12:33 +01:00 
			
		
		
		
	V-USB: Implement GET_PROTOCOL and SET_PROTOCOL handling (#22324)
				
					
				
			This commit is contained in:
		
							parent
							
								
									7e0147f8e6
								
							
						
					
					
						commit
						b7e62af755
					
				@ -325,20 +325,23 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) {
 | 
				
			|||||||
    usbRequest_t *rq = (void *)data;
 | 
					    usbRequest_t *rq = (void *)data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS) { /* class request type */
 | 
					    if ((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS) { /* class request type */
 | 
				
			||||||
        if (rq->bRequest == USBRQ_HID_GET_REPORT) {
 | 
					        switch (rq->bRequest) {
 | 
				
			||||||
 | 
					            case USBRQ_HID_GET_REPORT:
 | 
				
			||||||
                dprint("GET_REPORT:");
 | 
					                dprint("GET_REPORT:");
 | 
				
			||||||
                if (rq->wIndex.word == KEYBOARD_INTERFACE) {
 | 
					                if (rq->wIndex.word == KEYBOARD_INTERFACE) {
 | 
				
			||||||
                    usbMsgPtr = (usbMsgPtr_t)&keyboard_report_sent;
 | 
					                    usbMsgPtr = (usbMsgPtr_t)&keyboard_report_sent;
 | 
				
			||||||
                    return sizeof(keyboard_report_sent);
 | 
					                    return sizeof(keyboard_report_sent);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
        } else if (rq->bRequest == USBRQ_HID_GET_IDLE) {
 | 
					                break;
 | 
				
			||||||
 | 
					            case USBRQ_HID_GET_IDLE:
 | 
				
			||||||
                dprint("GET_IDLE:");
 | 
					                dprint("GET_IDLE:");
 | 
				
			||||||
                usbMsgPtr = (usbMsgPtr_t)&vusb_idle_rate;
 | 
					                usbMsgPtr = (usbMsgPtr_t)&vusb_idle_rate;
 | 
				
			||||||
                return 1;
 | 
					                return 1;
 | 
				
			||||||
        } else if (rq->bRequest == USBRQ_HID_SET_IDLE) {
 | 
					            case USBRQ_HID_GET_PROTOCOL:
 | 
				
			||||||
            vusb_idle_rate = rq->wValue.bytes[1];
 | 
					                dprint("GET_PROTOCOL:");
 | 
				
			||||||
            dprintf("SET_IDLE: %02X", vusb_idle_rate);
 | 
					                usbMsgPtr = (usbMsgPtr_t)&keyboard_protocol;
 | 
				
			||||||
        } else if (rq->bRequest == USBRQ_HID_SET_REPORT) {
 | 
					                return 1;
 | 
				
			||||||
 | 
					            case USBRQ_HID_SET_REPORT:
 | 
				
			||||||
                dprint("SET_REPORT:");
 | 
					                dprint("SET_REPORT:");
 | 
				
			||||||
                // Report Type: 0x02(Out)/ReportID: 0x00(none) && Interface: 0(keyboard)
 | 
					                // Report Type: 0x02(Out)/ReportID: 0x00(none) && Interface: 0(keyboard)
 | 
				
			||||||
                if (rq->wValue.word == 0x0200 && rq->wIndex.word == KEYBOARD_INTERFACE) {
 | 
					                if (rq->wValue.word == 0x0200 && rq->wIndex.word == KEYBOARD_INTERFACE) {
 | 
				
			||||||
@ -347,8 +350,19 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) {
 | 
				
			|||||||
                    last_req.len  = rq->wLength.word;
 | 
					                    last_req.len  = rq->wLength.word;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                return USB_NO_MSG; // to get data in usbFunctionWrite
 | 
					                return USB_NO_MSG; // to get data in usbFunctionWrite
 | 
				
			||||||
        } else {
 | 
					            case USBRQ_HID_SET_IDLE:
 | 
				
			||||||
 | 
					                vusb_idle_rate = rq->wValue.bytes[1];
 | 
				
			||||||
 | 
					                dprintf("SET_IDLE: %02X", vusb_idle_rate);
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case USBRQ_HID_SET_PROTOCOL:
 | 
				
			||||||
 | 
					                if (rq->wIndex.word == KEYBOARD_INTERFACE) {
 | 
				
			||||||
 | 
					                    keyboard_protocol = rq->wValue.word & 0xFF;
 | 
				
			||||||
 | 
					                    dprintf("SET_PROTOCOL: %02X", keyboard_protocol);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            default:
 | 
				
			||||||
                dprint("UNKNOWN:");
 | 
					                dprint("UNKNOWN:");
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        dprint("VENDOR:");
 | 
					        dprint("VENDOR:");
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user