summaryrefslogtreecommitdiffstats
path: root/tmk_core
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/protocol.mk42
-rw-r--r--tmk_core/protocol/arm_atsam/arm_atsam.mk (renamed from tmk_core/protocol/arm_atsam.mk)0
-rw-r--r--tmk_core/protocol/arm_atsam/main_arm_atsam.c2
-rw-r--r--tmk_core/protocol/arm_atsam/md_rgb_matrix.c16
-rw-r--r--tmk_core/protocol/arm_atsam/md_rgb_matrix.h8
-rw-r--r--tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c1
-rw-r--r--tmk_core/protocol/arm_atsam/spi_master.h2
-rw-r--r--tmk_core/protocol/chibios/chibios.c26
-rw-r--r--tmk_core/protocol/chibios/chibios.mk (renamed from tmk_core/protocol/chibios.mk)0
-rw-r--r--tmk_core/protocol/lufa/lufa.c4
-rw-r--r--tmk_core/protocol/lufa/lufa.mk (renamed from tmk_core/protocol/lufa.mk)0
-rw-r--r--tmk_core/protocol/report.c12
-rw-r--r--tmk_core/protocol/usb_descriptor.c2
-rw-r--r--tmk_core/protocol/usb_hid/usb_hid.mk (renamed from tmk_core/protocol/usb_hid.mk)0
-rw-r--r--tmk_core/protocol/usb_util.c6
-rw-r--r--tmk_core/protocol/usb_util.h3
-rw-r--r--tmk_core/protocol/vusb/vusb.c2
-rw-r--r--tmk_core/protocol/vusb/vusb.mk (renamed from tmk_core/protocol/vusb.mk)0
18 files changed, 72 insertions, 54 deletions
diff --git a/tmk_core/protocol.mk b/tmk_core/protocol.mk
index d3f15c4588..d159dacc55 100644
--- a/tmk_core/protocol.mk
+++ b/tmk_core/protocol.mk
@@ -1,4 +1,4 @@
-TMK_COMMON_SRC += \
+SRC += \
$(PROTOCOL_DIR)/host.c \
$(PROTOCOL_DIR)/report.c \
$(PROTOCOL_DIR)/usb_device_state.c \
@@ -7,7 +7,7 @@ TMK_COMMON_SRC += \
SHARED_EP_ENABLE = no
MOUSE_SHARED_EP ?= yes
ifeq ($(strip $(KEYBOARD_SHARED_EP)), yes)
- TMK_COMMON_DEFS += -DKEYBOARD_SHARED_EP
+ OPT_DEFS += -DKEYBOARD_SHARED_EP
SHARED_EP_ENABLE = yes
# With the current usb_descriptor.c code,
# you can't share kbd without sharing mouse;
@@ -18,31 +18,31 @@ endif
ifeq ($(strip $(MOUSE_ENABLE)), yes)
OPT_DEFS += -DMOUSE_ENABLE
ifeq ($(strip $(MOUSE_SHARED_EP)), yes)
- TMK_COMMON_DEFS += -DMOUSE_SHARED_EP
+ OPT_DEFS += -DMOUSE_SHARED_EP
SHARED_EP_ENABLE = yes
endif
endif
ifeq ($(strip $(EXTRAKEY_ENABLE)), yes)
- TMK_COMMON_DEFS += -DEXTRAKEY_ENABLE
+ OPT_DEFS += -DEXTRAKEY_ENABLE
SHARED_EP_ENABLE = yes
endif
ifeq ($(strip $(PROGRAMMABLE_BUTTON_ENABLE)), yes)
- TMK_COMMON_DEFS += -DPROGRAMMABLE_BUTTON_ENABLE
+ OPT_DEFS += -DPROGRAMMABLE_BUTTON_ENABLE
SHARED_EP_ENABLE = yes
endif
ifeq ($(strip $(RAW_ENABLE)), yes)
- TMK_COMMON_DEFS += -DRAW_ENABLE
+ OPT_DEFS += -DRAW_ENABLE
endif
ifeq ($(strip $(CONSOLE_ENABLE)), yes)
- TMK_COMMON_DEFS += -DCONSOLE_ENABLE
+ OPT_DEFS += -DCONSOLE_ENABLE
else
# TODO: decouple this so other print backends can exist
- TMK_COMMON_DEFS += -DNO_PRINT
- TMK_COMMON_DEFS += -DNO_DEBUG
+ OPT_DEFS += -DNO_PRINT
+ OPT_DEFS += -DNO_DEBUG
endif
ifeq ($(strip $(NKRO_ENABLE)), yes)
@@ -51,55 +51,55 @@ ifeq ($(strip $(NKRO_ENABLE)), yes)
else ifeq ($(strip $(BLUETOOTH_ENABLE)), yes)
$(info NKRO is not currently supported with Bluetooth, and has been disabled.)
else
- TMK_COMMON_DEFS += -DNKRO_ENABLE
+ OPT_DEFS += -DNKRO_ENABLE
SHARED_EP_ENABLE = yes
endif
endif
ifeq ($(strip $(RING_BUFFERED_6KRO_REPORT_ENABLE)), yes)
- TMK_COMMON_DEFS += -DRING_BUFFERED_6KRO_REPORT_ENABLE
+ OPT_DEFS += -DRING_BUFFERED_6KRO_REPORT_ENABLE
endif
ifeq ($(strip $(NO_SUSPEND_POWER_DOWN)), yes)
- TMK_COMMON_DEFS += -DNO_SUSPEND_POWER_DOWN
+ OPT_DEFS += -DNO_SUSPEND_POWER_DOWN
endif
ifeq ($(strip $(NO_USB_STARTUP_CHECK)), yes)
- TMK_COMMON_DEFS += -DNO_USB_STARTUP_CHECK
+ OPT_DEFS += -DNO_USB_STARTUP_CHECK
endif
ifeq ($(strip $(JOYSTICK_SHARED_EP)), yes)
- TMK_COMMON_DEFS += -DJOYSTICK_SHARED_EP
+ OPT_DEFS += -DJOYSTICK_SHARED_EP
SHARED_EP_ENABLE = yes
endif
ifeq ($(strip $(JOYSTICK_ENABLE)), yes)
- TMK_COMMON_DEFS += -DJOYSTICK_ENABLE
+ OPT_DEFS += -DJOYSTICK_ENABLE
ifeq ($(strip $(SHARED_EP_ENABLE)), yes)
- TMK_COMMON_DEFS += -DJOYSTICK_SHARED_EP
+ OPT_DEFS += -DJOYSTICK_SHARED_EP
SHARED_EP_ENABLE = yes
endif
endif
ifeq ($(strip $(DIGITIZER_SHARED_EP)), yes)
- TMK_COMMON_DEFS += -DDIGITIZER_SHARED_EP
+ OPT_DEFS += -DDIGITIZER_SHARED_EP
SHARED_EP_ENABLE = yes
endif
ifeq ($(strip $(DIGITIZER_ENABLE)), yes)
- TMK_COMMON_DEFS += -DDIGITIZER_ENABLE
+ OPT_DEFS += -DDIGITIZER_ENABLE
ifeq ($(strip $(SHARED_EP_ENABLE)), yes)
- TMK_COMMON_DEFS += -DDIGITIZER_SHARED_EP
+ OPT_DEFS += -DDIGITIZER_SHARED_EP
SHARED_EP_ENABLE = yes
endif
endif
ifeq ($(strip $(SHARED_EP_ENABLE)), yes)
- TMK_COMMON_DEFS += -DSHARED_EP_ENABLE
+ OPT_DEFS += -DSHARED_EP_ENABLE
endif
ifeq ($(strip $(USB_HID_ENABLE)), yes)
- include $(TMK_DIR)/protocol/usb_hid.mk
+ include $(TMK_DIR)/protocol/usb_hid/usb_hid.mk
endif
# Search Path
diff --git a/tmk_core/protocol/arm_atsam.mk b/tmk_core/protocol/arm_atsam/arm_atsam.mk
index ffd1fa9f50..ffd1fa9f50 100644
--- a/tmk_core/protocol/arm_atsam.mk
+++ b/tmk_core/protocol/arm_atsam/arm_atsam.mk
diff --git a/tmk_core/protocol/arm_atsam/main_arm_atsam.c b/tmk_core/protocol/arm_atsam/main_arm_atsam.c
index 1ccfbfb54a..30817c17b6 100644
--- a/tmk_core/protocol/arm_atsam/main_arm_atsam.c
+++ b/tmk_core/protocol/arm_atsam/main_arm_atsam.c
@@ -21,9 +21,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "report.h"
#include "host.h"
#include "host_driver.h"
+#include "suspend.h"
#include "keycode_config.h"
#include <string.h>
-#include "quantum.h"
// From protocol directory
#include "arm_atsam_protocol.h"
diff --git a/tmk_core/protocol/arm_atsam/md_rgb_matrix.c b/tmk_core/protocol/arm_atsam/md_rgb_matrix.c
index 52fe86d297..0f316b256c 100644
--- a/tmk_core/protocol/arm_atsam/md_rgb_matrix.c
+++ b/tmk_core/protocol/arm_atsam/md_rgb_matrix.c
@@ -23,6 +23,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# include "arm_atsam_protocol.h"
# include "led.h"
# include "rgb_matrix.h"
+# include "eeprom.h"
+# include "host.h"
# include <string.h>
# include <math.h>
@@ -347,24 +349,24 @@ static void flush(void) {
}
void md_rgb_matrix_indicators_advanced(uint8_t led_min, uint8_t led_max) {
- uint8_t kbled = keyboard_leds();
- if (kbled && rgb_matrix_config.enable) {
+ led_t led_state = host_keyboard_led_state();
+ if (led_state.raw && rgb_matrix_config.enable) {
for (uint8_t i = led_min; i < led_max; i++) {
if (
# if USB_LED_NUM_LOCK_SCANCODE != 255
- (led_map[i].scan == USB_LED_NUM_LOCK_SCANCODE && (kbled & (1 << USB_LED_NUM_LOCK))) ||
+ (led_map[i].scan == USB_LED_NUM_LOCK_SCANCODE && led_state.num_lock) ||
# endif // NUM LOCK
# if USB_LED_CAPS_LOCK_SCANCODE != 255
- (led_map[i].scan == USB_LED_CAPS_LOCK_SCANCODE && (kbled & (1 << USB_LED_CAPS_LOCK))) ||
+ (led_map[i].scan == USB_LED_CAPS_LOCK_SCANCODE && led_state.caps_lock) ||
# endif // CAPS LOCK
# if USB_LED_SCROLL_LOCK_SCANCODE != 255
- (led_map[i].scan == USB_LED_SCROLL_LOCK_SCANCODE && (kbled & (1 << USB_LED_SCROLL_LOCK))) ||
+ (led_map[i].scan == USB_LED_SCROLL_LOCK_SCANCODE && led_state.scroll_lock) ||
# endif // SCROLL LOCK
# if USB_LED_COMPOSE_SCANCODE != 255
- (led_map[i].scan == USB_LED_COMPOSE_SCANCODE && (kbled & (1 << USB_LED_COMPOSE))) ||
+ (led_map[i].scan == USB_LED_COMPOSE_SCANCODE && led_state.compose) ||
# endif // COMPOSE
# if USB_LED_KANA_SCANCODE != 255
- (led_map[i].scan == USB_LED_KANA_SCANCODE && (kbled & (1 << USB_LED_KANA))) ||
+ (led_map[i].scan == USB_LED_KANA_SCANCODE && led_state.kana) ||
# endif // KANA
(0)) {
if (rgb_matrix_get_flags() & LED_FLAG_INDICATOR) {
diff --git a/tmk_core/protocol/arm_atsam/md_rgb_matrix.h b/tmk_core/protocol/arm_atsam/md_rgb_matrix.h
index f27da028a0..bb3312e8e7 100644
--- a/tmk_core/protocol/arm_atsam/md_rgb_matrix.h
+++ b/tmk_core/protocol/arm_atsam/md_rgb_matrix.h
@@ -15,11 +15,9 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _LED_MATRIX_H_
-#define _LED_MATRIX_H_
+#pragma once
-#include "quantum.h"
-#include "eeprom.h"
+#include <stdint.h>
// From keyboard
#include "config_led.h"
@@ -200,5 +198,3 @@ void md_led_changed(void);
#else
extern uint8_t gcr_desired;
#endif // USE_MASSDROP_CONFIGURATOR
-
-#endif //_LED_MATRIX_H_
diff --git a/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c b/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c
index 58fc4efd9c..476b605297 100644
--- a/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c
+++ b/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# ifdef USE_MASSDROP_CONFIGURATOR
# include "md_rgb_matrix.h"
+# include "util.h"
// Teal <-> Salmon
led_setup_t leds_teal_salmon[] = {
diff --git a/tmk_core/protocol/arm_atsam/spi_master.h b/tmk_core/protocol/arm_atsam/spi_master.h
index 26c55128be..80678a5707 100644
--- a/tmk_core/protocol/arm_atsam/spi_master.h
+++ b/tmk_core/protocol/arm_atsam/spi_master.h
@@ -16,7 +16,9 @@
#pragma once
+#include <stdint.h>
#include <stdbool.h>
+#include "gpio.h"
typedef int16_t spi_status_t;
diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c
index 10a976608a..1eebdaf6c3 100644
--- a/tmk_core/protocol/chibios/chibios.c
+++ b/tmk_core/protocol/chibios/chibios.c
@@ -49,6 +49,8 @@
#include "suspend.h"
#include "wait.h"
+#define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED (2U)
+
/* -------------------------
* TMK host driver defs
* -------------------------
@@ -178,28 +180,24 @@ void protocol_post_init(void) {
}
void protocol_pre_task(void) {
- usb_event_queue_task();
-
#if !defined(NO_USB_STARTUP_CHECK)
if (USB_DRIVER.state == USB_SUSPENDED) {
- print("[s]");
+ dprintln("suspending keyboard");
while (USB_DRIVER.state == USB_SUSPENDED) {
- /* Do this in the suspended state */
- suspend_power_down(); // on AVR this deep sleeps for 15ms
- /* Remote wakeup */
- if (suspend_wakeup_condition()) {
+ suspend_power_down();
+ if ((USB_DRIVER.status & USB_GETSTATUS_REMOTE_WAKEUP_ENABLED) && suspend_wakeup_condition()) {
+ /* issue a remote wakeup event to the host which should resume
+ * the bus and get our keyboard out of suspension. */
usbWakeupHost(&USB_DRIVER);
- restart_usb_driver(&USB_DRIVER);
}
}
- /* Woken up */
- // variables has been already cleared by the wakeup hook
- send_keyboard_report();
-# ifdef MOUSEKEY_ENABLE
- mousekey_send();
-# endif /* MOUSEKEY_ENABLE */
+ /* after a successful wakeup a USB_EVENT_WAKEUP is signaled to QMK by
+ * ChibiOS, which triggers a wakeup callback that restores the state of
+ * the keyboard. Therefore we do nothing here. */
}
#endif
+
+ usb_event_queue_task();
}
void protocol_post_task(void) {
diff --git a/tmk_core/protocol/chibios.mk b/tmk_core/protocol/chibios/chibios.mk
index 8eaf5b10d2..8eaf5b10d2 100644
--- a/tmk_core/protocol/chibios.mk
+++ b/tmk_core/protocol/chibios/chibios.mk
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index 20bfc8fb3c..f04ca79a0c 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -48,10 +48,10 @@
# include "sleep_led.h"
#endif
#include "suspend.h"
+#include "wait.h"
#include "usb_descriptor.h"
#include "lufa.h"
-#include "quantum.h"
#include "usb_device_state.h"
#include <util/atomic.h>
@@ -858,7 +858,7 @@ void protocol_post_init(void) {
void protocol_pre_task(void) {
#if !defined(NO_USB_STARTUP_CHECK)
if (USB_DeviceState == DEVICE_STATE_Suspended) {
- print("[s]");
+ dprintln("suspending keyboard");
while (USB_DeviceState == DEVICE_STATE_Suspended) {
suspend_power_down();
if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
diff --git a/tmk_core/protocol/lufa.mk b/tmk_core/protocol/lufa/lufa.mk
index b048c1836c..b048c1836c 100644
--- a/tmk_core/protocol/lufa.mk
+++ b/tmk_core/protocol/lufa/lufa.mk
diff --git a/tmk_core/protocol/report.c b/tmk_core/protocol/report.c
index 5755098c60..1ba3be4604 100644
--- a/tmk_core/protocol/report.c
+++ b/tmk_core/protocol/report.c
@@ -281,13 +281,21 @@ void clear_keys_from_report(report_keyboard_t* keyboard_report) {
#ifdef MOUSE_ENABLE
/**
- * @brief Compares 2 mouse reports for difference and returns result
+ * @brief Compares 2 mouse reports for difference and returns result. Empty
+ * reports always evaluate as unchanged.
*
* @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));
+ // memcmp doesn't work here because of the `report_id` field when using
+ // shared mouse endpoint
+ bool changed = ((new_report->buttons != old_report->buttons) ||
+# ifdef MOUSE_EXTENDED_REPORT
+ (new_report->boot_x != 0 && new_report->boot_x != old_report->boot_x) || (new_report->boot_y != 0 && new_report->boot_y != old_report->boot_y) ||
+# endif
+ (new_report->x != 0 && new_report->x != old_report->x) || (new_report->y != 0 && new_report->y != old_report->y) || (new_report->h != 0 && new_report->h != old_report->h) || (new_report->v != 0 && new_report->v != old_report->v));
+ return changed;
}
#endif
diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c
index 5ab9e3ff4f..e215c90900 100644
--- a/tmk_core/protocol/usb_descriptor.c
+++ b/tmk_core/protocol/usb_descriptor.c
@@ -93,6 +93,8 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = {
HID_RI_USAGE_PAGE(8, 0x08), // LED
HID_RI_USAGE_MINIMUM(8, 0x01), // Num Lock
HID_RI_USAGE_MAXIMUM(8, 0x05), // Kana
+ HID_RI_LOGICAL_MINIMUM(8, 0x00),
+ HID_RI_LOGICAL_MAXIMUM(8, 0x01),
HID_RI_REPORT_COUNT(8, 0x05),
HID_RI_REPORT_SIZE(8, 0x01),
HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
diff --git a/tmk_core/protocol/usb_hid.mk b/tmk_core/protocol/usb_hid/usb_hid.mk
index c0c157c043..c0c157c043 100644
--- a/tmk_core/protocol/usb_hid.mk
+++ b/tmk_core/protocol/usb_hid/usb_hid.mk
diff --git a/tmk_core/protocol/usb_util.c b/tmk_core/protocol/usb_util.c
index 49aadedc2a..3b3be4a767 100644
--- a/tmk_core/protocol/usb_util.c
+++ b/tmk_core/protocol/usb_util.c
@@ -13,13 +13,17 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "quantum.h"
+
#include "usb_util.h"
+#include "gpio.h"
+#include "wait.h"
__attribute__((weak)) void usb_disconnect(void) {}
+
__attribute__((weak)) bool usb_connected_state(void) {
return true;
}
+
__attribute__((weak)) bool usb_vbus_state(void) {
#ifdef USB_VBUS_PIN
setPinInput(USB_VBUS_PIN);
diff --git a/tmk_core/protocol/usb_util.h b/tmk_core/protocol/usb_util.h
index 13db9fbfbd..6f0e406378 100644
--- a/tmk_core/protocol/usb_util.h
+++ b/tmk_core/protocol/usb_util.h
@@ -13,10 +13,13 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
#pragma once
#include <stdbool.h>
void usb_disconnect(void);
+
bool usb_connected_state(void);
+
bool usb_vbus_state(void);
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index b3eeff9e01..d74f375f66 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -435,6 +435,8 @@ const PROGMEM uchar keyboard_hid_report[] = {
0x05, 0x08, // Usage Page (LED)
0x19, 0x01, // Usage Minimum (Num Lock)
0x29, 0x05, // Usage Maximum (Kana)
+ 0x15, 0x00, // Logical Minimum (0)
+ 0x25, 0x01, // Logical Maximum (1)
0x95, 0x05, // Report Count (5)
0x75, 0x01, // Report Size (1)
0x91, 0x02, // Output (Data, Variable, Absolute)
diff --git a/tmk_core/protocol/vusb.mk b/tmk_core/protocol/vusb/vusb.mk
index 5572597e21..5572597e21 100644
--- a/tmk_core/protocol/vusb.mk
+++ b/tmk_core/protocol/vusb/vusb.mk