Cleanup code and debug messages

master
Jacopo De Simoi 1 year ago
parent 0b8243b220
commit 6a3616c016
  1. 89
      src/keyboard.c

@ -536,7 +536,6 @@ static long process_descriptor(struct keyboard *kbd, uint8_t code,
kbd->delayedphase = 3; // resolve the delay kbd->delayedphase = 3; // resolve the delay
if (!pressed && code == kbd->delayedcode0) { if (!pressed && code == kbd->delayedcode0) {
// this is the whole point of the delayed business // this is the whole point of the delayed business
dbg("supposedly not wanting to use it as a mod");
kbd->keyfrozenstate[kbd->delayedcode0] = 1; kbd->keyfrozenstate[kbd->delayedcode0] = 1;
process_descriptor(kbd, kbd->delayedcode0, process_descriptor(kbd, kbd->delayedcode0,
&kbd->delayeddescriptor0, dl, 1, time); &kbd->delayeddescriptor0, dl, 1, time);
@ -717,7 +716,6 @@ static long process_descriptor(struct keyboard *kbd, uint8_t code,
break; break;
case OP_OVERLOAD_HACK: case OP_OVERLOAD_HACK:
dbg("overload_hack");
idx = d->args[0].idx; // This is the overloaded layer idx = d->args[0].idx; // This is the overloaded layer
action = &kbd->config.descriptors[d->args[1].idx]; action = &kbd->config.descriptors[d->args[1].idx];
// This is the key to press, or the action to perform // This is the key to press, or the action to perform
@ -729,7 +727,6 @@ static long process_descriptor(struct keyboard *kbd, uint8_t code,
// record that we are pretending this key is a regular key so // record that we are pretending this key is a regular key so
// that we do not get confused on release // that we do not get confused on release
// how do I capture that? // how do I capture that?
dbg("here we should implement the hack %d", code);
kbd->keyhackstate[code]=1; kbd->keyhackstate[code]=1;
// pretend it is a regular keypress // pretend it is a regular keypress
process_descriptor(kbd, code, action, dl, 1, time); process_descriptor(kbd, code, action, dl, 1, time);
@ -769,55 +766,49 @@ static long process_descriptor(struct keyboard *kbd, uint8_t code,
break; break;
case OP_OVERLOAD_DELAYED: //At the moment this is just a copy of case OP_OVERLOAD_DELAYED: //At the moment this is just a copy of
//overload //overload
dbg("overload_delayed - got here"); idx = d->args[0].idx;
idx = d->args[0].idx; action = &kbd->config.descriptors[d->args[1].idx];
action = &kbd->config.descriptors[d->args[1].idx]; if (pressed && kbd->delayedphase == 0) {
if (pressed && kbd->delayedphase == 0) { kbd->delayedcode0 = code;
dbg("overload_delayed - initial press"); kbd->delayeddescriptor0 = *d;
kbd->delayedcode0 = code; kbd->delayedphase = 1;
kbd->delayeddescriptor0 = *d; } else if (pressed) {
kbd->delayedphase = 1; if (kbd->keyfrozenstate[code]) {
} else if (pressed) { // pressed while frozen; pretend it is the action
dbg("overload_delayed - press"); process_descriptor(kbd, code, action, dl, 1, time);
if (kbd->keyfrozenstate[code]) { kbd->keyfrozenstate[code] = 0;
dbg("overload_delayed - frozen press"); } else { // pressed but not frozen
// pressed while frozen; pretend it is the action kbd->overload_start_time = time;
process_descriptor(kbd, code, action, dl, 1, time); activate_layer(kbd, code, idx);
kbd->keyfrozenstate[code] = 0; update_mods(kbd, -1, 0);
} else { }
kbd->overload_start_time = time; } else { // not pressed
activate_layer(kbd, code, idx); if (kbd->keyfrozenstate [code]) { // frozen
update_mods(kbd, -1, 0); // released while frozen, pretend it is the action
} process_descriptor(kbd, code, action, dl, 0, time);
} else { kbd->keyfrozenstate[code] = 0;
if (kbd->keyfrozenstate [code]) { } else { // not frozen
dbg("overload_delayed - frozen release"); deactivate_layer(kbd, idx);
// released while frozen, pretend it is the action update_mods(kbd, -1, 0);
process_descriptor(kbd, code, action, dl, 0, time);
kbd->keyfrozenstate[code] = 0;
} else {
deactivate_layer(kbd, idx);
update_mods(kbd, -1, 0);
if (kbd->last_pressed_code == code && if (kbd->last_pressed_code == code &&
(!kbd->config.overload_tap_timeout || (!kbd->config.overload_tap_timeout ||
((time - kbd->overload_start_time) < kbd->config.overload_tap_timeout))) { ((time - kbd->overload_start_time) < kbd->config.overload_tap_timeout))) {
if (action->op == OP_MACRO) { if (action->op == OP_MACRO) {
/* /*
* Macro release relies on event logic, so we can't just synthesize a * Macro release relies on event logic, so we can't just synthesize a
* descriptor release. * descriptor release.
*/ */
struct macro *macro = &kbd->config.macros[action->args[0].idx]; struct macro *macro = &kbd->config.macros[action->args[0].idx];
execute_macro(kbd, dl, macro); execute_macro(kbd, dl, macro);
} else { } else {
process_descriptor(kbd, code, action, dl, 1, time); process_descriptor(kbd, code, action, dl, 1, time);
process_descriptor(kbd, code, action, dl, 0, time); process_descriptor(kbd, code, action, dl, 0, time);
}
} }
} }
} }
}
break; break;
case OP_ONESHOTM: case OP_ONESHOTM:
case OP_ONESHOT: case OP_ONESHOT:
idx = d->args[0].idx; idx = d->args[0].idx;

Loading…
Cancel
Save