mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-21 12:01:05 +00:00
Also use KeyDown for gamepads, add player argument
This commit is contained in:
parent
be3e7e7edf
commit
92b5e32127
2 changed files with 13 additions and 14 deletions
21
src/g_game.c
21
src/g_game.c
|
@ -2302,21 +2302,16 @@ boolean G_LuaResponder(event_t *ev)
|
|||
{
|
||||
boolean cancelled = false;
|
||||
|
||||
if (ev->type == ev_keydown)
|
||||
switch (ev->type)
|
||||
{
|
||||
cancelled = LUA_HookKey(ev, HOOK(KeyDown));
|
||||
LUA_InvalidateUserdata(ev);
|
||||
case ev_keydown: cancelled = LUA_HookKey(ev, HOOK(KeyDown)); break;
|
||||
case ev_keyup: cancelled = LUA_HookKey(ev, HOOK(KeyUp)); break;
|
||||
case ev_gamepad_down: cancelled = LUA_HookGamepadButton(ev, HOOK(GamepadButtonDown)) | LUA_HookKey(ev, HOOK(KeyDown)); break;
|
||||
case ev_gamepad_up: cancelled = LUA_HookGamepadButton(ev, HOOK(GamepadButtonUp)) | LUA_HookKey(ev, HOOK(KeyUp)); break;
|
||||
default: break;
|
||||
}
|
||||
else if (ev->type == ev_keyup)
|
||||
{
|
||||
cancelled = LUA_HookKey(ev, HOOK(KeyUp));
|
||||
LUA_InvalidateUserdata(ev);
|
||||
}
|
||||
else if (ev->type == ev_gamepad_down)
|
||||
cancelled = LUA_HookGamepadButton(ev, HOOK(GamepadButtonDown));
|
||||
else if (ev->type == ev_gamepad_up)
|
||||
cancelled = LUA_HookGamepadButton(ev, HOOK(GamepadButtonUp));
|
||||
|
||||
|
||||
LUA_InvalidateUserdata(ev);
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
|
|
|
@ -169,9 +169,13 @@ static luaL_Reg lib[] = {
|
|||
static int lib_getGameKeyDown(lua_State *L)
|
||||
{
|
||||
int i = luaL_checkinteger(L, 2);
|
||||
int p = luaL_optinteger(L, 3, 0);
|
||||
if (i < 0 || i >= NUMINPUTS)
|
||||
return luaL_error(L, "Key index %d out of range (0 - %d)", i, NUMINPUTS-1);
|
||||
lua_pushboolean(L, G_CheckKeyDown(0, i, false) || G_CheckKeyDown(1, i, false));
|
||||
if (p > 0)
|
||||
lua_pushboolean(L, G_CheckKeyDown(p-1, i, false));
|
||||
else
|
||||
lua_pushboolean(L, G_CheckKeyDown(0, i, false) | G_CheckKeyDown(1, i, false));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue