Remove key stuff

This commit is contained in:
SwitchKaze 2021-03-25 22:21:53 -05:00
parent eb2dc9e99b
commit cb3a8f7a58
10 changed files with 15 additions and 207 deletions

View file

@ -221,7 +221,7 @@ static void CONS_Bind_f(void)
for (key = 0; key < NUMINPUTS; key++)
if (bindtable[key])
{
CONS_Printf("%s : \"%s\"\n", G_KeyNumToString(key), bindtable[key]);
CONS_Printf("%s : \"%s\"\n", G_KeynumToString(key), bindtable[key]);
na = 1;
}
if (!na)
@ -229,7 +229,7 @@ static void CONS_Bind_f(void)
return;
}
key = G_KeyStringToNum(COM_Argv(1));
key = G_KeyStringtoNum(COM_Argv(1));
if (key <= 0 || key >= NUMINPUTS)
{
CONS_Alert(CONS_NOTICE, M_GetText("Invalid key name\n"));

View file

@ -183,8 +183,6 @@ void D_ProcessEvents(void)
for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1))
{
boolean hooked = false;
ev = &events[eventtail];
// Set mouse buttons early in case event is eaten later
@ -232,12 +230,6 @@ void D_ProcessEvents(void)
continue;
}
if (!CON_Ready() && !menuactive) {
if (G_LuaResponder(ev))
continue;
hooked = true;
}
// Menu input
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
@ -252,12 +244,6 @@ void D_ProcessEvents(void)
if (eaten)
continue; // menu ate the event
if (!hooked && !CON_Ready()) {
if (G_LuaResponder(ev))
continue;
hooked = true;
}
// console input
#ifdef HAVE_THREADS
I_lock_mutex(&con_mutex);
@ -272,9 +258,6 @@ void D_ProcessEvents(void)
if (eaten)
continue; // ate the event
if (!hooked && G_LuaResponder(ev))
continue;
G_Responder(ev);
}

View file

@ -24,7 +24,6 @@
#include "g_state.h" // gamestate_t (for lua)
#include "g_game.h" // Joystick axes (for lua)
#include "i_joy.h"
#include "g_input.h" // Game controls (for lua)
#include "deh_tables.h"
@ -5471,51 +5470,6 @@ struct int_const_s const INT_CONST[] = {
{"JA_FIRENORMAL",JA_FIRENORMAL},
{"JOYAXISRANGE",JOYAXISRANGE},
// Game controls
{"gc_null",gc_null},
{"gc_forward",gc_forward},
{"gc_backward",gc_backward},
{"gc_strafeleft",gc_strafeleft},
{"gc_straferight",gc_straferight},
{"gc_turnleft",gc_turnleft},
{"gc_turnright",gc_turnright},
{"gc_weaponnext",gc_weaponnext},
{"gc_weaponprev",gc_weaponprev},
{"gc_wepslot1",gc_wepslot1},
{"gc_wepslot2",gc_wepslot2},
{"gc_wepslot3",gc_wepslot3},
{"gc_wepslot4",gc_wepslot4},
{"gc_wepslot5",gc_wepslot5},
{"gc_wepslot6",gc_wepslot6},
{"gc_wepslot7",gc_wepslot7},
{"gc_wepslot8",gc_wepslot8},
{"gc_wepslot9",gc_wepslot9},
{"gc_wepslot10",gc_wepslot10},
{"gc_fire",gc_fire},
{"gc_firenormal",gc_firenormal},
{"gc_tossflag",gc_tossflag},
{"gc_spin",gc_spin},
{"gc_camtoggle",gc_camtoggle},
{"gc_camreset",gc_camreset},
{"gc_lookup",gc_lookup},
{"gc_lookdown",gc_lookdown},
{"gc_centerview",gc_centerview},
{"gc_mouseaiming",gc_mouseaiming},
{"gc_talkkey",gc_talkkey},
{"gc_teamkey",gc_teamkey},
{"gc_scores",gc_scores},
{"gc_jump",gc_jump},
{"gc_console",gc_console},
{"gc_pause",gc_pause},
{"gc_systemmenu",gc_systemmenu},
{"gc_screenshot",gc_screenshot},
{"gc_recordgif",gc_recordgif},
{"gc_viewpoint",gc_viewpoint},
{"gc_custom1",gc_custom1},
{"gc_custom2",gc_custom2},
{"gc_custom3",gc_custom3},
{"num_gamecontrols",num_gamecontrols},
// Mouse buttons
{"MB_BUTTON1",MB_BUTTON1},
{"MB_BUTTON2",MB_BUTTON2},

View file

@ -2183,16 +2183,6 @@ boolean G_Responder(event_t *ev)
return false;
}
//
// G_LuaResponder
// Let Lua handle key events.
//
boolean G_LuaResponder(event_t *ev)
{
return (ev->type == ev_keydown && LUAh_KeyDown(ev->data1)) ||
(ev->type == ev_keyup && LUAh_KeyUp(ev->data1));
}
//
// G_Ticker
// Make ticcmd_ts for the players.

