コード例 #1
0
ファイル: tty.c プロジェクト: kcao/kenos
/*======================================================================*
                           in_process
 *======================================================================*/
PUBLIC void in_process(TTY* p_tty, t_32 key)
{
	if (!(key & FLAG_EXT)) {
		put_key(p_tty, key);
	}
	else {
		int raw_code = key & MASK_RAW;
		switch(raw_code) {
		case ENTER:
			put_key(p_tty, '\n');
			break;
		case BACKSPACE:
			put_key(p_tty, '\b');
			break;
		case UP:
			if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) 
			{	/* Shift + Up */
				scroll_screen(p_tty->p_console,
						SCROLL_SCREEN_UP);
			}
			break;
		case DOWN:
			if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) 
			{	/* Shift + Down */
				scroll_screen(p_tty->p_console,
						SCROLL_SCREEN_DOWN);
			}
			break;
		case F1:
		case F2:
		case F3:
		case F4:
		case F5:
		case F6:
		case F7:
		case F8:
		case F9:
		case F10:
		case F11:
			if ((key & FLAG_ALT_L) || (key & FLAG_ALT_R)) 
			{	/* Alt + F1~F11 */
				select_console(raw_code - F1);
			}
			break;
		case F12:
			if ((key & FLAG_ALT_L) || (key & FLAG_ALT_R)) 
			{	
				if (schedule != sched0) {
					schedule = sched0;
				}
				else {
					schedule = (xmodfunc)XModPhyAddr;
				}
			}
			break;
		default:
			break;
		}
	}
}
コード例 #2
0
ファイル: tty.c プロジェクト: wsxiaoys/OS-Practice
/**
 * keyboard_read() will invoke this routine after having recognized a key press.
 * 
 * @param tty  The key press is for whom.
 * @param key  The integer key with metadata.
 *****************************************************************************/
PUBLIC void in_process(TTY* tty, u32 key)
{
	if (!(key & FLAG_EXT)) {
		put_key(tty, key);
	}
	else {
		int raw_code = key & MASK_RAW;
		switch(raw_code) {
		case ENTER:
			put_key(tty, '\n');
			break;
		case BACKSPACE:
			put_key(tty, '\b');
			break;
		case UP:
			if ((key & FLAG_SHIFT_L) ||
			    (key & FLAG_SHIFT_R)) {	/* Shift + Up */
				scroll_screen(tty->console, SCR_DN);
			}
			break;
		case DOWN:
			if ((key & FLAG_SHIFT_L) ||
			    (key & FLAG_SHIFT_R)) {	/* Shift + Down */
				scroll_screen(tty->console, SCR_UP);
			}
			break;
		case RIGHT:
			if ((key & FLAG_SHIFT_L) ||
			    (key & FLAG_SHIFT_R)) {	/* Shift + Right */
				select_console(current_console+1);
			}
			break;
		case LEFT:
			if ((key & FLAG_SHIFT_L) ||
			    (key & FLAG_SHIFT_R)) {	/* Shift + Left */
				select_console(current_console-1);
			}
			break;
		case F1:
		case F2:
		case F3:
		case F4:
		case F5:
		case F6:
		case F7:
		case F8:
		case F9:
		case F10:
		case F11:
		case F12:
			if ((key & FLAG_ALT_L) ||
			    (key & FLAG_ALT_R)) {	/* Alt + F1~F12 */
				select_console(raw_code - F1);
			}
			break;
		default:
			break;
		}
	}
}
コード例 #3
0
ファイル: tty.c プロジェクト: chenghuaijun/Orange
/*======================================================================*
				in_process
 *======================================================================*/
PUBLIC void in_process(TTY* p_tty, u32 key)
{
        if (!(key & FLAG_EXT)) {
		put_key(p_tty, key);
        }
        else {
                int raw_code = key & MASK_RAW;
                switch(raw_code) {
                case ENTER:
			put_key(p_tty, '\n');
			break;
                case BACKSPACE:
			put_key(p_tty, '\b');
			break;
                case UP:
                        if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) {
				scroll_screen(p_tty->p_console, SCR_DN);
                        }
			break;
		case DOWN:
			if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) {
				scroll_screen(p_tty->p_console, SCR_UP);
			}
			break;
		case F1:
		case F2:
		case F3:
		case F4:
		case F5:
		case F6:
		case F7:
		case F8:
		case F9:
		case F10:
		case F11:
		case F12:
			/* Alt + F1~F12 */
			if ((key & FLAG_CTRL_L) || (key & FLAG_CTRL_R)) {
				select_console(raw_code - F1);
			}
			else {
				if (raw_code == F12) {
					disable_int();
					dump_proc(proc_table + 4);
					for(;;);
				}
			}
			break;
                default:
                        break;
                }
        }
}
コード例 #4
0
ファイル: tty.c プロジェクト: wangjue444/programming-for-fun
PUBLIC void process_in_tty(TTY* tty, u32 key)
{
        char output[2] = {'\0', '\0'};

        if (!(key & FLAG_EXT)) {
		put_key(tty, key);
        }
        else {
                int raw_code = key & MASK_RAW;
                switch(raw_code) {
                case ENTER:
			put_key(tty, '\n');
			break;
                case BACKSPACE:
			put_key(tty, '\b');
			break;
                case UP:
                        if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) {
				scroll(tty->p_SCREEN, SCR_DN);
                        }
			break;
		case DOWN:
			if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) {
				scroll(tty->p_SCREEN, SCR_UP);
			}
			break;
		case F1:
		case F2:
		case F3:
		    select_SCREEN(raw_code - F1);

			break;
		case F4:
		case F5:
		case F6:
            proctable[raw_code-F1-2].runable=!proctable[raw_code-F1-2].runable;
            break;
        case F7:
            remain_show=!remain_show;
            break;

        case F8:
            keyboard_show=!keyboard_show;
            break;
        case F9:
            lunzhuan=!lunzhuan;
            break;

                default:
                        break;
                }
        }
}
コード例 #5
0
ファイル: tty.c プロジェクト: Jasminekiki/OSdesign
/*======================================================================*
                           in_process
 *======================================================================*/
