Skip to content

Commit

Permalink
Pass in actual character sdl saw into keypress functions
Browse files Browse the repository at this point in the history
Previously you couldn't detect what shift+somekey would do on alternate keyboard layours.
  • Loading branch information
jacob1 committed Feb 1, 2016
1 parent 435edb2 commit aa108be
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/lua/LegacyLuaAPI.cpp
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/lua/LuaScriptHelper.h
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/lua/LuaScriptInterface.cpp
Expand Up @@ -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)
Expand All @@ -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()
Expand Down

0 comments on commit aa108be

Please sign in to comment.