diff options
Diffstat (limited to 'tmk_core/protocol')
-rw-r--r-- | tmk_core/protocol/chibios/chibios.c | 17 | ||||
-rw-r--r-- | tmk_core/protocol/host.c | 11 | ||||
-rw-r--r-- | tmk_core/protocol/report.h | 8 | ||||
-rw-r--r-- | tmk_core/protocol/usb_descriptor.c | 24 | ||||
-rw-r--r-- | tmk_core/protocol/usb_descriptor_common.h | 20 | ||||
-rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 28 |
6 files changed, 89 insertions, 19 deletions
diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c index cf948154f9..d752f3746b 100644 --- a/tmk_core/protocol/chibios/chibios.c +++ b/tmk_core/protocol/chibios/chibios.c @@ -134,8 +134,6 @@ void protocol_setup(void) { // chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); } -static host_driver_t *driver = NULL; - void protocol_pre_init(void) { /* Init USB */ usb_event_queue_init(); @@ -146,18 +144,11 @@ void protocol_pre_init(void) { #endif /* Wait until USB is active */ - while (true) { -#if defined(USB_WAIT_FOR_ENUMERATION) - if (USB_DRIVER.state == USB_ACTIVE) { - driver = &chibios_driver; - break; - } -#else - driver = &chibios_driver; - break; -#endif +#ifdef USB_WAIT_FOR_ENUMERATION + while (USB_DRIVER.state != USB_ACTIVE) { wait_ms(50); } +#endif /* Do need to wait here! * Otherwise the next print might start a transfer on console EP @@ -170,7 +161,7 @@ void protocol_pre_init(void) { } void protocol_post_init(void) { - host_set_driver(driver); + host_set_driver(&chibios_driver); } void protocol_pre_task(void) { diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index df805c827c..453952049f 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -31,8 +31,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #endif #ifdef BLUETOOTH_ENABLE +# ifndef CONNECTION_ENABLE +# error CONNECTION_ENABLE required and not enabled +# endif +# include "connection.h" # include "bluetooth.h" -# include "outputselect.h" #endif #ifdef NKRO_ENABLE @@ -74,7 +77,7 @@ led_t host_keyboard_led_state(void) { /* send report */ void host_keyboard_send(report_keyboard_t *report) { #ifdef BLUETOOTH_ENABLE - if (where_to_send() == OUTPUT_BLUETOOTH) { + if (connection_get_host() == CONNECTION_HOST_BLUETOOTH) { bluetooth_send_keyboard(report); return; } @@ -111,7 +114,7 @@ void host_nkro_send(report_nkro_t *report) { void host_mouse_send(report_mouse_t *report) { #ifdef BLUETOOTH_ENABLE - if (where_to_send() == OUTPUT_BLUETOOTH) { + if (connection_get_host() == CONNECTION_HOST_BLUETOOTH) { bluetooth_send_mouse(report); return; } @@ -147,7 +150,7 @@ void host_consumer_send(uint16_t usage) { last_consumer_usage = usage; #ifdef BLUETOOTH_ENABLE - if (where_to_send() == OUTPUT_BLUETOOTH) { + if (connection_get_host() == CONNECTION_HOST_BLUETOOTH) { bluetooth_send_consumer(usage); return; } diff --git a/tmk_core/protocol/report.h b/tmk_core/protocol/report.h index d854f51d5c..9053b0bb3f 100644 --- a/tmk_core/protocol/report.h +++ b/tmk_core/protocol/report.h @@ -194,14 +194,22 @@ typedef struct { } PACKED report_programmable_button_t; #ifdef MOUSE_EXTENDED_REPORT +# define MOUSE_REPORT_XY_MIN INT16_MIN +# define MOUSE_REPORT_XY_MAX INT16_MAX typedef int16_t mouse_xy_report_t; #else +# define MOUSE_REPORT_XY_MIN INT8_MIN +# define MOUSE_REPORT_XY_MAX INT8_MAX typedef int8_t mouse_xy_report_t; #endif #ifdef WHEEL_EXTENDED_REPORT +# define MOUSE_REPORT_HV_MIN INT16_MIN +# define MOUSE_REPORT_HV_MAX INT16_MAX typedef int16_t mouse_hv_report_t; #else +# define MOUSE_REPORT_HV_MIN INT8_MIN +# define MOUSE_REPORT_HV_MAX INT8_MAX typedef int8_t mouse_hv_report_t; #endif diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index c7fb660b65..ceab9eef9a 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c @@ -165,6 +165,24 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = { # endif HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), +# ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE + HID_RI_COLLECTION(8, 0x02), + // Feature report and padding (1 byte) + HID_RI_USAGE(8, 0x48), // Resolution Multiplier + HID_RI_REPORT_COUNT(8, 0x01), + HID_RI_REPORT_SIZE(8, 0x02), + HID_RI_LOGICAL_MINIMUM(8, 0x00), + HID_RI_LOGICAL_MAXIMUM(8, 0x01), + HID_RI_PHYSICAL_MINIMUM(8, 1), + HID_RI_PHYSICAL_MAXIMUM(8, POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER), + HID_RI_UNIT_EXPONENT(8, POINTING_DEVICE_HIRES_SCROLL_EXPONENT), + HID_RI_FEATURE(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), + HID_RI_PHYSICAL_MINIMUM(8, 0x00), + HID_RI_PHYSICAL_MAXIMUM(8, 0x00), + HID_RI_REPORT_SIZE(8, 0x06), + HID_RI_FEATURE(8, HID_IOF_CONSTANT), +# endif + // Vertical wheel (1 or 2 bytes) HID_RI_USAGE(8, 0x38), // Wheel # ifndef WHEEL_EXTENDED_REPORT @@ -179,6 +197,7 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = { HID_RI_REPORT_SIZE(8, 0x10), # endif HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), + // Horizontal wheel (1 or 2 bytes) HID_RI_USAGE_PAGE(8, 0x0C),// Consumer HID_RI_USAGE(16, 0x0238), // AC Pan @@ -194,6 +213,11 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = { HID_RI_REPORT_SIZE(8, 0x10), # endif HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), + +# ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE + HID_RI_END_COLLECTION(0), +# endif + HID_RI_END_COLLECTION(0), HID_RI_END_COLLECTION(0), # ifndef MOUSE_SHARED_EP diff --git a/tmk_core/protocol/usb_descriptor_common.h b/tmk_core/protocol/usb_descriptor_common.h index 909c230a99..f782d83fbc 100644 --- a/tmk_core/protocol/usb_descriptor_common.h +++ b/tmk_core/protocol/usb_descriptor_common.h @@ -32,3 +32,23 @@ #ifndef RAW_USAGE_ID # define RAW_USAGE_ID 0x61 #endif + +///////////////////// +// Hires Scroll Defaults + +#ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE +# ifdef POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER +# if POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER > 127 || POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER < 1 +# error "POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER must be between 1 and 127, inclusive!" +# endif +# else +# define POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER 120 +# endif +# ifdef POINTING_DEVICE_HIRES_SCROLL_EXPONENT +# if POINTING_DEVICE_HIRES_SCROLL_EXPONENT > 127 || POINTING_DEVICE_HIRES_SCROLL_EXPONENT < 0 +# error "POINTING_DEVICE_HIRES_SCROLL_EXPONENT must be between 0 and 127, inclusive!" +# endif +# else +# define POINTING_DEVICE_HIRES_SCROLL_EXPONENT 0 +# endif +#endif
\ No newline at end of file diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index fdbfcc17dc..56cf82e5a6 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c @@ -520,6 +520,24 @@ const PROGMEM uchar shared_hid_report[] = { # endif 0x81, 0x06, // Input (Data, Variable, Relative) +# ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE + // Feature report and padding (1 byte) + 0xA1, 0x02, // Collection (Logical) + 0x09, 0x48, // Usage (Resolution Multiplier) + 0x95, 0x01, // Report Count (1) + 0x75, 0x02, // Report Size (2) + 0x15, 0x00, // Logical Minimum (0) + 0x25, 0x01, // Logical Maximum (1) + 0x35, 0x01, // Physical Minimum (1) + 0x45, POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER, // Physical Maximum (POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER) + 0x55, POINTING_DEVICE_HIRES_SCROLL_EXPONENT, // Unit Exponent (POINTING_DEVICE_HIRES_SCROLL_EXPONENT) + 0xB1, 0x02, // Feature (Data, Variable, Absolute) + 0x35, 0x00, // Physical Minimum (0) + 0x45, 0x00, // Physical Maximum (0) + 0x75, 0x06, // Report Size (6) + 0xB1, 0x03, // Feature (Constant) +# endif + // Vertical wheel (1 or 2 bytes) 0x09, 0x38, // Usage (Wheel) # ifndef WHEEL_EXTENDED_REPORT @@ -534,6 +552,7 @@ const PROGMEM uchar shared_hid_report[] = { 0x75, 0x10, // Report Size (16) # endif 0x81, 0x06, // Input (Data, Variable, Relative) + // Horizontal wheel (1 or 2 bytes) 0x05, 0x0C, // Usage Page (Consumer) 0x0A, 0x38, 0x02, // Usage (AC Pan) @@ -549,8 +568,13 @@ const PROGMEM uchar shared_hid_report[] = { 0x75, 0x10, // Report Size (16) # endif 0x81, 0x06, // Input (Data, Variable, Relative) - 0xC0, // End Collection - 0xC0, // End Collection + +# ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE + 0xC0, // End Collection +# endif + + 0xC0, // End Collection + 0xC0, // End Collection #endif #ifdef EXTRAKEY_ENABLE |