summaryrefslogtreecommitdiffstats
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/action.c148
-rw-r--r--quantum/action_code.h6
-rw-r--r--quantum/backlight/backlight_chibios.c51
-rw-r--r--quantum/backlight/backlight_driver_common.c2
-rw-r--r--quantum/backlight/backlight_software.c2
-rw-r--r--quantum/dip_switch.c4
-rw-r--r--quantum/dynamic_keymap.c25
-rw-r--r--quantum/eeconfig.c13
-rw-r--r--quantum/encoder.c8
-rw-r--r--quantum/encoder.h8
-rw-r--r--quantum/joystick.c98
-rw-r--r--quantum/joystick.h28
-rw-r--r--quantum/keyboard.c17
-rw-r--r--quantum/keycode.h14
-rw-r--r--quantum/keycode_config.h1
-rw-r--r--quantum/keycode_legacy.h3
-rw-r--r--quantum/keymap.h25
-rw-r--r--quantum/keymap_common.c10
-rw-r--r--quantum/keymap_extras/keymap_colemak.h2
-rw-r--r--quantum/keymap_introspection.c22
-rw-r--r--quantum/keymap_introspection.h10
-rw-r--r--quantum/led_matrix/led_matrix.c54
-rw-r--r--quantum/led_matrix/led_matrix.h24
-rw-r--r--quantum/led_matrix/led_matrix_drivers.c2
-rw-r--r--quantum/led_matrix/led_matrix_types.h4
-rw-r--r--quantum/painter/qp.h4
-rw-r--r--quantum/painter/qp_draw_image.c43
-rw-r--r--quantum/painter/qp_draw_text.c49
-rw-r--r--quantum/painter/qp_stream.c47
-rw-r--r--quantum/painter/qp_stream.h5
-rw-r--r--quantum/painter/rules.mk34
-rw-r--r--quantum/pointing_device/pointing_device.c28
-rw-r--r--quantum/pointing_device/pointing_device.h11
-rw-r--r--quantum/pointing_device/pointing_device_auto_mouse.c384
-rw-r--r--quantum/pointing_device/pointing_device_auto_mouse.h87
-rw-r--r--quantum/pointing_device/pointing_device_drivers.c38
-rw-r--r--quantum/pointing_device_internal.h14
-rw-r--r--quantum/process_keycode/autocorrect_data_default.h85
-rw-r--r--quantum/process_keycode/process_auto_shift.c12
-rw-r--r--quantum/process_keycode/process_autocorrect.c287
-rw-r--r--quantum/process_keycode/process_autocorrect.h17
-rw-r--r--quantum/process_keycode/process_dynamic_macro.c22
-rw-r--r--quantum/process_keycode/process_joystick.c152
-rw-r--r--quantum/process_keycode/process_joystick.h21
-rw-r--r--quantum/process_keycode/process_leader.c2
-rw-r--r--quantum/process_keycode/process_tap_dance.c12
-rw-r--r--quantum/process_keycode/process_tap_dance.h2
-rw-r--r--quantum/process_keycode/process_ucis.c17
-rw-r--r--quantum/process_keycode/process_ucis.h6
-rw-r--r--quantum/process_keycode/process_unicode.c12
-rw-r--r--quantum/process_keycode/process_unicode.h5
-rw-r--r--quantum/process_keycode/process_unicode_common.c298
-rw-r--r--quantum/process_keycode/process_unicode_common.h184
-rw-r--r--quantum/process_keycode/process_unicodemap.c5
-rw-r--r--quantum/process_keycode/process_unicodemap.h6
-rw-r--r--quantum/quantum.c16
-rw-r--r--quantum/quantum.h5
-rw-r--r--quantum/quantum_keycodes.h8
-rw-r--r--quantum/quantum_keycodes_legacy.h4
-rw-r--r--quantum/rgb_matrix/animations/jellybean_raindrops_anim.h2
-rw-r--r--quantum/rgb_matrix/animations/pixel_flow_anim.h4
-rw-r--r--quantum/rgb_matrix/animations/pixel_rain_anim.h2
-rw-r--r--quantum/rgb_matrix/animations/raindrops_anim.h2
-rw-r--r--quantum/rgb_matrix/rgb_matrix.c56
-rw-r--r--quantum/rgb_matrix/rgb_matrix.h24
-rw-r--r--quantum/rgb_matrix/rgb_matrix_drivers.c8
-rw-r--r--quantum/rgb_matrix/rgb_matrix_types.h4
-rw-r--r--quantum/rgblight/rgblight.c22
-rw-r--r--quantum/secure.c3
-rw-r--r--quantum/split_common/split_util.c14
-rw-r--r--quantum/split_common/transactions.c119
-rw-r--r--quantum/unicode/unicode.c383
-rw-r--r--quantum/unicode/unicode.h165
-rw-r--r--quantum/unicode/utf8.c (renamed from quantum/utf8.c)0
-rw-r--r--quantum/unicode/utf8.h (renamed from quantum/utf8.h)2
-rw-r--r--quantum/util.h52
-rw-r--r--quantum/via_ensure_keycode.h2
77 files changed, 2300 insertions, 1067 deletions
diff --git a/quantum/action.c b/quantum/action.c
index 6b2e9104e0..78322e4a83 100644
--- a/quantum/action.c
+++ b/quantum/action.c
@@ -293,19 +293,56 @@ void process_record_handler(keyrecord_t *record) {
process_action(record, action);
}
-#if defined(PS2_MOUSE_ENABLE) || defined(POINTING_DEVICE_ENABLE)
-void register_button(bool pressed, enum mouse_buttons button) {
-# ifdef PS2_MOUSE_ENABLE
- tp_buttons = pressed ? tp_buttons | button : tp_buttons & ~button;
-# endif
-# ifdef POINTING_DEVICE_ENABLE
- report_mouse_t currentReport = pointing_device_get_report();
- currentReport.buttons = pressed ? currentReport.buttons | button : currentReport.buttons & ~button;
- pointing_device_set_report(currentReport);
+/**
+ * @brief handles all the messy mouse stuff
+ *
+ * Handles all the edgecases and special stuff that is needed for coexistense
+ * of the multiple mouse subsystems.
+ *
+ * @param mouse_keycode[in] uint8_t mouse keycode
+ * @param pressed[in] bool
+ */
+
+void register_mouse(uint8_t mouse_keycode, bool pressed) {
+#ifdef MOUSEKEY_ENABLE
+ // if mousekeys is enabled, let it do the brunt of the work
+ if (pressed) {
+ mousekey_on(mouse_keycode);
+ } else {
+ mousekey_off(mouse_keycode);
+ }
+ // should mousekeys send report, or does something else handle this?
+ switch (mouse_keycode) {
+# if defined(PS2_MOUSE_ENABLE) || defined(POINTING_DEVICE_ENABLE)
+ case KC_MS_BTN1 ... KC_MS_BTN8:
+ // let pointing device handle the buttons
+ // expand if/when it handles more of the code
+# if defined(POINTING_DEVICE_ENABLE)
+ pointing_device_keycode_handler(mouse_keycode, pressed);
+# endif
+ break;
# endif
-}
+ default:
+ mousekey_send();
+ break;
+ }
+#elif defined(POINTING_DEVICE_ENABLE)
+ // if mousekeys isn't enabled, and pointing device is enabled, then
+ // let pointing device do all the heavy lifting, then
+ if IS_MOUSEKEY (mouse_keycode) {
+ pointing_device_keycode_handler(mouse_keycode, pressed);
+ }
#endif
+#ifdef PS2_MOUSE_ENABLE
+ // make sure that ps2 mouse has button report synced
+ if (KC_MS_BTN1 <= mouse_keycode && mouse_keycode <= KC_MS_BTN3) {
+ uint8_t tmp_button_msk = MOUSE_BTN_MASK(mouse_keycode - KC_MS_BTN1);
+ tp_buttons = pressed ? tp_buttons | tmp_button_msk : tp_buttons & ~tmp_button_msk;
+ }
+#endif
+}
+
/** \brief Take an action and processes it.
*
* FIXME: Needs documentation.
@@ -403,9 +440,9 @@ void process_action(keyrecord_t *record, action_t action) {
# if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
} else if (tap_count == ONESHOT_TAP_TOGGLE) {
dprint("MODS_TAP: Toggling oneshot");
+ register_mods(mods);
clear_oneshot_mods();
set_oneshot_locked_mods(mods | get_oneshot_locked_mods());
- register_mods(mods);
# endif
} else {
register_mods(mods | get_oneshot_mods());
@@ -418,16 +455,16 @@ 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()) {
+ unregister_mods(mods);
clear_oneshot_mods();
set_oneshot_locked_mods(~mods & get_oneshot_locked_mods());
- unregister_mods(mods);
}
} else if (tap_count == ONESHOT_TAP_TOGGLE) {
// Toggle Oneshot Layer
# endif
} else {
- clear_oneshot_mods();
unregister_mods(mods);
+ clear_oneshot_mods();
}
}
}
@@ -490,46 +527,18 @@ void process_action(keyrecord_t *record, action_t action) {
case ACT_USAGE:
switch (action.usage.page) {
case PAGE_SYSTEM:
- if (event.pressed) {
- host_system_send(action.usage.code);
- } else {
- host_system_send(0);
- }
+ host_system_send(event.pressed ? action.usage.code : 0);
break;
case PAGE_CONSUMER:
- if (event.pressed) {
- host_consumer_send(action.usage.code);
- } else {
- host_consumer_send(0);
- }
+ host_consumer_send(event.pressed ? action.usage.code : 0);
break;
}
break;
#endif
-#ifdef MOUSEKEY_ENABLE
/* Mouse key */
case ACT_MOUSEKEY:
- if (event.pressed) {
- mousekey_on(action.key.code);
- } else {
- mousekey_off(action.key.code);
- }
- switch (action.key.code) {
-# if defined(PS2_MOUSE_ENABLE) || defined(POINTING_DEVICE_ENABLE)
-# ifdef POINTING_DEVICE_ENABLE
- case KC_MS_BTN1 ... KC_MS_BTN8:
-# else
- case KC_MS_BTN1 ... KC_MS_BTN3:
-# endif
- register_button(event.pressed, MOUSE_BTN_MASK(action.key.code - KC_MS_BTN1));
- break;
-# endif
- default:
- mousekey_send();
- break;
- }
+ register_mouse(action.key.code, event.pressed);
break;
-#endif
#ifndef NO_ACTION_LAYER
case ACT_LAYER:
if (action.layer_bitop.on == 0) {
@@ -835,9 +844,9 @@ void process_action(keyrecord_t *record, action_t action) {
__attribute__((weak)) void register_code(uint8_t code) {
if (code == KC_NO) {
return;
- }
+
#ifdef LOCKING_SUPPORT_ENABLE
- else if (KC_LOCKING_CAPS_LOCK == 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;
@@ -847,9 +856,8 @@ __attribute__((weak)) void register_code(uint8_t code) {
wait_ms(TAP_HOLD_CAPS_DELAY);
del_key(KC_CAPS_LOCK);
send_keyboard_report();
- }
- else if (KC_LOCKING_NUM_LOCK == code) {
+ } else if (KC_LOCKING_NUM_LOCK == code) {
# ifdef LOCKING_RESYNC_ENABLE
if (host_keyboard_leds() & (1 << USB_LED_NUM_LOCK)) return;
# endif
@@ -858,9 +866,8 @@ __attribute__((weak)) void register_code(uint8_t code) {
wait_ms(100);
del_key(KC_NUM_LOCK);
send_keyboard_report();
- }
- else if (KC_LOCKING_SCROLL_LOCK == code) {
+ } else if (KC_LOCKING_SCROLL_LOCK == code) {
# ifdef LOCKING_RESYNC_ENABLE
if (host_keyboard_leds() & (1 << USB_LED_SCROLL_LOCK)) return;
# endif
@@ -869,10 +876,9 @@ __attribute__((weak)) void register_code(uint8_t code) {
wait_ms(100);
del_key(KC_SCROLL_LOCK);
send_keyboard_report();
- }
#endif
- else if IS_KEY (code) {
+ } else if IS_KEY (code) {
// TODO: should push command_proc out of this block?
if (command_proc(code)) return;
@@ -905,20 +911,17 @@ __attribute__((weak)) void register_code(uint8_t code) {
} else if IS_MOD (code) {
add_mods(MOD_BIT(code));
send_keyboard_report();
- }
+
#ifdef EXTRAKEY_ENABLE
- else if IS_SYSTEM (code) {
+ } else if IS_SYSTEM (code) {
host_system_send(KEYCODE2SYSTEM(code));
} else if IS_CONSUMER (code) {
host_consumer_send(KEYCODE2CONSUMER(code));
- }
#endif
-#ifdef MOUSEKEY_ENABLE
- else if IS_MOUSEKEY (code) {
- mousekey_on(code);
- mousekey_send();
+
+ } else if IS_MOUSEKEY (code) {
+ register_mouse(code, true);
}
-#endif
}
/** \brief Utilities for actions. (FIXME: Needs better description)
@@ -928,9 +931,9 @@ __attribute__((weak)) void register_code(uint8_t code) {
__attribute__((weak)) void unregister_code(uint8_t code) {
if (code == KC_NO) {
return;
- }
+
#ifdef LOCKING_SUPPORT_ENABLE
- else if (KC_LOCKING_CAPS_LOCK == 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;
@@ -939,9 +942,8 @@ __attribute__((weak)) void unregister_code(uint8_t code) {
send_keyboard_report();
del_key(KC_CAPS_LOCK);
send_keyboard_report();
- }
- else if (KC_LOCKING_NUM_LOCK == code) {
+ } else if (KC_LOCKING_NUM_LOCK == code) {
# ifdef LOCKING_RESYNC_ENABLE
if (!(host_keyboard_leds() & (1 << USB_LED_NUM_LOCK))) return;
# endif
@@ -949,9 +951,8 @@ __attribute__((weak)) void unregister_code(uint8_t code) {
send_keyboard_report();
del_key(KC_NUM_LOCK);
send_keyboard_report();
- }
- else if (KC_LOCKING_SCROLL_LOCK == code) {
+ } else if (KC_LOCKING_SCROLL_LOCK == code) {
# ifdef LOCKING_RESYNC_ENABLE
if (!(host_keyboard_leds() & (1 << USB_LED_SCROLL_LOCK))) return;
# endif
@@ -959,26 +960,25 @@ __attribute__((weak)) void unregister_code(uint8_t code) {
send_keyboard_report();
del_key(KC_SCROLL_LOCK);
send_keyboard_report();
- }
#endif
- else if IS_KEY (code) {
+ } else if IS_KEY (code) {
del_key(code);
send_keyboard_report();
} else if IS_MOD (code) {
del_mods(MOD_BIT(code));
send_keyboard_report();
+
+#ifdef EXTRAKEY_ENABLE
} else if IS_SYSTEM (code) {
host_system_send(0);
} else if IS_CONSUMER (code) {
host_consumer_send(0);
- }
-#ifdef MOUSEKEY_ENABLE
- else if IS_MOUSEKEY (code) {
- mousekey_off(code);
- mousekey_send();
- }
#endif
+
+ } else if IS_MOUSEKEY (code) {
+ register_mouse(code, false);
+ }
}
/** \brief Tap a keycode with a delay.
diff --git a/quantum/action_code.h b/quantum/action_code.h
index e107f0a740..14cfd025f1 100644
--- a/quantum/action_code.h
+++ b/quantum/action_code.h
@@ -192,7 +192,11 @@ enum mods_codes {
/** \brief Other Keys
*/
-enum usage_pages { PAGE_SYSTEM, PAGE_CONSUMER };
+enum usage_pages {
+ PAGE_SYSTEM,
+ PAGE_CONSUMER,
+};
+
#define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, PAGE_SYSTEM << 10 | (id))
#define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, PAGE_CONSUMER << 10 | (id))
#define ACTION_MOUSEKEY(key) ACTION(ACT_MOUSEKEY, key)
diff --git a/quantum/backlight/backlight_chibios.c b/quantum/backlight/backlight_chibios.c
index e8f9e70f78..30e95bd5c8 100644
--- a/quantum/backlight/backlight_chibios.c
+++ b/quantum/backlight/backlight_chibios.c
@@ -40,16 +40,22 @@
# endif
#endif
-static PWMConfig pwmCFG = {0xFFFF, /* PWM clock frequency */
- 256, /* PWM period (in ticks) 1S (1/10kHz=0.1mS 0.1ms*10000 ticks=1S) */
- NULL, /* Breathing Callback */
- { /* Default all channels to disabled - Channels will be configured durring init */
- {PWM_OUTPUT_DISABLED, NULL},
- {PWM_OUTPUT_DISABLED, NULL},
- {PWM_OUTPUT_DISABLED, NULL},
- {PWM_OUTPUT_DISABLED, NULL}},
- 0, /* HW dependent part.*/
- 0};
+#ifndef BACKLIGHT_PWM_COUNTER_FREQUENCY
+# define BACKLIGHT_PWM_COUNTER_FREQUENCY 0xFFFF
+#endif
+
+#ifndef BACKLIGHT_PWM_PERIOD
+# define BACKLIGHT_PWM_PERIOD 256
+#endif
+
+static PWMConfig pwmCFG = {
+ .frequency = BACKLIGHT_PWM_COUNTER_FREQUENCY, /* PWM clock frequency */
+ .period = BACKLIGHT_PWM_PERIOD, /* PWM period in counter ticks. e.g. clock frequency is 10KHz, period is 256 ticks then t_period is 25.6ms */
+};
+
+#ifdef BACKLIGHT_BREATHING
+static virtual_timer_t breathing_vt;
+#endif
// See http://jared.geek.nz/2013/feb/linear-led-pwm
static uint16_t cie_lightness(uint16_t v) {
@@ -60,10 +66,11 @@ static uint16_t cie_lightness(uint16_t v) {
// to get a useful result with integer division, we shift left in the expression above
// and revert what we've done again after squaring.
y = y * y * y >> 8;
- if (y > 0xFFFFUL) // prevent overflow
+ if (y > 0xFFFFUL) { // prevent overflow
return 0xFFFFU;
- else
+ } else {
return (uint16_t)y;
+ }
}
}
@@ -85,6 +92,7 @@ void backlight_init_ports(void) {
backlight_set(get_backlight_level());
#ifdef BACKLIGHT_BREATHING
+ chVTObjectInit(&breathing_vt);
if (is_backlight_breathing()) {
breathing_enable();
}
@@ -92,7 +100,9 @@ void backlight_init_ports(void) {
}
void backlight_set(uint8_t level) {
- if (level > BACKLIGHT_LEVELS) level = BACKLIGHT_LEVELS;
+ if (level > BACKLIGHT_LEVELS) {
+ level = BACKLIGHT_LEVELS;
+ }
if (level == 0) {
// Turn backlight off
@@ -115,20 +125,19 @@ void backlight_task(void) {}
*/
static const uin