int tty_getcursor() { port_byte_out(REG_SCREEN_CTRL, 14); int offset = port_byte_in(REG_SCREEN_DATA) << 8; port_byte_out(REG_SCREEN_CTRL, 15); offset += port_byte_in(REG_SCREEN_DATA); return offset; }
int get_cursor_offset() { /* Use the VGA ports to get the current cursor position * 1. Ask for high byte of the cursor offset (data 14) * 2. Ask for low byte (data 15) */ port_byte_out(REG_SCREEN_CTRL, 14); int offset = port_byte_in(REG_SCREEN_DATA) << 8; /* High byte: << 8 */ port_byte_out(REG_SCREEN_CTRL, 15); offset += port_byte_in(REG_SCREEN_DATA); return offset * 2; /* Position * size of character cell */ }
static struct cursor get_cursor(void) { port_byte_out(CTRL_PORT, 14); uint8_t high_byte = port_byte_in(DATA_PORT); port_byte_out(CTRL_PORT, 15); uint8_t low_byte = port_byte_in(DATA_PORT); uint16_t offset = high_byte; offset <<= 8; offset += low_byte; struct cursor cur = {(uint16_t)(offset / MAX_COLS), (uint16_t)(offset % MAX_COLS)}; return cur; }
int get_cursor() { // The device uses its control register as an index // to select its interl registers, in which we are // interested in // reg 14: which is the high byte of cursor offset // reg 15: which is the low byte of cursor offet port_byte_out(REG_SCREEN_CTRL, 14); int nOffset = port_byte_in(REG_SCREEN_DATA) << 8; port_byte_out(REG_SCREEN_CTRL, 15); nOffset += port_byte_in(REG_SCREEN_DATA); // Since the cursor offset reported by the VGA hardware // is the number of characters, we have to multiply it // by two to convert it to a character cell offset return nOffset * 2; }
void echoKey() { unsigned char keymap[128] = { 0, 27, '1', '2', '3', '4', '5', '6', '7', '8', /* 9 */ '9', '0', '-', '=', '\b', /* Backspace */ '\t', /* Tab */ 'q', 'w', 'e', 'r', /* 19 */ 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', /* Enter key */ 0, /* 29 - Control */ 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', /* 39 */ '\'', '`', 0, /* Left shift */ '\\', 'z', 'x', 'c', 'v', 'b', 'n', /* 49 */ 'm', ',', '.', '/', 0, /* Right shift */ '*', 0, /* Alt */ ' ', /* Space bar */ 0, /* Caps lock */ 0, /* 59 - F1 key ... > */ 0, 0, 0, 0, 0, 0, 0, 0, 0, /* < ... F10 */ 0, /* 69 - Num lock*/ 0, /* Scroll Lock */ 0, /* Home key */ 0, /* Up Arrow */ 0, /* Page Up */ '-', 0, /* Left Arrow */ 0, 0, /* Right Arrow */ '+', 0, /* 79 - End key*/ 0, /* Down Arrow */ 0, /* Page Down */ 0, /* Insert Key */ 0, /* Delete Key */ 0, 0, 0, 0, /* F11 Key */ 0, /* F12 Key */ 0, /* All other keys are undefined */}; unsigned char scanCode = port_byte_in(0x60); if(!(scanCode & KEY_RELEASED)) { printChar(keymap[scanCode]); } }
static void keyboard_callback() { unsigned char code = port_byte_in(0x60); ash_receive_key(code); }