From 4dd2115592bddf05cc29a7718c5ffb7900447aba Mon Sep 17 00:00:00 2001 From: julianb0 Date: Sun, 7 Jul 2019 15:43:37 +0200 Subject: [PATCH] keyboard --- vm/pc/keybd.c | 69 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 25 deletions(-) diff --git a/vm/pc/keybd.c b/vm/pc/keybd.c index 4cc79c1..9981ff4 100644 --- a/vm/pc/keybd.c +++ b/vm/pc/keybd.c @@ -37,30 +37,6 @@ keycode_t console_scankeybuf(ctx_t *ctx) return 0; } -void console_handle_input(ctx_t *ctx, SDL_Keycode key) -{ - keycode_t code = 0; - - SDL_Keymod mod = SDL_GetModState(); - - if (key <= 'z' && key >= 'a') - { - if (mod & (KMOD_CTRL|KMOD_ALT)) - { - if (key == 'c') - _except(ctx, E_BRK, "Ctrl+C received"); - - return; - } - - if (mod & KMOD_SHIFT) - key -= ('a' - 'A'); - - console_addkey(ctx, key); - - return; - } - #define QKEY(key, c, cshift, cmode, calt, cgui) \ _QKEY(SDLK_##key, c, cshift, cmode, calt, cgui) @@ -75,6 +51,20 @@ _QKEY(SDLK_##key, c, cshift, cmode, calt, cgui) else if ((mod & KMOD_GUI)) code = cgui; \ break; +void console_handle_input(ctx_t *ctx, SDL_Keycode key) +{ + keycode_t code = 0; + + SDL_Keymod mod = SDL_GetModState(); + + if (mod & KMOD_CTRL) + { + if (key == SDLK_c) + _except(ctx, E_BRK, "Ctrl+C received"); + + return; + } + switch (key) { case SDLK_SPACE: code = ' '; break; @@ -87,6 +77,35 @@ _QKEY(SDLK_##key, c, cshift, cmode, calt, cgui) case SDLK_TAB: code = '\t'; break; + // COMMON + + QKEY(a, 'a', 'A', 0, 0, 0); + QKEY(b, 'b', 'B', 0, 0, 0); + QKEY(c, 'c', 'C', 0, 0, 0); + QKEY(d, 'd', 'D', 0, 0, 0); + QKEY(e, 'e', 'E', 0, 0, 0); + QKEY(f, 'f', 'F', 0, 0, 0); + QKEY(g, 'g', 'G', 0, 0, 0); + QKEY(h, 'h', 'H', 0, 0, 0); + QKEY(i, 'i', 'I', 0, 0, 0); + QKEY(j, 'j', 'J', 0, 0, 0); + QKEY(k, 'k', 'K', 0, 0, 0); + QKEY(l, 'l', 'L', 0, 0, 0); + QKEY(m, 'm', 'M', 0, 0, 0); + QKEY(n, 'n', 'N', 0, 0, 0); + QKEY(o, 'o', 'O', 0, 0, 0); + QKEY(p, 'p', 'P', 0, 0, 0); + QKEY(q, 'q', 'Q', 0, 0, 0); + QKEY(r, 'r', 'R', 0, 0, 0); + QKEY(s, 's', 'S', 0, 0, 0); + QKEY(t, 't', 'T', 0, 0, 0); + QKEY(u, 'u', 'U', 0, 0, 0); + QKEY(v, 'v', 'V', 0, 0, 0); + QKEY(w, 'w', 'W', 0, 0, 0); + QKEY(x, 'x', 'X', 0, 0, 0); + QKEY(y, 'y', 'Y', 0, 0, 0); + QKEY(z, 'z', 'Z', 0, 0, 0); + // AZERTY QKEY(EXCLAIM, '!', 0, 0, 0, 0); @@ -151,13 +170,13 @@ _QKEY(SDLK_##key, c, cshift, cmode, calt, cgui) QKEY(AT, '@', 0, 0, 0, 0); // Found experimentally + _QKEY(231, 0, '0', '@', 0, 0); _QKEY(232, 0, '7', '`', 0, 0); _QKEY(233, 0, '2', '~', 0, 0); _QKEY(249, 0, '%', 0, 0, 0); default: - trace("??%d!!\n", key); return; }