コード例 #1
0
ファイル: action_layer.c プロジェクト: Habmala/qmk_firmware
static void layer_state_set(uint32_t state)
{
    dprint("layer_state: ");
    layer_debug(); dprint(" to ");
    layer_state = state;
    layer_debug(); dprintln();
    clear_keyboard_but_mods(); // To avoid stuck keys
}
コード例 #2
0
ファイル: action_layer.c プロジェクト: Habmala/qmk_firmware
static void default_layer_state_set(uint32_t state)
{
    debug("default_layer_state: ");
    default_layer_debug(); debug(" to ");
    default_layer_state = state;
    default_layer_debug(); debug("\n");
    clear_keyboard_but_mods(); // To avoid stuck keys
}
コード例 #3
0
void special_esc(bool pressed) {
    if (pressed) {
        if (shifted() || guied()) {
            add_key(KC_GRV);
        } else {
            add_key(KC_ESC);
        }
        send_keyboard_report();
    } else {
        clear_keyboard_but_mods();
    }
}
コード例 #4
0
ファイル: keyboard.c プロジェクト: mfung/tmk_keyboard
static void profile_switch(uint8_t code)
{
    if (!IS_PRO(code)) return;
    pro_state_bits = PRO_BIT(code);
    uint8_t new_profile = (pro_state_bits ? keymap_profile(biton(pro_state_bits)) : default_profile);
    if (current_profile != new_profile) {
        Kdebug("Profile Switch: "); Kdebug_hex(current_profile);
        Kdebug(" -> "); Kdebug_hex(new_profile); Kdebug("\n");

        clear_keyboard_but_mods();
        current_profile = new_profile;
    }
}
コード例 #5
0
ファイル: keyboard.c プロジェクト: mfung/tmk_keyboard
static void layer_switch_on(uint8_t code)
{
    if (!IS_FN(code)) return;
    fn_state_bits |= FN_BIT(code);
    uint8_t new_layer = (fn_state_bits ? keymap_fn_layer(biton(fn_state_bits)) : default_layer);
    if (current_layer != new_layer) {
        Kdebug("Layer Switch(on): "); Kdebug_hex(current_layer);
        Kdebug(" -> "); Kdebug_hex(new_layer); Kdebug("\n");

        clear_keyboard_but_mods();
        current_layer = new_layer;
    }
}
コード例 #6
0
ファイル: action_layer.c プロジェクト: wenbu/tmk_keyboard
static void layer_state_set(uint32_t state)
{
    dprint("layer_state: ");
    layer_debug(); dprint(" to ");
    layer_state = state;
    layer_debug(); dprintln();
    clear_keyboard_but_mods(); // To avoid stuck keys

    // find highest set bit and set LED color appropriately
    uint8_t active_layer = 32 - __builtin_clzl(layer_state | default_layer_state) - 1;

    on_layer_change(active_layer);
}
コード例 #7
0
ファイル: keyboard.c プロジェクト: mfung/tmk_keyboard
static bool layer_switch_off(uint8_t code)
{
    if (!IS_FN(code)) return false;
    fn_state_bits &= ~FN_BIT(code);
    uint8_t new_layer = (fn_state_bits ? keymap_fn_layer(biton(fn_state_bits)) : default_layer);
    if (current_layer != new_layer) {
        Kdebug("Layer Switch(off): "); Kdebug_hex(current_layer);
        Kdebug(" -> "); Kdebug_hex(new_layer); Kdebug("\n");

        clear_keyboard_but_mods();
        current_layer = new_layer;
        return true;
    }
    return false;
}