diff options
Diffstat (limited to 'tmk_core')
-rw-r--r-- | tmk_core/protocol/arm_atsam/md_rgb_matrix.c | 2 | ||||
-rw-r--r-- | tmk_core/protocol/chibios/usb_main.c | 136 | ||||
-rw-r--r-- | tmk_core/protocol/host.c | 5 | ||||
-rw-r--r-- | tmk_core/protocol/report.h | 18 | ||||
-rw-r--r-- | tmk_core/protocol/usb_descriptor.c | 15 | ||||
-rw-r--r-- | tmk_core/protocol/usb_descriptor.h | 15 | ||||
-rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 16 |
7 files changed, 126 insertions, 81 deletions
diff --git a/tmk_core/protocol/arm_atsam/md_rgb_matrix.c b/tmk_core/protocol/arm_atsam/md_rgb_matrix.c index 3ed83a44a6..52fe86d297 100644 --- a/tmk_core/protocol/arm_atsam/md_rgb_matrix.c +++ b/tmk_core/protocol/arm_atsam/md_rgb_matrix.c @@ -450,7 +450,7 @@ static void md_rgb_matrix_config_override(int i) { float bo = 0; float po; - uint8_t highest_active_layer = biton32(layer_state); + uint8_t highest_active_layer = get_highest_layer(layer_state); if (led_animation_circular) { // TODO: should use min/max values from LED configuration instead of diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 19e2e858fc..eb9ef82554 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -32,6 +32,7 @@ #include "usb_main.h" #include "host.h" +#include "chibios_config.h" #include "debug.h" #include "suspend.h" #ifdef SLEEP_LED_ENABLE @@ -91,6 +92,13 @@ uint8_t extra_report_blank[3] = {0}; * --------------------------------------------------------- */ +/* USB Low Level driver specific endpoint fields */ +#if !defined(usb_lld_endpoint_fields) +# define usb_lld_endpoint_fields \ + 2, /* IN multiplier */ \ + NULL, /* SETUP buffer (not a SETUP endpoint) */ +#endif + /* HID specific constants */ #define HID_GET_REPORT 0x01 #define HID_GET_IDLE 0x02 @@ -121,16 +129,15 @@ static const USBDescriptor *usb_get_descriptor_cb(USBDriver *usbp, uint8_t dtype static USBInEndpointState kbd_ep_state; /* keyboard endpoint initialization structure (IN) - see USBEndpointConfig comment at top of file */ static const USBEndpointConfig kbd_ep_config = { - USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ - NULL, /* SETUP packet notification callback */ - kbd_in_cb, /* IN notification callback */ - NULL, /* OUT notification callback */ - KEYBOARD_EPSIZE, /* IN maximum packet size */ - 0, /* OUT maximum packet size */ - &kbd_ep_state, /* IN Endpoint state */ - NULL, /* OUT endpoint state */ - 2, /* IN multiplier */ - NULL /* SETUP buffer (not a SETUP endpoint) */ + USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ + NULL, /* SETUP packet notification callback */ + kbd_in_cb, /* IN notification callback */ + NULL, /* OUT notification callback */ + KEYBOARD_EPSIZE, /* IN maximum packet size */ + 0, /* OUT maximum packet size */ + &kbd_ep_state, /* IN Endpoint state */ + NULL, /* OUT endpoint state */ + usb_lld_endpoint_fields /* USB driver specific endpoint fields */ }; #endif @@ -140,16 +147,15 @@ static USBInEndpointState mouse_ep_state; /* mouse endpoint initialization structure (IN) - see USBEndpointConfig comment at top of file */ static const USBEndpointConfig mouse_ep_config = { - USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ - NULL, /* SETUP packet notification callback */ - mouse_in_cb, /* IN notification callback */ - NULL, /* OUT notification callback */ - MOUSE_EPSIZE, /* IN maximum packet size */ - 0, /* OUT maximum packet size */ - &mouse_ep_state, /* IN Endpoint state */ - NULL, /* OUT endpoint state */ - 2, /* IN multiplier */ - NULL /* SETUP buffer (not a SETUP endpoint) */ + USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ + NULL, /* SETUP packet notification callback */ + mouse_in_cb, /* IN notification callback */ + NULL, /* OUT notification callback */ + MOUSE_EPSIZE, /* IN maximum packet size */ + 0, /* OUT maximum packet size */ + &mouse_ep_state, /* IN Endpoint state */ + NULL, /* OUT endpoint state */ + usb_lld_endpoint_fields /* USB driver specific endpoint fields */ }; #endif @@ -159,20 +165,19 @@ static USBInEndpointState shared_ep_state; /* shared endpoint initialization structure (IN) - see USBEndpointConfig comment at top of file */ static const USBEndpointConfig shared_ep_config = { - USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ - NULL, /* SETUP packet notification callback */ - shared_in_cb, /* IN notification callback */ - NULL, /* OUT notification callback */ - SHARED_EPSIZE, /* IN maximum packet size */ - 0, /* OUT maximum packet size */ - &shared_ep_state, /* IN Endpoint state */ - NULL, /* OUT endpoint state */ - 2, /* IN multiplier */ - NULL /* SETUP buffer (not a SETUP endpoint) */ + USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ + NULL, /* SETUP packet notification callback */ + shared_in_cb, /* IN notification callback */ + NULL, /* OUT notification callback */ + SHARED_EPSIZE, /* IN maximum packet size */ + 0, /* OUT maximum packet size */ + &shared_ep_state, /* IN Endpoint state */ + NULL, /* OUT endpoint state */ + usb_lld_endpoint_fields /* USB driver specific endpoint fields */ }; #endif -#if STM32_USB_USE_OTG1 +#ifdef USB_ENDPOINTS_ARE_REORDERABLE typedef struct { size_t queue_capacity_in; size_t queue_capacity_out; @@ -199,23 +204,22 @@ typedef struct { } usb_driver_config_t; #endif -#if STM32_USB_USE_OTG1 +#ifdef USB_ENDPOINTS_ARE_REORDERABLE /* Reusable initialization structure - see USBEndpointConfig comment at top of file */ # define QMK_USB_DRIVER_CONFIG(stream, notification, fixedsize) \ { \ .queue_capacity_in = stream##_IN_CAPACITY, .queue_capacity_out = stream##_OUT_CAPACITY, \ .inout_ep_config = \ { \ - stream##_IN_MODE, /* Interrupt EP */ \ - NULL, /* SETUP packet notification callback */ \ - qmkusbDataTransmitted, /* IN notification callback */ \ - qmkusbDataReceived, /* OUT notification callback */ \ - stream##_EPSIZE, /* IN maximum packet size */ \ - stream##_EPSIZE, /* OUT maximum packet size */ \ - NULL, /* IN Endpoint state */ \ - NULL, /* OUT endpoint state */ \ - 2, /* IN multiplier */ \ - NULL /* SETUP buffer (not a SETUP endpoint) */ \ + stream##_IN_MODE, /* Interrupt EP */ \ + NULL, /* SETUP packet notification callback */ \ + qmkusbDataTransmitted, /* IN notification callback */ \ + qmkusbDataReceived, /* OUT notification callback */ \ + stream##_EPSIZE, /* IN maximum packet size */ \ + stream##_EPSIZE, /* OUT maximum packet size */ \ + NULL, /* IN Endpoint state */ \ + NULL, /* OUT endpoint state */ \ + usb_lld_endpoint_fields /* USB driver specific endpoint fields */ \ }, \ .int_ep_config = \ { \ @@ -227,8 +231,7 @@ typedef struct { 0, /* OUT maximum packet size */ \ NULL, /* IN Endpoint state */ \ NULL, /* OUT endpoint state */ \ - 2, /* IN multiplier */ \ - NULL, /* SETUP buffer (not a SETUP endpoint) */ \ + usb_lld_endpoint_fields /* USB driver specific endpoint fields */ \ }, \ .config = { \ .usbp = &USB_DRIVER, \ @@ -251,29 +254,27 @@ typedef struct { .queue_capacity_in = stream##_IN_CAPACITY, .queue_capacity_out = stream##_OUT_CAPACITY, \ .in_ep_config = \ { \ - stream##_IN_MODE, /* Interrupt EP */ \ - NULL, /* SETUP packet notification callback */ \ - qmkusbDataTransmitted, /* IN notification callback */ \ - NULL, /* OUT notification callback */ \ - stream##_EPSIZE, /* IN maximum packet size */ \ - 0, /* OUT maximum packet size */ \ - NULL, /* IN Endpoint state */ \ - NULL, /* OUT endpoint state */ \ - 2, /* IN multiplier */ \ - NULL /* SETUP buffer (not a SETUP endpoint) */ \ + stream##_IN_MODE, /* Interrupt EP */ \ + NULL, /* SETUP packet notification callback */ \ + qmkusbDataTransmitted, /* IN notification callback */ \ + NULL, /* OUT notification callback */ \ + stream##_EPSIZE, /* IN maximum packet size */ \ + 0, /* OUT maximum packet size */ \ + NULL, /* IN Endpoint state */ \ + NULL, /* OUT endpoint state */ \ + usb_lld_endpoint_fields /* USB driver specific endpoint fields */ \ }, \ .out_ep_config = \ { \ - stream##_OUT_MODE, /* Interrupt EP */ \ - NULL, /* SETUP packet notification callback */ \ - NULL, /* IN notification callback */ \ - qmkusbDataReceived, /* OUT notification callback */ \ - 0, /* IN maximum packet size */ \ - stream##_EPSIZE, /* OUT maximum packet size */ \ - NULL, /* IN Endpoint state */ \ - NULL, /* OUT endpoint state */ \ - 2, /* IN multiplier */ \ - NULL, /* SETUP buffer (not a SETUP endpoint) */ \ + stream##_OUT_MODE, /* Interrupt EP */ \ + NULL, /* SETUP packet notification callback */ \ + NULL, /* IN notification callback */ \ + qmkusbDataReceived, /* OUT notification callback */ \ + 0, /* IN maximum packet size */ \ + stream##_EPSIZE, /* OUT maximum packet size */ \ + NULL, /* IN Endpoint state */ \ + NULL, /* OUT endpoint state */ \ + usb_lld_endpoint_fields /* USB driver specific endpoint fields */ \ }, \ .int_ep_config = \ { \ @@ -285,8 +286,7 @@ typedef struct { 0, /* OUT maximum packet size */ \ NULL, /* IN Endpoint state */ \ NULL, /* OUT endpoint state */ \ - 2, /* IN multiplier */ \ - NULL, /* SETUP buffer (not a SETUP endpoint) */ \ + usb_lld_endpoint_fields /* USB driver specific endpoint fields */ \ }, \ .config = { \ .usbp = &USB_DRIVER, \ @@ -488,7 +488,7 @@ static void usb_event_cb(USBDriver *usbp, usbevent_t event) { usbInitEndpointI(usbp, SHARED_IN_EPNUM, &shared_ep_config); #endif for (int i = 0; i < NUM_USB_DRIVERS; i++) { -#if STM32_USB_USE_OTG1 +#ifdef USB_ENDPOINTS_ARE_REORDERABLE usbInitEndpointI(usbp, drivers.array[i].config.bulk_in, &drivers.array[i].inout_ep_config); #else usbInitEndpointI(usbp, drivers.array[i].config.bulk_in, &drivers.array[i].in_ep_config); @@ -715,7 +715,7 @@ static const USBConfig usbcfg = { */ void init_usb_driver(USBDriver *usbp) { for (int i = 0; i < NUM_USB_DRIVERS; i++) { -#if STM32_USB_USE_OTG1 +#ifdef USB_ENDPOINTS_ARE_REORDERABLE QMKUSBDriver *driver = &drivers.array[i].driver; drivers.array[i].inout_ep_config.in_state = &drivers.array[i].in_ep_state; drivers.array[i].inout_ep_config.out_state = &drivers.array[i].out_ep_state; diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index 053d2b79e3..3d8604d541 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -94,6 +94,11 @@ void host_mouse_send(report_mouse_t *report) { #ifdef MOUSE_SHARED_EP report->report_id = REPORT_ID_MOUSE; #endif +#ifdef MOUSE_EXTENDED_REPORT + // clip and copy to Boot protocol XY + report->boot_x = (report->x > 127) ? 127 : ((report->x < -127) ? -127 : report->x); + report->boot_y = (report->y > 127) ? 127 : ((report->y < -127) ? -127 : report->y); +#endif (*driver->send_mouse)(report); } diff --git a/tmk_core/protocol/report.h b/tmk_core/protocol/report.h index 7bbeb78af7..735ccdb4a1 100644 --- a/tmk_core/protocol/report.h +++ b/tmk_core/protocol/report.h @@ -201,15 +201,25 @@ typedef struct { uint32_t usage; } __attribute__((packed)) report_programmable_button_t; +#ifdef MOUSE_EXTENDED_REPORT +typedef int16_t mouse_xy_report_t; +#else +typedef int8_t mouse_xy_report_t; +#endif + typedef struct { #ifdef MOUSE_SHARED_EP uint8_t report_id; #endif uint8_t buttons; - int8_t x; - int8_t y; - int8_t v; - int8_t h; +#ifdef MOUSE_EXTENDED_REPORT + int8_t boot_x; + int8_t boot_y; +#endif + mouse_xy_report_t x; + mouse_xy_report_t y; + int8_t v; + int8_t h; } __attribute__((packed)) report_mouse_t; typedef struct { diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index 063bd2c3f1..52e3276d35 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c @@ -126,14 +126,27 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = { HID_RI_REPORT_SIZE(8, 0x01), HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), - // X/Y position (2 bytes) +# ifdef MOUSE_EXTENDED_REPORT + // Boot protocol XY ignored in Report protocol + HID_RI_REPORT_COUNT(8, 0x02), + HID_RI_REPORT_SIZE(8, 0x08), + HID_RI_INPUT(8, HID_IOF_CONSTANT), +# endif + // X/Y position (2 or 4 bytes) HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop HID_RI_USAGE(8, 0x30), // X HID_RI_USAGE(8, 0x31), // Y +# ifndef MOUSE_EXTENDED_REPORT HID_RI_LOGICAL_MINIMUM(8, -127), HID_RI_LOGICAL_MAXIMUM(8, 127), HID_RI_REPORT_COUNT(8, 0x02), HID_RI_REPORT_SIZE(8, 0x08), +# else + HID_RI_LOGICAL_MINIMUM(16, -32767), + HID_RI_LOGICAL_MAXIMUM(16, 32767), + HID_RI_REPORT_COUNT(8, 0x02), + HID_RI_REPORT_SIZE(8, 0x10), +# endif HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), // Vertical wheel (1 byte) diff --git a/tmk_core/protocol/usb_descriptor.h b/tmk_core/protocol/usb_descriptor.h index 6c3424145c..f8b7a863aa 100644 --- a/tmk_core/protocol/usb_descriptor.h +++ b/tmk_core/protocol/usb_descriptor.h @@ -47,6 +47,9 @@ #ifdef PROTOCOL_CHIBIOS # include <hal.h> +# if STM32_USB_USE_OTG1 == TRUE +# define USB_ENDPOINTS_ARE_REORDERABLE +# endif #endif /* @@ -216,7 +219,7 @@ enum usb_endpoints { #ifdef RAW_ENABLE RAW_IN_EPNUM = NEXT_EPNUM, -# if STM32_USB_USE_OTG1 +# ifdef USB_ENDPOINTS_ARE_REORDERABLE # define RAW_OUT_EPNUM RAW_IN_EPNUM # else RAW_OUT_EPNUM = NEXT_EPNUM, @@ -234,7 +237,7 @@ enum usb_endpoints { // ChibiOS has enough memory and descriptor to actually enable the endpoint // It could use the same endpoint numbers, as that's supported by ChibiOS // But the QMK code currently assumes that the endpoint numbers are different -# if STM32_USB_USE_OTG1 +# ifdef USB_ENDPOINTS_ARE_REORDERABLE # define CONSOLE_OUT_EPNUM CONSOLE_IN_EPNUM # else CONSOLE_OUT_EPNUM = NEXT_EPNUM, @@ -246,7 +249,7 @@ enum usb_endpoints { #ifdef MIDI_ENABLE MIDI_STREAM_IN_EPNUM = NEXT_EPNUM, -# if STM32_USB_USE_OTG1 +# ifdef USB_ENDPOINTS_ARE_REORDERABLE # define MIDI_STREAM_OUT_EPNUM MIDI_STREAM_IN_EPNUM # else MIDI_STREAM_OUT_EPNUM = NEXT_EPNUM, @@ -256,7 +259,7 @@ enum usb_endpoints { #ifdef VIRTSER_ENABLE CDC_NOTIFICATION_EPNUM = NEXT_EPNUM, CDC_IN_EPNUM = NEXT_EPNUM, -# if STM32_USB_USE_OTG1 +# ifdef USB_ENDPOINTS_ARE_REORDERABLE # define CDC_OUT_EPNUM CDC_IN_EPNUM # else CDC_OUT_EPNUM = NEXT_EPNUM, @@ -264,7 +267,7 @@ enum usb_endpoints { #endif #ifdef JOYSTICK_ENABLE JOYSTICK_IN_EPNUM = NEXT_EPNUM, -# if STM32_USB_USE_OTG1 +# ifdef USB_ENDPOINTS_ARE_REORDERABLE JOYSTICK_OUT_EPNUM = JOYSTICK_IN_EPNUM, # else JOYSTICK_OUT_EPNUM = NEXT_EPNUM, @@ -274,7 +277,7 @@ enum usb_endpoints { #ifdef DIGITIZER_ENABLE # if !defined(DIGITIZER_SHARED_EP) DIGITIZER_IN_EPNUM = NEXT_EPNUM, -# if STM32_USB_USE_OTG1 +# ifdef USB_ENDPOINTS_ARE_REORDERABLE DIGITIZER_OUT_EPNUM = DIGITIZER_IN_EPNUM, # else DIGITIZER_OUT_EPNUM = NEXT_EPNUM, diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index ebde955d3b..d07cc0d27e 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c @@ -482,14 +482,28 @@ const PROGMEM uchar shared_hid_report[] = { 0x75, 0x01, // Report Size (1) 0x81, 0x02, // Input (Data, Variable, Absolute) - // X/Y position (2 bytes) +# ifdef MOUSE_EXTENDED_REPORT + // Boot protocol XY ignored in Report protocol + 0x95, 0x02, // Report Count (2) + 0x75, 0x08, // Report Size (8) + 0x81, 0x03, // Input (Constant) +# endif + + // X/Y position (2 or 4 bytes) 0x05, 0x01, // Usage Page (Generic Desktop) 0x09, 0x30, // Usage (X) 0x09, 0x31, // Usage (Y) +# ifndef MOUSE_EXTENDED_REPORT 0x15, 0x81, // Logical Minimum (-127) 0x25, 0x7F, // Logical Maximum (127) 0x95, 0x02, // Report Count (2) 0x75, 0x08, // Report Size (8) +# else + 0x16, 0x01, 0x80, // Logical Minimum (-32767) + 0x26, 0xFF, 0x7F, // Logical Maximum (32767) + 0x95, 0x02, // Report Count (2) + 0x75, 0x10, // Report Size (16) +# endif 0x81, 0x06, // Input (Data, Variable, Relative) // Vertical wheel (1 byte) |