📄 sunkbd.c
字号:
rep = 0; clear_bit(keycode, key_down); } else { auto_repeat_timer.expires = jiffies+HZ/5; add_timer (&auto_repeat_timer); rep = set_bit(keycode, key_down); } if(raw_mode) return; if(kbd->kbdmode == VC_MEDIUMRAW) { put_queue(keycode + up_flag); return; } /* * Small change in philosophy: earlier we defined repetition by * rep = keycode == prev_keycode; * prev_keycode = keycode; * but now by the fact that the depressed key was down already. * Does this ever make a difference? Yes. */ /* * Repeat a key only if the input buffers are empty or the * characters get echoed locally. This makes key repeat usable * with slow applications and under heavy loads. */ if (!rep || (vc_kbd_mode(kbd,VC_REPEAT) && tty && (L_ECHO(tty) || (tty->driver.chars_in_buffer(tty) == 0)))) { u_short keysym; u_char type; /* the XOR below used to be an OR */ int shift_final = shift_state ^ kbd->lockstate; ushort *key_map = key_maps[shift_final]; if (key_map != NULL) { keysym = key_map[keycode]; type = KTYP(keysym); if (type >= 0xf0) { type -= 0xf0; if (type == KT_LETTER) { type = KT_LATIN; if (vc_kbd_led(kbd, VC_CAPSLOCK)) { key_map = key_maps[shift_final ^ (1<<KG_SHIFT)]; if (key_map) keysym = key_map[keycode]; } } (*key_handler[type])(keysym & 0xff, up_flag); if (type != KT_SLOCK) kbd->slockstate = 0; } } else { /* maybe beep? */ /* we have at least to update shift_state */ compute_shiftstate(); } }}static void put_queue(int ch){ wake_up(&keypress_wait); if (tty) { tty_insert_flip_char(tty, ch, 0); tty_schedule_flip(tty); }}static void puts_queue(char *cp){ wake_up(&keypress_wait); if (!tty) return; while (*cp) { tty_insert_flip_char(tty, *cp, 0); cp++; } tty_schedule_flip(tty);}static void applkey(int key, char mode){ static char buf[] = { 0x1b, 'O', 0x00, 0x00 }; buf[1] = (mode ? 'O' : '['); buf[2] = key; puts_queue(buf);}static void enter(void){ put_queue(13); if (vc_kbd_mode(kbd,VC_CRLF)) put_queue(10);}static void caps_toggle(void){ if (rep) return; chg_vc_kbd_led(kbd, VC_CAPSLOCK);}static void caps_on(void){ if (rep) return; set_vc_kbd_led(kbd, VC_CAPSLOCK);}static void show_ptregs(void){ if (pt_regs) show_regs(pt_regs);}static void hold(void){ if (rep || !tty) return; /* * Note: SCROLLOCK will be set (cleared) by stop_tty (start_tty); * these routines are also activated by ^S/^Q. * (And SCROLLOCK can also be set by the ioctl KDSKBLED.) */ if (tty->stopped) start_tty(tty); else stop_tty(tty);}static void num(void){ if (vc_kbd_mode(kbd,VC_APPLIC)) applkey('P', 1); else bare_num();}/* * Bind this to Shift-NumLock if you work in application keypad mode * but want to be able to change the NumLock flag. * Bind this to NumLock if you prefer that the NumLock key always * changes the NumLock flag. */static void bare_num(void){ if (!rep) chg_vc_kbd_led(kbd,VC_NUMLOCK);}static void lastcons(void){ /* switch to the last used console, ChN */ set_console(last_console);}static void decr_console(void){ int i; for (i = fg_console-1; i != fg_console; i--) { if (i == -1) i = MAX_NR_CONSOLES-1; if (vc_cons_allocated(i)) break; } set_console(i);}static void incr_console(void){ int i; for (i = fg_console+1; i != fg_console; i++) { if (i == MAX_NR_CONSOLES) i = 0; if (vc_cons_allocated(i)) break; } set_console(i);}static void send_intr(void){ if (!tty) return; tty_insert_flip_char(tty, 0, TTY_BREAK); tty_schedule_flip(tty);}static void scroll_forw(void){ scrollfront(0);}static void scroll_back(void){ scrollback(0);}static void boot_it(void){ extern int obp_system_intr(void); if (!obp_system_intr()) ctrl_alt_del(); /* sigh.. attempt to prevent multiple entry */ last_keycode=1; rep = 0;}static void compose(void){ dead_key_next = 1;}int spawnpid, spawnsig;static void spawn_console(void){ if (spawnpid) if(kill_proc(spawnpid, spawnsig, 1)) spawnpid = 0;}static void SAK(void){ do_SAK(tty);#if 0 /* * Need to fix SAK handling to fix up RAW/MEDIUM_RAW and * vt_cons modes before we can enable RAW/MEDIUM_RAW SAK * handling. * * We should do this some day --- the whole point of a secure * attention key is that it should be guaranteed to always * work. */ reset_vc(fg_console); do_unblank_screen(); /* not in interrupt routine? */#endif}static void do_ignore(unsigned char value, char up_flag){}static void do_null(){ compute_shiftstate();}static void do_spec(unsigned char value, char up_flag){ if (up_flag) return; if (value >= SIZE(spec_fn_table)) return; spec_fn_table[value]();}static void do_lowercase(unsigned char value, char up_flag){ printk("keyboard.c: do_lowercase was called - impossible\n");}static void do_self(unsigned char value, char up_flag){ if (up_flag) return; /* no action, if this is a key release */ if (diacr) value = handle_diacr(value); if (dead_key_next) { dead_key_next = 0; diacr = value; return; } put_queue(value);}#define A_GRAVE '`'#define A_ACUTE '\''#define A_CFLEX '^'#define A_TILDE '~'#define A_DIAER '"'#define A_CEDIL ','static unsigned char ret_diacr[NR_DEAD] = {A_GRAVE, A_ACUTE, A_CFLEX, A_TILDE, A_DIAER, A_CEDIL };/* If a dead key pressed twice, output a character corresponding to it, *//* otherwise just remember the dead key. */static void do_dead(unsigned char value, char up_flag){ if (up_flag) return; value = ret_diacr[value]; if (diacr == value) { /* pressed twice */ diacr = 0; put_queue(value); return; } diacr = value;}/* If space is pressed, return the character corresponding the pending *//* dead key, otherwise try to combine the two. */unsigned char handle_diacr(unsigned char ch){ int d = diacr; int i; diacr = 0; if (ch == ' ') return d; for (i = 0; i < accent_table_size; i++) { if (accent_table[i].diacr == d && accent_table[i].base == ch) return accent_table[i].result; } put_queue(d); return ch;}static void do_cons(unsigned char value, char up_flag){ if (up_flag) return; want_console = value;}static void do_fn(unsigned char value, char up_flag){ if (up_flag) return; if (value < SIZE(func_table)) { if (func_table[value]) puts_queue(func_table[value]); } else printk("do_fn called with value=%d\n", value);}static void do_pad(unsigned char value, char up_flag){ static const char *pad_chars = "0123456789+-*/\015,.?"; static const char *app_map = "pqrstuvwxylSRQMnn?"; if (up_flag) return; /* no action, if this is a key release */ /* kludge... shift forces cursor/number keys */ if (vc_kbd_mode(kbd,VC_APPLIC) && !k_down[KG_SHIFT]) { applkey(app_map[value], 1); return; } if (!vc_kbd_led(kbd,VC_NUMLOCK)) switch (value) { case KVAL(K_PCOMMA): case KVAL(K_PDOT): do_fn(KVAL(K_REMOVE), 0); return; case KVAL(K_P0): do_fn(KVAL(K_INSERT), 0); return; case KVAL(K_P1): do_fn(KVAL(K_SELECT), 0); return; case KVAL(K_P2): do_cur(KVAL(K_DOWN), 0); return; case KVAL(K_P3): do_fn(KVAL(K_PGDN), 0); return; case KVAL(K_P4): do_cur(KVAL(K_LEFT), 0); return; case KVAL(K_P6): do_cur(KVAL(K_RIGHT), 0); return; case KVAL(K_P7): do_fn(KVAL(K_FIND), 0); return; case KVAL(K_P8): do_cur(KVAL(K_UP), 0); return; case KVAL(K_P9): do_fn(KVAL(K_PGUP), 0); return; case KVAL(K_P5): applkey('G', vc_kbd_mode(kbd, VC_APPLIC)); return; } put_queue(pad_chars[value]); if (value == KVAL(K_PENTER) && vc_kbd_mode(kbd, VC_CRLF)) put_queue(10);}static void do_cur(unsigned char value, char up_flag){ static const char *cur_chars = "BDCA"; if (up_flag) return; applkey(cur_chars[value], vc_kbd_mode(kbd,VC_CKMODE));}static void do_shift(unsigned char value, char up_flag){ int old_state = shift_state; if (rep) return; /* Mimic typewriter: a CapsShift key acts like Shift but undoes CapsLock */ if (value == KVAL(K_CAPSSHIFT)) { value = KVAL(K_SHIFT); if (!up_flag) clr_vc_kbd_led(kbd, VC_CAPSLOCK); } if (up_flag) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -