summaryrefslogtreecommitdiffstats
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/action.c95
-rw-r--r--quantum/action_layer.c76
-rw-r--r--quantum/action_tapping.c34
-rw-r--r--quantum/action_tapping.h8
-rw-r--r--quantum/action_util.c14
-rw-r--r--quantum/backlight/backlight_avr.c8
-rw-r--r--quantum/dynamic_keymap.c69
-rw-r--r--quantum/dynamic_keymap.h6
-rw-r--r--quantum/eeconfig.c2
-rw-r--r--quantum/eeconfig.h2
-rw-r--r--quantum/encoder.c142
-rw-r--r--quantum/encoder.h34
-rw-r--r--quantum/encoder/tests/config_mock.h22
-rw-r--r--quantum/encoder/tests/config_mock_split_left_eq_right.h26
-rw-r--r--quantum/encoder/tests/config_mock_split_left_gt_right.h26
-rw-r--r--quantum/encoder/tests/config_mock_split_left_lt_right.h26
-rw-r--r--quantum/encoder/tests/config_mock_split_no_left.h26
-rw-r--r--quantum/encoder/tests/config_mock_split_no_right.h26
-rw-r--r--quantum/encoder/tests/encoder_tests.cpp36
-rw-r--r--quantum/encoder/tests/encoder_tests_split_left_eq_right.cpp135
-rw-r--r--quantum/encoder/tests/encoder_tests_split_left_gt_right.cpp139
-rw-r--r--quantum/encoder/tests/encoder_tests_split_left_lt_right.cpp139
-rw-r--r--quantum/encoder/tests/encoder_tests_split_no_left.cpp (renamed from quantum/encoder/tests/encoder_tests_split.cpp)68
-rw-r--r--quantum/encoder/tests/encoder_tests_split_no_right.cpp118
-rw-r--r--quantum/encoder/tests/mock.h6
-rw-r--r--quantum/encoder/tests/mock_split.h16
-rw-r--r--quantum/encoder/tests/rules.mk53
-rw-r--r--quantum/encoder/tests/testlist.mk6
-rw-r--r--quantum/joystick.c37
-rw-r--r--quantum/joystick.h17
-rw-r--r--quantum/keyboard.c6
-rw-r--r--quantum/keyboard.h36
-rw-r--r--quantum/keycode_config.h2
-rw-r--r--quantum/keymap.h6
-rw-r--r--quantum/keymap_common.c13
-rw-r--r--quantum/main.c11
-rw-r--r--quantum/mousekey.c25
-rw-r--r--quantum/painter/qff.c137
-rw-r--r--quantum/painter/qff.h88
-rw-r--r--quantum/painter/qgf.c292
-rw-r--r--quantum/painter/qgf.h136
-rw-r--r--quantum/painter/qp.c228
-rw-r--r--quantum/painter/qp.h453
-rw-r--r--quantum/painter/qp_comms.c72
-rw-r--r--quantum/painter/qp_comms.h25
-rw-r--r--quantum/painter/qp_draw.h85
-rw-r--r--quantum/painter/qp_draw_circle.c172
-rw-r--r--quantum/painter/qp_draw_codec.c142
-rw-r--r--quantum/painter/qp_draw_core.c294
-rw-r--r--quantum/painter/qp_draw_ellipse.c116
-rw-r--r--quantum/painter/qp_draw_image.c382
-rw-r--r--quantum/painter/qp_draw_text.c444
-rw-r--r--quantum/painter/qp_internal.h33
-rw-r--r--quantum/painter/qp_internal_driver.h82
-rw-r--r--quantum/painter/qp_internal_formats.h49
-rw-r--r--quantum/painter/qp_stream.c171
-rw-r--r--quantum/painter/qp_stream.h82
-rw-r--r--quantum/painter/rules.mk116
-rw-r--r--quantum/pointing_device.c13
-rw-r--r--quantum/pointing_device.h1
-rw-r--r--quantum/pointing_device_drivers.c18
-rw-r--r--quantum/process_keycode/process_auto_shift.c7
-rw-r--r--quantum/process_keycode/process_combo.c11
-rw-r--r--quantum/process_keycode/process_joystick.c36
-rw-r--r--quantum/process_keycode/process_secure.c39
-rw-r--r--quantum/process_keycode/process_secure.h15
-rw-r--r--quantum/process_keycode/process_space_cadet.c7
-rw-r--r--quantum/process_keycode/process_tap_dance.c6
-rw-r--r--quantum/process_keycode/process_unicode_common.c63
-rw-r--r--quantum/process_keycode/process_unicode_common.h1
-rw-r--r--quantum/quantum.c29
-rw-r--r--quantum/quantum.h13
-rw-r--r--quantum/quantum_keycodes.h6
-rw-r--r--quantum/rgb_matrix/animations/digital_rain_anim.h22
-rw-r--r--quantum/rgb_matrix/animations/typing_heatmap_anim.h5
-rw-r--r--quantum/rgblight/rgblight.c23
-rw-r--r--quantum/rgblight/rgblight.h26
-rw-r--r--quantum/secure.c87
-rw-r--r--quantum/secure.h67
-rw-r--r--quantum/split_common/transactions.c21
-rw-r--r--quantum/split_common/transport.h3
-rw-r--r--quantum/utf8.c46
-rw-r--r--quantum/utf8.h21
-rw-r--r--quantum/util.h8
-rw-r--r--quantum/via.c108
85 files changed, 5397 insertions, 415 deletions
diff --git a/quantum/action.c b/quantum/action.c
index 3efed443a3..4e81a5466f 100644
--- a/quantum/action.c
+++ b/quantum/action.c
@@ -14,9 +14,18 @@ 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/>.
*/
+#include <limits.h>
+
+#ifdef DEBUG_ACTION
+# include "debug.h"
+#else
+# include "nodebug.h"
+#endif
+
#include "host.h"
#include "keycode.h"
#include "keyboard.h"
+#include "keymap.h"
#include "mousekey.h"
#include "programmable_button.h"
#include "command.h"
@@ -32,12 +41,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# include "backlight.h"
#endif
-#ifdef DEBUG_ACTION
-# include "debug.h"
-#else
-# include "nodebug.h"
-#endif
-
#ifdef POINTING_DEVICE_ENABLE
# include "pointing_device.h"
#endif
@@ -89,6 +92,7 @@ void action_exec(keyevent_t event) {
}
#ifdef SWAP_HANDS_ENABLE
+ // Swap hands handles both keys and encoders, if ENCODER_MAP_ENABLE is defined.
if (!IS_NOEVENT(event)) {
process_hand_swap(&event);
}
@@ -97,7 +101,7 @@ void action_exec(keyevent_t event) {
keyrecord_t record = {.event = event};
#ifndef NO_ACTION_ONESHOT
- if (!keymap_config.oneshot_disable) {
+ if (keymap_config.oneshot_enable) {
# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
if (has_oneshot_layer_timed_out()) {
clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
@@ -136,27 +140,65 @@ void action_exec(keyevent_t event) {
}
#ifdef SWAP_HANDS_ENABLE
+extern const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS];
+# ifdef ENCODER_MAP_ENABLE
+extern const uint8_t PROGMEM encoder_hand_swap_config[NUM_ENCODERS];
+# endif // ENCODER_MAP_ENABLE
+
bool swap_hands = false;
bool swap_held = false;
+bool should_swap_hands(size_t index, uint8_t *swap_state, bool pressed) {
+ size_t array_index = index / (CHAR_BIT);
+ size_t bit_index = index % (CHAR_BIT);
+ uint8_t bit_val = 1 << bit_index;
+ bool do_swap = pressed ? swap_hands : swap_state[array_index] & bit_val;
+ return do_swap;
+}
+
+void set_swap_hands_state(size_t index, uint8_t *swap_state, bool on) {
+ size_t array_index = index / (CHAR_BIT);
+ size_t bit_index = index % (CHAR_BIT);
+ uint8_t bit_val = 1 << bit_index;
+ if (on) {
+ swap_state[array_index] |= bit_val;
+ } else {
+ swap_state[array_index] &= ~bit_val;
+ }
+}
+
/** \brief Process Hand Swap
*
* FIXME: Needs documentation.
*/
void process_hand_swap(keyevent_t *event) {
- static swap_state_row_t swap_state[MATRIX_ROWS];
-
- keypos_t pos = event->key;
- swap_state_row_t col_bit = (swap_state_row_t)1 << pos.col;
- bool do_swap = event->pressed ? swap_hands : swap_state[pos.row] & (col_bit);
-
- if (do_swap) {
- event->key.row = pgm_read_byte(&hand_swap_config[pos.row][pos.col].row);
- event->key.col = pgm_read_byte(&hand_swap_config[pos.row][pos.col].col);
- swap_state[pos.row] |= col_bit;
- } else {
- swap_state[pos.row] &= ~(col_bit);
+ keypos_t pos = event->key;
+ if (pos.row < MATRIX_ROWS && pos.col < MATRIX_COLS) {
+ static uint8_t matrix_swap_state[((MATRIX_ROWS * MATRIX_COLS) + (CHAR_BIT)-1) / (CHAR_BIT)];
+ size_t index = (size_t)(pos.row * MATRIX_COLS) + pos.col;
+ bool do_swap = should_swap_hands(index, matrix_swap_state, event->pressed);
+ if (do_swap) {
+ event->key.row = pgm_read_byte(&hand_swap_config[pos.row][pos.col].row);
+ event->key.col = pgm_read_byte(&hand_swap_config[pos.row][pos.col].col);
+ set_swap_hands_state(index, matrix_swap_state, true);
+ } else {
+ set_swap_hands_state(index, matrix_swap_state, false);
+ }
+ }
+# ifdef ENCODER_MAP_ENABLE
+ else if (pos.row == KEYLOC_ENCODER_CW || pos.row == KEYLOC_ENCODER_CCW) {
+ static uint8_t encoder_swap_state[((NUM_ENCODERS) + (CHAR_BIT)-1) / (CHAR_BIT)];
+ size_t index = pos.col;
+ bool do_swap = should_swap_hands(index, encoder_swap_state, event->pressed);
+ if (do_swap) {
+ event->key.row = pos.row;
+ event->key.col = pgm_read_byte(&encoder_hand_swap_config[pos.col]);
+ set_swap_hands_state(index, encoder_swap_state, true);
+ } else {
+ set_swap_hands_state(index, encoder_swap_state, false);
+ }
}
+# endif // ENCODER_MAP_ENABLE
}
#endif
@@ -216,7 +258,7 @@ void process_record(keyrecord_t *record) {
if (!process_record_quantum(record)) {
#ifndef NO_ACTION_ONESHOT
- if (is_oneshot_layer_active() && record->event.pressed && !keymap_config.oneshot_disable) {
+ if (is_oneshot_layer_active() && record->event.pressed && keymap_config.oneshot_enable) {
clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
}
#endif
@@ -281,7 +323,7 @@ void process_action(keyrecord_t *record, action_t action) {
# ifdef SWAP_HANDS_ENABLE
&& !(action.kind.id == ACT_SWAP_HANDS && action.swap.code == OP_SH_ONESHOT)
# endif
- && !keymap_config.oneshot_disable) {
+ && keymap_config.oneshot_enable) {
clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
do_release_oneshot = !is_oneshot_layer_active();
}
@@ -325,7 +367,7 @@ void process_action(keyrecord_t *record, action_t action) {
# ifndef NO_ACTION_ONESHOT
case MODS_ONESHOT:
// Oneshot modifier
- if (keymap_config.oneshot_disable) {
+ if (!keymap_config.oneshot_enable) {
if (event.pressed) {
if (mods) {
if (IS_MOD(action.key.code) || action.key.code == KC_NO) {
@@ -362,7 +404,7 @@ void process_action(keyrecord_t *record, action_t action) {
} else if (tap_count == ONESHOT_TAP_TOGGLE) {
dprint("MODS_TAP: Toggling oneshot");
clear_oneshot_mods();
- set_oneshot_locked_mods(mods);
+ set_oneshot_locked_mods(mods | get_oneshot_locked_mods());
register_mods(mods);
# endif
} else {
@@ -376,8 +418,8 @@ void process_action(keyrecord_t *record, action_t action) {
// Retain Oneshot mods
# if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
if (mods & get_mods()) {
- clear_oneshot_locked_mods();
clear_oneshot_mods();
+ set_oneshot_locked_mods(~mods & get_oneshot_locked_mods());
unregister_mods(mods);
}
} else if (tap_count == ONESHOT_TAP_TOGGLE) {
@@ -571,7 +613,7 @@ void process_action(keyrecord_t *record, action_t action) {
# ifndef NO_ACTION_ONESHOT
case OP_ONESHOT:
// Oneshot modifier
- if (keymap_config.oneshot_disable) {
+ if (!keymap_config.oneshot_enable) {
if (event.pressed) {
layer_on(action.layer_tap.val);
} else {
@@ -581,7 +623,6 @@ void process_action(keyrecord_t *record, action_t action) {
# if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
do_release_oneshot = false;
if (event.pressed) {
- del_mods(get_oneshot_locked_mods());
if (get_oneshot_layer_state() == ONESHOT_TOGGLED) {
reset_oneshot_layer();
layer_off(action.layer_tap.val);
@@ -591,10 +632,8 @@ void process_action(keyrecord_t *record, action_t action) {
set_oneshot_layer(action.layer_tap.val, ONESHOT_START);
}
} else {
- add_mods(get_oneshot_locked_mods());
if (tap_count >= ONESHOT_TAP_TOGGLE) {
reset_oneshot_layer();
- clear_oneshot_locked_mods();
set_oneshot_layer(action.layer_tap.val, ONESHOT_TOGGLED);
} else {
clear_oneshot_layer_state(ONESHOT_PRESSED);
diff --git a/quantum/action_layer.c b/quantum/action_layer.c
index e20eedee40..473e0e948d 100644
--- a/quantum/action_layer.c
+++ b/quantum/action_layer.c
@@ -1,8 +1,5 @@
+#include <limits.h>
#include <stdint.h>
-#include "keyboard.h"
-#include "action.h"
-#include "util.h"
-#include "action_layer.h"
#ifdef DEBUG_ACTION
# include "debug.h"
@@ -10,6 +7,12 @@
# include "nodebug.h"
#endif
+#include "keyboard.h"
+#include "keymap.h"
+#include "action.h"
+#include "util.h"
+#include "action_layer.h"
+
/** \brief Default Layer State
*/
layer_state_t default_layer_state = 0;
@@ -223,19 +226,20 @@ void layer_debug(void) {
/** \brief source layer cache
*/
-uint8_t source_layers_cache[(MATRIX_ROWS * MATRIX_COLS + 7) / 8][MAX_LAYER_BITS] = {{0}};
+uint8_t source_layers_cache[((MATRIX_ROWS * MATRIX_COLS) + (CHAR_BIT)-1) / (CHAR_BIT)][MAX_LAYER_BITS] = {{0}};
+# ifdef ENCODER_MAP_ENABLE
+uint8_t encoder_source_layers_cache[(NUM_ENCODERS + (CHAR_BIT)-1) / (CHAR_BIT)][MAX_LAYER_BITS] = {{0}};
+# endif // ENCODER_MAP_ENABLE
-/** \brief update source layers cache
+/** \brief update source layers cache impl
*
- * Updates the cached keys when changing layers
+ * Updates the supplied cache when changing layers
*/
-void update_source_layers_cache(keypos_t key, uint8_t layer) {
- const uint8_t key_number = key.col + (key.row * MATRIX_COLS);
- const uint8_t storage_row = key_number / 8;
- const uint8_t storage_bit = key_number % 8;
-
+void update_source_layers_cache_impl(uint8_t layer, uint16_t entry_number, uint8_t cache[][MAX_LAYER_BITS]) {
+ const uint16_t storage_idx = entry_number / (CHAR_BIT);
+ const uint8_t storage_bit = entry_number % (CHAR_BIT);
for (uint8_t bit_number = 0; bit_number < MAX_LAYER_BITS; bit_number++) {
- source_layers_cache[storage_row][bit_number] ^= (-((layer & (1U << bit_number)) != 0) ^ source_layers_cache[storage_row][bit_number]) & (1U << storage_bit);
+ cache[storage_idx][bit_number] ^= (-((layer & (1U << bit_number)) != 0) ^ cache[storage_idx][bit_number]) & (1U << storage_bit);
}
}
@@ -243,18 +247,52 @@ void update_source_layers_cache(keypos_t key, uint8_t layer) {
*
* reads the cached keys stored when the layer was changed
*/
-uint8_t read_source_layers_cache(keypos_t key) {
- const uint8_t key_number = key.col + (key.row * MATRIX_COLS);
- const uint8_t storage_row = key_number / 8;
- const uint8_t storage_bit = key_number % 8;
- uint8_t layer = 0;
+uint8_t read_source_layers_cache_impl(uint16_t entry_number, uint8_t cache[][MAX_LAYER_BITS]) {
+ const uint16_t storage_idx = entry_number / (CHAR_BIT);
+ const uint8_t storage_bit = entry_number % (CHAR_BIT);
+ uint8_t layer = 0;
for (uint8_t bit_number = 0; bit_number < MAX_LAYER_BITS; bit_number++) {
- layer |= ((source_layers_cache[storage_row][bit_number] & (1U << storage_bit)) != 0) << bit_number;
+ layer |= ((cache[storage_idx][bit_number] & (1U << storage_bit)) != 0) << bit_number;
}
return layer;
}
+
+/** \brief update encoder source layers cache
+ *
+ * Updates the cached encoders when changing layers
+ */
+void update_source_layers_cache(keypos_t key, uint8_t layer) {
+ if (key.row < MATRIX_ROWS && key.col < MATRIX_COLS) {
+ const uint16_t entry_number = (uint16_t)(key.row * MATRIX_COLS) + key.col;
+ update_source_layers_cache_impl(layer, entry_number, source_layers_cache);
+ }
+# ifdef ENCODER_MAP_ENABLE
+ else if (key.row == KEYLOC_ENCODER_CW || key.row == KEYLOC_ENCODER_CCW) {
+ const uint16_t entry_number = key.col;
+ update_source_layers_cache_impl(layer, entry_number, encoder_source_layers_cache);
+ }
+# endif // ENCODER_MAP_ENABLE
+}
+
+/** \brief read source layers cache
+ *
+ * reads the cached keys stored when the layer was changed
+ */
+uint8_t read_source_layers_cache(keypos_t key) {
+ if (key.row < MATRIX_ROWS && key.col < MATRIX_COLS) {
+ const uint16_t entry_number = (uint16_t)(key.row *