vial/encoder: fix memory corruption in exec_keycode
get_record_keycode calls into update_source_layers_cache which corrupts
memory because our magic row/col isn't present in the matrix
based on drashna code in ed6153062f/users/drashna/encoder_stuff.c
This commit is contained in:
parent
c9c90c06b7
commit
c69a05c216
@ -179,12 +179,14 @@ void post_process_record_quantum(keyrecord_t *record) {
|
|||||||
post_process_record_kb(keycode, record);
|
post_process_record_kb(keycode, record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool process_record_quantum(keyrecord_t *record) {
|
||||||
|
uint16_t keycode = get_record_keycode(record, true);
|
||||||
|
return process_record_quantum_helper(keycode, record);
|
||||||
|
}
|
||||||
/* Core keycode function, hands off handling to other functions,
|
/* Core keycode function, hands off handling to other functions,
|
||||||
then processes internal quantum keycodes, and then processes
|
then processes internal quantum keycodes, and then processes
|
||||||
ACTIONs. */
|
ACTIONs. */
|
||||||
bool process_record_quantum(keyrecord_t *record) {
|
bool process_record_quantum_helper(uint16_t keycode, keyrecord_t *record) {
|
||||||
uint16_t keycode = get_record_keycode(record, true);
|
|
||||||
|
|
||||||
// This is how you use actions here
|
// This is how you use actions here
|
||||||
// if (keycode == KC_LEAD) {
|
// if (keycode == KC_LEAD) {
|
||||||
// action_t action;
|
// action_t action;
|
||||||
|
@ -257,6 +257,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record);
|
|||||||
bool process_record_user(uint16_t keycode, keyrecord_t *record);
|
bool process_record_user(uint16_t keycode, keyrecord_t *record);
|
||||||
void post_process_record_kb(uint16_t keycode, keyrecord_t *record);
|
void post_process_record_kb(uint16_t keycode, keyrecord_t *record);
|
||||||
void post_process_record_user(uint16_t keycode, keyrecord_t *record);
|
void post_process_record_user(uint16_t keycode, keyrecord_t *record);
|
||||||
|
bool process_record_quantum_helper(uint16_t keycode, keyrecord_t *record);
|
||||||
|
|
||||||
#ifndef BOOTMAGIC_LITE_COLUMN
|
#ifndef BOOTMAGIC_LITE_COLUMN
|
||||||
# define BOOTMAGIC_LITE_COLUMN 0
|
# define BOOTMAGIC_LITE_COLUMN 0
|
||||||
|
@ -176,15 +176,23 @@ static void exec_keycode(uint16_t keycode) {
|
|||||||
#else
|
#else
|
||||||
g_vial_magic_keycode_override = keycode;
|
g_vial_magic_keycode_override = keycode;
|
||||||
|
|
||||||
action_exec((keyevent_t){
|
keyrecord_t record = {.event = (keyevent_t){.key = { VIAL_ENCODER_MATRIX_MAGIC, VIAL_ENCODER_MATRIX_MAGIC }, .pressed = true, .time = (timer_read() | 1)}};
|
||||||
.key = (keypos_t){.row = VIAL_ENCODER_MATRIX_MAGIC, .col = VIAL_ENCODER_MATRIX_MAGIC}, .pressed = 1, .time = (timer_read() | 1) /* time should not be 0 */
|
|
||||||
});
|
if (keycode <= QK_MODS_MAX)
|
||||||
|
register_code16(keycode);
|
||||||
|
else
|
||||||
|
process_record_quantum_helper(keycode, &record);
|
||||||
|
|
||||||
#if VIAL_ENCODER_KEYCODE_DELAY > 0
|
#if VIAL_ENCODER_KEYCODE_DELAY > 0
|
||||||
wait_ms(VIAL_ENCODER_KEYCODE_DELAY);
|
wait_ms(VIAL_ENCODER_KEYCODE_DELAY);
|
||||||
#endif
|
#endif
|
||||||
action_exec((keyevent_t){
|
record.event.time = timer_read() | 1;
|
||||||
.key = (keypos_t){.row = VIAL_ENCODER_MATRIX_MAGIC, .col = VIAL_ENCODER_MATRIX_MAGIC}, .pressed = 0, .time = (timer_read() | 1) /* time should not be 0 */
|
record.event.pressed = false;
|
||||||
});
|
|
||||||
|
if (keycode <= QK_MODS_MAX)
|
||||||
|
unregister_code16(keycode);
|
||||||
|
else
|
||||||
|
process_record_quantum_helper(keycode, &record);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user