shithub: choc

Download patch

ref: 93f58bbef5f4c941f32edbb6285d4650d6456c5d
parent: 123eeafba7561bf44e8b66927386a6a5dd11b549
author: Simon Howard <fraggle@soulsphere.org>
date: Wed Dec 30 11:59:27 EST 2015

video: Apply shiftxform with vanilla_keyboard_mapping.

We still don't have a story yet for how to do input properly when
vanilla_keyboard_mapping=false, but applying shiftxform to scancode
input when vanilla_keyboard_mapping=true seems like the right thing to
do.

--- a/src/i_video.c
+++ b/src/i_video.c
@@ -568,7 +568,17 @@
     // Otherwise we should use the native key mapping.
     if (vanilla_keyboard_mapping)
     {
-        return TranslateKey(&event->key.keysym);
+        int result = TranslateKey(&event->key.keysym);
+
+        // If shift is held down, apply the original uppercase
+        // translation table used under DOS.
+        if ((SDL_GetModState() & KMOD_SHIFT) != 0
+         && result >= 0 && result < arrlen(shiftxform))
+        {
+            result = shiftxform[result];
+        }
+
+        return result;
     }
     else
     {
@@ -702,11 +712,6 @@
                 event.type = ev_keydown;
                 event.data1 = TranslateKey(&sdlevent.key.keysym);
                 event.data2 = GetTypedChar(&sdlevent);
-
-                // SDL2-TODO: Need to generate a parallel text input event
-                // here that can be used for typing text, eg. multiplayer
-                // chat and savegame names. This is only for the Vanilla
-                // case; we must use the shiftxform table.
 
                 if (event.data1 != 0)
                 {