View file

@ -223,7 +223,6 @@ void G_EndGame(void); // moved from y_inter.c/h and renamed
void G_Ticker(boolean run);
boolean G_Responder(event_t *ev);
boolean G_LuaResponder(event_t *ev);
void G_AddPlayer(INT32 playernum);

View file

@ -624,7 +624,7 @@ void G_ClearAllControlKeys(void)
// Returns the name of a key (or virtual key for mouse and joy)
// the input value being an keynum
//
const char *G_KeyNumToString(INT32 keynum)
const char *G_KeynumToString(INT32 keynum)
{
static char keynamestr[8];
@ -648,7 +648,7 @@ const char *G_KeyNumToString(INT32 keynum)
return keynamestr;
}
INT32 G_KeyStringToNum(const char *keystr)
INT32 G_KeyStringtoNum(const char *keystr)
{
UINT32 j;
@ -811,10 +811,10 @@ void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis
for (i = 1; i < num_gamecontrols; i++)
{
fprintf(f, "setcontrol \"%s\" \"%s\"", gamecontrolname[i],
G_KeyNumToString(fromcontrols[i][0]));
G_KeynumToString(fromcontrols[i][0]));
if (fromcontrols[i][1])
fprintf(f, " \"%s\"\n", G_KeyNumToString(fromcontrols[i][1]));
fprintf(f, " \"%s\"\n", G_KeynumToString(fromcontrols[i][1]));
else
fprintf(f, "\n");
}
@ -822,10 +822,10 @@ void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis
for (i = 1; i < num_gamecontrols; i++)
{
fprintf(f, "setcontrol2 \"%s\" \"%s\"", gamecontrolname[i],
G_KeyNumToString(fromcontrolsbis[i][0]));
G_KeynumToString(fromcontrolsbis[i][0]));
if (fromcontrolsbis[i][1])
fprintf(f, " \"%s\"\n", G_KeyNumToString(fromcontrolsbis[i][1]));
fprintf(f, " \"%s\"\n", G_KeynumToString(fromcontrolsbis[i][1]));
else
fprintf(f, "\n");
}
@ -1001,8 +1001,8 @@ static void setcontrol(INT32 (*gc)[2])
CONS_Printf(M_GetText("Control '%s' unknown\n"), namectrl);
return;
}
keynum1 = G_KeyStringToNum(COM_Argv(2));
keynum2 = G_KeyStringToNum(COM_Argv(3));
keynum1 = G_KeyStringtoNum(COM_Argv(2));
keynum2 = G_KeyStringtoNum(COM_Argv(3));
keynum = G_FilterKeyByVersion(numctrl, 0, player, &keynum1, &keynum2, &nestedoverride);
if (keynum >= 0)

View file

@ -181,8 +181,8 @@ extern const INT32 gcl_jump_spin[num_gcl_jump_spin];
void G_MapEventsToControls(event_t *ev);
// returns the name of a key
const char *G_KeyNumToString(INT32 keynum);
INT32 G_KeyStringToNum(const char *keystr);
const char *G_KeynumToString(INT32 keynum);
INT32 G_KeyStringtoNum(const char *keystr);
// detach any keys associated to the given game control
void G_ClearControlKeys(INT32 (*setupcontrols)[2], INT32 control);

View file

