Browse Source

Added support for ALT qualifier.
Fixed LineEdit input when ALT-GR held down.

Lasse Öörni 14 years ago
parent
commit
b8155e9558
4 changed files with 24 additions and 72 deletions
  1. 8 36
      Engine/Engine/InputAPI.cpp
  2. 6 0
      Engine/Input/Input.cpp
  3. 8 35
      Engine/Input/InputEvents.h
  4. 2 1
      Engine/UI/LineEdit.cpp

+ 8 - 36
Engine/Engine/InputAPI.cpp

@@ -35,20 +35,16 @@ static void RegisterKeyCodes(asIScriptEngine* engine)
     engine->RegisterGlobalProperty("const int MOUSEB_MIDDLE", (void*)&MOUSEB_MIDDLE);
     engine->RegisterGlobalProperty("const int QUAL_SHIFT", (void*)&QUAL_SHIFT);
     engine->RegisterGlobalProperty("const int QUAL_CTRL", (void*)&QUAL_CTRL);
-    engine->RegisterGlobalProperty("const int KEY_BACK", (void*)&KEY_BACK);
+    engine->RegisterGlobalProperty("const int QUAL_ALT", (void*)&QUAL_ALT);
+    engine->RegisterGlobalProperty("const int KEY_BACKSPACE", (void*)&KEY_BACKSPACE);
     engine->RegisterGlobalProperty("const int KEY_TAB", (void*)&KEY_TAB);
-    engine->RegisterGlobalProperty("const int KEY_CLEAR", (void*)&KEY_CLEAR);
     engine->RegisterGlobalProperty("const int KEY_RETURN", (void*)&KEY_RETURN);
     engine->RegisterGlobalProperty("const int KEY_SHIFT", (void*)&KEY_SHIFT);
     engine->RegisterGlobalProperty("const int KEY_CTRL", (void*)&KEY_CTRL);
-    engine->RegisterGlobalProperty("const int KEY_MENU", (void*)&KEY_MENU);
+    engine->RegisterGlobalProperty("const int KEY_ALT", (void*)&KEY_ALT);
     engine->RegisterGlobalProperty("const int KEY_PAUSE", (void*)&KEY_PAUSE);
-    engine->RegisterGlobalProperty("const int KEY_CAPITAL", (void*)&KEY_CAPITAL);
+    engine->RegisterGlobalProperty("const int KEY_CAPSLOCK", (void*)&KEY_CAPSLOCK);
     engine->RegisterGlobalProperty("const int KEY_ESC", (void*)&KEY_ESC);
-    engine->RegisterGlobalProperty("const int KEY_CONVERT", (void*)&KEY_CONVERT);
-    engine->RegisterGlobalProperty("const int KEY_NONCONVERT", (void*)&KEY_NONCONVERT);
-    engine->RegisterGlobalProperty("const int KEY_ACCEPT", (void*)&KEY_ACCEPT);
-    engine->RegisterGlobalProperty("const int KEY_MODECHANGE", (void*)&KEY_MODECHANGE);
     engine->RegisterGlobalProperty("const int KEY_SPACE", (void*)&KEY_SPACE);
     engine->RegisterGlobalProperty("const int KEY_PAGEUP", (void*)&KEY_PAGEUP);
     engine->RegisterGlobalProperty("const int KEY_PAGEDOWN", (void*)&KEY_PAGEDOWN);
@@ -58,17 +54,12 @@ static void RegisterKeyCodes(asIScriptEngine* engine)
     engine->RegisterGlobalProperty("const int KEY_UP", (void*)&KEY_UP);
     engine->RegisterGlobalProperty("const int KEY_RIGHT", (void*)&KEY_RIGHT);
     engine->RegisterGlobalProperty("const int KEY_DOWN", (void*)&KEY_DOWN);
-    engine->RegisterGlobalProperty("const int KEY_SELECT", (void*)&KEY_SELECT);
-    engine->RegisterGlobalProperty("const int KEY_PRINT", (void*)&KEY_PRINT);
-    engine->RegisterGlobalProperty("const int KEY_EXEC", (void*)&KEY_EXEC);
-    engine->RegisterGlobalProperty("const int KEY_SNAPSHOT", (void*)&KEY_SNAPSHOT);
+    engine->RegisterGlobalProperty("const int KEY_PRINTSCREEN", (void*)&KEY_PRINTSCREEN);
     engine->RegisterGlobalProperty("const int KEY_INSERT", (void*)&KEY_INSERT);
     engine->RegisterGlobalProperty("const int KEY_DELETE", (void*)&KEY_DELETE);
