summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-07-02 15:30:31 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-07-02 15:30:31 +0200
commit1193ca1ac272904d18d04ebb5bb27522484e0b0e (patch)
treeb349c2dc98350427f38a9376b6278247852a08ff /src
parent4089e006820e1029a2dd7093bae596b1b31d1686 (diff)
downloadabaos-1193ca1ac272904d18d04ebb5bb27522484e0b0e.tar.gz
abaos-1193ca1ac272904d18d04ebb5bb27522484e0b0e.tar.bz2
added ESC key in PS/2 keyboard driver
allow pressing ESC in graphics mode to return to text mode
Diffstat (limited to 'src')
-rw-r--r--src/drivers/hdi/ps2/keyboard.c12
-rw-r--r--src/kernel/kernel.c15
2 files changed, 19 insertions, 8 deletions
diff --git a/src/drivers/hdi/ps2/keyboard.c b/src/drivers/hdi/ps2/keyboard.c
index 740c9ec..ccae3e7 100644
--- a/src/drivers/hdi/ps2/keyboard.c
+++ b/src/drivers/hdi/ps2/keyboard.c
@@ -141,7 +141,8 @@ void keyboard_deinit( void *obj )
typedef enum {
KEYCODE_UNKNOWN,
- KEYCODE_ASCII_CHAR
+ KEYCODE_ASCII_CHAR,
+ KEYCODE_ESC
} keycode_type_t;
typedef struct {
@@ -233,6 +234,8 @@ static char scancode_map[4][128] = {
}
};
+#define SCAN_CODE_ESC 0x01
+
static keycode_t scancode_to_keycode( scancode_set_t set, uint8_t scan_code )
{
keycode_t key_code;
@@ -242,6 +245,11 @@ static keycode_t scancode_to_keycode( scancode_set_t set, uint8_t scan_code )
if( key_code.c > 0 ) {
key_code.type = KEYCODE_ASCII_CHAR;
}
+
+ if( scan_code == SCAN_CODE_ESC ) {
+ key_code.type = KEYCODE_ESC;
+ }
+
return key_code;
}
@@ -303,6 +311,8 @@ uint32_t keyboard_handle_interrupt( interrupt_handler_t *handler, uint32_t esp )
if( key_code.type == KEYCODE_ASCII_CHAR ) {
event.key = KEYBOARD_KEY_ASCII;
event.ascii_key = key_code.c;
+ } else if( key_code.type == KEYCODE_ESC ) {
+ event.key = KEYBOARD_KEY_ESC;
}
keyboard->handler( &event, keyboard->context );
diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c
index b97c3ea..55dd6f9 100644
--- a/src/kernel/kernel.c
+++ b/src/kernel/kernel.c
@@ -267,13 +267,6 @@ static void handle_keyboard_event( keyboard_event_t *event, void *context )
break;
case MODE_GRAPHICS:
- vga_text_restore( vga_text );
-
- if( vga_set_mode( vga, vga_make_mode( VGA_MODE_TYPE_TEXT, 640, 480, 4 ) ) ) {
- vga_text_set_cursor( vga_text, vga_text->cursor_x, vga_text->cursor_y );
- mouse_set_resolution( mouse, vga_text->res_x, vga_text->res_y );
- global_context->mode = MODE_TEXT;
- }
break;
}
@@ -297,6 +290,14 @@ static void handle_keyboard_event( keyboard_event_t *event, void *context )
if( event->type == KEYBOARD_EVENT_TYPE_KEY_PRESSED ) {
if( event->key == KEYBOARD_KEY_ASCII ) {
((widget_t *)desktop)->vtable->on_key_down( &global_context->desktop, event->ascii_key );
+ } else if( event->key == KEYBOARD_KEY_ESC ) {
+ vga_text_restore( vga_text );
+
+ if( vga_set_mode( vga, vga_make_mode( VGA_MODE_TYPE_TEXT, 640, 480, 4 ) ) ) {
+ vga_text_set_cursor( vga_text, vga_text->cursor_x, vga_text->cursor_y );
+ mouse_set_resolution( mouse, vga_text->res_x, vga_text->res_y );
+ global_context->mode = MODE_TEXT;
+ }
}
}
break;