From a72863112b34527f4b7ee1ce2833eb84456b0f6e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Oct 2019 17:50:08 +0100 Subject: [PATCH] - fix compilation --- source/blood/src/controls.cpp | 5 --- source/common/gamecontrol.cpp | 82 ++++++++++++++++++++--------------- source/common/inputstate.h | 3 +- source/duke3d/src/game.cpp | 6 --- source/mact/include/control.h | 1 - source/mact/src/control.cpp | 16 +------ source/rr/src/game.cpp | 6 --- source/sw/src/game.cpp | 2 - source/sw/src/setup.cpp | 13 ------ 9 files changed, 50 insertions(+), 84 deletions(-) diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index a3d9b0d0d..41e4a8bef 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -70,11 +70,6 @@ int32_t GetTime(void) void ctrlInit(void) { - KB_ClearKeysDown(); - KB_FlushKeyboardQueue(); - KB_FlushKeyboardQueueScans(); - CONFIG_SetupMouse(); - CONFIG_SetupJoystick(); } void ctrlTerm(void) diff --git a/source/common/gamecontrol.cpp b/source/common/gamecontrol.cpp index 161e4800b..0e4df516f 100644 --- a/source/common/gamecontrol.cpp +++ b/source/common/gamecontrol.cpp @@ -10,6 +10,8 @@ #include "gamecvars.h" #include "build.h" #include "inputstate.h" +#include "_control.h" +#include "control.h" InputState inputState; @@ -343,41 +345,6 @@ void CONFIG_SetDefaultKeys(const char *defbinds, bool lazy/*=false*/) } } -// FIXME: Consider the mouse as well! -FString CONFIG_GetBoundKeyForLastInput(int gameFunc) -{ - if (CONTROL_LastSeenInput == LastSeenInput::Joystick) - { - char const * joyname = CONFIG_GetGameFuncOnJoystick(gameFunc); - if (joyname != nullptr && joyname[0] != '\0') - { - return joyname; - } - - char const * keyname = CONFIG_GetGameFuncOnKeyboard(gameFunc); - if (keyname != nullptr && keyname[0] != '\0') - { - return keyname; - } - } - else - { - char const * keyname = CONFIG_GetGameFuncOnKeyboard(gameFunc); - if (keyname != nullptr && keyname[0] != '\0') - { - return keyname; - } - - char const * joyname = CONFIG_GetGameFuncOnJoystick(gameFunc); - if (joyname != nullptr && joyname[0] != '\0') - { - return joyname; - } - - return "UNBOUND"; - } - -} //========================================================================== // // @@ -1007,8 +974,47 @@ char const* CONFIG_GetGameFuncOnJoystick(int gameFunc) for (int i = 0; i < joystick.numAxes; ++i) for (int j = 0; j < 2; ++j) if (JoystickDigitalFunctions[i][j] == gameFunc) + return joyGetName(0, i); + + return ""; +} + +// FIXME: Consider the mouse as well! +FString CONFIG_GetBoundKeyForLastInput(int gameFunc) +{ + if (CONTROL_LastSeenInput == LastSeenInput::Joystick) + { + char const* joyname = CONFIG_GetGameFuncOnJoystick(gameFunc); + if (joyname != nullptr && joyname[0] != '\0') + { + return joyname; + } + + char const* keyname = CONFIG_GetGameFuncOnKeyboard(gameFunc); + if (keyname != nullptr && keyname[0] != '\0') + { + return keyname; + } + } + else + { + char const* keyname = CONFIG_GetGameFuncOnKeyboard(gameFunc); + if (keyname != nullptr && keyname[0] != '\0') + { + return keyname; + } + + char const* joyname = CONFIG_GetGameFuncOnJoystick(gameFunc); + if (joyname != nullptr && joyname[0] != '\0') + { + return joyname; + } + + return "UNBOUND"; + } + +} - void CONFIG_InitMouseAndController() { @@ -1041,8 +1047,12 @@ void CONFIG_InitMouseAndController() } CONFIG_SetupMouse(); CONFIG_SetupJoystick(); + KB_ClearKeysDown(); + KB_FlushKeyboardQueue(); + KB_FlushKeyboardQueueScans(); } + void CONFIG_PutNumber(const char* key, int number) { FStringf str("%d", number); diff --git a/source/common/inputstate.h b/source/common/inputstate.h index d7076adb5..4ef2bfe13 100644 --- a/source/common/inputstate.h +++ b/source/common/inputstate.h @@ -27,6 +27,7 @@ enum }; extern consolekeybind_t CONTROL_KeyBinds[NUMKEYS + MAXMOUSEBUTTONS]; +extern int32_t CONTROL_ButtonFlags[NUMKEYS]; extern bool CONTROL_BindsEnabled; // Order is that of EDuke32 by necessity because it exposes the key binds to scripting by index instead of by name. @@ -130,7 +131,7 @@ class InputState struct ButtonStateFlags { bool ButtonActive; // Button currently reports being active to the client - bool ButtonCleared;, // Button has been cleared by the client, i.e. do not set to active until no input for this button is active anymore. + bool ButtonCleared; // Button has been cleared by the client, i.e. do not set to active until no input for this button is active anymore. }; ButtonStateFlags ButtonState[NUMGAMEFUNCTIONS]; diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index c3d683a51..dac3af288 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -6482,12 +6482,6 @@ int app_main(int argc, const char * const*argv) OSD_SetParameters(0, 0, 0, 12, 2, 12, OSD_ERROR, OSDTEXT_RED, 0); registerosdcommands(); - if (g_networkMode != NET_DEDICATED_SERVER) - { - CONFIG_SetupMouse(); - CONFIG_SetupJoystick(); - } - #ifdef HAVE_CLIPSHAPE_FEATURE int const clipMapError = engineLoadClipMaps(); if (clipMapError > 0) diff --git a/source/mact/include/control.h b/source/mact/include/control.h index 35de5766a..51578d0a9 100644 --- a/source/mact/include/control.h +++ b/source/mact/include/control.h @@ -181,7 +181,6 @@ int CONTROL_FlagActive( int which ); void CONTROL_ClearAssignments( void ); // void CONTROL_GetFunctionInput( void ); void CONTROL_GetInput( ControlInfo *info ); -void CONTROL_ClearButton( int whichbutton ); extern float CONTROL_MouseSensitivity; bool CONTROL_Startup(controltype which, int32_t ( *TimeFunction )( void ), int32_t ticspersecond); void CONTROL_Shutdown( void ); diff --git a/source/mact/src/control.cpp b/source/mact/src/control.cpp index 32c82263a..8735a7b4c 100644 --- a/source/mact/src/control.cpp +++ b/source/mact/src/control.cpp @@ -59,12 +59,12 @@ static int32_t(*ExtGetTime)(void); //static int32_t ticrate; static uint8_t CONTROL_DoubleClickSpeed; -int32_t CONTROL_ButtonFlags[CONTROL_NUM_FLAGS]; +int32_t CONTROL_ButtonFlags[NUMKEYS]; consolekeybind_t CONTROL_KeyBinds[NUMKEYS + MAXMOUSEBUTTONS]; bool CONTROL_BindsEnabled = 0; bool CONTROL_SmoothMouse = 0; -#define CONTROL_CheckRange(which) ((unsigned)which >= (unsigned)CONTROL_NUM_FLAGS) +#define CONTROL_CheckRange(which) ((unsigned)which >= (unsigned)NUMKEYS) #define BIND(x, s, r, k) do { Xfree(x.cmdstr); x.cmdstr = s; x.repeat = r; x.key = k; } while (0) void CONTROL_ClearAllBinds(void) @@ -615,18 +615,6 @@ static void CONTROL_ButtonFunctionState(int32_t *p1) } } -void CONTROL_ClearButton(int whichbutton) -{ - if (CONTROL_CheckRange(whichbutton)) return; - -#ifdef __ANDROID__ - CONTROL_Android_ClearButton(whichbutton); -#endif - - inputState.ClearButton(whichbutton); - CONTROL_Flags[whichbutton].cleared = TRUE; -} - int32_t CONTROL_GetGameControllerDigitalAxisPos(int32_t axis) { if (!joystick.isGameController) diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index 01de286f5..ae39f9454 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -7865,12 +7865,6 @@ int app_main(int argc, char const * const * argv) OSD_SetParameters(0, 0, 0, 12, 2, 12, OSD_ERROR, OSDTEXT_RED, 0); registerosdcommands(); - //if (g_networkMode != NET_DEDICATED_SERVER) - { - CONFIG_SetupMouse(); - CONFIG_SetupJoystick(); - } - #ifdef HAVE_CLIPSHAPE_FEATURE int const clipMapError = engineLoadClipMaps(); if (clipMapError > 0) diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index f5b8b6784..d91bc72c0 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -888,8 +888,6 @@ InitGame(int32_t argc, char const * const * argv) SW_FatalEngineError(); //initgroupfile(G_GrpFile()); // JBF: moving this close to start of program to detect shareware - InitSetup(); - InitAutoNet(); timerInit(120); diff --git a/source/sw/src/setup.cpp b/source/sw/src/setup.cpp index 0d727820b..8177426ba 100644 --- a/source/sw/src/setup.cpp +++ b/source/sw/src/setup.cpp @@ -85,18 +85,5 @@ int32_t GetTime(void) //return timert++; } -void InitSetup(void) -{ - CONFIG_SetupMouse(); - CONFIG_SetupJoystick(); -} - -#if 0 -void TermSetup(void) -{ - //FreeKeyDefList(); -} -#endif - END_SW_NS