-    engine->RegisterGlobalProperty("const int KEY_HELP", (void*)&KEY_HELP);
     engine->RegisterGlobalProperty("const int KEY_LWIN", (void*)&KEY_LWIN);
     engine->RegisterGlobalProperty("const int KEY_RWIN", (void*)&KEY_RWIN);
     engine->RegisterGlobalProperty("const int KEY_APPS", (void*)&KEY_APPS);
-    engine->RegisterGlobalProperty("const int KEY_SLEEP", (void*)&KEY_SLEEP);
     engine->RegisterGlobalProperty("const int KEY_NUMPAD0", (void*)&KEY_NUMPAD0);
     engine->RegisterGlobalProperty("const int KEY_NUMPAD1", (void*)&KEY_NUMPAD1);
     engine->RegisterGlobalProperty("const int KEY_NUMPAD2", (void*)&KEY_NUMPAD2);
@@ -81,7 +72,6 @@ static void RegisterKeyCodes(asIScriptEngine* engine)
     engine->RegisterGlobalProperty("const int KEY_NUMPAD9", (void*)&KEY_NUMPAD9);
     engine->RegisterGlobalProperty("const int KEY_MULTIPLY", (void*)&KEY_MULTIPLY);
     engine->RegisterGlobalProperty("const int KEY_ADD", (void*)&KEY_ADD);
-    engine->RegisterGlobalProperty("const int KEY_SEPARATOR", (void*)&KEY_SEPARATOR);
     engine->RegisterGlobalProperty("const int KEY_SUBTRACT", (void*)&KEY_SUBTRACT);
     engine->RegisterGlobalProperty("const int KEY_DECIMAL", (void*)&KEY_DECIMAL);
     engine->RegisterGlobalProperty("const int KEY_DIVIDE", (void*)&KEY_DIVIDE);
@@ -110,31 +100,13 @@ static void RegisterKeyCodes(asIScriptEngine* engine)
     engine->RegisterGlobalProperty("const int KEY_F23", (void*)&KEY_F23);
     engine->RegisterGlobalProperty("const int KEY_F24", (void*)&KEY_F24);
     engine->RegisterGlobalProperty("const int KEY_NUMLOCK", (void*)&KEY_NUMLOCK);
-    engine->RegisterGlobalProperty("const int KEY_SCROLL", (void*)&KEY_SCROLL);
+    engine->RegisterGlobalProperty("const int KEY_SCROLLLOCK", (void*)&KEY_SCROLLLOCK);
     engine->RegisterGlobalProperty("const int KEY_LSHIFT", (void*)&KEY_LSHIFT);
     engine->RegisterGlobalProperty("const int KEY_RSHIFT", (void*)&KEY_RSHIFT);
     engine->RegisterGlobalProperty("const int KEY_LCTRL", (void*)&KEY_LCTRL);
     engine->RegisterGlobalProperty("const int KEY_RCTRL", (void*)&KEY_RCTRL);