@ -13,7 +13,6 @@
#include "fastcmp.h"
#include "g_input.h"
#include "g_game.h"
#include "hu_stuff.h"
#include "i_system.h"
#include "lua_script.h"
@ -23,44 +22,6 @@
// FUNCTIONS //
///////////////
static int lib_gameControlDown(lua_State *L)
{
int i = luaL_checkinteger(L, 1);
if (i < 0 || i >= num_gamecontrols)
return luaL_error(L, "gc_* constant %d out of range (0 - %d)", i, num_gamecontrols-1);
lua_pushinteger(L, PLAYER1INPUTDOWN(i));
return 1;
}
static int lib_gameControl2Down(lua_State *L)
{
int i = luaL_checkinteger(L, 1);
if (i < 0 || i >= num_gamecontrols)
return luaL_error(L, "gc_* constant %d out of range (0 - %d)", i, num_gamecontrols-1);
lua_pushinteger(L, PLAYER2INPUTDOWN(i));
return 1;
}
static int lib_gameControlToKeyNum(lua_State *L)
{
int i = luaL_checkinteger(L, 1);
if (i < 0 || i >= num_gamecontrols)
return luaL_error(L, "gc_* constant %d out of range (0 - %d)", i, num_gamecontrols-1);
lua_pushinteger(L, gamecontrol[i][0]);
lua_pushinteger(L, gamecontrol[i][1]);
return 2;
}
static int lib_gameControl2ToKeyNum(lua_State *L)
{
int i = luaL_checkinteger(L, 1);
if (i < 0 || i >= num_gamecontrols)
return luaL_error(L, "gc_* constant %d out of range (0 - %d)", i, num_gamecontrols-1);
lua_pushinteger(L, gamecontrolbis[i][0]);
lua_pushinteger(L, gamecontrolbis[i][1]);
return 2;
}
static int lib_joyAxis(lua_State *L)
{
int i = luaL_checkinteger(L, 1);
@ -75,35 +36,6 @@ static int lib_joy2Axis(lua_State *L)
return 1;
}
static int lib_keyNumToString(lua_State *L)
{
int i = luaL_checkinteger(L, 1);
lua_pushstring(L, G_KeyNumToString(i));
return 1;
}
static int lib_keyStringToNum(lua_State *L)
{
const char *str = luaL_checkstring(L, 1);
lua_pushinteger(L, G_KeyStringToNum(str));
return 1;
}
static int lib_keyNumPrintable(lua_State *L)
{
int i = luaL_checkinteger(L, 1);
lua_pushboolean(L, i >= 32 && i <= 127);
return 1;
}
static int lib_shiftKeyNum(lua_State *L)
{
int i = luaL_checkinteger(L, 1);
if (i >= 32 && i <= 127)
lua_pushinteger(L, shiftxform[i]);
return 1;
}
static int lib_getMouseGrab(lua_State *L)
{
lua_pushboolean(L, I_GetMouseGrab());
@ -127,51 +59,14 @@ static boolean lib_getCursorPosition(lua_State *L)
}
static luaL_Reg lib[] = {
{"G_GameControlDown", lib_gameControlDown},
{"G_GameControl2Down", lib_gameControl2Down},
{"G_GameControlToKeyNum", lib_gameControlToKeyNum},
{"G_GameControl2ToKeyNum", lib_gameControl2ToKeyNum},
{"G_JoyAxis", lib_joyAxis},
{"G_Joy2Axis", lib_joy2Axis},
{"G_KeyNumToString", lib_keyNumToString},
{"G_KeyStringToNum", lib_keyStringToNum},
{"HU_KeyNumPrintable", lib_keyNumPrintable},
{"HU_ShiftKeyNum", lib_shiftKeyNum},
{"I_GetMouseGrab", lib_getMouseGrab},
{"I_SetMouseGrab", lib_setMouseGrab},
{"I_GetCursorPosition", lib_getCursorPosition},
{NULL, NULL}
};
///////////////////
// gamekeydown[] //
///////////////////
static int lib_getGameKeyDown(lua_State *L)
{
int i = luaL_checkinteger(L, 2);
if (i < 0 || i >= NUMINPUTS)
return luaL_error(L, "gamekeydown[] index %d out of range (0 - %d)", i, NUMINPUTS-1);
lua_pushboolean(L, gamekeydown[i]);
return 1;
}
static int lib_setGameKeyDown(lua_State *L)
{
int i = luaL_checkinteger(L, 2);
boolean j = luaL_checkboolean(L, 3);
if (i < 0 || i >= NUMINPUTS)
return luaL_error(L, "gamekeydown[] index %d out of range (0 - %d)", i, NUMINPUTS-1);
gamekeydown[i] = j;
return 0;
}
static int lib_lenGameKeyDown(lua_State *L)
{
lua_pushinteger(L, NUMINPUTS);
return 1;
}
///////////
// MOUSE //
///////////
@ -214,19 +109,6 @@ static int mouse_num(lua_State *L)
int LUA_InputLib(lua_State *L)
{
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getGameKeyDown);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_setGameKeyDown);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, lib_lenGameKeyDown);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "gamekeydown");
luaL_newmetatable(L, META_MOUSE);
lua_pushcfunction(L, mouse_get);
lua_setfield(L, -2, "__index");

View file

@ -12683,13 +12683,13 @@ static void M_DrawControl(void)
else
{
if (keys[0] != KEY_NULL)
strcat (tmp, G_KeyNumToString (keys[0]));
strcat (tmp, G_KeynumToString (keys[0]));
if (keys[0] != KEY_NULL && keys[1] != KEY_NULL)
strcat(tmp," or ");
if (keys[1] != KEY_NULL)
strcat (tmp, G_KeyNumToString (keys[1]));
strcat (tmp, G_KeynumToString (keys[1]));
}