// display.c // Author: Josh Holtrop // Date: 08/07/04 // Modified: 03/19/05 #include "devices.h" #include "char/vconsole.h" #include "display.h" #include "lang/lang.h" #include "kernel.h" #include "char/keyboard.h" #include "display/kout.h" extern real_mode_param_t rm_params; // check if a video mode is activated int display_type; int display_activeConsole = -1; // start with no active console // initialization routine for display subsystem int display_init() { if (!rm_params.vid_addr) // framebuffer mode { vconsole_setup(80, 25); display_activate(KERNEL_MSG_CONSOLE); display_type = DISPLAY_CONSOLE; } else display_type = DISPLAY_GRAPHICAL; return 0; } // activate the given display int display_activate(u32_t id) { if (id == display_activeConsole) return 0; if (display_type != DISPLAY_CONSOLE) return -1; if (id >= VCONSOLE_MAX) return -2; if (display_activeConsole >= 0) vconsole_deactivate(display_activeConsole); if (vconsole_activate(id)) // if true, didn't work to activate console { vconsole_activate(display_activeConsole); // restore old one return -3; } display_activeConsole = id; return 0; } void display_key_event(u32_t keyCode) { if (display_type == DISPLAY_CONSOLE) { u32_t kbdScan = KBD_SCAN(keyCode); if ( /* kbdFlags & KBDF_ALT && */ kbdScan >= 0x3B && kbdScan <= 0x44) // switch displays F1-F10 { display_activate(kbdScan - 0x3B); return; } if ( /* kbdFlags & KBDF_ALT && */ kbdScan >= 0x57 && kbdScan <= 0x58) // F11-F12 { display_activate(kbdScan - 0x4D); return; } if (KBD_ASCII(keyCode)) putc(KBD_ASCII(keyCode)); } /* TODO: send key to process on active console or graphical control process */ }