aboutsummaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/color.c6
-rw-r--r--quantum/dynamic_keymap.c20
-rw-r--r--quantum/encoder.c8
-rw-r--r--quantum/process_keycode/process_rgb.c10
-rw-r--r--quantum/quantum.c8
-rw-r--r--quantum/quantum.h4
-rw-r--r--quantum/quantum_keycodes.h6
-rw-r--r--quantum/rgb_matrix.c8
-rw-r--r--quantum/rgblight.c6
-rw-r--r--quantum/via.c247
-rw-r--r--quantum/via.h61
11 files changed, 168 insertions, 216 deletions
diff --git a/quantum/color.c b/quantum/color.c
index 8bd52444f..c05030062 100644
--- a/quantum/color.c
+++ b/quantum/color.c
@@ -87,9 +87,9 @@ RGB hsv_to_rgb(HSV hsv) {
87} 87}
88 88
89#ifdef RGBW 89#ifdef RGBW
90#ifndef MIN 90# ifndef MIN
91# define MIN(a, b) ((a) < (b) ? (a) : (b)) 91# define MIN(a, b) ((a) < (b) ? (a) : (b))
92#endif 92# endif
93void convert_rgb_to_rgbw(LED_TYPE *led) { 93void convert_rgb_to_rgbw(LED_TYPE *led) {
94 // Determine lowest value in all three colors, put that into 94 // Determine lowest value in all three colors, put that into
95 // the white channel and then shift all colors by that amount 95 // the white channel and then shift all colors by that amount
diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c
index 11d28592d..0d8ea56b7 100644
--- a/quantum/dynamic_keymap.c
+++ b/quantum/dynamic_keymap.c
@@ -20,36 +20,36 @@
20#include "progmem.h" // to read default from flash 20#include "progmem.h" // to read default from flash
21#include "quantum.h" // for send_string() 21#include "quantum.h" // for send_string()
22#include "dynamic_keymap.h" 22#include "dynamic_keymap.h"
23#include "via.h" // for default VIA_EEPROM_ADDR_END 23#include "via.h" // for default VIA_EEPROM_ADDR_END
24 24
25#ifndef DYNAMIC_KEYMAP_LAYER_COUNT 25#ifndef DYNAMIC_KEYMAP_LAYER_COUNT
26# define DYNAMIC_KEYMAP_LAYER_COUNT 4 26# define DYNAMIC_KEYMAP_LAYER_COUNT 4
27#endif 27#endif
28 28
29#ifndef DYNAMIC_KEYMAP_MACRO_COUNT 29#ifndef DYNAMIC_KEYMAP_MACRO_COUNT
30# define DYNAMIC_KEYMAP_MACRO_COUNT 16 30# define DYNAMIC_KEYMAP_MACRO_COUNT 16
31#endif 31#endif
32 32
33// If DYNAMIC_KEYMAP_EEPROM_ADDR not explicitly defined in config.h, 33// If DYNAMIC_KEYMAP_EEPROM_ADDR not explicitly defined in config.h,
34// default it start after VIA_EEPROM_CUSTOM_ADDR+VIA_EEPROM_CUSTOM_SIZE 34// default it start after VIA_EEPROM_CUSTOM_ADDR+VIA_EEPROM_CUSTOM_SIZE
35#ifndef DYNAMIC_KEYMAP_EEPROM_ADDR 35#ifndef DYNAMIC_KEYMAP_EEPROM_ADDR
36# ifdef VIA_EEPROM_CUSTOM_CONFIG_ADDR 36# ifdef VIA_EEPROM_CUSTOM_CONFIG_ADDR
37# define DYNAMIC_KEYMAP_EEPROM_ADDR (VIA_EEPROM_CUSTOM_CONFIG_ADDR+VIA_EEPROM_CUSTOM_CONFIG_SIZE) 37# define DYNAMIC_KEYMAP_EEPROM_ADDR (VIA_EEPROM_CUSTOM_CONFIG_ADDR + VIA_EEPROM_CUSTOM_CONFIG_SIZE)
38# else 38# else
39# error DYNAMIC_KEYMAP_EEPROM_ADDR not defined 39# error DYNAMIC_KEYMAP_EEPROM_ADDR not defined
40# endif 40# endif
41#endif 41#endif
42 42
43// Dynamic macro starts after dynamic keymaps 43// Dynamic macro starts after dynamic keymaps
44#ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 44#ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR
45# define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR (DYNAMIC_KEYMAP_EEPROM_ADDR+(DYNAMIC_KEYMAP_LAYER_COUNT*MATRIX_ROWS*MATRIX_COLS*2)) 45# define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR (DYNAMIC_KEYMAP_EEPROM_ADDR + (DYNAMIC_KEYMAP_LAYER_COUNT * MATRIX_ROWS * MATRIX_COLS * 2))
46#endif 46#endif
47 47
48// Dynamic macro uses up all remaining memory 48// Dynamic macro uses up all remaining memory
49// Assumes 1K EEPROM on ATMega32U4 49// Assumes 1K EEPROM on ATMega32U4
50// Override for anything different 50// Override for anything different
51#ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 51#ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE
52# define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE (1024-DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR) 52# define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE (1024 - DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR)
53#endif 53#endif
54 54
55uint8_t dynamic_keymap_get_layer_count(void) { return DYNAMIC_KEYMAP_LAYER_COUNT; } 55uint8_t dynamic_keymap_get_layer_count(void) { return DYNAMIC_KEYMAP_LAYER_COUNT; }
diff --git a/quantum/encoder.c b/quantum/encoder.c
index c41b89f49..8e11562eb 100644
--- a/quantum/encoder.c
+++ b/quantum/encoder.c
@@ -37,8 +37,8 @@ static pin_t encoders_pad_b[] = ENCODERS_PAD_B;
37 37
38static int8_t encoder_LUT[] = {0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0}; 38static int8_t encoder_LUT[] = {0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0};
39 39
40static uint8_t encoder_state[NUMBER_OF_ENCODERS] = {0}; 40static uint8_t encoder_state[NUMBER_OF_ENCODERS] = {0};
41static int8_t encoder_pulses[NUMBER_OF_ENCODERS] = {0}; 41static int8_t encoder_pulses[NUMBER_OF_ENCODERS] = {0};
42 42
43#ifdef SPLIT_KEYBOARD 43#ifdef SPLIT_KEYBOARD
44// right half encoders come over as second set of encoders 44// right half encoders come over as second set of encoders
@@ -88,7 +88,7 @@ static void encoder_update(int8_t index, uint8_t state) {
88 encoder_value[index]++; 88 encoder_value[index]++;
89 encoder_update_kb(index, true); 89 encoder_update_kb(index, true);
90 } 90 }
91 if (encoder_pulses[i] <= -ENCODER_RESOLUTION) { // direction is arbitrary here, but this clockwise 91 if (encoder_pulses[i] <= -ENCODER_RESOLUTION) { // direction is arbitrary here, but this clockwise
92 encoder_value[index]--; 92 encoder_value[index]--;
93 encoder_update_kb(index, false); 93 encoder_update_kb(index, false);
94 } 94 }
@@ -109,7 +109,7 @@ void encoder_state_raw(uint8_t* slave_state) { memcpy(slave_state, &encoder_valu
109void encoder_update_raw(uint8_t* slave_state) { 109void encoder_update_raw(uint8_t* slave_state) {
110 for (uint8_t i = 0; i < NUMBER_OF_ENCODERS; i++) { 110 for (uint8_t i = 0; i < NUMBER_OF_ENCODERS; i++) {
111 uint8_t index = i + thatHand; 111 uint8_t index = i + thatHand;
112 int8_t delta = slave_state[i] - encoder_value[index]; 112 int8_t delta = slave_state[i] - encoder_value[index];
113 while (delta > 0) { 113 while (delta > 0) {
114 delta--; 114 delta--;
115 encoder_value[index]++; 115 encoder_value[index]++;
diff --git a/quantum/process_keycode/process_rgb.c b/quantum/process_keycode/process_rgb.c
index c76166342..627e5986f 100644
--- a/quantum/process_keycode/process_rgb.c
+++ b/quantum/process_keycode/process_rgb.c
@@ -20,8 +20,8 @@ typedef void (*rgb_func_pointer)(void);
20 20
21/** 21/**
22 * Wrapper for inc/dec rgb keycode 22 * Wrapper for inc/dec rgb keycode
23 * 23 *
24 * noinline to optimise for firmware size not speed (not in hot path) 24 * noinline to optimise for firmware size not speed (not in hot path)
25 */ 25 */
26static void __attribute__((noinline)) handleKeycodeRGB(const uint8_t is_shifted, const rgb_func_pointer inc_func, const rgb_func_pointer dec_func) { 26static void __attribute__((noinline)) handleKeycodeRGB(const uint8_t is_shifted, const rgb_func_pointer inc_func, const rgb_func_pointer dec_func) {
27 if (is_shifted) { 27 if (is_shifted) {
@@ -35,10 +35,10 @@ static void __attribute__((noinline)) handleKeycodeRGB(const uint8_t is_shifted,
35 * Wrapper for animation mode 35 * Wrapper for animation mode
36 * - if not in animation family -> jump to that animation 36 * - if not in animation family -> jump to that animation
37 * - otherwise -> wrap round animation speed 37 * - otherwise -> wrap round animation speed
38 * 38 *
39 * noinline to optimise for firmware size not speed (not in hot path) 39 * noinline to optimise for firmware size not speed (not in hot path)
40 */ 40 */
41static void __attribute__((noinline,unused)) handleKeycodeRGBMode(const uint8_t start, const uint8_t end) { 41static void __attribute__((noinline, unused)) handleKeycodeRGBMode(const uint8_t start, const uint8_t end) {
42 if ((start <= rgblight_get_mode()) && (rgblight_get_mode() < end)) { 42 if ((start <= rgblight_get_mode()) && (rgblight_get_mode() < end)) {
43 rgblight_step(); 43 rgblight_step();
44 } else { 44 } else {
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 9cd50b11d..36062866e 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -320,8 +320,8 @@ bool process_record_quantum(keyrecord_t *record) {
320 switch (keycode) { 320 switch (keycode) {
321 case GRAVE_ESC: { 321 case GRAVE_ESC: {
322 /* true if the last press of GRAVE_ESC was shifted (i.e. GUI or SHIFT were pressed), false otherwise. 322 /* true if the last press of GRAVE_ESC was shifted (i.e. GUI or SHIFT were pressed), false otherwise.
323 * Used to ensure that the correct keycode is released if the key is released. 323 * Used to ensure that the correct keycode is released if the key is released.
324 */ 324 */
325 static bool grave_esc_was_shifted = false; 325 static bool grave_esc_was_shifted = false;
326 326
327 uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT) | MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI))); 327 uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT) | MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)));
@@ -379,6 +379,7 @@ __attribute__((weak)) const bool ascii_to_altgr_lut[128] PROGMEM = {0, 0, 0, 0,
379 379
380 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 380 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
381 381
382// clang-format off
382__attribute__((weak)) const uint8_t ascii_to_keycode_lut[128] PROGMEM = {// NUL SOH STX ETX EOT ENQ ACK BEL 383__attribute__((weak)) const uint8_t ascii_to_keycode_lut[128] PROGMEM = {// NUL SOH STX ETX EOT ENQ ACK BEL
383 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, 384 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
384 // BS TAB LF VT FF CR SO SI 385 // BS TAB LF VT FF CR SO SI
@@ -412,6 +413,7 @@ __attribute__((weak)) const uint8_t ascii_to_keycode_lut[128] PROGMEM = {// NUL
412 KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W, 413 KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
413 // x y z { | } ~ DEL 414 // x y z { | } ~ DEL
414 KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL}; 415 KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL};
416// clang-format on
415 417
416void send_string(const char *str) { send_string_with_delay(str, 0); } 418void send_string(const char *str) { send_string_with_delay(str, 0); }
417 419
@@ -477,7 +479,7 @@ void send_string_with_delay_P(const char *str, uint8_t interval) {
477 479
478void send_char(char ascii_code) { 480void send_char(char ascii_code) {
479#if defined(AUDIO_ENABLE) && defined(SENDSTRING_BELL) 481#if defined(AUDIO_ENABLE) && defined(SENDSTRING_BELL)
480 if (ascii_code == '\a') { // BEL 482 if (ascii_code == '\a') { // BEL
481 PLAY_SONG(bell_song); 483 PLAY_SONG(bell_song);
482 return; 484 return;
483 } 485 }
diff --git a/quantum/quantum.h b/quantum/quantum.h
index 09550fec3..48887026d 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -163,11 +163,11 @@ extern layer_state_t layer_state;
163#endif 163#endif
164 164
165#ifdef DYNAMIC_KEYMAP_ENABLE 165#ifdef DYNAMIC_KEYMAP_ENABLE
166# include "dynamic_keymap.h" 166# include "dynamic_keymap.h"
167#endif 167#endif
168 168
169#ifdef VIA_ENABLE 169#ifdef VIA_ENABLE
170# include "via.h" 170# include "via.h"
171#endif 171#endif
172 172
173// Function substitutions to ease GPIO manipulation 173// Function substitutions to ease GPIO manipulation
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index c8d0e354b..54428fe1f 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -677,7 +677,7 @@ enum quantum_keycodes {
677#define AG_TOGG MAGIC_TOGGLE_ALT_GUI 677#define AG_TOGG MAGIC_TOGGLE_ALT_GUI
678 678
679#define GUI_OFF MAGIC_NO_GUI 679#define GUI_OFF MAGIC_NO_GUI
680#define GUI_ON MAGIC_UNNO_GUI 680#define GUI_ON MAGIC_UNNO_GUI
681 681
682#define GE_SWAP MAGIC_SWAP_GRAVE_ESC 682#define GE_SWAP MAGIC_SWAP_GRAVE_ESC
683#define GE_NORM MAGIC_UNSWAP_GRAVE_ESC 683#define GE_NORM MAGIC_UNSWAP_GRAVE_ESC
@@ -685,8 +685,8 @@ enum quantum_keycodes {
685#define BS_SWAP MAGIC_SWAP_BACKSLASH_BACKSPACE 685#define BS_SWAP MAGIC_SWAP_BACKSLASH_BACKSPACE
686#define BS_NORM MAGIC_UNSWAP_BACKSLASH_BACKSPACE 686#define BS_NORM MAGIC_UNSWAP_BACKSLASH_BACKSPACE
687 687
688#define NK_ON MAGIC_HOST_NKRO 688#define NK_ON MAGIC_HOST_NKRO
689#define NK_OFF MAGIC_UNHOST_NKRO 689#define NK_OFF MAGIC_UNHOST_NKRO
690#define NK_TOGG MAGIC_TOGGLE_NKRO 690#define NK_TOGG MAGIC_TOGGLE_NKRO
691 691
692#define EH_LEFT MAGIC_EE_HANDS_LEFT 692#define EH_LEFT MAGIC_EE_HANDS_LEFT
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c
index 25ca44054..1a9cf82e5 100644
--- a/quantum/rgb_matrix.c
+++ b/quantum/rgb_matrix.c
@@ -434,11 +434,11 @@ void rgb_matrix_init(void) {
434 eeconfig_debug_rgb_matrix(); // display current eeprom values 434 eeconfig_debug_rgb_matrix(); // display current eeprom values
435} 435}
436 436
437void rgb_matrix_set_suspend_state(bool state) { 437void rgb_matrix_set_suspend_state(bool state) {
438 if (RGB_DISABLE_WHEN_USB_SUSPENDED && state) { 438 if (RGB_DISABLE_WHEN_USB_SUSPENDED && state) {
439 rgb_matrix_set_color_all(0, 0, 0); // turn off all LEDs when suspending 439 rgb_matrix_set_color_all(0, 0, 0); // turn off all LEDs when suspending
440 } 440 }
441 g_suspend_state = state; 441 g_suspend_state = state;
442} 442}
443 443
444void rgb_matrix_toggle(void) { 444void rgb_matrix_toggle(void) {
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index 141dc2e7b..26887f057 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -622,12 +622,12 @@ void rgblight_set(void) {
622 start_led = led + clipping_start_pos; 622 start_led = led + clipping_start_pos;
623# endif 623# endif
624 624
625#ifdef RGBW 625# ifdef RGBW
626 for (uint8_t i = 0; i < num_leds; i++) { 626 for (uint8_t i = 0; i < num_leds; i++) {
627 convert_rgb_to_rgbw(&start_led[i]); 627 convert_rgb_to_rgbw(&start_led[i]);
628 } 628 }
629#endif 629# endif
630 ws2812_setleds(start_led, num_leds); 630 ws2812_setleds(start_led, num_leds);
631} 631}
632#endif 632#endif
633 633
diff --git a/quantum/via.c b/quantum/via.c
index 64b05324a..b3934d9f0 100644
--- a/quantum/via.c
+++ b/quantum/via.c
@@ -28,41 +28,36 @@
28#include "raw_hid.h" 28#include "raw_hid.h"
29#include "dynamic_keymap.h" 29#include "dynamic_keymap.h"
30#include "tmk_core/common/eeprom.h" 30#include "tmk_core/common/eeprom.h"
31#include "version.h" // for QMK_BUILDDATE used in EEPROM magic 31#include "version.h" // for QMK_BUILDDATE used in EEPROM magic
32 32
33// Can be called in an overriding via_init_kb() to test if keyboard level code usage of 33// Can be called in an overriding via_init_kb() to test if keyboard level code usage of
34// EEPROM is invalid and use/save defaults. 34// EEPROM is invalid and use/save defaults.
35bool via_eeprom_is_valid(void) 35bool via_eeprom_is_valid(void) {
36{ 36 char * p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54"
37 char *p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54" 37 uint8_t magic0 = ((p[2] & 0x0F) << 4) | (p[3] & 0x0F);
38 uint8_t magic0 = ( ( p[2] & 0x0F ) << 4 ) | ( p[3] & 0x0F ); 38 uint8_t magic1 = ((p[5] & 0x0F) << 4) | (p[6] & 0x0F);
39 uint8_t magic1 = ( ( p[5] & 0x0F ) << 4 ) | ( p[6] & 0x0F ); 39 uint8_t magic2 = ((p[8] & 0x0F) << 4) | (p[9] & 0x0F);
40 uint8_t magic2 = ( ( p[8] & 0x0F ) << 4 ) | ( p[9] & 0x0F );
41 40
42 return (eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+0 ) == magic0 && 41 return (eeprom_read_byte((void *)VIA_EEPROM_MAGIC_ADDR + 0) == magic0 && eeprom_read_byte((void *)VIA_EEPROM_MAGIC_ADDR + 1) == magic1 && eeprom_read_byte((void *)VIA_EEPROM_MAGIC_ADDR + 2) == magic2);
43 eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+1 ) == magic1 &&
44 eeprom_read_byte( (void*)VIA_EEPROM_MAGIC_ADDR+2 ) == magic2 );
45} 42}
46 43
47// Sets VIA/keyboard level usage of EEPROM to valid/invalid 44// Sets VIA/keyboard level usage of EEPROM to valid/invalid
48// Keyboard level code (eg. via_init_kb()) should not call this 45// Keyboard level code (eg. via_init_kb()) should not call this
49void via_eeprom_set_valid(bool valid) 46void via_eeprom_set_valid(bool valid) {
50{ 47 char * p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54"
51 char *p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54" 48 uint8_t magic0 = ((p[2] & 0x0F) << 4) | (p[3] & 0x0F);
52 uint8_t magic0 = ( ( p[2] & 0x0F ) << 4 ) | ( p[3] & 0x0F ); 49 uint8_t magic1 = ((p[5] & 0x0F) << 4) | (p[6] & 0x0F);
53 uint8_t magic1 = ( ( p[5] & 0x0F ) << 4 ) | ( p[6] & 0x0F ); 50 uint8_t magic2 = ((p[8] & 0x0F) << 4) | (p[9] & 0x0F);
54 uint8_t magic2 = ( ( p[8] & 0x0F ) << 4 ) | ( p[9] & 0x0F );
55 51
56 eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+0, valid ? magic0 : 0xFF); 52 eeprom_update_byte((void *)VIA_EEPROM_MAGIC_ADDR + 0, valid ? magic0 : 0xFF);
57 eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+1, valid ? magic1 : 0xFF); 53 eeprom_update_byte((void *)VIA_EEPROM_MAGIC_ADDR + 1, valid ? magic1 : 0xFF);
58 eeprom_update_byte( (void*)VIA_EEPROM_MAGIC_ADDR+2, valid ? magic2 : 0xFF); 54 eeprom_update_byte((void *)VIA_EEPROM_MAGIC_ADDR + 2, valid ? magic2 : 0xFF);
59} 55}
60 56
61// Flag QMK and VIA/keyboard level EEPROM as invalid. 57// Flag QMK and VIA/keyboard level EEPROM as invalid.
62// Used in bootmagic_lite() and VIA command handler. 58// Used in bootmagic_lite() and VIA command handler.
63// Keyboard level code should not need to call this. 59// Keyboard level code should not need to call this.
64void via_eeprom_reset(void) 60void via_eeprom_reset(void) {
65{
66 // Set the VIA specific EEPROM state as invalid. 61 // Set the VIA specific EEPROM state as invalid.
67 via_eeprom_set_valid(false); 62 via_eeprom_set_valid(false);
68 // Set the TMK/QMK EEPROM state as invalid. 63 // Set the TMK/QMK EEPROM state as invalid.
@@ -72,8 +67,7 @@ void via_eeprom_reset(void)
72// Override bootmagic_lite() so it can flag EEPROM as invalid 67// Override bootmagic_lite() so it can flag EEPROM as invalid
73// as well as jump to bootloader, thus performing a "factory reset" 68// as well as jump to bootloader, thus performing a "factory reset"
74// of dynamic keymaps and optionally backlight/other settings. 69// of dynamic keymaps and optionally backlight/other settings.
75void bootmagic_lite(void) 70void bootmagic_lite(void) {
76{
77 // The lite version of TMK's bootmagic based on Wilba. 71 // The lite version of TMK's bootmagic based on Wilba.
78 // 100% less potential for accidentally making the 72 // 100% less potential for accidentally making the
79 // keyboard do stupid things. 73 // keyboard do stupid things.
@@ -106,12 +100,10 @@ void bootmagic_lite(void)
106// for backlight, rotary encoders, etc. 100// for backlight, rotary encoders, etc.
107// The override should not set via_eeprom_set_valid(true) as 101// The override should not set via_eeprom_set_valid(true) as
108// the caller also needs to check the valid state. 102// the caller also needs to check the valid state.
109__attribute__((weak)) void via_init_kb(void) { 103__attribute__((weak)) void via_init_kb(void) {}
110}
111 104
112// Called by QMK core to initialize dynamic keymaps etc. 105// Called by QMK core to initialize dynamic keymaps etc.
113void via_init(void) 106void via_init(void) {
114{
115 // Let keyboard level test EEPROM valid state, 107 // Let keyboard level test EEPROM valid state,
116 // but not set it valid, it is done here. 108 // but not set it valid, it is done here.
117 via_init_kb(); 109 via_init_kb();
@@ -119,7 +111,7 @@ void via_init(void)
119 // If the EEPROM has the magic, the data is good. 111 // If the EEPROM has the magic, the data is good.
120 // OK to load from EEPROM. 112 // OK to load from EEPROM.
121 if (via_eeprom_is_valid()) { 113 if (via_eeprom_is_valid()) {
122 } else { 114 } else {
123 // This resets the layout options 115 // This resets the layout options
124 via_set_layout_options(0); 116 via_set_layout_options(0);
125 // This resets the keymaps in EEPROM to what is in flash. 117 // This resets the keymaps in EEPROM to what is in flash.
@@ -133,12 +125,11 @@ void via_init(void)
133 125
134// This is generalized so the layout options EEPROM usage can be 126// This is generalized so the layout options EEPROM usage can be
135// variable, between 1 and 4 bytes. 127// variable, between 1 and 4 bytes.
136uint32_t via_get_layout_options(void) 128uint32_t via_get_layout_options(void) {
137{
138 uint32_t value = 0; 129 uint32_t value = 0;
139 // Start at the most significant byte 130 // Start at the most significant byte
140 void * source = (void *)(VIA_EEPROM_LAYOUT_OPTIONS_ADDR); 131 void *source = (void *)(VIA_EEPROM_LAYOUT_OPTIONS_ADDR);
141 for ( uint8_t i = 0; i < VIA_EEPROM_LAYOUT_OPTIONS_SIZE; i++ ) { 132 for (uint8_t i = 0; i < VIA_EEPROM_LAYOUT_OPTIONS_SIZE; i++) {
142 value = value << 8; 133 value = value << 8;
143 value |= eeprom_read_byte(source); 134 value |= eeprom_read_byte(source);
144 source++; 135 source++;
@@ -146,24 +137,21 @@ uint32_t via_get_layout_options(void)
146 return value; 137 return value;
147} 138}
148 139
149void via_set_layout_options(uint32_t value) 140void via_set_layout_options(uint32_t value) {
150{
151 // Start at the least significant byte 141 // Start at the least significant byte
152 void * target = (void *)(VIA_EEPROM_LAYOUT_OPTIONS_ADDR+VIA_EEPROM_LAYOUT_OPTIONS_SIZE-1); 142 void *target = (void *)(VIA_EEPROM_LAYOUT_OPTIONS_ADDR + VIA_EEPROM_LAYOUT_OPTIONS_SIZE - 1);
153 for ( uint8_t i = 0; i < VIA_EEPROM_LAYOUT_OPTIONS_SIZE; i++ ) { 143 for (uint8_t i = 0; i < VIA_EEPROM_LAYOUT_OPTIONS_SIZE; i++) {
154 eeprom_update_byte(target, value & 0xFF ); 144 eeprom_update_byte(target, value & 0xFF);
155 value = value >> 8; 145 value = value >> 8;
156 target--; 146 target--;
157 } 147 }
158} 148}
159 149
160// Called by QMK core to process VIA-specific keycodes. 150// Called by QMK core to process VIA-specific keycodes.
161bool process_record_via(uint16_t keycode, keyrecord_t *record) 151bool process_record_via(uint16_t keycode, keyrecord_t *record) {
162{
163 // Handle macros 152 // Handle macros
164 if (record->event.pressed) { 153 if (record->event.pressed) {
165 if ( keycode >= MACRO00 && keycode <= MACRO15 ) 154 if (keycode >= MACRO00 && keycode <= MACRO15) {
166 {
167 uint8_t id = keycode - MACRO00; 155 uint8_t id = keycode - MACRO00;
168 dynamic_keymap_macro_send(id); 156 dynamic_keymap_macro_send(id);
169 return false; 157 return false;
@@ -173,7 +161,7 @@ bool process_record_via(uint16_t keycode, keyrecord_t *record)
173 // TODO: ideally this would be generalized and refactored into 161 // TODO: ideally this would be generalized and refactored into
174 // QMK core as advanced keycodes, until then, the simple case 162 // QMK core as advanced keycodes, until then, the simple case
175 // can be available here to keyboards using VIA 163 // can be available here to keyboards using VIA
176 switch(keycode) { 164 switch (keycode) {
177 case FN_MO13: 165 case FN_MO13:
178 if (record->event.pressed) { 166 if (record->event.pressed) {
179 layer_on(1); 167 layer_on(1);
@@ -203,7 +191,7 @@ bool process_record_via(uint16_t keycode, keyrecord_t *record)
203// DO NOT call raw_hid_send() in the overide function. 191// DO NOT call raw_hid_send() in the overide function.
204__attribute__((weak)) void raw_hid_receive_kb(uint8_t *data, uint8_t length) { 192__attribute__((weak)) void raw_hid_receive_kb(uint8_t *data, uint8_t length) {
205 uint8_t *command_id = &(data[0]); 193 uint8_t *command_id = &(data[0]);
206 *command_id = id_unhandled; 194 *command_id = id_unhandled;
207} 195}
208 196
209// VIA handles received HID messages first, and will route to 197// VIA handles received HID messages first, and will route to
@@ -211,182 +199,151 @@ __attribute__((weak)) void raw_hid_receive_kb(uint8_t *data, uint8_t length) {
211// This gives the keyboard code level the ability to handle the command 199// This gives the keyboard code level the ability to handle the command
212// specifically. 200// specifically.
213// 201//
214// raw_hid_send() is called at the end, with the same buffer, which was 202// raw_hid_send() is called at the end, with the same buffer, which was
215// possibly modified with returned values. 203// possibly modified with returned values.
216void raw_hid_receive( uint8_t *data, uint8_t length ) 204void raw_hid_receive(uint8_t *data, uint8_t length) {
217{ 205 uint8_t *command_id = &(data[0]);
218 uint8_t *command_id = &(data[0]);
219 uint8_t *command_data = &(data[1]); 206 uint8_t *command_data = &(data[1]);
220 switch ( *command_id ) 207 switch (*command_id) {
221 { 208 case id_get_protocol_version: {
222 case id_get_protocol_version:
223 {
224 command_data[0] = VIA_PROTOCOL_VERSION >> 8; 209 command_data[0] = VIA_PROTOCOL_VERSION >> 8;
225 command_data[1] = VIA_PROTOCOL_VERSION & 0xFF; 210 command_data[1] = VIA_PROTOCOL_VERSION & 0xFF;
226 break; 211 break;
227 } 212 }
228 case id_get_keyboard_value: 213 case id_get_keyboard_value: {
229 { 214 switch (command_data[0]) {
230 switch ( command_data[0] ) 215 case id_uptime: {
231 { 216 uint32_t value = timer_read32();
232 case id_uptime: 217 command_data[1] = (value >> 24) & 0xFF;
233 { 218 command_data[2] = (value >> 16) & 0xFF;
234 uint32_t value = timer_read32(); 219 command_data[3] = (value >> 8) & 0xFF;
235 command_data[1] = (value >> 24 ) & 0xFF;
236 command_data[2] = (value >> 16 ) & 0xFF;
237 command_data[3] = (value >> 8 ) & 0xFF;
238 command_data[4] = value & 0xFF; 220 command_data[4] = value & 0xFF;
239 break; 221 break;
240 } 222 }
241 case id_layout_options: 223 case id_layout_options: {
242 { 224 uint32_t value = via_get_layout_options();
243 uint32_t value = via_get_layout_options(); 225 command_data[1] = (value >> 24) & 0xFF;
244 command_data[1] = (value >> 24 ) & 0xFF; 226 command_data[2] = (value >> 16) & 0xFF;
245 command_data[2] = (value >> 16 ) & 0xFF; 227 command_data[3] = (value >> 8) & 0xFF;
246 command_data[3] = (value >> 8 ) & 0xFF;
247 command_data[4] = value & 0xFF; 228 command_data[4] = value & 0xFF;
248 break; 229 break;
249 } 230 }
250 case id_switch_matrix_state: 231 case id_switch_matrix_state: {
251 { 232#if ((MATRIX_COLS / 8 + 1) * MATRIX_ROWS <= 28)
252#if ( (MATRIX_COLS/8+1)*MATRIX_ROWS <= 28 )
253 uint8_t i = 1; 233 uint8_t i = 1;
254 for ( uint8_t row=0; row<MATRIX_ROWS; row++ ) { 234 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
255 matrix_row_t value = matrix_get_row(row); 235 matrix_row_t value = matrix_get_row(row);
256#if (MATRIX_COLS > 24) 236# if (MATRIX_COLS > 24)
257 command_data[i++] = (value >> 24 ) & 0xFF; 237 command_data[i++] = (value >> 24) & 0xFF;
258#endif 238# endif
259#if (MATRIX_COLS > 16) 239# if (MATRIX_COLS > 16)
260 command_data[i++] = (value >> 16 ) & 0xFF; 240 command_data[i++] = (value >> 16) & 0xFF;
261#endif 241# endif
262#if (MATRIX_COLS > 8) 242# if (MATRIX_COLS > 8)
263 command_data[i++] = (value >> 8 ) & 0xFF; 243 command_data[i++] = (value >> 8) & 0xFF;
264#endif 244# endif
265 command_data[i++] = value & 0xFF; 245 command_data[i++] = value & 0xFF;
266 } 246 }
267#endif 247#endif
268 break; 248 break;
269 } 249 }
270 default: 250 default: {
271 { 251 raw_hid_receive_kb(data, length);
272 raw_hid_receive_kb(data,length);
273 break; 252 break;
274 } 253 }
275 } 254 }
276 break; 255 break;
277 } 256 }
278 case id_set_keyboard_value: 257 case id_set_keyboard_value: {
279 { 258 switch (command_data[0]) {
280 switch ( command_data[0] ) 259 case id_layout_options: {
281 { 260 uint32_t value = ((uint32_t)command_data[1] << 24) | ((uint32_t)command_data[2] << 16) | ((uint32_t)command_data[3] << 8) | (uint32_t)command_data[4];
282 case id_layout_options:
283 {
284 uint32_t value = ( (uint32_t)command_data[1] << 24 ) |
285 ( (uint32_t)command_data[2] << 16 ) |
286 ( (uint32_t)command_data[3] << 8 ) |
287 (uint32_t)command_data[4];
288 via_set_layout_options(value); 261 via_set_layout_options(value);
289 break; 262 break;
290 } 263 }
291 default: 264 default: {
292 { 265 raw_hid_receive_kb(data, length);
293 raw_hid_receive_kb(data,length);
294 break; 266 break;
295 } 267 }
296 } 268 }
297 break; 269 break;
298 } 270 }
299 case id_dynamic_keymap_get_keycode: 271 case id_dynamic_keymap_get_keycode: {
300 { 272 uint16_t keycode = dynamic_keymap_get_keycode(command_data[0], command_data[1], command_data[2]);
301 uint16_t keycode = dynamic_keymap_get_keycode( command_data[0], command_data[1], command_data[2] ); 273 command_data[3] = keycode >> 8;
302 command_data[3] = keycode >> 8; 274 command_data[4] = keycode & 0xFF;
303 command_data[4] = keycode & 0xFF;
304 break; 275 break;
305 } 276 }
306 case id_dynamic_keymap_set_keycode: 277 case id_dynamic_keymap_set_keycode: {
307 { 278 dynamic_keymap_set_keycode(command_data[0], command_data[1], command_data[2], (command_data[3] << 8) | command_data[4]);
308 dynamic_keymap_set_keycode( command_data[0], command_data[1], command_data[2], ( command_data[3] << 8 ) | command_data[4] );
309 break; 279 break;
310 } 280 }
311 case id_dynamic_keymap_reset: 281 case id_dynamic_keymap_reset: {
312 {
313 dynamic_keymap_reset(); 282 dynamic_keymap_reset();
314 break; 283 break;
315 } 284 }
316 case id_backlight_config_set_value: 285 case id_backlight_config_set_value:
317 case id_backlight_config_get_value: 286 case id_backlight_config_get_value:
318 case id_backlight_config_save: 287 case id_backlight_config_save: {
319 {
320 raw_hid_receive_kb(data, length); 288 raw_hid_receive_kb(data, length);
321 break; 289 break;
322 } 290 }
323 case id_dynamic_keymap_macro_get_count: 291 case id_dynamic_keymap_macro_get_count: {
324 {
325 command_data[0] = dynamic_keymap_macro_get_count(); 292 command_data[0] = dynamic_keymap_macro_get_count();
326 break; 293 break;
327 } 294 }
328 case id_dynamic_keymap_macro_get_buffer_size: 295 case id_dynamic_keymap_macro_get_buffer_size: {
329 { 296 uint16_t size = dynamic_keymap_macro_get_buffer_size();
330 uint16_t size = dynamic_keymap_macro_get_buffer_size();
331 command_data[0] = size >> 8; 297 command_data[0] = size >> 8;
332 command_data[1] = size & 0xFF; 298 command_data[1] = size & 0xFF;
333 break; 299 break;
334 } 300 }
335 case id_dynamic_keymap_macro_get_buffer: 301 case id_dynamic_keymap_macro_get_buffer: {
336 { 302 uint16_t offset = (command_data[0] << 8) | command_data[1];
337 uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; 303 uint16_t size = command_data[2]; // size <= 28
338 uint16_t size = command_data[2]; // size <= 28 304 dynamic_keymap_macro_get_buffer(offset, size, &command_data[3]);
339 dynamic_keymap_macro_get_buffer( offset, size, &command_data[3] );
340 break; 305 break;
341 } 306 }
342 case id_dynamic_keymap_macro_set_buffer: 307 case id_dynamic_keymap_macro_set_buffer: {
343 { 308 uint16_t offset = (command_data[0] << 8) | command_data[1];
344 uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; 309 uint16_t size = command_data[2]; // size <= 28
345 uint16_t size = command_data[2]; // size <= 28 310 dynamic_keymap_macro_set_buffer(offset, size, &command_data[3]);
346 dynamic_keymap_macro_set_buffer( offset, size, &command_data[3] );
347 break; 311 break;
348 } 312 }
349 case id_dynamic_keymap_macro_reset: 313 case id_dynamic_keymap_macro_reset: {
350 {
351 dynamic_keymap_macro_reset(); 314 dynamic_keymap_macro_reset();
352 break; 315 break;
353 } 316 }
354 case id_dynamic_keymap_get_layer_count: 317 case id_dynamic_keymap_get_layer_count: {
355 {
356 command_data[0] = dynamic_keymap_get_layer_count(); 318 command_data[0] = dynamic_keymap_get_layer_count();
357 break; 319 break;
358 } 320 }
359 case id_dynamic_keymap_get_buffer: 321 case id_dynamic_keymap_get_buffer: {
360 { 322 uint16_t offset = (command_data[0] << 8) | command_data[1];
361 uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; 323 uint16_t size = command_data[2]; // size <= 28
362 uint16_t size = command_data[2]; // size <= 28 324 dynamic_keymap_get_buffer(offset, size, &command_data[3]);
363 dynamic_keymap_get_buffer( offset, size, &command_data[3] );
364 break; 325 break;
365 } 326 }
366 case id_dynamic_keymap_set_buffer: 327 case id_dynamic_keymap_set_buffer: {
367 { 328 uint16_t offset = (command_data[0] << 8) | command_data[1];
368 uint16_t offset = ( command_data[0] << 8 ) | command_data[1]; 329 uint16_t size = command_data[2]; // size <= 28
369 uint16_t size = command_data[2]; // size <= 28 330 dynamic_keymap_set_buffer(offset, size, &command_data[3]);
370 dynamic_keymap_set_buffer( offset, size, &command_data[3] );
371 break; 331 break;
372 } 332 }
373 case id_eeprom_reset: 333 case id_eeprom_reset: {
374 {
375 via_eeprom_reset(); 334 via_eeprom_reset();
376 break; 335 break;
377 } 336 }
378 case id_bootloader_jump: 337 case id_bootloader_jump: {
379 {
380 // Need to send data back before the jump 338 // Need to send data back before the jump
381 // Informs host that the command is handled 339 // Informs host that the command is handled
382 raw_hid_send( data, length ); 340 raw_hid_send(data, length);
383 // Give host time to read it 341 // Give host time to read it
384 wait_ms(100); 342 wait_ms(100);
385 bootloader_jump(); 343 bootloader_jump();
386 break; 344 break;
387 } 345 }
388 default: 346 default: {
389 {
390 // The command ID is not known 347 // The command ID is not known
391 // Return the unhandled state 348 // Return the unhandled state
392 *command_id = id_unhandled; 349 *command_id = id_unhandled;
@@ -396,5 +353,5 @@ void raw_hid_receive( uint8_t *data, uint8_t length )
396 353
397 // Return the same buffer, optionally with values changed 354 // Return the same buffer, optionally with values changed
398 // (i.e. returning state to the host, or the unhandled state). 355 // (i.e. returning state to the host, or the unhandled state).
399 raw_hid_send( data, length ); 356 raw_hid_send(data, length);
400} 357}
diff --git a/quantum/via.h b/quantum/via.h
index f9a8017b2..98f8dea8c 100644
--- a/quantum/via.h
+++ b/quantum/via.h
@@ -16,7 +16,7 @@
16 16
17#pragma once 17#pragma once
18 18
19#include <tmk_core/common/eeconfig.h> // for EECONFIG_SIZE 19#include <tmk_core/common/eeconfig.h> // for EECONFIG_SIZE
20 20
21// Keyboard level code can change where VIA stores the magic. 21// Keyboard level code can change where VIA stores the magic.
22// The magic is the build date YYMMDD encoded as BCD in 3 bytes, 22// The magic is the build date YYMMDD encoded as BCD in 3 bytes,
@@ -25,34 +25,33 @@
25// The only reason this is important is in case EEPROM usage changes 25// The only reason this is important is in case EEPROM usage changes
26// and the EEPROM was not explicitly reset by bootmagic lite. 26// and the EEPROM was not explicitly reset by bootmagic lite.
27#ifndef VIA_EEPROM_MAGIC_ADDR 27#ifndef VIA_EEPROM_MAGIC_ADDR
28# define VIA_EEPROM_MAGIC_ADDR (EECONFIG_SIZE) 28# define VIA_EEPROM_MAGIC_ADDR (EECONFIG_SIZE)
29#endif 29#endif
30 30
31#define VIA_EEPROM_LAYOUT_OPTIONS_ADDR (VIA_EEPROM_MAGIC_ADDR+3) 31#define VIA_EEPROM_LAYOUT_OPTIONS_ADDR (VIA_EEPROM_MAGIC_ADDR + 3)
32 32
33// Changing the layout options size after release will invalidate EEPROM, 33// Changing the layout options size after release will invalidate EEPROM,
34// but this is something that should be set correctly on initial implementation. 34// but this is something that should be set correctly on initial implementation.
35// 1 byte is enough for most uses (i.e. 8 binary states, or 6 binary + 1 ternary/quaternary ) 35// 1 byte is enough for most uses (i.e. 8 binary states, or 6 binary + 1 ternary/quaternary )
36#ifndef VIA_EEPROM_LAYOUT_OPTIONS_SIZE 36#ifndef VIA_EEPROM_LAYOUT_OPTIONS_SIZE
37# define VIA_EEPROM_LAYOUT_OPTIONS_SIZE 1 37# define VIA_EEPROM_LAYOUT_OPTIONS_SIZE 1
38#endif 38#endif
39 39
40// The end of the EEPROM memory used by VIA 40// The end of the EEPROM memory used by VIA
41// By default, dynamic keymaps will start at this if there is no 41// By default, dynamic keymaps will start at this if there is no
42// custom config 42// custom config
43#define VIA_EEPROM_CUSTOM_CONFIG_ADDR (VIA_EEPROM_LAYOUT_OPTIONS_ADDR+VIA_EEPROM_LAYOUT_OPTIONS_SIZE) 43#define VIA_EEPROM_CUSTOM_CONFIG_ADDR (VIA_EEPROM_LAYOUT_OPTIONS_ADDR + VIA_EEPROM_LAYOUT_OPTIONS_SIZE)
44 44
45#ifndef VIA_EEPROM_CUSTOM_CONFIG_SIZE 45#ifndef VIA_EEPROM_CUSTOM_CONFIG_SIZE
46# define VIA_EEPROM_CUSTOM_CONFIG_SIZE 0 46# define VIA_EEPROM_CUSTOM_CONFIG_SIZE 0
47#endif 47#endif
48 48
49// This is changed only when the command IDs change, 49// This is changed only when the command IDs change,
50// so VIA Configurator can detect compatible firmware. 50// so VIA Configurator can detect compatible firmware.
51#define VIA_PROTOCOL_VERSION 0x0009 51#define VIA_PROTOCOL_VERSION 0x0009
52 52
53enum via_command_id 53enum via_command_id {
54{ 54 id_get_protocol_version = 0x01, // always 0x01
55 id_get_protocol_version = 0x01, // always 0x01
56 id_get_keyboard_value, 55 id_get_keyboard_value,
57 id_set_keyboard_value, 56 id_set_keyboard_value,
58 id_dynamic_keymap_get_keycode, 57 id_dynamic_keymap_get_keycode,
@@ -74,12 +73,7 @@ enum via_command_id
74 id_unhandled = 0xFF, 73 id_unhandled = 0xFF,
75}; 74};
76 75
77enum via_keyboard_value_id 76enum via_keyboard_value_id { id_uptime = 0x01, id_layout_options, id_switch_matrix_state };
78{
79 id_uptime = 0x01,
80 id_layout_options,
81 id_switch_matrix_state
82};
83 77
84// Can't use SAFE_RANGE here, it might change if someone adds 78// Can't use SAFE_RANGE here, it might change if someone adds
85// new values to enum quantum_keycodes. 79// new values to enum quantum_keycodes.
@@ -108,22 +102,22 @@ enum via_keycodes {
108}; 102};
109 103
110enum user_keycodes { 104enum user_keycodes {
111 USER00 = 0x5F80, 105 USER00 = 0x5F80,
112 USER01, 106 USER01,
113 USER02, 107 USER02,
114 USER03, 108 USER03,
115 USER04, 109 USER04,
116 USER05, 110 USER05,
117 USER06, 111 USER06,
118 USER07, 112 USER07,
119 USER08, 113 USER08,
120 USER09, 114 USER09,
121 USER10, 115 USER10,
122 USER11, 116 USER11,
123 USER12, 117 USER12,
124 USER13, 118 USER13,
125 USER14, 119 USER14,
126 USER15, 120 USER15,
127}; 121};
128 122
129// Can be called in an overriding via_init_kb() to test if keyboard level code usage of 123// Can be called in an overriding via_init_kb() to test if keyboard level code usage of
@@ -144,8 +138,7 @@ void via_init(void);
144 138
145// Used by VIA to store and retrieve the layout options. 139// Used by VIA to store and retrieve the layout options.
146uint32_t via_get_layout_options(void); 140uint32_t via_get_layout_options(void);
147void via_set_layout_options(uint32_t value); 141void via_set_layout_options(uint32_t value);
148 142
149// Called by QMK core to process VIA-specific keycodes. 143// Called by QMK core to process VIA-specific keycodes.
150bool process_record_via(uint16_t keycode, keyrecord_t *record); 144bool process_record_via(uint16_t keycode, keyrecord_t *record);
151