summaryrefslogtreecommitdiffstats
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/debounce/asym_eager_defer_pk.c2
-rw-r--r--quantum/debounce/sym_eager_pk.c1
-rw-r--r--quantum/debounce/sym_eager_pr.c1
-rw-r--r--quantum/keymap.h20
-rw-r--r--quantum/mousekey.c18
-rw-r--r--quantum/process_keycode/process_autocorrect.c19
-rw-r--r--quantum/process_keycode/process_autocorrect.h1
-rw-r--r--quantum/process_keycode/process_dynamic_macro.c117
-rw-r--r--quantum/process_keycode/process_dynamic_macro.h1
-rw-r--r--quantum/quantum.c2
-rw-r--r--quantum/quantum_keycodes.h4
-rw-r--r--quantum/quantum_keycodes_legacy.h3
-rw-r--r--quantum/rgb_matrix/animations/pixel_rain_anim.h10
-rw-r--r--quantum/rgb_matrix/rgb_matrix_drivers.c15
-rw-r--r--quantum/split_common/transactions.c2
15 files changed, 118 insertions, 98 deletions
diff --git a/quantum/debounce/asym_eager_defer_pk.c b/quantum/debounce/asym_eager_defer_pk.c
index 4745c6f465..0f7640a80c 100644
--- a/quantum/debounce/asym_eager_defer_pk.c
+++ b/quantum/debounce/asym_eager_defer_pk.c
@@ -144,6 +144,8 @@ static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[],
static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows) {
debounce_counter_t *debounce_pointer = debounce_counters;
+ matrix_need_update = false;
+
for (uint8_t row = 0; row < num_rows; row++) {
matrix_row_t delta = raw[row] ^ cooked[row];
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
diff --git a/quantum/debounce/sym_eager_pk.c b/quantum/debounce/sym_eager_pk.c
index f736d1645c..15360441de 100644
--- a/quantum/debounce/sym_eager_pk.c
+++ b/quantum/debounce/sym_eager_pk.c
@@ -125,6 +125,7 @@ static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time) {
// upload from raw_matrix to final matrix;
static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows) {
+ matrix_need_update = false;
debounce_counter_t *debounce_pointer = debounce_counters;
for (uint8_t row = 0; row < num_rows; row++) {
matrix_row_t delta = raw[row] ^ cooked[row];
diff --git a/quantum/debounce/sym_eager_pr.c b/quantum/debounce/sym_eager_pr.c
index aad5ca351b..84f897d674 100644
--- a/quantum/debounce/sym_eager_pr.c
+++ b/quantum/debounce/sym_eager_pr.c
@@ -119,6 +119,7 @@ static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time) {
// upload from raw_matrix to final matrix;
static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows) {
+ matrix_need_update = false;
debounce_counter_t *debounce_pointer = debounce_counters;
for (uint8_t row = 0; row < num_rows; row++) {
matrix_row_t existing_row = cooked[row];
diff --git a/quantum/keymap.h b/quantum/keymap.h
deleted file mode 100644
index a067e1aa36..0000000000
--- a/quantum/keymap.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
-Copyright 2012-2016 Jun Wako <wakojun@gmail.com>
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-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
-
-#pragma message("'keymap.h' should no longer be included!")
diff --git a/quantum/mousekey.c b/quantum/mousekey.c
index df8aa613be..ede055dc8f 100644
--- a/quantum/mousekey.c
+++ b/quantum/mousekey.c
@@ -74,7 +74,7 @@ uint8_t mk_time_to_max = MOUSEKEY_TIME_TO_MAX;
uint8_t mk_wheel_delay = MOUSEKEY_WHEEL_DELAY / 10;
/* milliseconds between repeated motion events (0-255) */
# ifdef MK_KINETIC_SPEED
-float mk_wheel_interval = 1000.0f / MOUSEKEY_WHEEL_INITIAL_MOVEMENTS;
+uint16_t mk_wheel_interval = 1000U / MOUSEKEY_WHEEL_INITIAL_MOVEMENTS;
# else
uint8_t mk_wheel_interval = MOUSEKEY_WHEEL_INTERVAL;
# endif
@@ -190,37 +190,37 @@ const uint16_t mk_decelerated_speed = MOUSEKEY_DECELERATED_SPEED;
const uint16_t mk_initial_speed = MOUSEKEY_INITIAL_SPEED;
static uint8_t move_unit(void) {
- float speed = mk_initial_speed;
+ uint16_t speed = mk_initial_speed;
if (mousekey_accel & ((1 << 0) | (1 << 2))) {
speed = mousekey_accel & (1 << 2) ? mk_accelerated_speed : mk_decelerated_speed;
} else if (mousekey_repeat && mouse_timer) {
- const float time_elapsed = timer_elapsed(mouse_timer) / 50;
- speed = mk_initial_speed + MOUSEKEY_MOVE_DELTA * time_elapsed + MOUSEKEY_MOVE_DELTA * 0.5 * time_elapsed * time_elapsed;
+ const uint16_t time_elapsed = timer_elapsed(mouse_timer) / 50;
+ speed = mk_initial_speed + MOUSEKEY_MOVE_DELTA * time_elapsed + MOUSEKEY_MOVE_DELTA * 0.5 * time_elapsed * time_elapsed;
speed = speed > mk_base_speed ? mk_base_speed : speed;
}
/* convert speed to USB mouse speed 1 to 127 */
- speed = (uint8_t)(speed / (1000.0f / mk_interval));
+ speed = (uint8_t)(speed / (1000U / mk_interval));
speed = speed < 1 ? 1 : speed;
return speed > MOUSEKEY_MOVE_MAX ? MOUSEKEY_MOVE_MAX : speed;
}
static uint8_t wheel_unit(void) {
- float speed = MOUSEKEY_WHEEL_INITIAL_MOVEMENTS;
+ uint16_t speed = MOUSEKEY_WHEEL_INITIAL_MOVEMENTS;
if (mousekey_accel & ((1 << 0) | (1 << 2))) {
speed = mousekey_accel & (1 << 2) ? MOUSEKEY_WHEEL_ACCELERATED_MOVEMENTS : MOUSEKEY_WHEEL_DECELERATED_MOVEMENTS;
} else if (mousekey_wheel_repeat && mouse_timer) {
if (mk_wheel_interval != MOUSEKEY_WHEEL_BASE_MOVEMENTS) {
- const float time_elapsed = timer_elapsed(mouse_timer) / 50;
- speed = MOUSEKEY_WHEEL_INITIAL_MOVEMENTS + 1 * time_elapsed + 1 * 0.5 * time_elapsed * time_elapsed;
+ const uint16_t time_elapsed = timer_elapsed(mouse_timer) / 50;
+ speed = MOUSEKEY_WHEEL_INITIAL_MOVEMENTS + 1 * time_elapsed + 1 * 0.5 * time_elapsed * time_elapsed;
}
speed = speed > MOUSEKEY_WHEEL_BASE_MOVEMENTS ? MOUSEKEY_WHEEL_BASE_MOVEMENTS : speed;
}
- mk_wheel_interval = 1000.0f / speed;
+ mk_wheel_interval = 1000U / speed;
return (uint8_t)speed > MOUSEKEY_WHEEL_INITIAL_MOVEMENTS ? 2 : 1;
}
diff --git a/quantum/process_keycode/process_autocorrect.c b/quantum/process_keycode/process_autocorrect.c
index 1376788266..7c9cb814e5 100644
--- a/quantum/process_keycode/process_autocorrect.c
+++ b/quantum/process_keycode/process_autocorrect.c
@@ -57,7 +57,7 @@ void autocorrect_toggle(void) {
}
/**
- * @brief handler for determining if autocorrect should process keypress
+ * @brief handler for user to override whether autocorrect should process this keypress
*
* @param keycode Keycode registered by matrix press, per keymap
* @param record keyrecord_t structure
@@ -67,6 +67,23 @@ void autocorrect_toggle(void) {
* @return false Stop processing and escape from autocorrect.
*/
__attribute__((weak)) bool process_autocorrect_user(uint16_t *keycode, keyrecord_t *record, uint8_t *typo_buffer_size, uint8_t *mods) {
+ return process_autocorrect_default_handler(keycode, record, typo_buffer_size, mods);
+}
+
+/**
+ * @brief fallback handler for determining if autocorrect should process this keypress
+ * can be used by user callback to get the basic keycode being "wrapped"
+ *
+ * NOTE: These values may have been edited by user callback before getting here
+ *
+ * @param keycode Keycode registered by matrix press, per keymap
+ * @param record keyrecord_t structure
+ * @param typo_buffer_size passed along to allow resetting of autocorrect buffer
+ * @param mods allow processing of mod status
+ * @return true Allow autocorection
+ * @return false Stop processing and escape from autocorrect.
+ */
+bool process_autocorrect_default_handler(uint16_t *keycode, keyrecord_t *record, uint8_t *typo_buffer_size, uint8_t *mods) {
// See quantum_keycodes.h for reference on these matched ranges.
switch (*keycode) {
// Exclude these keycodes from processing.
diff --git a/quantum/process_keycode/process_autocorrect.h b/quantum/process_keycode/process_autocorrect.h
index c7596107e5..00dacbf958 100644
--- a/quantum/process_keycode/process_autocorrect.h
+++ b/quantum/process_keycode/process_autocorrect.h
@@ -9,6 +9,7 @@
bool process_autocorrect(uint16_t keycode, keyrecord_t *record);
bool process_autocorrect_user(uint16_t *keycode, keyrecord_t *record, uint8_t *typo_buffer_size, uint8_t *mods);
+bool process_autocorrect_default_handler(uint16_t *keycode, keyrecord_t *record, uint8_t *typo_buffer_size, uint8_t *mods);
bool apply_autocorrect(uint8_t backspaces, const char *str);
bool autocorrect_is_enabled(void);
diff --git a/quantum/process_keycode/process_dynamic_macro.c b/quantum/process_keycode/process_dynamic_macro.c
index bf6af566e2..a022949d3d 100644
--- a/quantum/process_keycode/process_dynamic_macro.c
+++ b/quantum/process_keycode/process_dynamic_macro.c
@@ -151,6 +151,67 @@ void dynamic_macro_record_end(keyrecord_t *macro_buffer, keyrecord_t *macro_poin
*macro_end = macro_pointer;
}
+/* Both macros use the same buffer but read/write on different
+ * ends of it.
+ *
+ * Macro1 is written left-to-right starting from the beginning of
+ * the buffer.
+ *
+ * Macro2 is written right-to-left starting from the end of the
+ * buffer.
+ *
+ * &macro_buffer macro_end
+ * v v
+ * +------------------------------------------------------------+
+ * |>>>>>> MACRO1 >>>>>> <<<<<<<<<<<<< MACRO2 <<<<<<<<<<<<<|
+ * +------------------------------------------------------------+
+ * ^ ^
+ * r_macro_end r_macro_buffer
+ *
+ * During the recording when one macro encounters the end of the
+ * other macro, the recording is stopped. Apart from this, there
+ * are no arbitrary limits for the macros' length in relation to
+ * each other: for example one can either have two medium sized
+ * macros or one long macro and one short macro. Or even one empty
+ * and one using the whole buffer.
+ */
+static keyrecord_t macro_buffer[DYNAMIC_MACRO_SIZE];
+
+/* Pointer to the first buffer element after the first macro.
+ * Initially points to the very beginning of the buffer since the
+ * macro is empty. */
+static keyrecord_t *macro_end = macro_buffer;
+
+/* The other end of the macro buffer. Serves as the beginning of
+ * the second macro. */
+static keyrecord_t *const r_macro_buffer = macro_buffer + DYNAMIC_MACRO_SIZE - 1;
+
+/* Like macro_end but for the second macro. */
+static keyrecord_t *r_macro_end = r_macro_buffer;
+
+/* A persistent pointer to the current macro position (iterator)
+ * used during the recording. */
+static keyrecord_t *macro_pointer = NULL;
+
+/* 0 - no macro is being recorded right now
+ * 1,2 - either macro 1 or 2 is being recorded */
+static uint8_t macro_id = 0;
+
+/**
+ * If a dynamic macro is currently being recorded, stop recording.
+ */
+void dynamic_macro_stop_recording(void) {
+ switch (macro_id) {
+ case 1:
+ dynamic_macro_record_end(macro_buffer, macro_pointer, +1, &macro_end);
+ break;
+ case 2:
+ dynamic_macro_record_end(r_macro_buffer, macro_pointer, -1, &r_macro_end);
+ break;
+ }
+ macro_id = 0;
+}
+
/* Handle the key events related to the dynamic macros. Should be
* called from process_record_user() like this:
*
@@ -162,52 +223,6 @@ void dynamic_macro_record_end(keyrecord_t *macro_buffer, keyrecord_t *macro_poin
* }
*/
bool process_dynamic_macro(uint16_t keycode, keyrecord_t *record) {
- /* Both macros use the same buffer but read/write on different
- * ends of it.
- *
- * Macro1 is written left-to-right starting from the beginning of
- * the buffer.
- *
- * Macro2 is written right-to-left starting from the end of the
- * buffer.
- *
- * &macro_buffer macro_end
- * v v
- * +------------------------------------------------------------+
- * |>>>>>> MACRO1 >>>>>> <<<<<<<<<<<<< MACRO2 <<<<<<<<<<<<<|
- * +------------------------------------------------------------+
- * ^ ^
- * r_macro_end r_macro_buffer
- *
- * During the recording when one macro encounters the end of the
- * other macro, the recording is stopped. Apart from this, there
- * are no arbitrary limits for the macros' length in relation to
- * each other: for example one can either have two medium sized
- * macros or one long macro and one short macro. Or even one empty
- * and one using the whole buffer.
- */
- static keyrecord_t macro_buffer[DYNAMIC_MACRO_SIZE];
-
- /* Pointer to the first buffer element after the first macro.
- * Initially points to the very beginning of the buffer since the
- * macro is empty. */
- static keyrecord_t *macro_end = macro_buffer;
-
- /* The other end of the macro buffer. Serves as the beginning of
- * the second macro. */
- static keyrecord_t *const r_macro_buffer = macro_buffer + DYNAMIC_MACRO_SIZE - 1;
-
- /* Like macro_end but for the second macro. */
- static keyrecord_t *r_macro_end = r_macro_buffer;
-
- /* A persistent pointer to the current macro position (iterator)
- * used during the recording. */
- static keyrecord_t *macro_pointer = NULL;
-
- /* 0 - no macro is being recorded right now
- * 1,2 - either macro 1 or 2 is being recorded */
- static uint8_t macro_id = 0;
-
if (macro_id == 0) {
/* No macro recording in progress. */
if (!record->event.pressed) {
@@ -238,15 +253,7 @@ bool process_dynamic_macro(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed ^ (keycode != QK_DYNAMIC_MACRO_RECORD_STOP)) { /* Ignore the initial release
* just after the recording
* starts for DM_RSTP. */
- switch (macro_id) {
- case 1:
- dynamic_macro_record_end(macro_buffer, macro_pointer, +1, &macro_end);
- break;
- case 2:
- dynamic_macro_record_end(r_macro_buffer, macro_pointer, -1, &r_macro_end);
- break;
- }
- macro_id = 0;
+ dynamic_macro_stop_recording();
}
return false;
#ifdef DYNAMIC_MACRO_NO_NESTING
diff --git a/quantum/process_keycode/process_dynamic_macro.h b/quantum/process_keycode/process_dynamic_macro.h
index ab70726897..9841254af4 100644
--- a/quantum/process_keycode/process_dynamic_macro.h
+++ b/quantum/process_keycode/process_dynamic_macro.h
@@ -39,3 +39,4 @@ void dynamic_macro_record_start_user(int8_t direction);
void dynamic_macro_play_user(int8_t direction);
void dynamic_macro_record_key_user(int8_t direction, keyrecord_t *record);
void dynamic_macro_record_end_user(int8_t direction);
+void dynamic_macro_stop_recording(void);
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 091cf298f7..fe3e85720d 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -468,7 +468,7 @@ void suspend_power_down_quantum(void) {
#ifndef NO_SUSPEND_POWER_DOWN
// Turn off backlight
# ifdef BACKLIGHT_ENABLE
- backlight_set(0);
+ backlight_level_noeeprom(0);
# endif
# ifdef LED_MATRIX_ENABLE
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index f931b7e4c7..d3249bd455 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -179,10 +179,10 @@
#define QK_UNICODE_GET_CODE_POINT(kc) ((kc)&0x7FFF)
// UNICODEMAP_ENABLE - Allows Unicode input up to 0x10FFFF, requires unicode_map
-#define X(i) (QK_UNICODEMAP | ((i)&0x3FFF))
+#define UM(i) (QK_UNICODEMAP | ((i)&0x3FFF))
#define QK_UNICODEMAP_GET_INDEX(kc) ((kc)&0x3FFF)
-#define XP(i, j) (QK_UNICODEMAP_PAIR | ((i)&0x7F) | (((j)&0x7F) << 7)) // 127 max i and j
+#define UP(i, j) (QK_UNICODEMAP_PAIR | ((i)&0x7F) | (((j)&0x7F) << 7)) // 127 max i and j
#define QK_UNICODEMAP_PAIR_GET_UNSHIFTED_INDEX(kc) ((kc)&0x7F)
#define QK_UNICODEMAP_PAIR_GET_SHIFTED_INDEX(kc) (((kc) >> 7) & 0x7F)
diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h
index 120c98bc62..ad078cdad5 100644
--- a/quantum/quantum_keycodes_legacy.h
+++ b/quantum/quantum_keycodes_legacy.h
@@ -53,3 +53,6 @@
#define GUI_ON QK_MAGIC_GUI_ON
#define GUI_OFF QK_MAGIC_GUI_OFF
#define GUI_TOG QK_MAGIC_TOGGLE_GUI
+
+#define X(i) UM(i)
+#define XP(i, j) UM(i, j)
diff --git a/quantum/rgb_matrix/animations/pixel_rain_anim.h b/quantum/rgb_matrix/animations/pixel_rain_anim.h
index 9d63f451e2..26cd73b578 100644
--- a/quantum/rgb_matrix/animations/pixel_rain_anim.h
+++ b/quantum/rgb_matrix/animations/pixel_rain_anim.h
@@ -16,13 +16,9 @@ static bool PIXEL_RAIN(effect_params_t* params) {
if (!HAS_ANY_FLAGS(g_led_config.flags[led_index], params->flags)) {
return;
}
- if (random8() & 2) {
- rgb_matrix_set_color(led_index, 0, 0, 0);
- } else {
- HSV hsv = {random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v};
- RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
- rgb_matrix_set_color(led_index, rgb.r, rgb.g, rgb.b);
- }
+ HSV hsv = (random8() & 2) ? (HSV){0, 0, 0} : (HSV){random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v};
+ RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
+ rgb_matrix_set_color(led_index, rgb.r, rgb.g, rgb.b);
wait_timer = g_rgb_timer + interval();
}
diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c
index d66fc801dd..6de20ac8a5 100644
--- a/quantum/rgb_matrix/rgb_matrix_drivers.c
+++ b/quantum/rgb_matrix/rgb_matrix_drivers.c
@@ -426,11 +426,17 @@ const rgb_matrix_driver_t rgb_matrix_driver = {
// LED color buffer
LED_TYPE rgb_matrix_ws2812_array[RGB_MATRIX_LED_COUNT];
+bool ws2812_dirty = false;
-static void init(void) {}
+static void init(void) {
+ ws2812_dirty = false;
+}
static void flush(void) {
- ws2812_setleds(rgb_matrix_ws2812_array, RGB_MATRIX_LED_COUNT);
+ if (ws2812_dirty) {
+ ws2812_setleds(rgb_matrix_ws2812_array, RGB_MATRIX_LED_COUNT);
+ ws2812_dirty = false;
+ }
}
// Set an led in the buffer to a color
@@ -448,6 +454,11 @@ static inline void setled(int i, uint8_t r, uint8_t g, uint8_t b) {
}
# endif
+ if (rgb_matrix_ws2812_array[i].r == r && rgb_matrix_ws2812_array[i].g == g && rgb_matrix_ws2812_array[i].b == b) {
+ return;
+ }
+
+ ws2812_dirty = true;
rgb_matrix_ws2812_array[i].r = r;
rgb_matrix_ws2812_array[i].g = g;
rgb_matrix_ws2812_array[i].b = b;
diff --git a/quantum/split_common/transactions.c b/quantum/split_common/transactions.c
index b3c80f1194..8cd018a6ec 100644
--- a/quantum/split_common/transactions.c
+++ b/quantum/split_common/transactions.c
@@ -412,7 +412,7 @@ static void backlight_handlers_slave(matrix_row_t master_matrix[], matrix_row_t
uint8_t backlight_level = split_shmem->backlight_level;
split_shared_memory_unlock();
- backlight_set(backlight_level);
+ backlight_level_noeeprom(backlight_level);
}
# define TRANSACTIONS_BACKLIGHT_MASTER() TRANSACTION_HANDLER_MASTER(backlight)