diff options
Diffstat (limited to 'tmk_core')
-rw-r--r-- | tmk_core/protocol.mk | 12 | ||||
-rw-r--r-- | tmk_core/protocol/chibios/chibios.c | 29 | ||||
-rw-r--r-- | tmk_core/protocol/chibios/usb_main.c | 12 | ||||
-rw-r--r-- | tmk_core/protocol/host.c | 110 | ||||
-rw-r--r-- | tmk_core/protocol/host.h | 2 | ||||
-rw-r--r-- | tmk_core/protocol/host_driver.h | 3 | ||||
-rw-r--r-- | tmk_core/protocol/lufa/lufa.c | 35 | ||||
-rw-r--r-- | tmk_core/protocol/report.c | 12 | ||||
-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 | 50 |
12 files changed, 228 insertions, 89 deletions
diff --git a/tmk_core/protocol.mk b/tmk_core/protocol.mk index 8f01976548..81520c1bc8 100644 --- a/tmk_core/protocol.mk +++ b/tmk_core/protocol.mk @@ -33,10 +33,6 @@ ifeq ($(strip $(PROGRAMMABLE_BUTTON_ENABLE)), yes) SHARED_EP_ENABLE = yes endif -ifeq ($(strip $(RAW_ENABLE)), yes) - OPT_DEFS += -DRAW_ENABLE -endif - ifeq ($(strip $(CONSOLE_ENABLE)), yes) OPT_DEFS += -DCONSOLE_ENABLE else @@ -46,12 +42,8 @@ else endif ifeq ($(strip $(NKRO_ENABLE)), yes) - ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) - $(info NKRO is not currently supported with Bluetooth, and has been disabled.) - else - OPT_DEFS += -DNKRO_ENABLE - SHARED_EP_ENABLE = yes - endif + OPT_DEFS += -DNKRO_ENABLE + SHARED_EP_ENABLE = yes endif ifeq ($(strip $(NO_SUSPEND_POWER_DOWN)), yes) diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c index cf948154f9..19d8121e34 100644 --- a/tmk_core/protocol/chibios/chibios.c +++ b/tmk_core/protocol/chibios/chibios.c @@ -66,9 +66,19 @@ void send_keyboard(report_keyboard_t *report); void send_nkro(report_nkro_t *report); void send_mouse(report_mouse_t *report); void send_extra(report_extra_t *report); +void send_raw_hid(uint8_t *data, uint8_t length); /* host struct */ -host_driver_t chibios_driver = {.keyboard_leds = usb_device_state_get_leds, .send_keyboard = send_keyboard, .send_nkro = send_nkro, .send_mouse = send_mouse, .send_extra = send_extra}; +host_driver_t chibios_driver = { + .keyboard_leds = usb_device_state_get_leds, + .send_keyboard = send_keyboard, + .send_nkro = send_nkro, + .send_mouse = send_mouse, + .send_extra = send_extra, +#ifdef RAW_ENABLE + .send_raw_hid = send_raw_hid, +#endif +}; #ifdef VIRTSER_ENABLE void virtser_task(void); @@ -134,8 +144,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 +154,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 +171,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/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 5a5354416f..f9d7f5c4d6 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -32,6 +32,10 @@ #include "usb_driver.h" #include "usb_types.h" +#ifdef RAW_ENABLE +# include "raw_hid.h" +#endif + #ifdef NKRO_ENABLE # include "keycode_config.h" @@ -515,19 +519,13 @@ void console_task(void) { #endif /* CONSOLE_ENABLE */ #ifdef RAW_ENABLE -void raw_hid_send(uint8_t *data, uint8_t length) { +void send_raw_hid(uint8_t *data, uint8_t length) { if (length != RAW_EPSIZE) { return; } send_report(USB_ENDPOINT_IN_RAW, data, length); } -__attribute__((weak)) void raw_hid_receive(uint8_t *data, uint8_t length) { - // Users should #include "raw_hid.h" in their own code - // and implement this function there. Leave this as weak linkage - // so users can opt to not handle data coming in. -} - void raw_hid_task(void) { uint8_t buffer[RAW_EPSIZE]; while (receive_report(USB_ENDPOINT_OUT_RAW, buffer, sizeof(buffer))) { diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index df805c827c..4874d7c1d3 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "host.h" #include "util.h" #include "debug.h" +#include "usb_device_state.h" #ifdef DIGITIZER_ENABLE # include "digitizer.h" @@ -30,9 +31,34 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. # include "joystick.h" #endif +#ifdef CONNECTION_ENABLE +# include "connection.h" +#endif + #ifdef BLUETOOTH_ENABLE # include "bluetooth.h" -# include "outputselect.h" + +static void bluetooth_send_extra(report_extra_t *report) { + switch (report->report_id) { + case REPORT_ID_SYSTEM: + bluetooth_send_system(report->usage); + return; + case REPORT_ID_CONSUMER: + bluetooth_send_consumer(report->usage); + return; + } +} + +host_driver_t bt_driver = { + .keyboard_leds = bluetooth_keyboard_leds, + .send_keyboard = bluetooth_send_keyboard, + .send_nkro = bluetooth_send_nkro, + .send_mouse = bluetooth_send_mouse, + .send_extra = bluetooth_send_extra, +# ifdef RAW_ENABLE + .send_raw_hid = bluetooth_send_raw_hid, +# endif +}; #endif #ifdef NKRO_ENABLE @@ -52,6 +78,39 @@ host_driver_t *host_get_driver(void) { return driver; } +static host_driver_t *host_get_active_driver(void) { +#ifdef CONNECTION_ENABLE + switch (connection_get_host()) { +# ifdef BLUETOOTH_ENABLE + case CONNECTION_HOST_BLUETOOTH: + return &bt_driver; +# endif + case CONNECTION_HOST_NONE: + return NULL; + default: + break; + } +#endif + return driver; +} + +bool host_can_send_nkro(void) { +#ifdef CONNECTION_ENABLE + switch (connection_get_host()) { +# ifdef BLUETOOTH_ENABLE + case CONNECTION_HOST_BLUETOOTH: + return bluetooth_can_send_nkro(); +# endif + case CONNECTION_HOST_NONE: + return false; + default: + break; + } +#endif + + return usb_device_state_get_protocol() == USB_PROTOCOL_REPORT; +} + #ifdef SPLIT_KEYBOARD uint8_t split_led_state = 0; void set_split_host_keyboard_leds(uint8_t led_state) { @@ -63,7 +122,10 @@ uint8_t host_keyboard_leds(void) { #ifdef SPLIT_KEYBOARD if (!is_keyboard_master()) return split_led_state; #endif - if (!driver) return 0; + + host_driver_t *driver = host_get_active_driver(); + if (!driver || !driver->keyboard_leds) return 0; + return (*driver->keyboard_leds)(); } @@ -73,14 +135,9 @@ 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) { - bluetooth_send_keyboard(report); - return; - } -#endif + host_driver_t *driver = host_get_active_driver(); + if (!driver || !driver->send_keyboard) return; - if (!driver) return; #ifdef KEYBOARD_SHARED_EP report->report_id = REPORT_ID_KEYBOARD; #endif @@ -96,7 +153,9 @@ void host_keyboard_send(report_keyboard_t *report) { } void host_nkro_send(report_nkro_t *report) { - if (!driver) return; + host_driver_t *driver = host_get_active_driver(); + if (!driver || !driver->send_nkro) return; + report->report_id = REPORT_ID_NKRO; (*driver->send_nkro)(report); @@ -110,14 +169,9 @@ 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) { - bluetooth_send_mouse(report); - return; - } -#endif + host_driver_t *driver = host_get_active_driver(); + if (!driver || !driver->send_mouse) return; - if (!driver) return; #ifdef MOUSE_SHARED_EP report->report_id = REPORT_ID_MOUSE; #endif @@ -133,7 +187,8 @@ void host_system_send(uint16_t usage) { if (usage == last_system_usage) return; last_system_usage = usage; - if (!driver) return; + host_driver_t *driver = host_get_active_driver(); + if (!driver || !driver->send_extra) return; report_extra_t report = { .report_id = REPORT_ID_SYSTEM, @@ -146,14 +201,8 @@ void host_consumer_send(uint16_t usage) { if (usage == last_consumer_usage) return; last_consumer_usage = usage; -#ifdef BLUETOOTH_ENABLE - if (where_to_send() == OUTPUT_BLUETOOTH) { - bluetooth_send_consumer(usage); - return; - } -#endif - - if (!driver) return; + host_driver_t *driver = host_get_active_driver(); + if (!driver || !driver->send_extra) return; report_extra_t report = { .report_id = REPORT_ID_CONSUMER, @@ -253,6 +302,15 @@ void host_programmable_button_send(uint32_t data) { __attribute__((weak)) void send_programmable_button(report_programmable_button_t *report) {} +#ifdef RAW_ENABLE +void host_raw_hid_send(uint8_t *data, uint8_t length) { + host_driver_t *driver = host_get_active_driver(); + if (!driver || !driver->send_raw_hid) return; + + (*driver->send_raw_hid)(data, length); +} +#endif + uint16_t host_last_system_usage(void) { return last_system_usage; } diff --git a/tmk_core/protocol/host.h b/tmk_core/protocol/host.h index d824fca077..a0b1e73dcc 100644 --- a/tmk_core/protocol/host.h +++ b/tmk_core/protocol/host.h @@ -32,6 +32,7 @@ void host_set_driver(host_driver_t *driver); host_driver_t *host_get_driver(void); /* host driver interface */ +bool host_can_send_nkro(void); uint8_t host_keyboard_leds(void); led_t host_keyboard_led_state(void); void host_keyboard_send(report_keyboard_t *report); @@ -40,6 +41,7 @@ void host_mouse_send(report_mouse_t *report); void host_system_send(uint16_t usage); void host_consumer_send(uint16_t usage); void host_programmable_button_send(uint32_t data); +void host_raw_hid_send(uint8_t *data, uint8_t length); uint16_t host_last_system_usage(void); uint16_t host_last_consumer_usage(void); diff --git a/tmk_core/protocol/host_driver.h b/tmk_core/protocol/host_driver.h index 8aa38b6dee..c2835aaa99 100644 --- a/tmk_core/protocol/host_driver.h +++ b/tmk_core/protocol/host_driver.h @@ -29,6 +29,9 @@ typedef struct { void (*send_nkro)(report_nkro_t *); void (*send_mouse)(report_mouse_t *); void (*send_extra)(report_extra_t *); +#ifdef RAW_ENABLE + void (*send_raw_hid)(uint8_t *, uint8_t); +#endif } host_driver_t; void send_joystick(report_joystick_t *report); diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 81da035f0c..d59468133c 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -75,11 +75,24 @@ static report_keyboard_t keyboard_report_sent; /* Host driver */ -static void send_keyboard(report_keyboard_t *report); -static void send_nkro(report_nkro_t *report); -static void send_mouse(report_mouse_t *report); -static void send_extra(report_extra_t *report); -host_driver_t lufa_driver = {.keyboard_leds = usb_device_state_get_leds, .send_keyboard = send_keyboard, .send_nkro = send_nkro, .send_mouse = send_mouse, .send_extra = send_extra}; +static void send_keyboard(report_keyboard_t *report); +static void send_nkro(report_nkro_t *report); +static void send_mouse(report_mouse_t *report); +static void send_extra(report_extra_t *report); +#ifdef RAW_ENABLE +static void send_raw_hid(uint8_t *data, uint8_t length); +#endif + +host_driver_t lufa_driver = { + .keyboard_leds = usb_device_state_get_leds, + .send_keyboard = send_keyboard, + .send_nkro = send_nkro, + .send_mouse = send_mouse, + .send_extra = send_extra, +#ifdef RAW_ENABLE + .send_raw_hid = send_raw_hid, +#endif +}; void send_report(uint8_t endpoint, void *report, size_t size) { uint8_t timeout = 255; @@ -131,21 +144,11 @@ USB_ClassInfo_CDC_Device_t cdc_device = { * * FIXME: Needs doc */ -void raw_hid_send(uint8_t *data, uint8_t length) { +static void send_raw_hid(uint8_t *data, uint8_t length) { if (length != RAW_EPSIZE) return; send_report(RAW_IN_EPNUM, data, RAW_EPSIZE); } -/** \brief Raw HID Receive - * - * FIXME: Needs doc - */ -__attribute__((weak)) void raw_hid_receive(uint8_t *data, uint8_t length) { - // Users should #include "raw_hid.h" in their own code - // and implement this function there. Leave this as weak linkage - // so users can opt to not handle data coming in. -} - /** \brief Raw HID Task * * FIXME: Needs doc diff --git a/tmk_core/protocol/report.c b/tmk_core/protocol/report.c index 6203a3116b..f68334adeb 100644 --- a/tmk_core/protocol/report.c +++ b/tmk_core/protocol/report.c @@ -32,7 +32,7 @@ uint8_t has_anykey(void) { uint8_t* p = keyboard_report->keys; uint8_t lp = sizeof(keyboard_report->keys); #ifdef NKRO_ENABLE - if (usb_device_state_get_protocol() == USB_PROTOCOL_REPORT && keymap_config.nkro) { + if (host_can_send_nkro() && keymap_config.nkro) { p = nkro_report->bits; lp = sizeof(nkro_report->bits); } @@ -49,7 +49,7 @@ uint8_t has_anykey(void) { */ uint8_t get_first_key(void) { #ifdef NKRO_ENABLE - if (usb_device_state_get_protocol() == USB_PROTOCOL_REPORT && keymap_config.nkro) { + if (host_can_send_nkro() && keymap_config.nkro) { uint8_t i = 0; for (; i < NKRO_REPORT_BITS && !nkro_report->bits[i]; i++) ; @@ -69,7 +69,7 @@ bool is_key_pressed(uint8_t key) { return false; } #ifdef NKRO_ENABLE - if (usb_device_state_get_protocol() == USB_PROTOCOL_REPORT && keymap_config.nkro) { + if (host_can_send_nkro() && keymap_config.nkro) { if ((key >> 3) < NKRO_REPORT_BITS) { return nkro_report->bits[key >> 3] & 1 << (key & 7); } else { @@ -151,7 +151,7 @@ void del_key_bit(report_nkro_t* nkro_report, uint8_t code) { */ void add_key_to_report(uint8_t key) { #ifdef NKRO_ENABLE - if (usb_device_state_get_protocol() == USB_PROTOCOL_REPORT && keymap_config.nkro) { + if (host_can_send_nkro() && keymap_config.nkro) { add_key_bit(nkro_report, key); return; } @@ -165,7 +165,7 @@ void add_key_to_report(uint8_t key) { */ void del_key_from_report(uint8_t key) { #ifdef NKRO_ENABLE - if (usb_device_state_get_protocol() == USB_PROTOCOL_REPORT && keymap_config.nkro) { + if (host_can_send_nkro() && keymap_config.nkro) { del_key_bit(nkro_report, key); return; } @@ -180,7 +180,7 @@ void del_key_from_report(uint8_t key) { void clear_keys_from_report(void) { // not clear mods #ifdef NKRO_ENABLE - if (usb_device_state_get_protocol() == USB_PROTOCOL_REPORT && keymap_config.nkro) { + if (host_can_send_nkro() && keymap_config.nkro) { memset(nkro_report->bits, 0, sizeof(nkro_report->bits)); 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..43cce6eb2f 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c @@ -144,7 +144,7 @@ static void send_report(uint8_t endpoint, void *report, size_t size) { static uint8_t raw_output_buffer[RAW_BUFFER_SIZE]; static uint8_t raw_output_received_bytes = 0; -void raw_hid_send(uint8_t *data, uint8_t length) { +static void send_raw_hid(uint8_t *data, uint8_t length) { if (length != RAW_BUFFER_SIZE) { return; } @@ -152,12 +152,6 @@ void raw_hid_send(uint8_t *data, uint8_t length) { send_report(4, data, 32); } -__attribute__((weak)) void raw_hid_receive(uint8_t *data, uint8_t length) { - // Users should #include "raw_hid.h" in their own code - // and implement this function there. Leave this as weak linkage - // so users can opt to not handle data coming in. -} - void raw_hid_task(void) { usbPoll(); @@ -213,8 +207,20 @@ static void send_keyboard(report_keyboard_t *report); static void send_nkro(report_nkro_t *report); static void send_mouse(report_mouse_t *report); static void send_extra(report_extra_t *report); +#ifdef RAW_ENABLE +static void send_raw_hid(uint8_t *data, uint8_t length); +#endif -static host_driver_t driver = {.keyboard_leds = usb_device_state_get_leds, .send_keyboard = send_keyboard, .send_nkro = send_nkro, .send_mouse = send_mouse, .send_extra = send_extra}; +static host_driver_t driver = { + .keyboard_leds = usb_device_state_get_leds, + .send_keyboard = send_keyboard, + .send_nkro = send_nkro, + .send_mouse = send_mouse, + .send_extra = send_extra, +#ifdef RAW_ENABLE + .send_raw_hid = send_raw_hid, +#endif +}; host_driver_t *vusb_driver(void) { return &driver; @@ -520,6 +526,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 +558,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 +574,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 |