自作キーボード / QMK / 俺設定

自作キーボード / QMK / 俺設定

static bool ctrl_pressed = false;
bool combo_ctrl_key(uint16_t target_keycode, uint16_t fire_keycode, uint16_t keycode, bool pressed) {
    if(keycode == target_keycode){
        if(pressed) {
            if(ctrl_pressed){
                // 状況的にはこのタイミングで ctrl が押しっぱなしになっているはずなので外す
                unregister_code(KC_LCTRL);
                register_code(fire_keycode);
                return false;
            }
        }else{
            unregister_code(fire_keycode);
        }
    }
    return true;
}
 
 
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
    if(keycode == KC_LCTRL){
        if(record->event.pressed){
            ctrl_pressed = true;
        }else{
            ctrl_pressed = false;
        }
    }
    if(!combo_ctrl_key(KC_H, KC_BSPACE, keycode, record->event.pressed)){
        return false;
    }
    if(!combo_ctrl_key(KC_J, KC_ENT, keycode, record->event.pressed)){
        return false;
    }
    if(!combo_ctrl_key(KC_P, KC_ESC, keycode, record->event.pressed)){
        return false;
    }
    return true;
}
keyboard/diy_keyboard/qmk/etc/my_setting.txt · 最終更新: 2021-06-30 16:20 by ore