From 32c0df1b5374834145b4a373fcd560766b997c52 Mon Sep 17 00:00:00 2001 From: James Ross-Gowan Date: Mon, 20 Jan 2014 00:20:02 +1100 Subject: w32: use the w32_common keymap in terminal-win too --- osdep/terminal-win.c | 53 +++++++++++++--------------------------------------- 1 file changed, 13 insertions(+), 40 deletions(-) (limited to 'osdep/terminal-win.c') diff --git a/osdep/terminal-win.c b/osdep/terminal-win.c index 9d49936d70..918a073a17 100644 --- a/osdep/terminal-win.c +++ b/osdep/terminal-win.c @@ -33,6 +33,7 @@ #include "input/keycodes.h" #include "input/input.h" #include "terminal.h" +#include "osdep/w32_keyboard.h" int screen_width = 79; int screen_height = 24; @@ -121,52 +122,24 @@ static int getch2_internal(void) /*filter out keyevents*/ for (i = 0; i < retval; i++) { switch (eventbuffer[i].EventType) { - case KEY_EVENT: + case KEY_EVENT: { + KEY_EVENT_RECORD *record = &eventbuffer[i].Event.KeyEvent; + /*only a pressed key is interresting for us*/ - if (eventbuffer[i].Event.KeyEvent.bKeyDown == TRUE) { - /*check for special keys*/ - switch (eventbuffer[i].Event.KeyEvent.wVirtualKeyCode) { - case VK_HOME: - return MP_KEY_HOME; - case VK_END: - return MP_KEY_END; - case VK_DELETE: - return MP_KEY_DEL; - case VK_INSERT: - return MP_KEY_INS; - case VK_BACK: - return MP_KEY_BS; - case VK_PRIOR: - return MP_KEY_PGUP; - case VK_NEXT: - return MP_KEY_PGDWN; - case VK_RETURN: - return MP_KEY_ENTER; - case VK_ESCAPE: - return MP_KEY_ESC; - case VK_LEFT: - return MP_KEY_LEFT; - case VK_UP: - return MP_KEY_UP; - case VK_RIGHT: - return MP_KEY_RIGHT; - case VK_DOWN: - return MP_KEY_DOWN; - case VK_SHIFT: - continue; - } - /*check for function keys*/ - if (0x87 >= eventbuffer[i].Event.KeyEvent.wVirtualKeyCode && - eventbuffer[i].Event.KeyEvent.wVirtualKeyCode >= 0x70) - return MP_KEY_F + 1 + - eventbuffer[i].Event.KeyEvent.wVirtualKeyCode - 0x70; + if (record->bKeyDown) { + UINT vkey = record->wVirtualKeyCode; + bool ext = record->dwControlKeyState & ENHANCED_KEY; + + int mpkey = mp_w32_vkey_to_mpkey(vkey, ext); + if (mpkey) + return mpkey; /*only characters should be remaining*/ //printf("getch2: YOU PRESSED \"%c\" \n",eventbuffer[i].Event.KeyEvent.uChar.AsciiChar); - return eventbuffer[i].Event.KeyEvent.uChar.AsciiChar; + return eventbuffer[i].Event.KeyEvent.uChar.UnicodeChar; } break; - + } case MOUSE_EVENT: case WINDOW_BUFFER_SIZE_EVENT: case FOCUS_EVENT: -- cgit v1.2.3