summaryrefslogtreecommitdiffstats
path: root/tmk_core
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/avr.mk4
-rw-r--r--tmk_core/common.mk3
-rw-r--r--tmk_core/common/action_layer.c2
-rw-r--r--tmk_core/common/action_layer.h2
-rw-r--r--tmk_core/common/arm_atsam/suspend.c3
-rw-r--r--tmk_core/common/chibios/suspend.c26
-rw-r--r--tmk_core/common/eeconfig.c6
-rw-r--r--tmk_core/common/host.c6
-rw-r--r--tmk_core/common/host.h2
-rw-r--r--tmk_core/common/keyboard.c10
-rw-r--r--tmk_core/common/keycode.h1
-rw-r--r--tmk_core/common/led.h13
-rw-r--r--tmk_core/common/mbed/bootloader.c3
-rw-r--r--tmk_core/common/mbed/suspend.c5
-rw-r--r--tmk_core/common/mbed/timer.c23
-rw-r--r--tmk_core/common/mbed/xprintf.cpp50
-rw-r--r--tmk_core/common/mbed/xprintf.h16
-rw-r--r--tmk_core/common/print.h33
-rw-r--r--tmk_core/common/wait.h2
-rw-r--r--tmk_core/protocol.mk27
-rw-r--r--tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h7
-rw-r--r--tmk_core/protocol/chibios/main.c8
-rw-r--r--tmk_core/protocol/chibios/usb_main.c152
-rw-r--r--tmk_core/protocol/iwrap/iwrap.c3
-rw-r--r--tmk_core/protocol/iwrap/main.c2
-rw-r--r--tmk_core/protocol/lufa/adafruit_ble.cpp6
-rw-r--r--tmk_core/protocol/lufa/lufa.c7
-rw-r--r--tmk_core/protocol/mbed/HIDKeyboard.cpp260
-rw-r--r--tmk_core/protocol/mbed/HIDKeyboard.h32
-rw-r--r--tmk_core/protocol/mbed/mbed_driver.cpp21
-rw-r--r--tmk_core/protocol/mbed/mbed_driver.h3
-rw-r--r--tmk_core/protocol/ps2_io_mbed.c51
-rw-r--r--tmk_core/protocol/serial_soft.c3
-rw-r--r--tmk_core/protocol/usb_descriptor.c1048
-rw-r--r--tmk_core/protocol/vusb/vusb.c28
-rw-r--r--tmk_core/rules.mk2
36 files changed, 893 insertions, 977 deletions
diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk
index 1846a9b4bc..ecd2fd39a4 100644
--- a/tmk_core/avr.mk
+++ b/tmk_core/avr.mk
@@ -240,7 +240,7 @@ avrdude-split-right: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
$(call EXEC_AVRDUDE,eeprom-righthand.eep)
define EXEC_USBASP
- avrdude -p $(MCU) -c usbasp -U flash:w:$(BUILD_DIR)/$(TARGET).hex
+ avrdude -p $(AVRDUDE_MCU) -c usbasp -U flash:w:$(BUILD_DIR)/$(TARGET).hex
endef
usbasp: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
@@ -321,7 +321,7 @@ extcoff: $(BUILD_DIR)/$(TARGET).elf
bootloader:
make -C lib/lufa/Bootloaders/DFU/ clean
$(TMK_DIR)/make_dfu_header.sh $(ALL_CONFIGS)
- $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne '/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0))
+ $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne 's/\r//;/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0))
$(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0))
$(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0))
$(eval FLASH_SIZE_KB=$(shell n=`expr $(PROGRAM_SIZE_KB) + $(BOOT_SECTION_SIZE_KB)` && echo $$(($$n)) || echo 0))
diff --git a/tmk_core/common.mk b/tmk_core/common.mk
index db55353465..d43950299b 100644
--- a/tmk_core/common.mk
+++ b/tmk_core/common.mk
@@ -203,6 +203,9 @@ ifeq ($(strip $(SHARED_EP_ENABLE)), yes)
TMK_COMMON_DEFS += -DSHARED_EP_ENABLE
endif
+ifeq ($(strip $(LTO_ENABLE)), yes)
+ LINK_TIME_OPTIMIZATION_ENABLE = yes
+endif
ifeq ($(strip $(LINK_TIME_OPTIMIZATION_ENABLE)), yes)
EXTRAFLAGS += -flto
diff --git a/tmk_core/common/action_layer.c b/tmk_core/common/action_layer.c
index 07d78c56d4..4c7d15cd50 100644
--- a/tmk_core/common/action_layer.c
+++ b/tmk_core/common/action_layer.c
@@ -268,7 +268,7 @@ uint8_t layer_switch_get_layer(keypos_t key) {
/* fall back to layer 0 */
return 0;
#else
- return biton32(default_layer_state);
+ return get_highest_layer(default_layer_state);
#endif
}
diff --git a/tmk_core/common/action_layer.h b/tmk_core/common/action_layer.h
index fee9b244df..b8562f5a46 100644
--- a/tmk_core/common/action_layer.h
+++ b/tmk_core/common/action_layer.h
@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#if defined(LAYER_STATE_8BIT)
typedef uint8_t layer_state_t;
-# define get_highest_layer(state) biton8(state)
+# define get_highest_layer(state) biton(state)
#elif defined(LAYER_STATE_16BIT)
typedef uint16_t layer_state_t;
# define get_highest_layer(state) biton16(state)
diff --git a/tmk_core/common/arm_atsam/suspend.c b/tmk_core/common/arm_atsam/suspend.c
index 2dad005706..d1077be4c2 100644
--- a/tmk_core/common/arm_atsam/suspend.c
+++ b/tmk_core/common/arm_atsam/suspend.c
@@ -7,7 +7,8 @@
*
* FIXME: needs doc
*/
-void suspend_idle(uint8_t time) { /* Note: Not used anywhere currently */ }
+void suspend_idle(uint8_t time) { /* Note: Not used anywhere currently */
+}
/** \brief Run user level Power down
*
diff --git a/tmk_core/common/chibios/suspend.c b/tmk_core/common/chibios/suspend.c
index c0f9c28d44..5be1b76777 100644
--- a/tmk_core/common/chibios/suspend.c
+++ b/tmk_core/common/chibios/suspend.c
@@ -15,6 +15,13 @@
# include "backlight.h"
#endif
+#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
+# include "rgblight.h"
+extern rgblight_config_t rgblight_config;
+static bool rgblight_enabled;
+static bool is_suspended;
+#endif
+
/** \brief suspend idle
*
* FIXME: needs doc
@@ -43,6 +50,16 @@ void suspend_power_down(void) {
// TODO: figure out what to power down and how
// shouldn't power down TPM/FTM if we want a breathing LED
// also shouldn't power down USB
+#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
+# ifdef RGBLIGHT_ANIMATIONS
+ rgblight_timer_disable();
+# endif
+ if (!is_suspended) {
+ is_suspended = true;
+ rgblight_enabled = rgblight_config.enable;
+ rgblight_disable_noeeprom();
+ }
+#endif
suspend_power_down_kb();
// on AVR, this enables the watchdog for 15ms (max), and goes to
@@ -104,5 +121,14 @@ void suspend_wakeup_init(void) {
#ifdef BACKLIGHT_ENABLE
backlight_init();
#endif /* BACKLIGHT_ENABLE */
+#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
+ is_suspended = false;
+ if (rgblight_enabled) {
+ rgblight_enable_noeeprom();
+ }
+# ifdef RGBLIGHT_ANIMATIONS
+ rgblight_timer_enable();
+# endif
+#endif
suspend_wakeup_init_kb();
}
diff --git a/tmk_core/common/eeconfig.c b/tmk_core/common/eeconfig.c
index 4cf4ca3ace..7cec4bd7df 100644
--- a/tmk_core/common/eeconfig.c
+++ b/tmk_core/common/eeconfig.c
@@ -2,13 +2,13 @@
#include <stdbool.h>
#include "eeprom.h"
#include "eeconfig.h"
+#include "action_layer.h"
#ifdef STM32_EEPROM_ENABLE
# include "hal.h"
# include "eeprom_stm32.h"
#endif
-extern uint32_t default_layer_state;
/** \brief eeconfig enable
*
* FIXME: needs doc
@@ -51,10 +51,10 @@ void eeconfig_init_quantum(void) {
// TODO: Remove once ARM has a way to configure EECONFIG_HANDEDNESS
// within the emulated eeprom via dfu-util or another tool
#if defined INIT_EE_HANDS_LEFT
- #pragma message "Faking EE_HANDS for left hand"
+# pragma message "Faking EE_HANDS for left hand"
eeprom_update_byte(EECONFIG_HANDEDNESS, 1);
#elif defined INIT_EE_HANDS_RIGHT
- #pragma message "Faking EE_HANDS for right hand"
+# pragma message "Faking EE_HANDS for right hand"
eeprom_update_byte(EECONFIG_HANDEDNESS, 0);
#endif
diff --git a/tmk_core/common/host.c b/tmk_core/common/host.c
index ce39760a5b..e7d92cfac6 100644
--- a/tmk_core/common/host.c
+++ b/tmk_core/common/host.c
@@ -39,6 +39,12 @@ uint8_t host_keyboard_leds(void) {
if (!driver) return 0;
return (*driver->keyboard_leds)();
}
+
+led_t host_keyboard_led_state(void) {
+ if (!driver) return (led_t){0};
+ return (led_t)((*driver->keyboard_leds)());
+}
+
/* send report */
void host_keyboard_send(report_keyboard_t *report) {
if (!driver) return;
diff --git a/tmk_core/common/host.h b/tmk_core/common/host.h
index b2a7f98427..2cffef6e15 100644
--- a/tmk_core/common/host.h
+++ b/tmk_core/common/host.h
@@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdbool.h>
#include "report.h"
#include "host_driver.h"
+#include "led.h"
#define IS_LED_ON(leds, led_name) ((leds) & (1 << (led_name)))
#define IS_LED_OFF(leds, led_name) (~(leds) & (1 << (led_name)))
@@ -41,6 +42,7 @@ host_driver_t *host_get_driver(void);
/* host driver interface */
uint8_t host_keyboard_leds(void);
+led_t host_keyboard_led_state(void);
void host_keyboard_send(report_keyboard_t *report);
void host_mouse_send(report_mouse_t *report);
void host_system_send(uint16_t data);
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index 63ace9793c..af2b2fd48b 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -254,6 +254,7 @@ void keyboard_init(void) {
#endif
#if defined(NKRO_ENABLE) && defined(FORCE_NKRO)
keymap_config.nkro = 1;
+ eeconfig_update_keymap(keymap_config.raw);
#endif
keyboard_post_init_kb(); /* Always keep this last */
}
@@ -296,13 +297,14 @@ void keyboard_task(void) {
}
#endif
if (debug_matrix) matrix_print();
- for (uint8_t c = 0; c < MATRIX_COLS; c++) {
- if (matrix_change & ((matrix_row_t)1 << c)) {
+ matrix_row_t col_mask = 1;
+ for (uint8_t c = 0; c < MATRIX_COLS; c++, col_mask <<= 1) {
+ if (matrix_change & col_mask) {
action_exec((keyevent_t){
- .key = (keypos_t){.row = r, .col = c}, .pressed = (matrix_row & ((matrix_row_t)1 << c)), .time = (timer_read() | 1) /* time should not be 0 */
+ .key = (keypos_t){.row = r, .col = c}, .pressed = (matrix_row & col_mask), .time = (timer_read() | 1) /* time should not be 0 */
});
// record a processed key
- matrix_prev[r] ^= ((matrix_row_t)1 << c);
+ matrix_prev[r] ^= col_mask;
#ifdef QMK_KEYS_PER_SCAN
// only jump out if we have processed "enough" keys.
if (++keys_processed >= QMK_KEYS_PER_SCAN)
diff --git a/tmk_core/common/keycode.h b/tmk_core/common/keycode.h
index fd5d606805..e1059fadf0 100644
--- a/tmk_core/common/keycode.h
+++ b/tmk_core/common/keycode.h
@@ -175,7 +175,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define KC_MPLY KC_MEDIA_PLAY_PAUSE
#define KC_MSEL KC_MEDIA_SELECT
#define KC_EJCT KC_MEDIA_EJECT
-#define KC_MAIL KC_MAIL
#define KC_CALC KC_CALCULATOR
#define KC_MYCM KC_MY_COMPUTER
#define KC_WSCH KC_WWW_SEARCH
diff --git a/tmk_core/common/led.h b/tmk_core/common/led.h
index 2c28fe5401..990282862b 100644
--- a/tmk_core/common/led.h
+++ b/tmk_core/common/led.h
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef LED_H
#define LED_H
#include "stdint.h"
+#include "stdbool.h"
/* FIXME: Add doxygen comments here. */
@@ -32,6 +33,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
extern "C" {
#endif
+typedef union {
+ uint8_t raw;
+ struct {
+ bool num_lock : 1;
+ bool caps_lock : 1;
+ bool scroll_lock : 1;
+ bool compose : 1;
+ bool kana : 1;
+ uint8_t reserved : 3;
+ };
+} led_t;
+
void led_set(uint8_t usb_led);
void led_init_ports(void);
diff --git a/tmk_core/common/mbed/bootloader.c b/tmk_core/common/mbed/bootloader.c
deleted file mode 100644
index 88945eb050..0000000000
--- a/tmk_core/common/mbed/bootloader.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "bootloader.h"
-
-void bootloader_jump(void) {}
diff --git a/tmk_core/common/mbed/suspend.c b/tmk_core/common/mbed/suspend.c
deleted file mode 100644
index 3d0554f87b..0000000000
--- a/tmk_core/common/mbed/suspend.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <stdbool.h>
-
-void suspend_power_down(void) {}
-bool suspend_wakeup_condition(void) { return true; }
-void suspend_wakeup_init(void) {}
diff --git a/tmk_core/common/mbed/timer.c b/tmk_core/common/mbed/timer.c
deleted file mode 100644
index 7e4070af29..0000000000
--- a/tmk_core/common/mbed/timer.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include "cmsis.h"
-#include "timer.h"
-
-/* Mill second tick count */
-volatile uint32_t timer_count = 0;
-
-/* Timer interrupt handler */
-void SysTick_Handler(void) { timer_count++; }
-
-void timer_init(void) {
- timer_count = 0;
- SysTick_Config(SystemCoreClock / 1000); /* 1ms tick */
-}
-
-void timer_clear(void) { timer_count = 0; }
-
-uint16_t timer_read(void) { return (uint16_t)(timer_count & 0xFFFF); }
-
-uint32_t timer_read32(void) { return timer_count; }
-
-uint16_t timer_elapsed(uint16_t last) { return TIMER_DIFF_16(timer_read(), last); }
-
-uint32_t timer_elapsed32(uint32_t last) { return TIMER_DIFF_32(timer_read32(), last); }
diff --git a/tmk_core/common/mbed/xprintf.cpp b/tmk_core/common/mbed/xprintf.cpp
deleted file mode 100644
index 184b7fa7a0..0000000000
--- a/tmk_core/common/mbed/xprintf.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-#include <cstdarg>
-//#include <stdarg.h>
-#include "mbed.h"
-#include "mbed/xprintf.h"
-
-#define STRING_STACK_LIMIT 120
-
-// TODO
-int __xprintf(const char* format, ...) { return 0; }
-
-#if 0
-/* mbed Serial */
-Serial ser(UART_TX, UART_RX);
-
-/* TODO: Need small implementation for embedded */
-int xprintf(const char* format, ...)
-{
- /* copy from mbed/common/RawSerial.cpp */
- std::va_list arg;
- va_start(arg, format);
- int len = vsnprintf(NULL, 0, format, arg);
- if (len < STRING_STACK_LIMIT) {
- char temp[STRING_STACK_LIMIT];
- vsprintf(temp, format, arg);
- ser.puts(temp);
- } else {
- char *temp = new char[len + 1];
- vsprintf(temp, format, arg);
- ser.puts(temp);
- delete[] temp;
- }
- va_end(arg);
- return len;
-
-/* Fail: __builtin_va_arg_pack?
- * https://gcc.gnu.org/onlinedocs/gcc-4.3.5/gcc/Constructing-Calls.html#Constructing-Calls
- void *arg = __builtin_apply_args();
- void *ret = __builtin_apply((void*)(&(ser.printf)), arg, 100);
- __builtin_return(ret)
-*/
-/* Fail: varargs can not be passed to printf
- //int r = ser.printf("test %i\r\n", 123);
- va_list arg;
- va_start(arg, format);
- int r = ser.printf(format, arg);
- va_end(arg);
- return r;
-*/
-}
-#endif
diff --git a/tmk_core/common/mbed/xprintf.h b/tmk_core/common/mbed/xprintf.h
deleted file mode 100644
index e27822d3a8..0000000000
--- a/tmk_core/common/mbed/xprintf.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef XPRINTF_H
-#define XPRINTF_H
-
-//#define xprintf(format, ...) __xprintf(format, ##__VA_ARGS__)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int __xprintf(const char *format, ...);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/tmk_core/common/print.h b/tmk_core/common/print.h
index 20189838fe..04ca558109 100644
--- a/tmk_core/common/print.h
+++ b/tmk_core/common/print.h
@@ -128,38 +128,7 @@ extern "C"
# endif /* USER_PRINT / NORMAL PRINT */
-# elif defined(__arm__) /* __arm__ */
-
-# include "mbed/xprintf.h"
-
-# ifdef USER_PRINT /* USER_PRINT */
-
-// Remove normal print defines
-# define print(s)
-# define println(s)
-# define xprintf(fmt, ...)
-
-// Create user print defines
-# define uprintf(fmt, ...) __xprintf(fmt, ##__VA_ARGS__)
-# define uprint(s) xprintf(s)
-# define uprintln(s) xprintf(s "\r\n")
-
-# else /* NORMAL PRINT */
-
-// Create user & normal print defines
-# define xprintf(fmt, ...) __xprintf(fmt, ##__VA_ARGS__)
-# define print(s) xprintf(s)
-# define println(s) xprintf(s "\r\n")
-# define uprint(s) print(s)
-# define uprintln(s) println(s)
-# define uprintf(fmt, ...) xprintf(fmt, ##__VA_ARGS__)
-
-# endif /* USER_PRINT / NORMAL PRINT */
-
-/* TODO: to select output destinations: UART/USBSerial */
-# define print_set_sendchar(func)
-
-# endif /* __AVR__ / PROTOCOL_CHIBIOS / PROTOCOL_ARM_ATSAM / __arm__ */
+# endif /* __AVR__ / PROTOCOL_CHIBIOS / PROTOCOL_ARM_ATSAM */
// User print disables the normal print messages in the body of QMK/TMK code and
// is meant as a lightweight alternative to NOPRINT. Use it when you only want to do
diff --git a/tmk_core/common/wait.h b/tmk_core/common/wait.h
index cb1f386a61..c82cd2d65a 100644
--- a/tmk_core/common/wait.h
+++ b/tmk_core/common/wait.h
@@ -33,8 +33,6 @@ extern "C" {
# include "clks.h"
# define wait_ms(ms) CLK_delay_ms(ms)
# define wait_us(us) CLK_delay_us(us)
-#elif defined(__arm__)
-# include "wait_api.h"
#else // Unit tests
void wait_ms(uint32_t ms);
# define wait_us(us) wait_ms(us / 1000)
diff --git a/tmk_core/protocol.mk b/tmk_core/protocol.mk
index 78b9deb297..0c41642b9b 100644
--- a/tmk_core/protocol.mk
+++ b/tmk_core/protocol.mk
@@ -1,58 +1,57 @@
PROTOCOL_DIR = protocol
-
-ifdef PS2_MOUSE_ENABLE
+ifeq ($(strip $(PS2_MOUSE_ENABLE)), yes)
SRC += $(PROTOCOL_DIR)/ps2_mouse.c
OPT_DEFS += -DPS2_MOUSE_ENABLE
OPT_DEFS += -DMOUSE_ENABLE
endif
-ifdef PS2_USE_BUSYWAIT
+ifeq ($(strip $(PS2_USE_BUSYWAIT)), yes)
SRC += protocol/ps2_busywait.c
SRC += protocol/ps2_io_avr.c
OPT_DEFS += -DPS2_USE_BUSYWAIT
endif
-ifdef PS2_USE_INT
+ifeq ($(strip $(PS2_USE_INT)), yes)
SRC += protocol/ps2_interrupt.c
SRC += protocol/ps2_io_avr.c
OPT_DEFS += -DPS2_USE_INT
endif
-ifdef PS2_USE_USART
+ifeq ($(strip $(PS2_USE_USART)), yes)
SRC += protocol/ps2_usart.c
SRC += protocol/ps2_io_avr.c
OPT_DEFS += -DPS2_USE_USART
endif
-ifdef SERIAL_MOUSE_MICROSOFT_ENABLE
+ifeq ($(strip $(SERIAL_MOUSE_MICROSOFT_ENABLE)), yes)
SRC += $(PROTOCOL_DIR)/serial_mouse_microsoft.c
OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MICROSOFT \
-DMOUSE_ENABLE
endif
-ifdef SERIAL_MOUSE_MOUSESYSTEMS_ENABLE
+ifeq ($(strip $(SERIAL_MOUSE_MOUSESYSTEMS_ENABLE)), yes)
SRC += $(PROTOCOL_DIR)/serial_mouse_mousesystems.c
OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MOUSESYSTEMS \
-DMOUSE_ENABLE
endif
-ifdef SERIAL_MOUSE_USE_SOFT
+ifeq ($(strip $(SERIAL_MOUSE_USE_SOFT)), yes)
SRC += $(PROTOCOL_DIR)/serial_soft.c
endif
-ifdef SERIAL_MOUSE_USE_UART
+ifeq ($(strip $(SERIAL_MOUSE_USE_UART)), yes)
SRC += $(PROTOCOL_DIR)/serial_uart.c
endif
-ifdef ADB_MOUSE_ENABLE
- OPT_DEFS += -DADB_MOUSE_ENABLE -DMOUSE_ENABLE
+ifeq ($(strip $(ADB_MOUSE_ENABLE)), yes)
+ OPT_DEFS += -DADB_MOUSE_ENABLE -DMOUSE_ENABLE
endif
-ifdef XT_ENABLE
- SRC += $(PROTOCOL_DIR)/xt_interrupt.c
- OPT_DEFS += -DXT_ENABLE
+ifeq ($(strip $(XT_ENABLE)), yes)
+ SRC += $(PROTOCOL_DIR)/xt_interrupt.c
+ OPT_DEFS += -DXT_ENABLE
endif
# Search Path
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h b/tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h
index 2f8a39bdd8..fb97f63cef 100644
--- a/tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h
+++ b/tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h
@@ -186,9 +186,10 @@ COMPILER_PACK_RESET()
#define USB_HID_COUNTRY_UK 32 // UK
#define USB_HID_COUNTRY_US 33 // US
#define USB_HID_COUNTRY_YUGOSLAVIA 34 // Yugoslavia
-#define USB_HID_COUNTRY_TURKISH_F 35 // Turkish-F
- //! @}
- //! @}
+#define USB_HID_COUNTRY_TURKISH_F \
+ 35 // Turkish-F
+ //! @}
+ //! @}
//! @}
//! \name HID KEYS values
diff --git a/tmk_core/protocol/chibios/main.c b/tmk_core/protocol/chibios/main.c
index de2b493b84..c304f4d795 100644
--- a/tmk_core/protocol/chibios/main.c
+++ b/tmk_core/protocol/chibios/main.c
@@ -32,6 +32,11 @@
#include "sendchar.h"
#include "debug.h"
#include "printf.h"
+#include "rgblight_reconfig.h"
+
+#if (defined(RGB_MIDI) || defined(RGBLIGHT_ANIMATIONS)) && defined(RGBLIGHT_ENABLE)
+# include "rgblight.h"
+#endif
#ifdef SLEEP_LED_ENABLE
# include "sleep_led.h"
#endif
@@ -215,5 +220,8 @@ int main(void) {
#ifdef RAW_ENABLE
raw_hid_task();
#endif
+#if defined(RGBLIGHT_ANIMATIONS) && defined(RGBLIGHT_ENABLE)
+ rgblight_task();
+#endif
}
}
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index c8a6bbb43f..740763de2f 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -15,6 +15,16 @@
* GPL v2 or later.
*/
+/*
+ * Implementation notes:
+ *
+ * USBEndpointConfig - Configured using explicit order instead of struct member name.
+ * This is due to ChibiOS hal LLD differences, which is dependent on hardware,
+ * "USBv1" devices have `ep_buffers` and "OTGv1" have `in_multiplier`.
+ * Given `USBv1/hal_usb_lld.h` marks the field as "not currently used" this code file
+ * makes the assumption this is safe to avoid littering with preprocessor directives.
+ */
+
#include "ch.h"
#include "hal.h"
@@ -98,7 +108,7 @@ static const USBDescriptor *usb_get_descriptor_cb(USBDriver *usbp, uint8_t dtype
#ifndef KEYBOARD_SHARED_EP
/* keyboard endpoint state structure */
static USBInEndpointState kbd_ep_state;
-/* keyboard endpoint initialization structure (IN) */
+/* keyboard endpoint initialization structure (IN) - see USBEndpointConfig comment at top of file */
static const USBEndpointConfig kbd_ep_config = {
USB_EP_MODE_TYPE_INTR, /* Interrupt EP */
NULL, /* SETUP packet notification callback */
@@ -117,7 +127,7 @@ static const USBEndpointConfig kbd_ep_config = {
/* mouse endpoint state structure */
static USBInEndpointState mouse_ep_state;
-/* mouse endpoint initialization structure (IN) */
+/* mouse endpoint initialization structure (IN) - see USBEndpointConfig comment at top of file */
static const USBEndpointConfig mouse_ep_config = {
USB_EP_MODE_TYPE_INTR, /* Interrupt EP */
NULL, /* SETUP packet notification callback */
@@ -136,7 +146,7 @@ static const USBEndpointConfig mouse_ep_config = {
/* shared endpoint state structure */
static USBInEndpointState shared_ep_state;
-/* shared endpoint initialization structure (IN) */
+/* shared endpoint initialization structure (IN) - see USBEndpointConfig comment at top of file */
static const USBEndpointConfig shared_ep_config = {
USB_EP_MODE_TYPE_INTR, /* Interrupt EP */
NULL, /* SETUP packet notification callback */
@@ -164,58 +174,62 @@ typedef struct {
QMKUSBDriver driver;
} usb_driver_config_t;
-#define QMK_USB_DRIVER_CONFIG(stream, notification, fixedsize) \
- { \
- .queue_capacity_in = stream##_IN_CAPACITY, .queue_capacity_out = stream##_OUT_CAPACITY, \
- .in_ep_config = {.ep_mode = stream##_IN_MODE, \
- .setup_cb = NULL, \
- .in_cb = qmkusbDataTransmitted, \
- .out_cb = NULL, \
- .in_maxsize = stream##_EPSIZE, \
- .out_maxsize = 0, /* The pointer to the states will be filled during initialization */ \
- .in_state = NULL, \
- .out_state = NULL, \
- .ep_buffers = 2, \
- .setup_buf = NULL}, \
- .out_ep_config = \
- { \
- .ep_mode = stream##_OUT_MODE, \
- .setup_cb = NULL, \
- .in_cb = NULL, \
- .out_cb = qmkusbDataReceived, \
- .in_maxsize = 0, \
- .out_maxsize = stream##_EPSIZE, /* The pointer to the states will be filled during initialization */ \
- .in_state = NULL, \
- .out_state = NULL, \
- .ep_buffers = 2, \
- .setup_buf = NULL, \
- }, \
- .int_ep_config = \
- { \
- .ep_mode = USB_EP_MODE_TYPE_INTR, \
- .setup_cb = NULL, \
- .in_cb = qmkusbInterruptTransmitted, \
- .out_cb = NULL, \
- .in_maxsize = CDC_NOTIFICATION_EPSIZE, \
- .out_maxsize = 0, /* The pointer to the states will be filled during initialization */ \
- .in_state = NULL, \
- .out_state = NULL, \
- .ep_buffers = 2, \
- .setup_buf = NULL, \
- }, \