summaryrefslogtreecommitdiffstats
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/action.c19
-rw-r--r--quantum/action_util.c25
-rw-r--r--quantum/action_util.h13
-rw-r--r--quantum/audio/audio.c45
-rw-r--r--quantum/backlight/backlight.c1
-rw-r--r--quantum/backlight/backlight_avr.c473
-rw-r--r--quantum/backlight/backlight_chibios.c173
-rw-r--r--quantum/backlight/backlight_driver_common.c3
-rw-r--r--quantum/backlight/backlight_software.c54
-rw-r--r--quantum/backlight/backlight_timer.c179
-rw-r--r--quantum/debounce.h4
-rw-r--r--quantum/debounce/asym_eager_defer_pk.c5
-rw-r--r--quantum/debounce/none.c4
-rw-r--r--quantum/debounce/sym_defer_g.c3
-rw-r--r--quantum/debounce/sym_defer_pk.c3
-rw-r--r--quantum/debounce/sym_defer_pr.c3
-rw-r--r--quantum/debounce/sym_eager_pk.c4
-rw-r--r--quantum/debounce/sym_eager_pr.c4
-rw-r--r--quantum/debounce/tests/debounce_test_common.cpp3
-rw-r--r--quantum/debounce/tests/debounce_test_common.h2
-rw-r--r--quantum/dynamic_keymap.c15
-rw-r--r--quantum/keycode_config.c44
-rw-r--r--quantum/keymap.h20
-rw-r--r--quantum/keymap_extras/sendstring_belgian.h2
-rw-r--r--quantum/keymap_extras/sendstring_bepo.h2
-rw-r--r--quantum/keymap_extras/sendstring_brazilian_abnt2.h2
-rw-r--r--quantum/keymap_extras/sendstring_canadian_multilingual.h2
-rw-r--r--quantum/keymap_extras/sendstring_colemak.h1
-rw-r--r--quantum/keymap_extras/sendstring_croatian.h2
-rw-r--r--quantum/keymap_extras/sendstring_czech.h2
-rw-r--r--quantum/keymap_extras/sendstring_danish.h2
-rw-r--r--quantum/keymap_extras/sendstring_dvorak.h1
-rw-r--r--quantum/keymap_extras/sendstring_dvorak_fr.h1
-rw-r--r--quantum/keymap_extras/sendstring_dvorak_programmer.h2
-rw-r--r--quantum/keymap_extras/sendstring_estonian.h2
-rw-r--r--quantum/keymap_extras/sendstring_finnish.h2
-rw-r--r--quantum/keymap_extras/sendstring_french.h2
-rw-r--r--quantum/keymap_extras/sendstring_french_afnor.h2
-rw-r--r--quantum/keymap_extras/sendstring_french_mac_iso.h2
-rw-r--r--quantum/keymap_extras/sendstring_german.h2
-rw-r--r--quantum/keymap_extras/sendstring_german_mac_iso.h2
-rw-r--r--quantum/keymap_extras/sendstring_hungarian.h2
-rw-r--r--quantum/keymap_extras/sendstring_icelandic.h2
-rw-r--r--quantum/keymap_extras/sendstring_italian.h2
-rw-r--r--quantum/keymap_extras/sendstring_italian_mac_ansi.h2
-rw-r--r--quantum/keymap_extras/sendstring_italian_mac_iso.h2
-rw-r--r--quantum/keymap_extras/sendstring_japanese.h2
-rw-r--r--quantum/keymap_extras/sendstring_latvian.h2
-rw-r--r--quantum/keymap_extras/sendstring_lithuanian_azerty.h2
-rw-r--r--quantum/keymap_extras/sendstring_lithuanian_qwerty.h2
-rw-r--r--quantum/keymap_extras/sendstring_norman.h1
-rw-r--r--quantum/keymap_extras/sendstring_norwegian.h2
-rw-r--r--quantum/keymap_extras/sendstring_portuguese.h2
-rw-r--r--quantum/keymap_extras/sendstring_portuguese_mac_iso.h2
-rw-r--r--quantum/keymap_extras/sendstring_romanian.h2
-rw-r--r--quantum/keymap_extras/sendstring_serbian_latin.h2
-rw-r--r--quantum/keymap_extras/sendstring_slovak.h2
-rw-r--r--quantum/keymap_extras/sendstring_slovenian.h2
-rw-r--r--quantum/keymap_extras/sendstring_spanish.h2
-rw-r--r--quantum/keymap_extras/sendstring_spanish_dvorak.h2
-rw-r--r--quantum/keymap_extras/sendstring_swedish.h2
-rw-r--r--quantum/keymap_extras/sendstring_swiss_de.h2
-rw-r--r--quantum/keymap_extras/sendstring_swiss_fr.h2
-rw-r--r--quantum/keymap_extras/sendstring_turkish_f.h2
-rw-r--r--quantum/keymap_extras/sendstring_turkish_q.h2
-rw-r--r--quantum/keymap_extras/sendstring_uk.h2
-rw-r--r--quantum/keymap_extras/sendstring_us_international.h2
-rw-r--r--quantum/keymap_extras/sendstring_workman.h1
-rw-r--r--quantum/keymap_extras/sendstring_workman_zxcvm.h1
-rw-r--r--quantum/led.c6
-rw-r--r--quantum/led.h7
-rw-r--r--quantum/led_matrix/led_matrix.c5
-rw-r--r--quantum/led_matrix/led_matrix.h3
-rw-r--r--quantum/mousekey.c68
-rw-r--r--quantum/mousekey.h6
-rw-r--r--quantum/painter/lvgl/qp_lvgl.c2
-rw-r--r--quantum/painter/qp.c29
-rw-r--r--quantum/painter/qp_comms.c8
-rw-r--r--quantum/painter/qp_draw_circle.c2
-rw-r--r--quantum/painter/qp_draw_core.c6
-rw-r--r--quantum/painter/qp_draw_ellipse.c2
-rw-r--r--quantum/painter/qp_draw_image.c6
-rw-r--r--quantum/painter/qp_draw_text.c8
-rw-r--r--quantum/process_keycode/process_auto_shift.c10
-rw-r--r--quantum/process_keycode/process_auto_shift.h8
-rw-r--r--quantum/process_keycode/process_autocorrect.c74
-rw-r--r--quantum/process_keycode/process_autocorrect.h4
-rw-r--r--quantum/process_keycode/process_dynamic_macro.c117
-rw-r--r--quantum/process_keycode/process_dynamic_macro.h1
-rw-r--r--quantum/process_keycode/process_key_override.c9
-rw-r--r--quantum/quantum.c8
-rw-r--r--quantum/quantum_keycodes.h4
-rw-r--r--quantum/quantum_keycodes_legacy.h3
-rw-r--r--quantum/rgb_matrix/animations/pixel_fractal_anim.h6
-rw-r--r--quantum/rgb_matrix/animations/pixel_rain_anim.h10
-rw-r--r--quantum/rgb_matrix/rgb_matrix.c5
-rw-r--r--quantum/rgb_matrix/rgb_matrix.h3
-rw-r--r--quantum/rgb_matrix/rgb_matrix_drivers.c15
-rw-r--r--quantum/split_common/transactions.c2
-rw-r--r--quantum/via.c99
-rw-r--r--quantum/via.h14
101 files changed, 571 insertions, 1164 deletions
diff --git a/quantum/action.c b/quantum/action.c
index a45e70c557..6368f7398c 100644
--- a/quantum/action.c
+++ b/quantum/action.c
@@ -528,6 +528,13 @@ void process_action(keyrecord_t *record, action_t action) {
unregister_code(action.key.code);
} else {
ac_dprintf("MODS_TAP: No tap: add_mods\n");
+# if defined(RETRO_TAPPING) && defined(DUMMY_MOD_NEUTRALIZER_KEYCODE)
+ // Send a dummy keycode to neutralize flashing modifiers
+ // if the key was held and then released with no interruptions.
+ if (retro_tapping_counter == 2) {
+ neutralize_flashing_modifiers(get_mods());
+ }
+# endif
unregister_mods(mods);
}
}
@@ -882,7 +889,7 @@ __attribute__((weak)) void register_code(uint8_t code) {
} else if (KC_LOCKING_CAPS_LOCK == code) {
# ifdef LOCKING_RESYNC_ENABLE
// Resync: ignore if caps lock already is on
- if (host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK)) return;
+ if (host_keyboard_led_state().caps_lock) return;
# endif
add_key(KC_CAPS_LOCK);
send_keyboard_report();
@@ -892,7 +899,7 @@ __attribute__((weak)) void register_code(uint8_t code) {
} else if (KC_LOCKING_NUM_LOCK == code) {
# ifdef LOCKING_RESYNC_ENABLE
- if (host_keyboard_leds() & (1 << USB_LED_NUM_LOCK)) return;
+ if (host_keyboard_led_state().num_lock) return;
# endif
add_key(KC_NUM_LOCK);
send_keyboard_report();
@@ -902,7 +909,7 @@ __attribute__((weak)) void register_code(uint8_t code) {
} else if (KC_LOCKING_SCROLL_LOCK == code) {
# ifdef LOCKING_RESYNC_ENABLE
- if (host_keyboard_leds() & (1 << USB_LED_SCROLL_LOCK)) return;
+ if (host_keyboard_led_state().scroll_lock) return;
# endif
add_key(KC_SCROLL_LOCK);
send_keyboard_report();
@@ -952,7 +959,7 @@ __attribute__((weak)) void unregister_code(uint8_t code) {
} else if (KC_LOCKING_CAPS_LOCK == code) {
# ifdef LOCKING_RESYNC_ENABLE
// Resync: ignore if caps lock already is off
- if (!(host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK))) return;
+ if (!host_keyboard_led_state().caps_lock) return;
# endif
add_key(KC_CAPS_LOCK);
send_keyboard_report();
@@ -961,7 +968,7 @@ __attribute__((weak)) void unregister_code(uint8_t code) {
} else if (KC_LOCKING_NUM_LOCK == code) {
# ifdef LOCKING_RESYNC_ENABLE
- if (!(host_keyboard_leds() & (1 << USB_LED_NUM_LOCK))) return;
+ if (!host_keyboard_led_state().num_lock) return;
# endif
add_key(KC_NUM_LOCK);
send_keyboard_report();
@@ -970,7 +977,7 @@ __attribute__((weak)) void unregister_code(uint8_t code) {
} else if (KC_LOCKING_SCROLL_LOCK == code) {
# ifdef LOCKING_RESYNC_ENABLE
- if (!(host_keyboard_leds() & (1 << USB_LED_SCROLL_LOCK))) return;
+ if (!host_keyboard_led_state().scroll_lock) return;
# endif
add_key(KC_SCROLL_LOCK);
send_keyboard_report();
diff --git a/quantum/action_util.c b/quantum/action_util.c
index 361f410d2d..909dea0595 100644
--- a/quantum/action_util.c
+++ b/quantum/action_util.c
@@ -500,3 +500,28 @@ __attribute__((weak)) void oneshot_layer_changed_kb(uint8_t layer) {
uint8_t has_anymod(void) {
return bitpop(real_mods);
}
+
+#ifdef DUMMY_MOD_NEUTRALIZER_KEYCODE
+/** \brief Send a dummy keycode in between the register and unregister event of a modifier key, to neutralize the "flashing modifiers" phenomenon.
+ *
+ * \param active_mods 8-bit packed bit-array describing the currently active modifiers (in the format GASCGASC).
+ *
+ * Certain QMK features like key overrides or retro tap must unregister a previously
+ * registered modifier before sending another keycode but this can trigger undesired
+ * keyboard shortcuts if the clean tap of a single modifier key is bound to an action
+ * on the host OS, as is for example the case for the left GUI key on Windows, which
+ * opens the Start Menu when tapped.
+ */
+void neutralize_flashing_modifiers(uint8_t active_mods) {
+ // In most scenarios, the flashing modifiers phenomenon is a problem
+ // only for a subset of modifier masks.
+ const static uint8_t mods_to_neutralize[] = MODS_TO_NEUTRALIZE;
+ const static uint8_t n_mods = ARRAY_SIZE(mods_to_neutralize);
+ for (uint8_t i = 0; i < n_mods; ++i) {
+ if (active_mods == mods_to_neutralize[i]) {
+ tap_code(DUMMY_MOD_NEUTRALIZER_KEYCODE);
+ break;
+ }
+ }
+}
+#endif
diff --git a/quantum/action_util.h b/quantum/action_util.h
index 02f6e9e6df..831caf3c0a 100644
--- a/quantum/action_util.h
+++ b/quantum/action_util.h
@@ -102,6 +102,19 @@ void use_oneshot_swaphands(void);
void clear_oneshot_swaphands(void);
#endif
+#ifdef DUMMY_MOD_NEUTRALIZER_KEYCODE
+// KC_A is used as the lowerbound instead of QK_BASIC because the range QK_BASIC...KC_A includes
+// internal keycodes like KC_NO and KC_TRANSPARENT which are unsuitable for use with `tap_code(kc)`.
+# if !(KC_A <= DUMMY_MOD_NEUTRALIZER_KEYCODE && DUMMY_MOD_NEUTRALIZER_KEYCODE <= QK_BASIC_MAX)
+# error "DUMMY_MOD_NEUTRALIZER_KEYCODE must be a basic, unmodified, HID keycode!"
+# endif
+void neutralize_flashing_modifiers(uint8_t active_mods);
+#endif
+#ifndef MODS_TO_NEUTRALIZE
+# define MODS_TO_NEUTRALIZE \
+ { MOD_BIT(KC_LEFT_ALT), MOD_BIT(KC_LEFT_GUI) }
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c
index 2570ad9cd1..0300483a93 100644
--- a/quantum/audio/audio.c
+++ b/quantum/audio/audio.c
@@ -547,20 +547,39 @@ void audio_decrease_tempo(uint8_t tempo_change) {
note_tempo -= tempo_change;
}
-// TODO in the int-math version are some bugs; songs sometimes abruptly end - maybe an issue with the timer/system-tick wrapping around?
+/**
+ * Converts from units of 1/64ths of a beat to milliseconds.
+ *
+ * Round-off error is at most 1 millisecond.
+ *
+ * Conversion will never overflow for duration_bpm <= 699, provided that
+ * note_tempo is at least 10. This is quite a long duration, over ten beats.
+ *
+ * Beware that for duration_bpm > 699, the result may overflow uint16_t range
+ * when duration_bpm is large compared to note_tempo:
+ *
+ * duration_bpm * 60 * 1000 / (64 * note_tempo) > UINT16_MAX
+ *
+ * duration_bpm > (2 * 65535 / 1875) * note_tempo
+ * = 69.904 * note_tempo.
+ */
uint16_t audio_duration_to_ms(uint16_t duration_bpm) {
-#if defined(__AVR__)
- // doing int-math saves us some bytes in the overall firmware size, but the intermediate result is less accurate before being cast to/returned as uint
- return ((uint32_t)duration_bpm * 60 * 1000) / (64 * note_tempo);
- // NOTE: beware of uint16_t overflows when note_tempo is low and/or the duration is long
-#else
- return ((float)duration_bpm * 60) / (64 * note_tempo) * 1000;
-#endif
+ return ((uint32_t)duration_bpm * 1875) / ((uint_fast16_t)note_tempo * 2