aboutsummaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/protocol.mk12
-rw-r--r--tmk_core/protocol/chibios/chibios.c32
-rw-r--r--tmk_core/protocol/chibios/usb_endpoints.h2
-rw-r--r--tmk_core/protocol/chibios/usb_main.c24
-rw-r--r--tmk_core/protocol/host.c110
-rw-r--r--tmk_core/protocol/host.h2
-rw-r--r--tmk_core/protocol/host_driver.h3
-rw-r--r--tmk_core/protocol/lufa/lufa.c48
-rw-r--r--tmk_core/protocol/report.c12
-rw-r--r--tmk_core/protocol/report.h8
-rw-r--r--tmk_core/protocol/usb_descriptor.c24
-rw-r--r--tmk_core/protocol/usb_descriptor_common.h20
-rw-r--r--tmk_core/protocol/vusb/protocol.c24
-rw-r--r--tmk_core/protocol/vusb/vusb.c53
14 files changed, 233 insertions, 141 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..5720bc3c4c 100644
--- a/tmk_core/protocol/chibios/chibios.c
+++ b/tmk_core/protocol/chibios/chibios.c
@@ -40,9 +40,6 @@
# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP FALSE
#endif
-#ifdef SLEEP_LED_ENABLE
-# include "sleep_led.h"
-#endif
#ifdef MIDI_ENABLE
# include "qmk_midi.h"
#endif
@@ -66,9 +63,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 +141,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 +151,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 +168,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_endpoints.h b/tmk_core/protocol/chibios/usb_endpoints.h
index a4e5ed88fc..9fad83726e 100644
--- a/tmk_core/protocol/chibios/usb_endpoints.h
+++ b/tmk_core/protocol/chibios/usb_endpoints.h
@@ -121,7 +121,7 @@ typedef enum {
#define IS_VALID_USB_ENDPOINT_IN_LUT(i) ((i) >= 0 && (i) < USB_ENDPOINT_IN_COUNT)
-usb_endpoint_in_lut_t usb_endpoint_interface_lut[TOTAL_INTERFACES];
+extern usb_endpoint_in_lut_t usb_endpoint_interface_lut[TOTAL_INTERFACES];
typedef enum {
#if defined(RAW_ENABLE)
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index 5a5354416f..b798a8d1cb 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -21,10 +21,6 @@
#include "host.h"
#include "suspend.h"
#include "timer.h"
-#ifdef SLEEP_LED_ENABLE
-# include "sleep_led.h"
-# include "led.h"
-#endif
#include "wait.h"
#include "usb_endpoints.h"
#include "usb_device_state.h"
@@ -32,6 +28,10 @@
#include "usb_driver.h"
#include "usb_types.h"
+#ifdef RAW_ENABLE
+# include "raw_hid.h"
+#endif
+
#ifdef NKRO_ENABLE
# include "keycode_config.h"
@@ -127,19 +127,11 @@ static inline bool usb_event_queue_dequeue(usbevent_t *event) {
static inline void usb_event_suspend_handler(void) {
usb_device_state_set_suspend(USB_DRIVER.configuration != 0, USB_DRIVER.configuration);
-#ifdef SLEEP_LED_ENABLE
- sleep_led_enable();
-#endif /* SLEEP_LED_ENABLE */
}
static inline void usb_event_wakeup_handler(void) {
suspend_wakeup_init();
usb_device_state_set_resume(USB_DRIVER.configuration != 0, USB_DRIVER.configuration);
-#ifdef SLEEP_LED_ENABLE
- sleep_led_disable();
- // NOTE: converters may not accept this
- led_set(host_keyboard_leds());
-#endif /* SLEEP_LED_ENABLE */
}
bool last_suspend_state = false;
@@ -515,19 +507,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..e13f4b548e 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -44,9 +44,6 @@
#include "led.h"
#include "sendchar.h"
#include "debug.h"
-#ifdef SLEEP_LED_ENABLE
-# include "sleep_led.h"
-#endif
#include "suspend.h"
#include "wait.h"
@@ -75,11 +72,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 +141,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
@@ -275,10 +275,6 @@ void EVENT_USB_Device_Reset(void) {
void EVENT_USB_Device_Suspend(void) {
print("[S]");
usb_device_state_set_suspend(USB_Device_ConfigurationNumber != 0, USB_Device_ConfigurationNumber);
-
-#ifdef SLEEP_LED_ENABLE
- sleep_led_enable();
-#endif
}
/** \brief Event USB Device Connect
@@ -292,12 +288,6 @@ void EVENT_USB_Device_WakeUp(void) {
#endif
usb_device_state_set_resume(USB_DeviceState == DEVICE_STATE_Configured, USB_Device_ConfigurationNumber);
-
-#ifdef SLEEP_LED_ENABLE
- sleep_led_disable();
- // NOTE: converters may not accept this
- led_set(host_keyboard_leds());
-#endif
}
#ifdef CONSOLE_ENABLE
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/protocol.c b/tmk_core/protocol/vusb/protocol.c
index 41ccf451fd..e2d0c4112e 100644
--- a/tmk_core/protocol/vusb/protocol.c
+++ b/tmk_core/protocol/vusb/protocol.c
@@ -27,10 +27,6 @@
#include "wait.h"
#include "sendchar.h"
-#ifdef SLEEP_LED_ENABLE
-# include "sleep_led.h"
-#endif
-
/* This is from main.c of USBaspLoader */
static void initForUsbConnectivity(void) {
uint8_t i = 0;
@@ -64,22 +60,6 @@ static inline void vusb_send_remote_wakeup(void) {
bool vusb_suspended = false;
-static inline void vusb_suspend(void) {
-#ifdef SLEEP_LED_ENABLE
- sleep_led_enable();
-#endif
-
- suspend_power_down();
-}
-
-static inline void vusb_wakeup(void) {
- suspend_wakeup_init();
-
-#ifdef SLEEP_LED_ENABLE
- sleep_led_disable();
-#endif
-}
-
/** \brief Setup USB
*
* FIXME: Needs doc
@@ -133,7 +113,7 @@ void protocol_pre_task(void) {
if (should_do_suspend()) {
dprintln("suspending keyboard");
while (should_do_suspend()) {
- vusb_suspend();
+ suspend_power_down();
if (suspend_wakeup_condition()) {
vusb_send_remote_wakeup();
@@ -148,7 +128,7 @@ void protocol_pre_task(void) {
# endif
}
}
- vusb_wakeup();
+ suspend_wakeup_init();
}
#endif
}
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index fdbfcc17dc..1f0f82664b 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <usbdrv/usbdrv.h>
+#include "compiler_support.h"
#include "usbconfig.h"
#include "host.h"
#include "report.h"
@@ -80,7 +81,7 @@ enum usb_interfaces {
#define MAX_INTERFACES 3
-_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.");
+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.");
#if (defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)) && CONSOLE_ENABLE
# error Mouse/Extra Keys share an endpoint with Console. Please disable one of the two.
@@ -144,7 +145,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 +153,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 +208,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 +527,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 +559,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 +575,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