void send_mods_and_code(uint8_t mods, uint8_t code) { const uint8_t original_mods = get_mods(); set_mods(mods); register_code(code); set_mods(original_mods); }
void tap_trema(uint8_t mods, uint16_t keycode) { register_code(KC_LALT); tap_code(KC_U); unregister_code(KC_LALT); set_mods(mods); tap_code(keycode); }
void tap_aigu(uint8_t mods, uint16_t keycode) { register_code(KC_LALT); tap_code(KC_E); unregister_code(KC_LALT); set_mods(mods); tap_code(keycode); }
void tap_circonflexe(uint8_t mods, uint16_t keycode) { register_code(KC_LALT); tap_code(KC_I); unregister_code(KC_LALT); set_mods(mods); tap_code(keycode); }
void tap_grave(uint8_t mods, uint16_t keycode) { register_code(KC_LALT); tap_code(KC_GRV); unregister_code(KC_LALT); set_mods(mods); tap_code(keycode); }
void handle_french_keycode(uint8_t mods, uint16_t keycode, keyrecord_t *record) { if (!record->event.pressed) return; switch (keycode) { // à case A_GRAVE: return tap_grave(mods, KC_A); // â case A_CIRCONFLEXE: return tap_circonflexe(mods, KC_A); // è case E_GRAVE: return tap_grave(mods, KC_E); // ê case E_CIRCONFLEXE: return tap_circonflexe(mods, KC_E); // é case E_AIGU: return tap_aigu(mods, KC_E); // ë case E_TREMA: return tap_trema(mods, KC_E); // î case I_CIRCONFLEXE: return tap_circonflexe(mods, KC_I); // ï case I_TREMA: return tap_trema(mods, KC_I); // ô case O_CIRCONFLEXE: return tap_circonflexe(mods, KC_O); // ù case U_GRAVE: return tap_grave(mods, KC_U); // û case U_CIRCONFLEXE: return tap_circonflexe(mods, KC_U); // ü case U_TREMA: return tap_trema(mods, KC_U); // ç case C_CEDILLE: set_mods(mods); register_code(KC_LALT); tap_code(KC_C); unregister_code(KC_LALT); return; // € case E_EURO: register_code(KC_LALT); register_code(KC_LSHIFT); tap_code(KC_2); unregister_code(KC_LALT); unregister_code(KC_LSHIFT); return; default: return; } }
bool process_record_user(uint16_t keycode, keyrecord_t *record) { uint8_t mods = get_mods(); clear_keyboard(); handle_french_keycode(mods, keycode, record); set_mods(mods); return true; }
void action_macro_play(const macro_t *macro_p) { macro_t macro = END; uint8_t interval = 0; uint8_t mod_storage = 0; if (!macro_p) return; while (true) { switch (MACRO_READ()) { case KEY_DOWN: MACRO_READ(); dprintf("KEY_DOWN(%02X)\n", macro); if (IS_MOD(macro)) { add_weak_mods(MOD_BIT(macro)); send_keyboard_report(); } else { register_code(macro); } break; case KEY_UP: MACRO_READ(); dprintf("KEY_UP(%02X)\n", macro); if (IS_MOD(macro)) { del_weak_mods(MOD_BIT(macro)); send_keyboard_report(); } else { unregister_code(macro); } break; case WAIT: MACRO_READ(); dprintf("WAIT(%u)\n", macro); { uint8_t ms = macro; while (ms--) wait_ms(1); } break; case INTERVAL: interval = MACRO_READ(); dprintf("INTERVAL(%u)\n", interval); break; case MOD_STORE: mod_storage = get_mods(); break; case MOD_RESTORE: set_mods(mod_storage); send_keyboard_report(); break; case MOD_CLEAR: clear_mods(); send_keyboard_report(); break; case 0x04 ... 0x73: dprintf("DOWN(%02X)\n", macro); register_code(macro); break; case 0x84 ... 0xF3: dprintf("UP(%02X)\n", macro); unregister_code(macro&0x7F); break; case END: default: return; } // interval { uint8_t ms = interval; while (ms--) wait_ms(1); } } }