-    engine->RegisterGlobalProperty("const int KEY_LMENU", (void*)&KEY_LMENU);
-    engine->RegisterGlobalProperty("const int KEY_RMENU", (void*)&KEY_RMENU);
-    engine->RegisterGlobalProperty("const int KEY_BROWSER_BACK", (void*)&KEY_BROWSER_BACK);
-    engine->RegisterGlobalProperty("const int KEY_BROWSER_FORWARD", (void*)&KEY_BROWSER_FORWARD);
-    engine->RegisterGlobalProperty("const int KEY_BROWSER_REFRESH", (void*)&KEY_BROWSER_REFRESH);
-    engine->RegisterGlobalProperty("const int KEY_BROWSER_STOP", (void*)&KEY_BROWSER_STOP);
-    engine->RegisterGlobalProperty("const int KEY_BROWSER_SEARCH", (void*)&KEY_BROWSER_SEARCH);
-    engine->RegisterGlobalProperty("const int KEY_BROWSER_FAVORITES", (void*)&KEY_BROWSER_FAVORITES);
-    engine->RegisterGlobalProperty("const int KEY_BROWSER_HOME", (void*)&KEY_BROWSER_HOME);
-    engine->RegisterGlobalProperty("const int KEY_VOLUME_MUTE", (void*)&KEY_VOLUME_MUTE);
-    engine->RegisterGlobalProperty("const int KEY_VOLUME_DOWN", (void*)&KEY_VOLUME_DOWN);
-    engine->RegisterGlobalProperty("const int KEY_VOLUME_UP", (void*)&KEY_VOLUME_UP);
-    engine->RegisterGlobalProperty("const int KEY_MEDIA_NEXT_TRACK", (void*)&KEY_MEDIA_NEXT_TRACK);
-    engine->RegisterGlobalProperty("const int KEY_MEDIA_PREV_TRACK", (void*)&KEY_MEDIA_PREV_TRACK);
-    engine->RegisterGlobalProperty("const int KEY_MEDIA_STOP", (void*)&KEY_MEDIA_STOP);
-    engine->RegisterGlobalProperty("const int KEY_MEDIA_PLAY_PAUSE", (void*)&KEY_MEDIA_PLAY_PAUSE);
-    engine->RegisterGlobalProperty("const int KEY_LAUNCH_MAIL", (void*)&KEY_LAUNCH_MAIL);
-    engine->RegisterGlobalProperty("const int KEY_LAUNCH_MEDIA_SELECT", (void*)&KEY_LAUNCH_MEDIA_SELECT);
-    engine->RegisterGlobalProperty("const int KEY_LAUNCH_APP1", (void*)&KEY_LAUNCH_APP1);
-    engine->RegisterGlobalProperty("const int KEY_LAUNCH_APP2", (void*)&KEY_LAUNCH_APP2);
+    engine->RegisterGlobalProperty("const int KEY_LALT", (void*)&KEY_LALT);
+    engine->RegisterGlobalProperty("const int KEY_RALT", (void*)&KEY_RALT);
     engine->RegisterGlobalProperty("const int KEY_OEM_1", (void*)&KEY_OEM_1);
     engine->RegisterGlobalProperty("const int KEY_OEM_PLUS", (void*)&KEY_OEM_PLUS);
     engine->RegisterGlobalProperty("const int KEY_OEM_COMMA", (void*)&KEY_OEM_COMMA);

+ 6 - 0
Engine/Input/Input.cpp

@@ -182,6 +182,8 @@ bool Input::GetQualifierDown(int qualifier) const
         return keyDown_[KEY_SHIFT] != 0;
     if (qualifier == QUAL_CTRL)
         return keyDown_[KEY_CTRL] != 0;
+    if (qualifier == QUAL_ALT)
+        return keyDown_[KEY_ALT] != 0;
     return false;
 }
 
@@ -191,6 +193,8 @@ bool Input::GetQualifierPress(int qualifier) const
         return keyPress_[KEY_SHIFT] != 0;
     if (qualifier == QUAL_CTRL)
         return keyPress_[KEY_CTRL] != 0;
+    if (qualifier == QUAL_ALT)
+        return keyPress_[KEY_ALT] != 0;
     return false;
 }
 
@@ -201,6 +205,8 @@ int Input::GetQualifiers() const
         ret |= QUAL_SHIFT;
     if (keyDown_[KEY_CTRL] != 0)
         ret |= QUAL_CTRL;
+    if (keyDown_[KEY_ALT] != 0)
+        ret |= QUAL_ALT;
     return ret;
 }
 

+ 8 - 35
Engine/Input/InputEvents.h

@@ -102,21 +102,17 @@ static const int MOUSEB_MIDDLE = 4;
 
 static const int QUAL_SHIFT = 1;
 static const int QUAL_CTRL = 2;
+static const int QUAL_ALT = 4;
 
-static const int KEY_BACK = 0x08;
+static const int KEY_BACKSPACE = 0x08;
 static const int KEY_TAB = 0x09;
-static const int KEY_CLEAR = 0x0c; 
 static const int KEY_RETURN = 0x0d;
 static const int KEY_SHIFT = 0x10;
 static const int KEY_CTRL = 0x11;
-static const int KEY_MENU = 0x12;
+static const int KEY_ALT = 0x12;
 static const int KEY_PAUSE = 0x13;
-static const int KEY_CAPITAL = 0x14;
+static const int KEY_CAPSLOCK = 0x14;
 static const int KEY_ESC = 0x1b;
