From aa108be3df13e09c7800f61f5d50a4d9dc12ea1e Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sun, 31 Jan 2016 21:39:39 -0500 Subject: [PATCH] Pass in actual character sdl saw into keypress functions Previously you couldn't detect what shift+somekey would do on alternate keyboard layours. --- src/lua/LegacyLuaAPI.cpp | 4 ++-- src/lua/LuaScriptHelper.h | 2 +- src/lua/LuaScriptInterface.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lua/LegacyLuaAPI.cpp b/src/lua/LegacyLuaAPI.cpp index 6f0571884..ae7bcca40 100644 --- a/src/lua/LegacyLuaAPI.cpp +++ b/src/lua/LegacyLuaAPI.cpp @@ -438,7 +438,7 @@ int luacon_elementwrite(lua_State* l) } bool shortcuts = true; -int luacon_keyevent(int key, int modifier, int event) +int luacon_keyevent(int key, Uint16 character, int modifier, int event) { int kycontinue = 1; lua_State* l=luacon_ci->l; @@ -456,7 +456,7 @@ int luacon_keyevent(int key, int modifier, int event) for (int i = 1; i <= len && kycontinue; i++) { lua_rawgeti(l, -1, i); - lua_pushlstring(l, (const char*)&key, 1); + lua_pushlstring(l, (const char*)&character, 1); lua_pushinteger(l, key); lua_pushinteger(l, modifier); lua_pushinteger(l, event); diff --git a/src/lua/LuaScriptHelper.h b/src/lua/LuaScriptHelper.h index 13cf1333d..85ab02c91 100644 --- a/src/lua/LuaScriptHelper.h +++ b/src/lua/LuaScriptHelper.h @@ -23,7 +23,7 @@ extern int tptParts, tptPartsMeta, tptElementTransitions, tptPartsCData, tptPart void luacon_hook(lua_State *L, lua_Debug *ar); int luacon_step(int mx, int my); int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel); -int luacon_keyevent(int key, int modifier, int event); +int luacon_keyevent(int key, Uint16 character, int modifier, int event); int luacon_eval(const char *command); const char *luacon_geterror(); void luacon_close(); diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp index 8ca916f6f..8898fea8e 100644 --- a/src/lua/LuaScriptInterface.cpp +++ b/src/lua/LuaScriptInterface.cpp @@ -3305,7 +3305,7 @@ bool LuaScriptInterface::OnMouseWheel(int x, int y, int d) bool LuaScriptInterface::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) { - return luacon_keyevent(key, GetModifiers(), LUACON_KDOWN); + return luacon_keyevent(key, character, GetModifiers(), LUACON_KDOWN); } bool LuaScriptInterface::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt) @@ -3317,7 +3317,7 @@ bool LuaScriptInterface::OnKeyRelease(int key, Uint16 character, bool shift, boo modifiers |= 0x040; if(alt) modifiers |= 0x100; - return luacon_keyevent(key, modifiers, LUACON_KUP); + return luacon_keyevent(key, character, modifiers, LUACON_KUP); } bool LuaScriptInterface::OnMouseTick()