diff options
Diffstat (limited to 'tmk_core')
-rw-r--r-- | tmk_core/protocol/chibios/usb_main.c | 14 | ||||
-rw-r--r-- | tmk_core/protocol/report.c | 13 | ||||
-rw-r--r-- | tmk_core/protocol/report.h | 4 | ||||
-rw-r--r-- | tmk_core/protocol/usb_descriptor.c | 43 |
4 files changed, 45 insertions, 29 deletions
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index d9aa351ecb..19e2e858fc 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -339,8 +339,12 @@ static usb_driver_configs_t drivers = { .console_driver = QMK_USB_DRIVER_CONFIG(CONSOLE, 0, true), #endif #ifdef RAW_ENABLE -# define RAW_IN_CAPACITY 4 -# define RAW_OUT_CAPACITY 4 +# ifndef RAW_IN_CAPACITY +# define RAW_IN_CAPACITY 4 +# endif +# ifndef RAW_OUT_CAPACITY +# define RAW_OUT_CAPACITY 4 +# endif # define RAW_IN_MODE USB_EP_MODE_TYPE_INTR # define RAW_OUT_MODE USB_EP_MODE_TYPE_INTR .raw_driver = QMK_USB_DRIVER_CONFIG(RAW, 0, false), @@ -1074,7 +1078,7 @@ void console_task(void) { uint8_t buffer[CONSOLE_EPSIZE]; size_t size = 0; do { - size_t size = chnReadTimeout(&drivers.console_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE); + size = chnReadTimeout(&drivers.console_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE); if (size > 0) { console_receive(buffer, size); } @@ -1102,7 +1106,7 @@ void raw_hid_task(void) { uint8_t buffer[RAW_EPSIZE]; size_t size = 0; do { - size_t size = chnReadTimeout(&drivers.raw_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE); + size = chnReadTimeout(&drivers.raw_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE); if (size > 0) { raw_hid_receive(buffer, size); } @@ -1125,7 +1129,7 @@ void midi_ep_task(void) { uint8_t buffer[MIDI_STREAM_EPSIZE]; size_t size = 0; do { - size_t size = chnReadTimeout(&drivers.midi_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE); + size = chnReadTimeout(&drivers.midi_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE); if (size > 0) { MIDI_EventPacket_t event; recv_midi_packet(&event); diff --git a/tmk_core/protocol/report.c b/tmk_core/protocol/report.c index 854b59ae48..5755098c60 100644 --- a/tmk_core/protocol/report.c +++ b/tmk_core/protocol/report.c @@ -278,3 +278,16 @@ void clear_keys_from_report(report_keyboard_t* keyboard_report) { #endif memset(keyboard_report->keys, 0, sizeof(keyboard_report->keys)); } + +#ifdef MOUSE_ENABLE +/** + * @brief Compares 2 mouse reports for difference and returns result + * + * @param[in] new_report report_mouse_t + * @param[in] old_report report_mouse_t + * @return bool result + */ +__attribute__((weak)) bool has_mouse_report_changed(report_mouse_t* new_report, report_mouse_t* old_report) { + return memcmp(new_report, old_report, sizeof(report_mouse_t)); +} +#endif diff --git a/tmk_core/protocol/report.h b/tmk_core/protocol/report.h index 1adc892f3b..7bbeb78af7 100644 --- a/tmk_core/protocol/report.h +++ b/tmk_core/protocol/report.h @@ -320,6 +320,10 @@ void add_key_to_report(report_keyboard_t* keyboard_report, uint8_t key); void del_key_from_report(report_keyboard_t* keyboard_report, uint8_t key); void clear_keys_from_report(report_keyboard_t* keyboard_report); +#ifdef MOUSE_ENABLE +bool has_mouse_report_changed(report_mouse_t* new_report, report_mouse_t* old_report); +#endif + #ifdef __cplusplus } #endif diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index 0b992ba6c5..063bd2c3f1 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c @@ -347,49 +347,44 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] = { #endif #ifdef JOYSTICK_ENABLE -# if JOYSTICK_AXES_COUNT == 0 && JOYSTICK_BUTTON_COUNT == 0 -# error Need at least one axis or button for joystick -# endif const USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] = { - HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop - HID_RI_USAGE(8, 0x04), // Joystick - HID_RI_COLLECTION(8, 0x01), // Application - HID_RI_COLLECTION(8, 0x00), // Physical + HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop + HID_RI_USAGE(8, 0x04), // Joystick + HID_RI_COLLECTION(8, 0x01), // Application + HID_RI_COLLECTION(8, 0x00), // Physical +# if JOYSTICK_AXES_COUNT > 0 HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop -# if JOYSTICK_AXES_COUNT >= 1 HID_RI_USAGE(8, 0x30), // X -# endif -# if JOYSTICK_AXES_COUNT >= 2 +# if JOYSTICK_AXES_COUNT > 1 HID_RI_USAGE(8, 0x31), // Y -# endif -# if JOYSTICK_AXES_COUNT >= 3 +# endif +# if JOYSTICK_AXES_COUNT > 2 HID_RI_USAGE(8, 0x32), // Z -# endif -# if JOYSTICK_AXES_COUNT >= 4 +# endif +# if JOYSTICK_AXES_COUNT > 3 HID_RI_USAGE(8, 0x33), // Rx -# endif -# if JOYSTICK_AXES_COUNT >= 5 +# endif +# if JOYSTICK_AXES_COUNT > 4 HID_RI_USAGE(8, 0x34), // Ry -# endif -# if JOYSTICK_AXES_COUNT >= 6 +# endif +# if JOYSTICK_AXES_COUNT > 5 HID_RI_USAGE(8, 0x35), // Rz -# endif -# if JOYSTICK_AXES_COUNT >= 1 - # if JOYSTICK_AXES_RESOLUTION == 8 +# endif +# if JOYSTICK_AXES_RESOLUTION == 8 HID_RI_LOGICAL_MINIMUM(8, -JOYSTICK_RESOLUTION), HID_RI_LOGICAL_MAXIMUM(8, JOYSTICK_RESOLUTION), HID_RI_REPORT_COUNT(8, JOYSTICK_AXES_COUNT), HID_RI_REPORT_SIZE(8, 0x08), - # else +# else HID_RI_LOGICAL_MINIMUM(16, -JOYSTICK_RESOLUTION), HID_RI_LOGICAL_MAXIMUM(16, JOYSTICK_RESOLUTION), HID_RI_REPORT_COUNT(8, JOYSTICK_AXES_COUNT), HID_RI_REPORT_SIZE(8, 0x10), - # endif +# endif HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), # endif -# if JOYSTICK_BUTTON_COUNT >= 1 +# if JOYSTICK_BUTTON_COUNT > 0 HID_RI_USAGE_PAGE(8, 0x09), // Button HID_RI_USAGE_MINIMUM(8, 0x01), HID_RI_USAGE_MAXIMUM(8, JOYSTICK_BUTTON_COUNT), |