bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case SFT_ESC: if (record->event.pressed) { if (get_mods() & MODS_SHIFT_MASK) { add_key(KC_GRV); send_keyboard_report(); } else { add_key(KC_ESC); send_keyboard_report(); } } else { if (get_mods() & MODS_SHIFT_MASK) { del_key(KC_GRV); send_keyboard_report(); } else { del_key(KC_ESC); send_keyboard_report(); } } return false; default: return true; } }
static pos translate_pos(int x, int y) { return (pos){ .x = floorf((x - PADDING) / (float)font_width ), .y = floorf((y - PADDING) / (float)font_height), }; } static pos get_mouse_pos(LPARAM lp) { return translate_pos(GET_X_LPARAM(lp), GET_Y_LPARAM(lp)); } static mouse_button clicked_button; static pos last_pos; void win_mouse_click(mouse_button b, LPARAM lp) { static mouse_button last_button; static uint last_time, count; static pos last_click_pos; win_show_mouse(); mod_keys mods = get_mods(); pos p = get_mouse_pos(lp); if (clicked_button) { term_mouse_release(b, mods, p); clicked_button = 0; } uint t = GetMessageTime(); if (b != last_button || p.x != last_click_pos.x || p.y != last_click_pos.y || t - last_time > GetDoubleClickTime() || ++count > 3) count = 1; term_mouse_click(b, mods, p, count); last_pos = last_click_pos = p; last_time = t; clicked_button = last_button = b; if (alt_state > ALT_NONE) alt_state = ALT_CANCELLED; } void win_mouse_release(mouse_button b, LPARAM lp) { win_show_mouse(); if (b == clicked_button) { term_mouse_release(b, get_mods(), get_mouse_pos(lp)); clicked_button = 0; ReleaseCapture(); } }
bool process_record_user(uint16_t keycode, keyrecord_t *record) { static uint16_t code_timer; switch (keycode) { case KC_MCBR: if(record->event.pressed){ code_timer= timer_read(); SEND_STRING("{"); } else { if (timer_elapsed(code_timer) > TAPPING_TERM) { SEND_STRING("}" SS_TAP(X_LEFT)); } } return false; break; case KC_MBRC: if(record->event.pressed){ code_timer= timer_read(); SEND_STRING("["); } else { if (timer_elapsed(code_timer) > TAPPING_TERM) { SEND_STRING("]" SS_TAP(X_LEFT)); } } return false; break; case KC_MPRN: if(record->event.pressed){ code_timer= timer_read(); SEND_STRING("("); } else { if (timer_elapsed(code_timer) > TAPPING_TERM) { SEND_STRING(")" SS_TAP(X_LEFT)); } } return false; break; case KC_MABK: if(record->event.pressed){ code_timer= timer_read(); if (get_mods() & MODS_SHIFT_MASK){ SEND_STRING("<"); } else { SEND_STRING(","); } } else { if (timer_elapsed(code_timer) > TAPPING_TERM) { if (get_mods() & MODS_SHIFT_MASK){ SEND_STRING(">" SS_TAP(X_LEFT)); } } } return false; break; } return true; }
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) { if (record->event.pressed) dprint("P"); else dprint("R"); if (record->tap.interrupted) dprint("i"); # define MODS_SHIFT_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT)) static uint8_t shift_mod; switch (id) { // Shift + Esc -> ~ case SHIFT_ESC: shift_mod = get_mods()&MODS_SHIFT_MASK; if (record->event.pressed) { if (shift_mod) { add_key(KC_GRV); send_keyboard_report(); // send grave with shift for tilde result } else { del_mods(shift_mod); // remove shift add_key(KC_ESC); send_keyboard_report(); // send escape add_mods(shift_mod); // return shift but not sent } } else { if (shift_mod) { del_key(KC_GRV); send_keyboard_report(); } else { del_key(KC_ESC); send_keyboard_report(); } } break; case SHIFT_BSPC: shift_mod = get_mods()&MODS_SHIFT_MASK; if (record->event.pressed) { if (shift_mod) { add_key(KC_BSLS); send_keyboard_report(); // send backslash with shift for pipe result } else { del_mods(shift_mod); // remove shift add_key(KC_BSPC); send_keyboard_report(); // send backspace add_mods(shift_mod); // return shift but not sent } } else { if (shift_mod) { del_key(KC_BSLS); send_keyboard_report(); } else { del_key(KC_BSPC); send_keyboard_report(); } } break; } }
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 action_function(keyrecord_t *record, uint8_t id, uint8_t opt) { # define MODS_CTRL_MASK (MOD_BIT(KC_LCTRL)|MOD_BIT(KC_RCTRL)) static uint8_t ctrl_space_i_prev_ctrl; switch (id) { // Ctrl + Up(SpaceFN) -> PgUp case CTRL_SPACE_I: ctrl_space_i_prev_ctrl = get_mods()&MODS_CTRL_MASK; if (record->event.pressed) { if (ctrl_space_i_prev_ctrl) { del_mods(ctrl_space_i_prev_ctrl); // remove Ctrl add_key(KC_PGUP); send_keyboard_report(); // send PgUp without Ctrl add_mods(ctrl_space_i_prev_ctrl); // return Ctrl but not sent } else { add_key(KC_UP); send_keyboard_report(); } } else { if (ctrl_space_i_prev_ctrl) { del_key(KC_PGUP); send_keyboard_report(); } else { del_key(KC_UP); send_keyboard_report(); } } break; } }
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) { static uint8_t mods_pressed; switch (id) { case 0: /* Handle the combined Grave/Esc key */ mods_pressed = get_mods()&GRAVE_MODS; // Check to see what mods are pressed if (record->event.pressed) { /* The key is being pressed. */ if (mods_pressed) { add_key(KC_GRV); send_keyboard_report(); } else { add_key(KC_ESC); send_keyboard_report(); } } else { /* The key is being released. */ if (mods_pressed) { del_key(KC_GRV); send_keyboard_report(); } else { del_key(KC_ESC); send_keyboard_report(); } } break; } }
void matrix_scan_keymap(void) { // runs frequently to update info uint8_t modifiders = get_mods(); if (!skip_leds) { ergodox_board_led_off(); ergodox_right_led_1_off(); ergodox_right_led_2_off(); ergodox_right_led_3_off(); // Since we're not using the LEDs here for layer indication anymore, // then lets use them for modifier indicators. Shame we don't have 4... // Also, no "else", since we want to know each, independantly. if (modifiders & MODS_SHIFT_MASK) { ergodox_right_led_2_on(); } if (modifiders & MODS_CTRL_MASK) { ergodox_right_led_1_on(); } if (modifiders & MODS_ALT_MASK) { ergodox_right_led_3_on(); } } };
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) { switch (id) { // The OS-Toggle function toggles our concept of mac or windows case FNOSTOGGLE: if (IS_RELEASED(record->event)) { is_mac = !is_mac; // Blink blue for mac, red otherwise blink_led(is_mac ? 3 : 1); } return; // The copy-cut function sends the copy key sequence for mac or windows // when it is pressed. If shift is held down, it will send the cut key // sequence instead, and cancels the shift modifier. case FNCOPYCUT: if (IS_RELEASED(record->event)) { int8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)); // Implicitly release the shift key so that it doesn't // mess with the macro that we play back unregister_mods(shifted); if (shifted) { action_macro_play(is_mac ? mac_cut : win_cut); } else { action_macro_play(is_mac ? mac_copy : win_copy); } } return; } }
void win_mouse_release(mouse_button b, LPARAM lp) { if (tab_bar_click(lp)) return; term_mouse_release(win_active_terminal(), b, get_mods(), get_mouse_pos(lp)); ReleaseCapture(); }
void win_mouse_click(mouse_button b, LPARAM lp) { static mouse_button last_button; static uint last_time, count; static pos last_click_pos; win_show_mouse(); mod_keys mods = get_mods(); pos p = get_mouse_pos(lp); uint t = GetMessageTime(); if (b != last_button || p.x != last_click_pos.x || p.y != last_click_pos.y || t - last_time > GetDoubleClickTime() || ++count > 3) count = 1; SetFocus(wnd); // in case focus was in search bar term_mouse_click(b, mods, p, count); last_pos = (pos){INT_MIN, INT_MIN}; last_click_pos = p; last_time = t; last_button = b; if (alt_state > ALT_NONE) alt_state = ALT_CANCELLED; }
void matrix_scan_keymap(void) { // runs frequently to update info uint8_t modifiers = get_mods(); uint8_t led_usb_state = host_keyboard_leds(); uint8_t one_shot = get_oneshot_mods(); if (!skip_leds) { ergodox_board_led_off(); ergodox_right_led_1_off(); ergodox_right_led_2_off(); ergodox_right_led_3_off(); // Since we're not using the LEDs here for layer indication anymore, // then lets use them for modifier indicators. Shame we don't have 4... // Also, no "else", since we want to know each, independently. if ( ( modifiers | one_shot ) & MOD_MASK_SHIFT || led_usb_state & (1<<USB_LED_CAPS_LOCK) ) { ergodox_right_led_2_on(); ergodox_right_led_2_set( 50 ); } if ( ( modifiers | one_shot ) & MOD_MASK_CTRL) { ergodox_right_led_1_on(); ergodox_right_led_1_set( 10 ); } if ( ( modifiers | one_shot ) & MOD_MASK_ALT) { ergodox_right_led_3_on(); ergodox_right_led_3_set( 10 ); } } };
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) { static uint8_t shift_esc_shift_mask; switch (id) { case SHIFT_ESC: shift_esc_shift_mask = get_mods()&MODS_CTRL_MASK; if (record->event.pressed) { if (shift_esc_shift_mask) { add_key(KC_GRV); send_keyboard_report(); } else { add_key(KC_ESC); send_keyboard_report(); } } else { if (shift_esc_shift_mask) { del_key(KC_GRV); send_keyboard_report(); } else { del_key(KC_ESC); send_keyboard_report(); } } break; } }
void win_mouse_click(mouse_button b, LPARAM lp) { static mouse_button last_button; static uint last_time, count; static pos last_click_pos; win_show_mouse(); if (tab_bar_click(lp)) return; mod_keys mods = get_mods(); pos p = get_mouse_pos(lp); uint t = GetMessageTime(); if (b != last_button || p.x != last_click_pos.x || p.y != last_click_pos.y || t - last_time > GetDoubleClickTime() || ++count > 3) count = 1; term_mouse_click(win_active_terminal(), b, mods, p, count); last_pos = (pos){INT_MIN, INT_MIN}; last_click_pos = p; last_time = t; last_button = b; if (alt_state > ALT_NONE) alt_state = ALT_CANCELLED; }
bool process_record_user(uint16_t keycode, keyrecord_t *record) { if((layer_state & (1 << CS_GO)) && (keycode == 44)){ if(get_mods() & (MOD_BIT(KC_LGUI))){ return false; } } return true; }
bool process_tap_dance(uint16_t keycode, keyrecord_t *record) { uint16_t idx = keycode - QK_TAP_DANCE; qk_tap_dance_action_t *action; if (last_td && last_td != keycode) { (&tap_dance_actions[last_td - QK_TAP_DANCE])->state.interrupted = true; } switch(keycode) { case QK_TAP_DANCE ... QK_TAP_DANCE_MAX: if ((int16_t)idx > highest_td) highest_td = idx; action = &tap_dance_actions[idx]; action->state.pressed = record->event.pressed; if (record->event.pressed) { action->state.keycode = keycode; action->state.count++; action->state.timer = timer_read(); action->state.oneshot_mods = get_oneshot_mods(); action->state.weak_mods = get_mods(); action->state.weak_mods |= get_weak_mods(); process_tap_dance_action_on_each_tap (action); if (last_td && last_td != keycode) { qk_tap_dance_action_t *paction = &tap_dance_actions[last_td - QK_TAP_DANCE]; paction->state.interrupted = true; process_tap_dance_action_on_dance_finished (paction); reset_tap_dance (&paction->state); } last_td = keycode; } break; default: if (!record->event.pressed) return true; if (highest_td == -1) return true; for (int i = 0; i <= highest_td; i++) { action = &tap_dance_actions[i]; if (action->state.count == 0) continue; action->state.interrupted = true; process_tap_dance_action_on_dance_finished (action); reset_tap_dance (&action->state); } break; } return true; }
void tap_space_spam_finished(qk_tap_dance_state_t *state, void *user_data) { if(get_mods() & (MOD_BIT(KC_LGUI))){ return; } if(state->pressed){ spam_space = true; } register_code(KC_SPC); unregister_code(KC_SPC); }
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 win_mouse_move(bool nc, LPARAM lp) { pos p = get_mouse_pos(lp); if (p.x == last_pos.x && p.y == last_pos.y) return; last_pos = p; win_show_mouse(); if (!nc) term_mouse_move(clicked_button, get_mods(), p); }
void matrix_scan_indicator(void) { current_mod = get_mods(); current_led = host_keyboard_leds(); current_osm = get_oneshot_mods(); set_rgb_indicators(current_mod, current_led, current_osm); last_mod = current_mod; last_led = current_led; last_osm = current_osm; }
/* Mixes in KM_HAXHAX via RALT modifier without shadowing the RALT key combinations. */ bool process_record_user(uint16_t keycode, keyrecord_t *record) { uint8_t modifiers = get_mods(); if (modifiers & MOD_BIT(KC_RALT) && record->event.pressed) { uint16_t kc = keymap_key_to_keycode(KM_HAXHAX, record->event.key); if (kc != KC_TRNS) { register_code(kc); unregister_code(kc); return false; } } return true; }
void matrix_scan_keymap (void) { static uint8_t current_mods; static uint8_t current_host_leds; static uint8_t current_oneshot_mods; static bool has_status_changed = true; if ( current_mods != get_mods() || current_host_leds != host_keyboard_leds() || current_oneshot_mods != get_oneshot_mods()) { has_status_changed = true; current_mods = get_mods(); current_host_leds = host_keyboard_leds(); current_oneshot_mods = get_oneshot_mods(); } if (has_status_changed) { has_status_changed = false; if (current_mods & MODS_SHIFT_MASK || current_host_leds & (1<<USB_LED_CAPS_LOCK) || current_oneshot_mods & MODS_SHIFT_MASK) { rgblight_sethsv_at(0, 255, 255, 5); rgblight_sethsv_at(0, 255, 255, 10); } else { rgblight_sethsv_default_helper(5); rgblight_sethsv_default_helper(10); } if (current_mods & MODS_CTRL_MASK || current_oneshot_mods & MODS_CTRL_MASK) { rgblight_sethsv_at(51, 255, 255, 6); rgblight_sethsv_at(51, 255, 255, 9); } else { rgblight_sethsv_default_helper(6); rgblight_sethsv_default_helper(9); } if (current_mods & MODS_GUI_MASK || current_oneshot_mods & MODS_GUI_MASK) { rgblight_sethsv_at(120, 255, 255, 7); rgblight_sethsv_at(120, 255, 255, 8); } else { rgblight_sethsv_default_helper(7); rgblight_sethsv_default_helper(8); } } }
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) { static uint8_t mods_pressed; static bool mod_flag; switch (id) { case 0: // clueboard specific hook to make escape quite tetris if (tetris_running) { tetris_running = 0; return; } /* Handle the combined Grave/Esc key */ mods_pressed = get_mods()&GRAVE_MODS; // Check to see what mods are pressed if (record->event.pressed) { /* The key is being pressed. */ if (mods_pressed) { mod_flag = true; add_key(KC_GRV); send_keyboard_report(); } else { add_key(KC_ESC); send_keyboard_report(); } } else { /* The key is being released. */ if (mod_flag) { mod_flag = false; del_key(KC_GRV); send_keyboard_report(); } else { del_key(KC_ESC); send_keyboard_report(); } } break; case 1: if (record->event.pressed) { tetris_running = 1; tetris_timer = 0; tetris_keypress = 0; // set randomness using total number of key presses tetris_start(tetris_key_presses); } break; } }
void win_mouse_move(bool nc, LPARAM lp) { if (lp == last_lp) return; win_show_mouse(); pos p = get_mouse_pos(lp); if (nc || (p.x == last_pos.x && p.y == last_pos.y)) return; last_pos = p; term_mouse_move(get_mods(), p); }
// New keycode KC_LAYO rotates between available default layers (for e.g., // selecting a base layout). Shift+KC_LAYO makes the current one persistent. bool process_record_layout(uint16_t keycode, keyrecord_t *record) { uint32_t default_layer; uint8_t i; #if defined(AUDIO_ENABLE) float saved_song[][2] = SONG(COIN_SOUND); #endif if (keycode != KC_LAYO || !record->event.pressed) { return true; } if (get_mods() & (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))) { // shift pressed // save default layer. whatever the current default layer is, store that eeconfig_update_default_layer(default_layer_state); #if defined(AUDIO_ENABLE) PLAY_SONG(saved_song); #endif } else { // rotate default layer. // find the current default layer default_layer = biton32(default_layer_state); // find next valid default layer for (i = 1; i < defaultlayers_n; i++) { if (defaultlayers[(default_layer + i) % defaultlayers_n]) { break; } } if (i == defaultlayers_n) { // we fell out of the loop without finding another default layer to switch // to. return false; } default_layer = (default_layer + i) % defaultlayers_n; default_layer_set(1U<<default_layer); led_set(host_keyboard_leds()); #if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS) PLAY_SONG(default_layer_songs[default_layer]); #endif } return false; }
void win_mouse_move(bool nc, LPARAM lp) { if (lp == last_lp) return; win_show_mouse(); pos p = get_mouse_pos(lp); if (nc || (p.x == last_pos.x && p.y == last_pos.y)) return; if (p.y < 0) { set_app_cursor(true); } else { win_update_mouse(); } last_pos = p; term_mouse_move(win_active_terminal(), get_mods(), p); }
uint32_t layer_state_set_keymap (uint32_t state) { uint8_t modifiders = get_mods(); uint8_t led_usb_state = host_keyboard_leds(); uint8_t one_shot = get_oneshot_mods(); if (modifiders & MODS_SHIFT_MASK || led_usb_state & (1<<USB_LED_CAPS_LOCK) || one_shot & MODS_SHIFT_MASK) { rgblight_sethsv_at(0, 255, 255, 5); rgblight_sethsv_at(0, 255, 255, 10); } if (modifiders & MODS_CTRL_MASK || one_shot & MODS_CTRL_MASK) { rgblight_sethsv_at(51, 255, 255, 6); rgblight_sethsv_at(51, 255, 255, 9); } if (modifiders & MODS_ALT_MASK || one_shot & MODS_ALT_MASK) { rgblight_sethsv_at(120, 255, 255, 7); rgblight_sethsv_at(120, 255, 255, 8); } return state; }
void matrix_init_rgb(void) { #ifdef INDICATOR_LIGHTS current_mod = last_mod = get_mods(); current_led = last_led = host_keyboard_leds(); current_osm = last_osm = get_oneshot_mods(); #endif if (userspace_config.rgb_layer_change) { rgblight_enable_noeeprom(); switch (biton32(eeconfig_read_default_layer())) { case _COLEMAK: rgblight_sethsv_noeeprom_magenta(); break; case _DVORAK: rgblight_sethsv_noeeprom_springgreen(); break; case _WORKMAN: rgblight_sethsv_noeeprom_goldenrod(); break; default: rgblight_sethsv_noeeprom_cyan(); break; } rgblight_mode_noeeprom(1); } }
bool process_record_cdeq(uint16_t keycode, keyrecord_t *record) { uint8_t shifted; uint16_t s_keycode; bool *k_shifted; switch (keycode) { case KC_COMM: s_keycode = KC_SLSH; k_shifted = &comm_shifted; break; case KC_DOT: s_keycode = KC_1; k_shifted = &ques_shifted; break; default: return true; } shifted = get_mods() & (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT)); // Keydown. If shift is currently pressed, register its alternate keycode. if (record->event.pressed && shifted) { *k_shifted = true; register_code(s_keycode); return false; // Keyup. If shift was pressed back when the key was pressed, unregister // its alternate keycode. } else if (!(record->event.pressed) && *k_shifted) { *k_shifted = false; unregister_code(s_keycode); return false; // Otherwise, behave as normal. } else { return true; } }
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) { switch (id) { case RGBLED_TOGGLE: //led operations if (record->event.pressed) { rgblight_toggle(); } break; case RGBLED_INCREASE_HUE: if (record->event.pressed) { rgblight_increase_hue(); } break; case RGBLED_DECREASE_HUE: if (record->event.pressed) { rgblight_decrease_hue(); } break; case RGBLED_INCREASE_SAT: if (record->event.pressed) { rgblight_increase_sat(); } break; case RGBLED_DECREASE_SAT: if (record->event.pressed) { rgblight_decrease_sat(); } break; case RGBLED_INCREASE_VAL: if (record->event.pressed) { rgblight_increase_val(); } break; case RGBLED_DECREASE_VAL: if (record->event.pressed) { rgblight_decrease_val(); } break; case RGBLED_STEP_MODE: if (record->event.pressed) { rgblight_step(); } break; static uint8_t shift_esc_shift_mask; // Shift + ESC = ~ case SHIFT_ESC: shift_esc_shift_mask = get_mods()&MODS_CTRL_MASK; if (record->event.pressed) { if (shift_esc_shift_mask) { add_key(KC_GRV); send_keyboard_report(); } else { add_key(KC_ESC); send_keyboard_report(); } } else { if (shift_esc_shift_mask) { del_key(KC_GRV); send_keyboard_report(); } else { del_key(KC_ESC); send_keyboard_report(); } } break; } };