V-USB: Fix GET_IDLE/SET_IDLE
(#22332)
Co-authored-by: Sergey Vlasov <sigprof@gmail.com>
This commit is contained in:
parent
c5716f84ad
commit
db4e3bb232
@ -222,21 +222,16 @@ static void print_status(void) {
|
|||||||
"\n\t- Status -\n"
|
"\n\t- Status -\n"
|
||||||
|
|
||||||
"host_keyboard_leds(): %02X\n"
|
"host_keyboard_leds(): %02X\n"
|
||||||
#ifndef PROTOCOL_VUSB
|
|
||||||
"keyboard_protocol: %02X\n"
|
"keyboard_protocol: %02X\n"
|
||||||
"keyboard_idle: %02X\n"
|
"keyboard_idle: %02X\n"
|
||||||
#endif
|
|
||||||
#ifdef NKRO_ENABLE
|
#ifdef NKRO_ENABLE
|
||||||
"keymap_config.nkro: %02X\n"
|
"keymap_config.nkro: %02X\n"
|
||||||
#endif
|
#endif
|
||||||
"timer_read32(): %08lX\n"
|
"timer_read32(): %08lX\n"
|
||||||
|
|
||||||
, host_keyboard_leds()
|
, host_keyboard_leds()
|
||||||
#ifndef PROTOCOL_VUSB
|
|
||||||
/* these aren't set on the V-USB protocol, so we just ignore them for now */
|
|
||||||
, keyboard_protocol
|
, keyboard_protocol
|
||||||
, keyboard_idle
|
, keyboard_idle
|
||||||
#endif
|
|
||||||
#ifdef NKRO_ENABLE
|
#ifdef NKRO_ENABLE
|
||||||
, keymap_config.nkro
|
, keymap_config.nkro
|
||||||
#endif
|
#endif
|
||||||
|
@ -48,16 +48,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
# include "os_detection.h"
|
# include "os_detection.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NEXT_INTERFACE __COUNTER__
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Interface indexes
|
* Interface indexes
|
||||||
*/
|
*/
|
||||||
enum usb_interfaces {
|
enum usb_interfaces {
|
||||||
#ifndef KEYBOARD_SHARED_EP
|
#ifndef KEYBOARD_SHARED_EP
|
||||||
KEYBOARD_INTERFACE = NEXT_INTERFACE,
|
KEYBOARD_INTERFACE,
|
||||||
#else
|
#else
|
||||||
SHARED_INTERFACE = NEXT_INTERFACE,
|
SHARED_INTERFACE,
|
||||||
# define KEYBOARD_INTERFACE SHARED_INTERFACE
|
# define KEYBOARD_INTERFACE SHARED_INTERFACE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -65,32 +63,30 @@ enum usb_interfaces {
|
|||||||
// interface number, to support Linux/OSX platforms and chrome.hid
|
// interface number, to support Linux/OSX platforms and chrome.hid
|
||||||
// If Raw HID is enabled, let it be always 1.
|
// If Raw HID is enabled, let it be always 1.
|
||||||
#ifdef RAW_ENABLE
|
#ifdef RAW_ENABLE
|
||||||
RAW_INTERFACE = NEXT_INTERFACE,
|
RAW_INTERFACE,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SHARED_EP_ENABLE) && !defined(KEYBOARD_SHARED_EP)
|
#if defined(SHARED_EP_ENABLE) && !defined(KEYBOARD_SHARED_EP)
|
||||||
SHARED_INTERFACE = NEXT_INTERFACE,
|
SHARED_INTERFACE,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONSOLE_ENABLE
|
#ifdef CONSOLE_ENABLE
|
||||||
CONSOLE_INTERFACE = NEXT_INTERFACE,
|
CONSOLE_INTERFACE,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TOTAL_INTERFACES = NEXT_INTERFACE
|
TOTAL_INTERFACES
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_INTERFACES 3
|
#define MAX_INTERFACES 3
|
||||||
|
|
||||||
#if (NEXT_INTERFACE - 1) > MAX_INTERFACES
|
_Static_assert(TOTAL_INTERFACES <= MAX_INTERFACES, "There are not enough available interfaces to support all functions. Please disable one or more of the following: Mouse Keys, Extra Keys, Raw HID, Console.");
|
||||||
# error There are not enough available interfaces to support all functions. Please disable one or more of the following: Mouse Keys, Extra Keys, Raw HID, Console
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)) && CONSOLE_ENABLE
|
#if (defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)) && CONSOLE_ENABLE
|
||||||
# error Mouse/Extra Keys share an endpoint with Console. Please disable one of the two.
|
# error Mouse/Extra Keys share an endpoint with Console. Please disable one of the two.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint8_t keyboard_led_state = 0;
|
static uint8_t keyboard_led_state = 0;
|
||||||
static uint8_t vusb_idle_rate = 0;
|
uint8_t keyboard_idle = 0;
|
||||||
uint8_t keyboard_protocol = 1;
|
uint8_t keyboard_protocol = 1;
|
||||||
|
|
||||||
/* Keyboard report send buffer */
|
/* Keyboard report send buffer */
|
||||||
@ -335,7 +331,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) {
|
|||||||
break;
|
break;
|
||||||
case USBRQ_HID_GET_IDLE:
|
case USBRQ_HID_GET_IDLE:
|
||||||
dprint("GET_IDLE:");
|
dprint("GET_IDLE:");
|
||||||
usbMsgPtr = (usbMsgPtr_t)&vusb_idle_rate;
|
usbMsgPtr = (usbMsgPtr_t)&keyboard_idle;
|
||||||
return 1;
|
return 1;
|
||||||
case USBRQ_HID_GET_PROTOCOL:
|
case USBRQ_HID_GET_PROTOCOL:
|
||||||
dprint("GET_PROTOCOL:");
|
dprint("GET_PROTOCOL:");
|
||||||
@ -351,8 +347,8 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) {
|
|||||||
}
|
}
|
||||||
return USB_NO_MSG; // to get data in usbFunctionWrite
|
return USB_NO_MSG; // to get data in usbFunctionWrite
|
||||||
case USBRQ_HID_SET_IDLE:
|
case USBRQ_HID_SET_IDLE:
|
||||||
vusb_idle_rate = rq->wValue.bytes[1];
|
keyboard_idle = (rq->wValue.word & 0xFF00) >> 8;
|
||||||
dprintf("SET_IDLE: %02X", vusb_idle_rate);
|
dprintf("SET_IDLE: %02X", keyboard_idle);
|
||||||
break;
|
break;
|
||||||
case USBRQ_HID_SET_PROTOCOL:
|
case USBRQ_HID_SET_PROTOCOL:
|
||||||
if (rq->wIndex.word == KEYBOARD_INTERFACE) {
|
if (rq->wIndex.word == KEYBOARD_INTERFACE) {
|
||||||
@ -1044,7 +1040,7 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) {
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case USBDESCR_HID:
|
case USBDESCR_HID:
|
||||||
switch (rq->wValue.bytes[0]) {
|
switch (rq->wIndex.word) {
|
||||||
#ifndef KEYBOARD_SHARED_EP
|
#ifndef KEYBOARD_SHARED_EP
|
||||||
case KEYBOARD_INTERFACE:
|
case KEYBOARD_INTERFACE:
|
||||||
usbMsgPtr = (usbMsgPtr_t)&usbConfigurationDescriptor.keyboardHID;
|
usbMsgPtr = (usbMsgPtr_t)&usbConfigurationDescriptor.keyboardHID;
|
||||||
|
Loading…
Reference in New Issue
Block a user