PUBLIC void in_process(TTY* p_tty, t_32 key)
{
	if (!(key & FLAG_EXT)) {
		if (p_tty->startScanf==0) return ;
		put_key(p_tty, key);
		putToTemp(p_tty,key);
	}
	else {
		int raw_code = key & MASK_RAW;
		switch(raw_code) {
		case ENTER:
			put_key(p_tty, '\n');
			putToStr(p_tty);
			break;
		case BACKSPACE:
			if (p_tty->tmpLen)
			{
				put_key(p_tty, '\b');
				p_tty->tmpLen--;
			}
			break;
		case UP:
			if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) {	/* Shift + Up */
				scroll_screen(p_tty->p_console, SCROLL_SCREEN_UP);
			}
			break;
		case DOWN:
			if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) {	/* Shift + Down */
				scroll_screen(p_tty->p_console, SCROLL_SCREEN_DOWN);
			}
			break;
		case F1:
		case F2:
		case F3:
		case F4:
		case F5:
		case F6:
		case F7:
		case F8:
		case F9:
		case F10:
		case F11:
		case F12:
			if ((key & FLAG_ALT_L) || (key & FLAG_ALT_R)) {	/* Alt + F1~F12 */
				select_console(raw_code - F1);
			}
			break;
		default:
			break;
		}
	}
}
コード例 #6
0
ファイル: tty.c プロジェクト: lizhengqiang/tinix
/*======================================================================*
                           in_process
 *======================================================================*/
PUBLIC void in_process(TTY* p_tty, t_32 key)
{
	if (!(key & FLAG_EXT)) {
		put_key(p_tty, key);
		out_char(p_tty->p_console, key);
	}
	else {
		int raw_code = key & MASK_RAW;
		switch(raw_code) {
		case ENTER:

			put_key(p_tty, '\n');
			handle_command(p_tty);
			break;
		case BACKSPACE:
			if(p_tty->inbuf_count>0){
				out_char(p_tty->p_console, '\b');
			}
			put_key(p_tty, '\b');
			
			break;
		case UP:
			if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) {	/* Shift + Up */
				scroll_screen(p_tty->p_console, SCROLL_SCREEN_UP);
			}
			break;
		case DOWN:
			if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) {	/* Shift + Down */
				scroll_screen(p_tty->p_console, SCROLL_SCREEN_DOWN);
			}
			break;
		case F1:
		case F2:
		case F3:
		case F4:
		case F5:
		case F6:
		case F7:
		case F8:
		case F9:
		case F10:
		case F11:
		case F12:
			if (1) {	/* Alt + F1~F12 */
				select_console(raw_code - F1);
			}
			break;
		default:
			break;
		}
	}
}
コード例 #7
0
ファイル: tty.c プロジェクト: Garfield-Chen/hf-2011
/*======================================================================*
				in_process
 *======================================================================*/
