summaryrefslogtreecommitdiffstats
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/audio/musical_notes.h4
-rw-r--r--quantum/config_common.h43
-rw-r--r--quantum/debounce.c52
-rw-r--r--quantum/debounce.h11
-rw-r--r--quantum/keymap_common.c2
-rw-r--r--quantum/matrix.c32
-rw-r--r--quantum/mcu_selection.mk70
-rw-r--r--quantum/process_keycode/process_combo.c18
-rw-r--r--quantum/process_keycode/process_combo.h1
-rw-r--r--quantum/process_keycode/process_terminal.c6
-rw-r--r--quantum/process_keycode/process_unicode_common.c2
-rw-r--r--quantum/process_keycode/process_unicodemap.c33
-rw-r--r--quantum/process_keycode/process_unicodemap.h4
-rw-r--r--quantum/quantum.c5
-rw-r--r--quantum/quantum.h3
-rw-r--r--quantum/quantum_keycodes.h72
-rw-r--r--quantum/split_common/i2c.h5
-rw-r--r--quantum/split_common/matrix.c639
-rw-r--r--quantum/split_common/matrix.h30
-rw-r--r--quantum/split_common/serial.h5
-rw-r--r--quantum/split_common/split_flags.h9
-rw-r--r--quantum/split_common/split_util.c152
-rw-r--r--quantum/split_common/split_util.h15
-rw-r--r--quantum/split_common/transport.c224
-rw-r--r--quantum/split_common/transport.h10
-rw-r--r--quantum/stm32/chconf.h520
-rw-r--r--quantum/stm32/halconf.h388
-rw-r--r--quantum/stm32/mcuconf.h257
-rw-r--r--quantum/stm32/proton_c.mk44
-rw-r--r--quantum/template/avr/config.h2
-rw-r--r--quantum/template/avr/template.c2
-rw-r--r--quantum/template/avr/template.h38
-rw-r--r--quantum/template/base/keymaps/default/config.h2
-rw-r--r--quantum/template/base/keymaps/default/keymap.c2
-rw-r--r--quantum/template/base/template.h (renamed from quantum/template/ps2avrgb/template.h)7
-rw-r--r--quantum/template/ps2avrgb/rules.mk2
-rw-r--r--quantum/template/ps2avrgb/template.c2
37 files changed, 1987 insertions, 726 deletions
diff --git a/quantum/audio/musical_notes.h b/quantum/audio/musical_notes.h
index 065608ccce..ce8d47d1c1 100644
--- a/quantum/audio/musical_notes.h
+++ b/quantum/audio/musical_notes.h
@@ -61,7 +61,11 @@
// Notes - # = Octave
+#ifdef __arm__
+#define NOTE_REST 1.00f
+#else
#define NOTE_REST 0.00f
+#endif
/* These notes are currently bugged
#define NOTE_C0 16.35f
diff --git a/quantum/config_common.h b/quantum/config_common.h
index cbff372eaf..0b2e408a43 100644
--- a/quantum/config_common.h
+++ b/quantum/config_common.h
@@ -21,6 +21,9 @@
#define ROW2COL 1
#define CUSTOM_MATRIX 2 /* Disables built-in matrix scanning code */
+// useful for direct pin mapping
+#define NO_PIN (~0)
+
#ifdef __AVR__
#ifndef __ASSEMBLER__
#include <avr/io.h>
@@ -125,6 +128,45 @@
#endif
#elif defined(PROTOCOL_CHIBIOS)
+ // Defines mapping for Proton C replacement
+ #ifdef CONVERT_TO_PROTON_C
+ // Left side (front)
+ #define D3 PAL_LINE(GPIOA, 9)
+ #define D2 PAL_LINE(GPIOA, 10)
+ // GND
+ // GND
+ #define D1 PAL_LINE(GPIOB, 7)
+ #define D0 PAL_LINE(GPIOB, 6)
+ #define D4 PAL_LINE(GPIOB, 5)
+ #define C6 PAL_LINE(GPIOB, 4)
+ #define D7 PAL_LINE(GPIOB, 3)
+ #define E6 PAL_LINE(GPIOB, 2)
+ #define B4 PAL_LINE(GPIOB, 1)
+ #define B5 PAL_LINE(GPIOB, 0)
+
+ // Right side (front)
+ // RAW
+ // GND
+ // RESET
+ // VCC
+ #define F4 PAL_LINE(GPIOA, 2)
+ #define F5 PAL_LINE(GPIOA, 1)
+ #define F6 PAL_LINE(GPIOA, 0)
+ #define F7 PAL_LINE(GPIOB, 8)
+ #define B1 PAL_LINE(GPIOB, 13)
+ #define B3 PAL_LINE(GPIOB, 14)
+ #define B2 PAL_LINE(GPIOB, 15)
+ #define B6 PAL_LINE(GPIOB, 9)
+
+ // LEDs (only D5/C13 uses an actual LED)
+ #ifdef CONVERT_TO_PROTON_C_RXLED
+ #define D5 PAL_LINE(GPIOC, 13)
+ #define B0 PAL_LINE(GPIOC, 13)
+ #else
+ #define D5 PAL_LINE(GPIOC, 13)
+ #define B0 PAL_LINE(GPIOC, 14)
+ #endif
+ #else
#define A0 PAL_LINE(GPIOA, 0)
#define A1 PAL_LINE(GPIOA, 1)
#define A2 PAL_LINE(GPIOA, 2)
@@ -221,6 +263,7 @@
#define F13 PAL_LINE(GPIOF, 13)
#define F14 PAL_LINE(GPIOF, 14)
#define F15 PAL_LINE(GPIOF, 15)
+ #endif
#endif
/* USART configuration */
diff --git a/quantum/debounce.c b/quantum/debounce.c
new file mode 100644
index 0000000000..929023ab2d
--- /dev/null
+++ b/quantum/debounce.c
@@ -0,0 +1,52 @@
+
+#include "matrix.h"
+#include "timer.h"
+#include "quantum.h"
+
+#ifndef DEBOUNCING_DELAY
+# define DEBOUNCING_DELAY 5
+#endif
+
+void debounce_init(uint8_t num_rows) {
+}
+
+#if DEBOUNCING_DELAY > 0
+
+static bool debouncing = false;
+
+void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
+ static uint16_t debouncing_time;
+
+ if (changed) {
+ debouncing = true;
+ debouncing_time = timer_read();
+ }
+
+ if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCING_DELAY)) {
+ for (uint8_t i = 0; i < num_rows; i++) {
+ cooked[i] = raw[i];
+ }
+ debouncing = false;
+ }
+}
+
+bool debounce_active(void) {
+ return debouncing;
+}
+
+#else
+
+// no debounce
+void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
+ if (changed)
+ {
+ for (uint8_t i = 0; i < num_rows; i++) {
+ cooked[i] = raw[i];
+ }
+ }
+}
+
+bool debounce_active(void) {
+ return false;
+}
+#endif
diff --git a/quantum/debounce.h b/quantum/debounce.h
new file mode 100644
index 0000000000..360af77e78
--- /dev/null
+++ b/quantum/debounce.h
@@ -0,0 +1,11 @@
+#pragma once
+
+// raw is the current key state
+// on entry cooked is the previous debounced state
+// on exit cooked is the current debounced state
+// changed is true if raw has changed since the last call
+void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed);
+
+bool debounce_active(void);
+
+void debounce_init(uint8_t num_rows); \ No newline at end of file
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c
index f6c8b70d28..1a6af9e08f 100644
--- a/quantum/keymap_common.c
+++ b/quantum/keymap_common.c
@@ -120,7 +120,7 @@ action_t action_for_key(uint8_t layer, keypos_t key)
break;
case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX: ;
// OSM(mod) - One-shot mod
- mod = keycode & 0xFF;
+ mod = mod_config(keycode & 0xFF);
action.code = ACTION_MODS_ONESHOT(mod);
break;
case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX:
diff --git a/quantum/matrix.c b/quantum/matrix.c
index 292171490c..71292db511 100644
--- a/quantum/matrix.c
+++ b/quantum/matrix.c
@@ -21,10 +21,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "debug.h"
#include "util.h"
#include "matrix.h"
-#include "timer.h"
+#include "debounce.h"
#include "quantum.h"
-
#if (MATRIX_COLS <= 8)
# define print_matrix_header() print("\nr/c 01234567\n")
# define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row))
@@ -52,8 +51,9 @@ static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
#endif
/* matrix state(1:on, 0:off) */
-static matrix_row_t matrix[MATRIX_ROWS];
+static matrix_row_t raw_matrix[MATRIX_ROWS];
+static matrix_row_t matrix[MATRIX_ROWS];
#if (DIODE_DIRECTION == COL2ROW)
static void init_cols(void);
@@ -120,34 +120,40 @@ void matrix_init(void) {
// initialize matrix state: all keys off
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
+ raw_matrix[i] = 0;
matrix[i] = 0;
}
+ debounce_init(MATRIX_ROWS);
matrix_init_quantum();
}
uint8_t matrix_scan(void)
{
+ bool changed = false;
#if (DIODE_DIRECTION == COL2ROW)
- // Set row, read cols
- for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
- read_cols_on_row(matrix, current_row);
- }
+ // Set row, read cols
+ for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
+ changed |= read_cols_on_row(raw_matrix, current_row);
+ }
#elif (DIODE_DIRECTION == ROW2COL)
- // Set col, read rows
- for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
- read_rows_on_col(matrix, current_col);
- }
+ // Set col, read rows
+ for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
+ changed |= read_rows_on_col(raw_matrix, current_col);
+ }
#endif
- matrix_scan_quantum();
- return 1;
+ debounce(raw_matrix, matrix, MATRIX_ROWS, changed);
+
+ matrix_scan_quantum();
+ return 1;
}
//Deprecated.
bool matrix_is_modified(void)
{
+ if (debounce_active()) return false;
return true;
}
diff --git a/quantum/mcu_selection.mk b/quantum/mcu_selection.mk
new file mode 100644
index 0000000000..209b578ea5
--- /dev/null
+++ b/quantum/mcu_selection.mk
@@ -0,0 +1,70 @@
+
+ifneq ($(findstring STM32F303, $(MCU)),)
+ ## chip/board settings
+ # - the next two should match the directories in
+ # <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
+ MCU_FAMILY ?= STM32
+ MCU_SERIES ?= STM32F3xx
+
+ # Linker script to use
+ # - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
+ # or <this_dir>/ld/
+ MCU_LDSCRIPT ?= STM32F303xC
+
+ # Startup code to use
+ # - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
+ MCU_STARTUP ?= stm32f3xx
+
+ # Board: it should exist either in <chibios>/os/hal/boards/
+ # or <this_dir>/boards
+ BOARD ?= GENERIC_STM32_F303XC
+
+ # Cortex version
+ MCU = cortex-m4
+
+ # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
+ ARMV ?= 7
+
+ USE_FPU = yes
+
+ # Vector table for application
+ # 0x00000000-0x00001000 area is occupied by bootlaoder.*/
+ # The CORTEX_VTOR... is needed only for MCHCK/Infinity KB
+ # OPT_DEFS = -DCORTEX_VTOR_INIT=0x08005000
+
+ # Options to pass to dfu-util when flashing
+ DFU_ARGS ?= -d 0483:df11 -a 0 -s 0x08000000:leave
+endif
+
+ifneq (,$(filter $(MCU),atmega32u4 at90usb1286))
+ # Processor frequency.
+ # This will define a symbol, F_CPU, in all source code files equal to the
+ # processor frequency in Hz. You can then use this symbol in your source code to
+ # calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+ # automatically to create a 32-bit value in your source code.
+ #
+ # This will be an integer division of F_USB below, as it is sourced by
+ # F_USB after it has run through any CPU prescalers. Note that this value
+ # does not *change* the processor frequency - it should merely be updated to
+ # reflect the processor speed set externally so that the code can use accurate
+ # software delays.
+ F_CPU ?= 16000000
+
+ # LUFA specific
+ #
+ # Target architecture (see library "Board Types" documentation).
+ ARCH ?= AVR8
+
+ # Input clock frequency.
+ # This will define a symbol, F_USB, in all source code files equal to the
+ # input clock frequency (before any prescaling is performed) in Hz. This value may
+ # differ from F_CPU if prescaling is used on the latter, and is required as the
+ # raw input clock is fed directly to the PLL sections of the AVR for high speed
+ # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+ # at the end, this will be done automatically to create a 32-bit value in your
+ # source code.
+ #
+ # If no clock division is performed on the input clock inside the AVR (via the
+ # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+ F_USB ?= $(F_CPU)
+endif
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c
index 6e9c28e4fc..13f8bbb331 100644
--- a/quantum/process_keycode/process_combo.c
+++ b/quantum/process_keycode/process_combo.c
@@ -18,9 +18,6 @@
#include "print.h"
-#define COMBO_TIMER_ELAPSED -1
-
-
__attribute__ ((weak))
combo_t key_combos[COMBO_COUNT] = {
@@ -65,7 +62,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
if (-1 == (int8_t)index) return false;
/* The combos timer is used to signal whether the combo is active */
- bool is_combo_active = COMBO_TIMER_ELAPSED == combo->timer ? false : true;
+ bool is_combo_active = combo->is_active;
if (record->event.pressed) {
KEY_STATE_DOWN(index);
@@ -73,9 +70,10 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
if (is_combo_active) {
if (ALL_COMBO_KEYS_ARE_DOWN) { /* Combo was pressed */
send_combo(combo->keycode, true);
- combo->timer = COMBO_TIMER_ELAPSED;
+ combo->is_active = false;
} else { /* Combo key was pressed */
combo->timer = timer_read();
+ combo->is_active = true;
#ifdef COMBO_ALLOW_ACTION_KEYS
combo->prev_record = *record;
#else
@@ -99,6 +97,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
send_keyboard_report();
unregister_code16(keycode);
#endif
+ combo->is_active = false;
combo->timer = 0;
}
@@ -106,6 +105,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
}
if (NO_COMBO_KEYS_ARE_DOWN) {
+ combo->is_active = true;
combo->timer = 0;
}
@@ -132,14 +132,14 @@ void matrix_scan_combo(void)
#pragma GCC diagnostic ignored "-Warray-bounds"
combo_t *combo = &key_combos[i];
#pragma GCC diagnostic pop
- if (combo->timer &&
- combo->timer != COMBO_TIMER_ELAPSED &&
+ if (combo->is_active &&
+ combo->timer &&
timer_elapsed(combo->timer) > COMBO_TERM) {
-
+
/* This disables the combo, meaning key events for this
* combo will be handled by the next processors in the chain
*/
- combo->timer = COMBO_TIMER_ELAPSED;
+ combo->is_active = false;
#ifdef COMBO_ALLOW_ACTION_KEYS
process_action(&combo->prev_record,
diff --git a/quantum/process_keycode/process_combo.h b/quantum/process_keycode/process_combo.h
index a5dbd788a4..a5787c9ed3 100644
--- a/quantum/process_keycode/process_combo.h
+++ b/quantum/process_keycode/process_combo.h
@@ -33,6 +33,7 @@ typedef struct
uint8_t state;
#endif
uint16_t timer;
+ bool is_active;
#ifdef COMBO_ALLOW_ACTION_KEYS
keyrecord_t prev_record;
#else
diff --git a/quantum/process_keycode/process_terminal.c b/quantum/process_keycode/process_terminal.c
index 6998639f20..e791deffc1 100644
--- a/quantum/process_keycode/process_terminal.c
+++ b/quantum/process_keycode/process_terminal.c
@@ -273,11 +273,17 @@ bool process_terminal(uint16_t keycode, keyrecord_t *record) {
disable_terminal();
return false;
}
+
+ if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
+ keycode = keycode & 0xFF;
+ }
+
if (keycode < 256) {
uint8_t str_len;
char char_to_add;
switch (keycode) {
case KC_ENTER:
+ case KC_KP_ENTER:
push_to_cmd_buffer();
current_cmd_buffer_pos = 0;
process_terminal_command();
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c
index 3286f45b5d..b64feb7003 100644
--- a/quantum/process_keycode/process_unicode_common.c
+++ b/quantum/process_keycode/process_unicode_common.c
@@ -216,7 +216,7 @@ bool process_unicode_common(uint16_t keycode, keyrecord_t *record) {
#if defined(UNICODE_ENABLE)
return process_unicode(keycode, record);
#elif defined(UNICODEMAP_ENABLE)
- return process_unicode_map(keycode, record);
+ return process_unicodemap(keycode, record);
#elif defined(UCIS_ENABLE)
return process_ucis(keycode, record);
#else
diff --git a/quantum/process_keycode/process_unicodemap.c b/quantum/process_keycode/process_unicodemap.c
index 75f35112b1..cee9acb5fc 100644
--- a/quantum/process_keycode/process_unicodemap.c
+++ b/quantum/process_keycode/process_unicodemap.c
@@ -18,8 +18,7 @@
#include "process_unicode_common.h"
__attribute__((weak))
-const uint32_t PROGMEM unicode_map[] = {
-};
+const uint32_t PROGMEM unicode_map[] = {};
void register_hex32(uint32_t hex) {
bool onzerostart = true;
@@ -42,26 +41,26 @@ void register_hex32(uint32_t hex) {
}
__attribute__((weak))
-void unicode_map_input_error() {}
+void unicodemap_input_error() {}
-bool process_unicode_map(uint16_t keycode, keyrecord_t *record) {
- uint8_t input_mode = get_unicode_input_mode();
- if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) {
- const uint32_t* map = unicode_map;
- uint16_t index = keycode - QK_UNICODE_MAP;
- uint32_t code = pgm_read_dword(&map[index]);
- if (code > 0xFFFF && code <= 0x10ffff && input_mode == UC_OSX) {
+bool process_unicodemap(uint16_t keycode, keyrecord_t *record) {
+ if ((keycode & QK_UNICODEMAP) == QK_UNICODEMAP && record->event.pressed) {
+ uint16_t index = keycode - QK_UNICODEMAP;
+ uint32_t code = pgm_read_dword(unicode_map + index);
+ uint8_t input_mode = get_unicode_input_mode();
+
+ if (code > 0xFFFF && code <= 0x10FFFF && input_mode == UC_OSX) {
// Convert to UTF-16 surrogate pair
code -= 0x10000;
- uint32_t lo = code & 0x3ff;
- uint32_t hi = (code & 0xffc00) >> 10;
+ uint32_t lo = code & 0x3FF, hi = (code & 0xFFC00) >> 10;
+
unicode_input_start();
- register_hex32(hi + 0xd800);
- register_hex32(lo + 0xdc00);
+ register_hex32(hi + 0xD800);
+ register_hex32(lo + 0xDC00);
unicode_input_finish();
- } else if ((code > 0x10ffff && input_mode == UC_OSX) || (code > 0xFFFFF && input_mode == UC_LNX)) {
- // when character is out of range supported by the OS
- unicode_map_input_error();
+ } else if ((code > 0x10FFFF && input_mode == UC_OSX) || (code > 0xFFFFF && input_mode == UC_LNX)) {
+ // Character is out of range supported by the OS
+ unicodemap_input_error();
} else {
unicode_input_start();
register_hex32(code);
diff --git a/quantum/process_keycode/process_unicodemap.h b/quantum/process_keycode/process_unicodemap.h
index f6d64bb86b..5764697f84 100644
--- a/quantum/process_keycode/process_unicodemap.h
+++ b/quantum/process_keycode/process_unicodemap.h
@@ -19,5 +19,5 @@
#include "quantum.h"
#include "process_unicode_common.h"
-void unicode_map_input_error(void);
-bool process_unicode_map(uint16_t keycode, keyrecord_t *record);
+void unicodemap_input_error(void);
+bool process_unicodemap(uint16_t keycode, keyrecord_t *record);
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 85db100ab4..5d8ffe34eb 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -15,6 +15,11 @@
*/
#include "quantum.h"
+
+#if !defined(RGBLIGHT_ENABLE) && !defined(RGB_MATRIX_ENABLE)
+ #include "rgb.h"
+#endif
+
#ifdef PROTOCOL_LUFA
#include "outputselect.h"
#endif
diff --git a/quantum/quantum.h b/quantum/quantum.h
index f78915fdfb..56a6a1a991 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -30,9 +30,6 @@
#ifdef BACKLIGHT_ENABLE
#include "backlight.h"
#endif
-#if !defined(RGBLIGHT_ENABLE) && !defined(RGB_MATRIX_ENABLE)
- #include "rgb.h"
-#endif
#ifdef RGBLIGHT_ENABLE
#include "rgblight.h"
#else
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index 2b309f4d52..0462291c2b 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -86,8 +86,8 @@ enum quantum_keycodes {
QK_UNICODE_MAX = 0xFFFF,
#endif
#ifdef UNICODEMAP_ENABLE
- QK_UNICODE_MAP = 0x8000,
- QK_UNICODE_MAP_MAX = 0x83FF,
+ QK_UNICODEMAP = 0x8000,
+ QK_UNICODEMAP_MAX = 0x83FF,
#endif
// Loose keycodes - to be used directly
@@ -489,9 +489,8 @@ enum quantum_keycodes {
#define SWIN(kc) SGUI(kc)
#define LCA(kc) (QK_LCTL | QK_LALT | (kc))
-#define MOD_HYPR 0xf
-#define MOD_MEH 0x7
-
+#define MOD_HYPR 0xF
+#define MOD_MEH 0x7
// Aliases for shifted symbols
// Each key has a 4-letter code, and some have longer aliases too.
@@ -568,9 +567,12 @@ enum quantum_keycodes {
#define FUNC(kc) (QK_FUNCTION | (kc))
// Aliases
+#define C(kc) LCTL(kc)
#define S(kc) LSFT(kc)
-#define F(kc) FUNC(kc)
+#define A(kc) LALT(kc)
+#define G(kc) LGUI(kc)
+#define F(kc) FUNC(kc)
#define M(kc) (QK_MACRO | (kc))
#define MACROTAP(kc) (QK_MACRO | (FUNC_TAP << 8) | (kc))
@@ -601,7 +603,7 @@ enum quantum_keycodes {
#define RGB_M_T RGB_MODE_RGBTEST
// L-ayer, T-ap - 256 keycode max, 16 layer max
-#define LT(layer, kc) (QK_LAYER_TAP | ((layer & 0xF) << 8) | ((kc) & 0xFF))
+#define LT(layer, kc) (QK_LAYER_TAP | (((layer) & 0xF) << 8) | ((kc) & 0xFF))
#define AG_SWAP MAGIC_SWAP_ALT_GUI
#define AG_NORM MAGIC_UNSWAP_ALT_GUI
@@ -615,79 +617,77 @@ enum quantum_keycodes {
// In fact, we changed it to assume ON_PRESS for sanity/simplicity. If needed, you can add your own
// keycode modeled after the old version, kept below for this.
/* #define TO(layer, when) (QK_TO | (when << 0x4) | (layer & 0xFF)) */
-#define TO(layer) (QK_TO | (ON_PRESS << 0x4) | (layer & 0xFF))
+#define TO(layer) (QK_TO | (ON_PRESS << 0x4) | ((layer) & 0xFF))
// Momentary switch layer - 256 layer max
-#define MO(layer) (QK_MOMENTARY | (layer & 0xFF))
+#define MO(layer) (QK_MOMENTARY | ((layer) & 0xFF))
// Set default layer - 256 layer max
-#define DF(layer) (QK_DEF_LAYER | (layer & 0xFF))
+#define DF(layer) (QK_DEF_LAYER | ((layer) & 0xFF))
// Toggle to layer - 256 layer max
-#define TG(layer) (QK_TOGGLE_LAYER | (layer & 0xFF))
+#define TG(layer) (QK_TOGGLE_LAYER | ((layer) & 0xFF))
// One-shot layer - 256 layer max
-#define OSL(layer) (QK_ONE_SHOT_LAYER | (layer & 0xFF))
+#define OSL(layer) (QK_ONE_SHOT_LAYER | ((layer) & 0xFF))
// L-ayer M-od: Momentary switch layer with modifiers active - 16 layer max, left mods only
-#define LM(layer, mod) (QK_LAYER_MOD | ((layer & 0xF) << 4) | ((mod) & 0xF))
+#define LM(layer, mod) (QK_LAYER_MOD | (((layer) & 0xF) << 4) | ((mod) & 0xF))
// One-shot mod
#define OSM(mod) (QK_ONE_SHOT_MOD | ((mod) & 0xFF))
// Layer tap-toggle
-#define TT(layer) (QK_LAYER_TAP_TOGGLE | (layer & 0xFF))
+#define TT(layer) (QK_LAYER_TAP_TOGGLE | ((layer) & 0xFF))
// M-od, T-ap - 256 keycode max
#define MT(mod, kc) (QK_MOD_TAP | (((mod) & 0x1F) << 8) | ((kc) & 0xFF))
-#define CTL_T(kc) MT(MOD_LCTL, kc)
#define LCTL_T(kc) MT(MOD_LCTL, kc)
#define RCTL_T(kc) MT(MOD_RCTL, kc)
+#define CTL_T(kc) LCTL_T(kc)
-#define SFT_T(kc) MT(MOD_LSFT, kc)
#define LSFT_T(kc) MT(MOD_LSFT, kc)
#define RSFT_T(kc) MT(MOD_RSFT, kc)
+#define SFT_T(kc) LSFT_T(kc)
-#define ALT_T(kc) MT(MOD_LALT, kc)
#define LALT_T(kc) MT(MOD_LALT, kc)
#define RALT_T(kc) MT(MOD_RALT, kc)
+#define ALT_T(kc) LALT_T(kc)
#define ALGR_T(kc) RALT_T(kc)
-#define GUI_T(kc) MT(MOD_LGUI, kc)
-#define CMD_T(kc) GUI_T(kc)
-#define WIN_T(kc) GUI_T(kc)
#define LGUI_T(kc) MT(MOD_LGUI, kc)
+#define RGUI_T(kc) MT(MOD_RGUI, kc)
#define LCMD_T(kc) LGUI_T(kc)
#define LWIN_T(kc) LGUI_T(kc)
-#define RGUI_T(kc) MT(MOD_RGUI, kc)
#define RCMD_T(kc) RGUI_T(kc)
#define RWIN_T(kc) RGUI_T(kc)
-
-#define C_S_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) // Control + Shift e.g. for gnome-terminal
-#define MEH_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT, kc) // Meh is a less hyper version of the Hyper key -- doesn't include Win or Cmd, so just alt+shift+ctrl
-#define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) // Left control alt and gui
-#define RCAG_T(kc) MT(MOD_RCTL | MOD_RALT | MOD_RGUI, kc) // Right control alt and gui
-#define ALL_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI, kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/
-#define SGUI_T(kc) MT(MOD_LGUI | MOD_LSFT, kc)
+#define GUI_T(kc) LGUI_T(kc)
+#define CMD_T(kc) LCMD_T(kc)
+#define WIN_T(kc) LWIN_T(kc)
+
+#define C_S_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) // Left Control + Shift e.g. for gnome-terminal
+#define MEH_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT, kc) // Meh is a less hyper version of the Hyper key -- doesn't include GUI, so just Left Control + Shift + Alt
+#define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) // Left Control + Alt + GUI
+#define RCAG_T(kc) MT(MOD_RCTL | MOD_RALT | MOD_RGUI, kc) // Right Control + Alt + GUI
+#define HYPR_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI, kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/
+#define SGUI_T(kc) MT(MOD_LGUI | MOD_LSFT, kc) // Left Shift + GUI
#define SCMD_T(kc) SGUI_T(kc)
#define SWIN_T(kc) SGUI_T(kc)
-#define LCA_T(kc) MT(MOD_LCTL | MOD_LALT, kc) // Left control and left alt
+#define LCA_T(kc) MT(MOD_LCTL | MOD_LALT, kc) // Left Control + Alt
+#define ALL_T(kc) HYPR_T(kc)
// Dedicated keycode versions for Hyper and Meh, if you want to use them as standalone keys rather than mod-tap
#define KC_HYPR HYPR(KC_NO)
#define KC_MEH MEH(KC_NO)
#ifdef UNICODE_ENABLE
- // For sending unicode codes.
- // You may not send codes over 7FFF -- this supports most of UTF8.
- // To have a key that sends out Œ, go UC(0x0152)
- #define UNICODE(n) (QK_UNICODE | (n))
- #define UC(n) UNICODE(n)
+ // Allows Unicode input up to 0x7FFF
+ #define UC(c) (QK_UNICODE | (c))
#endif
-
#ifdef UNICODEMAP_ENABLE
- #define X(n) (QK_UNICODE_MAP | (n))
+ // Allows Unicode input up to 0x10FFFF, requires unicode_map
+ #define X(i) (QK_UNICODEMAP | (i))
#endif
#define UC_MOD UNICODE_MODE_FORWARD
diff --git a/quantum/split_common/i2c.h b/quantum/split_common/i2c.h
index b3cbe8c826..91e8e96f47 100644
--- a/quantum/split_common/i2c.h
+++ b/quantum/split_common/i2c.h
@@ -1,5 +1,4 @@
-#ifndef I2C_H
-#define I2C_H
+#pragma once
#include <stdint.h>
@@ -58,5 +57,3 @@ extern unsigned char i2c_readNak(void);
extern unsigned char i2c_read(unsigned char ack);
#define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak();
-
-#endif
diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c
index 2c37053f88..c3d2857ed5 100644
--- a/