-static const int KEY_CONVERT = 0x1c;
-static const int KEY_NONCONVERT = 0x1d;
-static const int KEY_ACCEPT = 0x1e;
-static const int KEY_MODECHANGE = 0x1f;
 static const int KEY_SPACE = 0x20;
 static const int KEY_PAGEUP = 0x21;
 static const int KEY_PAGEDOWN = 0x22;
@@ -127,16 +123,12 @@ static const int KEY_UP = 0x26;
 static const int KEY_RIGHT = 0x27;
 static const int KEY_DOWN = 0x28;
 static const int KEY_SELECT = 0x29;
-static const int KEY_PRINT = 0x2a;
-static const int KEY_EXEC = 0x2b;
-static const int KEY_SNAPSHOT = 0x2c;
+static const int KEY_PRINTSCREEN = 0x2c;
 static const int KEY_INSERT = 0x2d;
 static const int KEY_DELETE = 0x2e;
-static const int KEY_HELP = 0x2f;
 static const int KEY_LWIN = 0x5b;
 static const int KEY_RWIN = 0x5c;
 static const int KEY_APPS = 0x5d;
-static const int KEY_SLEEP = 0x5f;
 static const int KEY_NUMPAD0 = 0x60;
 static const int KEY_NUMPAD1 = 0x61;
 static const int KEY_NUMPAD2 = 0x62;
@@ -149,7 +141,6 @@ static const int KEY_NUMPAD8 = 0x68;
 static const int KEY_NUMPAD9 = 0x69;
 static const int KEY_MULTIPLY = 0x6a;
 static const int KEY_ADD = 0x6b;
-static const int KEY_SEPARATOR = 0x6c;
 static const int KEY_SUBTRACT = 0x6d;
 static const int KEY_DECIMAL = 0x6e;
 static const int KEY_DIVIDE = 0x6f;
@@ -178,31 +169,13 @@ static const int KEY_F22 = 0x85;
 static const int KEY_F23 = 0x86;
 static const int KEY_F24 = 0x87;
 static const int KEY_NUMLOCK = 0x90;
-static const int KEY_SCROLL = 0x91;
+static const int KEY_SCROLLLOCK = 0x91;
 static const int KEY_LSHIFT = 0xa0;
 static const int KEY_RSHIFT = 0xa1;
 static const int KEY_LCTRL = 0xa2;
 static const int KEY_RCTRL = 0xa3;
-static const int KEY_LMENU = 0xa4;
-static const int KEY_RMENU = 0xa5;
-static const int KEY_BROWSER_BACK = 0xa6;
-static const int KEY_BROWSER_FORWARD = 0xa7;
-static const int KEY_BROWSER_REFRESH = 0xa8;
-static const int KEY_BROWSER_STOP = 0xa9;
-static const int KEY_BROWSER_SEARCH = 0xaa;
-static const int KEY_BROWSER_FAVORITES = 0xab;
-static const int KEY_BROWSER_HOME = 0xac;
-static const int KEY_VOLUME_MUTE = 0xad;
-static const int KEY_VOLUME_DOWN = 0xae;
-static const int KEY_VOLUME_UP = 0xaf;
-static const int KEY_MEDIA_NEXT_TRACK = 0xb0;
-static const int KEY_MEDIA_PREV_TRACK = 0xb1;
-static const int KEY_MEDIA_STOP = 0xb2;
-static const int KEY_MEDIA_PLAY_PAUSE = 0xb3;
-static const int KEY_LAUNCH_MAIL = 0xb4;
-static const int KEY_LAUNCH_MEDIA_SELECT = 0xb5;
-static const int KEY_LAUNCH_APP1 = 0xb6;
-static const int KEY_LAUNCH_APP2 = 0xb7;
+static const int KEY_LALT = 0xa4;
+static const int KEY_RALT = 0xa5;
 static const int KEY_OEM_1 = 0xba;
 static const int KEY_OEM_PLUS = 0xbb;
 static const int KEY_OEM_COMMA = 0xbc;

+ 2 - 1
Engine/UI/LineEdit.cpp

@@ -347,7 +347,8 @@ void LineEdit::OnChar(unsigned char c, int buttons, int qualifiers)
 {
     bool changed = false;
     
-    if (qualifiers & QUAL_CTRL)
+    // If only CTRL is held down, do not edit
+    if ((qualifiers & (QUAL_CTRL | QUAL_ALT)) == QUAL_CTRL)
         return;
     
     if (c == '\b')