PUBLIC void in_process(TTY* p_tty, u32 key)
{
        char output[2] = {'\0', '\0'};

        if (!(key & FLAG_EXT)) {
		put_key(p_tty, key);
        }
        else {
                int raw_code = key & MASK_RAW;
                switch(raw_code) {
                case ENTER:
			put_key(p_tty, '\n');
			break;
                case BACKSPACE:
			put_key(p_tty, '\b');
			break;
                case UP:
                        if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) {
				scroll_screen(p_tty->p_console, SCR_DN);
                        }
			break;
		case DOWN:
			if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) {
				scroll_screen(p_tty->p_console, SCR_UP);
			}
			break;
		case F1:
		case F2:
		case F3:
		case F4:
		case F5:
		case F6:
		case F7:
		case F8:
		case F9:
		case F10:
		case F11:
		case F12:
			/* Alt + F1~F12 */
			if ((key & FLAG_ALT_L) || (key & FLAG_ALT_R)) {
				select_console(raw_code - F1);
			}
			break;
                default:
                        break;
                }
        }
}
コード例 #8
0
ファイル: tty.c プロジェクト: zzt93/Exercise
void in_process(struct Tty *p_tty, uint32_t key)
{

        if (!(key & FLAG_EXT)) {
                put_key(p_tty, key);
                
        } else {
                int raw_code = key & MASK_RAW;
                switch(raw_code) {
                case ENTER:
                        put_key(p_tty, 0x0a);
                        break;
                case BACKSPACE:
                        put_key(p_tty, '\b');
                        break;
                case UP:
                        if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R))
                                scroll_screen(p_tty->p_console, SCR_DN);
                        break;
                case DOWN:
                        if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R))
                                scroll_screen(p_tty->p_console, SCR_UP);
                        break;
                case F1:
                case F2:
                case F3:
                case F4:
                case F5:
                case F6:
                case F7:
                case F8:
                case F9:
                case F10:
                case F11:
                case F12:
                        /* Alt + F1~F12 */
                        if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) {
                                select_console(raw_code - F1);
                        }
                        break;
                default:
                        break;
                }
        }

}
コード例 #9
0
ファイル: tty.c プロジェクト: Cee/Operating_System_Chap_3
/*======================================================================*
				in_process
 *======================================================================*/
PUBLIC void in_process(TTY* p_tty, u32 key)
{
        char output[2] = {'\0', '\0'};

        if (!(key & FLAG_EXT)) {
		put_key(p_tty, key);
        }
        else {
                int raw_code = key & MASK_RAW;
                switch(raw_code) {
                case ENTER:
			put_key(p_tty, '\n');
			break;
                case BACKSPACE:
			put_key(p_tty, '\b');
			break;
				case TAB:
					put_key(p_tty,' ');					
					put_key(p_tty,' ');
					put_key(p_tty,' ');
					put_key(p_tty,' ');
					break;
                case UP:
                        if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) {
				scroll_screen(p_tty->p_console, SCR_DN);
                        } else {
							changeColor();
						}
			break;
		case DOWN:
			if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) {
				scroll_screen(p_tty->p_console, SCR_UP);
			} else {
					changeColor();
			}
			break;
		
                default:
                        break;
                }
        }
}
コード例 #10
0
ファイル: usb.c プロジェクト: CommanderCoder/raspberry-pi-sdl
static void USPiKeyStatusHandlerRaw (unsigned char ucModifiers, const unsigned char RawKeys[6]) {
    static int keydown[MAX_KEYS] = { 0, 0, 0, 0, 0, 0 };
    static int capsLock = 1;
    int i, index, c;
    short key;

    for (index = 0; index < MAX_KEYS; index++) {
        key = RawKeys[index];
        if (key < 4 || key > KEY_MAX_CODE) { // Invalid key code
            continue;
        }
        for (i = 0; i < MAX_KEYS; i++) {
            if (key == keydown[i]) {
                break;
            }
        }
        if (i >= MAX_KEYS) {
            for (int i = 0; i < MAX_KEYS; i++) {
                if (keydown[i] == 0) {
                    if (key == 57) {
                        capsLock = capsLock ? 0 : 1;
                    }
                    else if ((ucModifiers & (LSHIFT | RSHIFT)) != 0 && (ucModifiers & ALTGR) != 0) {
                        c = keyMap[key][KEY_SHIFT_ALTGR];
                        put_key(c != 0 ? c : SWAP_BYTES(key));
                    }
                    else if ((ucModifiers & ALTGR) != 0) {
                        c = keyMap[key][KEY_ALTGR];
                        put_key(c != 0 ? c : SWAP_BYTES(key));
                    }
                    else if ((ucModifiers & (LSHIFT | RSHIFT)) != 0) {
                        c = keyMap[key][KEY_SHIFT];
                        if (capsLock) {
                            c = tolower(c);
                        }
                        put_key(c != 0 ? c : SWAP_BYTES(key));
                    }
                    else {
                        c = keyMap[key][KEY_NORMAL];
                        if (c >= 'a' && c <= 'z' && (ucModifiers & (LCTRL | RCTRL)) != 0) {
                            c = (c - 'a') + 1;
                        }
                        else if (capsLock) {
                            c = toupper(c);
                        }
                        put_key(c != 0 ? c : SWAP_BYTES(key));
                    }
                    keydown[i] = key;
                    kbd_status[key] = 1;
                    break;
                }
            }
        }
    }

    for (i = 0; i < MAX_KEYS; i++) {
        key = keydown[i];
        if (key != 0) {
            for (index = 0; index < MAX_KEYS; index++) {
                if (RawKeys[index] == key)
                    break;
            }
            if (index >= MAX_KEYS) {
                keydown[i] = 0;
                kbd_status[key] = 0;
            }
        }
    }
}