From d23b4a7e33d224a2189461d85f19cf506f1da49c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 14 Dec 2019 20:15:15 +0100 Subject: [PATCH] - hooked up ZDoom' joystick code and removed the remaining parts of the old MACT input library. --- source/CMakeLists.txt | 14 +- source/blood/CMakeLists.txt | 2 +- source/blood/src/blood.cpp | 1 - source/blood/src/config.h | 3 - source/blood/src/controls.cpp | 12 +- source/blood/src/credits.cpp | 1 - source/blood/src/d_menu.cpp | 1 - source/blood/src/demo.cpp | 2 - source/blood/src/gamemenu.cpp | 1 - source/blood/src/messages.cpp | 2 - source/blood/src/osdcmd.cpp | 2 - source/{mact/src => common}/animlib.cpp | 0 source/{mact/include => common}/animlib.h | 0 source/common/console/c_con.cpp | 3 +- source/common/gameconfigfile.cpp | 7 - source/common/gamecontrol.cpp | 41 +- source/common/gamecontrol.h | 3 - source/common/gamecvars.cpp | 10 +- source/common/input/i_input.cpp | 9 - source/{mact/src => common/input}/input.cpp | 25 +- source/{mact/include => common/input}/input.h | 0 source/common/inputstate.h | 37 +- source/duke3d/CMakeLists.txt | 2 +- source/duke3d/src/anim.cpp | 1 - source/duke3d/src/duke3d.h | 2 - source/duke3d/src/game.cpp | 1 - source/duke3d/src/gamestructures.cpp | 2 +- source/mact/gpl-2.0.txt | 339 --------------- source/mact/include/_control.h | 173 -------- source/mact/include/control.h | 169 -------- source/mact/include/joystick.h | 31 -- source/mact/include/mouse.h | 0 source/mact/src/control.cpp | 393 ------------------ source/mact/src/joystick.cpp | 128 ------ source/platform/win32/startwin.game.cpp | 3 - source/rr/CMakeLists.txt | 2 +- source/rr/src/anim.cpp | 1 - source/rr/src/duke3d.h | 2 - source/rr/src/game.cpp | 1 - source/sw/CMakeLists.txt | 2 +- source/sw/src/anim.cpp | 2 - source/sw/src/cheats.cpp | 1 - source/sw/src/config.cpp | 2 - source/sw/src/config.h | 2 - source/sw/src/console.cpp | 1 - source/sw/src/d_menu.cpp | 2 - source/sw/src/demo.cpp | 1 - source/sw/src/draw.cpp | 1 - source/sw/src/game.cpp | 2 - source/sw/src/game.h | 1 - source/sw/src/jplayer.cpp | 1 - source/sw/src/menus.cpp | 1 - source/sw/src/player.cpp | 1 - source/sw/src/predict.cpp | 7 - source/sw/src/setup.cpp | 2 - 55 files changed, 79 insertions(+), 1376 deletions(-) rename source/{mact/src => common}/animlib.cpp (100%) rename source/{mact/include => common}/animlib.h (100%) rename source/{mact/src => common/input}/input.cpp (84%) rename source/{mact/include => common/input}/input.h (100%) delete mode 100644 source/mact/gpl-2.0.txt delete mode 100644 source/mact/include/_control.h delete mode 100644 source/mact/include/control.h delete mode 100644 source/mact/include/joystick.h delete mode 100644 source/mact/include/mouse.h delete mode 100644 source/mact/src/control.cpp delete mode 100644 source/mact/src/joystick.cpp diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index e35304eab..9f971e4de 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -614,8 +614,6 @@ file( GLOB HEADER_FILES libsmackerdec/include/*.h libxmp-lite/include/libxmp-lite/*.h libxmp-lite/src/*.h - mact/include/*.h - mact/src/*.h common/*.h common/2d/*.h common/fonts/*.h @@ -691,11 +689,6 @@ set (PCH_SOURCES glbackend/gl_buffers.cpp glbackend/hw_draw2d.cpp - mact/src/animlib.cpp - mact/src/control.cpp - mact/src/joystick.cpp - mact/src/input.cpp - thirdparty/src/base64.cpp thirdparty/src/sjson.cpp thirdparty/src/fix16.cpp @@ -739,6 +732,7 @@ set (PCH_SOURCES build/src/timer.cpp build/src/voxmodel.cpp + common/animlib.cpp common/rts.cpp common/gameconfigfile.cpp common/gamecvars.cpp @@ -842,6 +836,7 @@ set (PCH_SOURCES common/input/i_joystick.cpp common/input/i_input.cpp common/input/m_joy.cpp + common/input/input.cpp ) if( MSVC ) @@ -888,7 +883,6 @@ target_link_libraries( demolition ${DEMOLITION_LIBS} gdtoa lzma duke3d blood rr include_directories( ${CMAKE_CURRENT_SOURCE_DIR} build/include - mact/include audiolib/include glad/include libxmp-lite/include @@ -906,6 +900,7 @@ include_directories( common/music common/dobject common/menu + common/input platform ${CMAKE_BINARY_DIR}/libraries/gdtoa @@ -1029,9 +1024,6 @@ source_group("Utility\\Smackerdec\\Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT source_group("Utility\\XMP-Lite" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/libxmp-lite/.+") source_group("Utility\\XMP-Lite Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/libxmp-lite/include/libxmp-lite/.+") source_group("Utility\\XMP-Lite Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/libxmp-lite/src/.+") -source_group("Utility\\Mact" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/mact/.+") -source_group("Utility\\Mact Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/mact/include/.+") -source_group("Utility\\Mact Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/mact/src/.+") source_group("Utility\\Third Party" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/.+") source_group("Utility\\Third Party Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/include/.+") source_group("Utility\\Third Party Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/src/.+") diff --git a/source/blood/CMakeLists.txt b/source/blood/CMakeLists.txt index 564c2a255..595335204 100644 --- a/source/blood/CMakeLists.txt +++ b/source/blood/CMakeLists.txt @@ -14,7 +14,6 @@ endif() include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../build/include - ${CMAKE_CURRENT_SOURCE_DIR}/../mact/include ${CMAKE_CURRENT_SOURCE_DIR}/../audiolib/include ${CMAKE_CURRENT_SOURCE_DIR}/../libsmackerdec/include ${CMAKE_CURRENT_SOURCE_DIR}/../thirdparty/include @@ -25,6 +24,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../common/fonts ${CMAKE_CURRENT_SOURCE_DIR}/../common/2d ${CMAKE_CURRENT_SOURCE_DIR}/../common/music + ${CMAKE_CURRENT_SOURCE_DIR}/../common/input ${CMAKE_CURRENT_SOURCE_DIR}/../platform ) diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 2bb26e7c9..86a115d73 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -175,7 +175,6 @@ void ShutDown(void) sndTerm(); sfxTerm(); scrUnInit(); - CONTROL_Shutdown(); // PORT_TODO: Check argument if (syncstate) printf("A packet was lost! (syncstate)\n"); diff --git a/source/blood/src/config.h b/source/blood/src/config.h index da8cf0efd..41758f109 100644 --- a/source/blood/src/config.h +++ b/source/blood/src/config.h @@ -24,9 +24,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef config_public_h_ #define config_public_h_ -#include "keyboard.h" -#include "control.h" -#include "_control.h" #include "hash.h" #include "gamecvars.h" #include "gamecontrol.h" diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index 4a85b6afe..558404b4b 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -25,10 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "compat.h" #include "baselayer.h" -#include "keyboard.h" -#include "mouse.h" -#include "joystick.h" -#include "control.h" #include "gamecontrol.h" #include "common_game.h" #include "blood.h" @@ -46,8 +42,8 @@ int32_t ctrlCheckAllInput(void) { return ( inputState.keyBufferWaiting() || - inputState.MouseGetButtons() || - JOYSTICK_GetButtons() + inputState.MouseGetButtons() + //JOYSTICK_GetButtons() ); } @@ -56,7 +52,8 @@ void ctrlClearAllInput(void) inputState.keyFlushChars(); inputState.ClearKeysDown(); inputState.MouseClearAllButtonss(); - JOYSTICK_ClearAllButtons(); + //JOYSTICK_ClearAllButtons() + ; } GINPUT gInput; @@ -75,7 +72,6 @@ void ctrlInit(void) void ctrlTerm(void) { - CONTROL_Shutdown(); } int32_t mouseyaxismode = -1; diff --git a/source/blood/src/credits.cpp b/source/blood/src/credits.cpp index 45c2157a2..1ca8799e6 100644 --- a/source/blood/src/credits.cpp +++ b/source/blood/src/credits.cpp @@ -27,7 +27,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "compat.h" #include "SmackerDecoder.h" #include "fx_man.h" -#include "keyboard.h" #include "common_game.h" #include "blood.h" #include "config.h" diff --git a/source/blood/src/d_menu.cpp b/source/blood/src/d_menu.cpp index 2b81b6317..579f83293 100644 --- a/source/blood/src/d_menu.cpp +++ b/source/blood/src/d_menu.cpp @@ -25,7 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "build.h" #include "compat.h" -#include "mouse.h" #include "common_game.h" #include "blood.h" #include "config.h" diff --git a/source/blood/src/demo.cpp b/source/blood/src/demo.cpp index 596ac9bc9..2d50af750 100644 --- a/source/blood/src/demo.cpp +++ b/source/blood/src/demo.cpp @@ -27,8 +27,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include #include "common.h" #include "common_game.h" -#include "keyboard.h" -#include "control.h" #include "osd.h" #include "mmulti.h" diff --git a/source/blood/src/gamemenu.cpp b/source/blood/src/gamemenu.cpp index 4ce789220..31bf46c39 100644 --- a/source/blood/src/gamemenu.cpp +++ b/source/blood/src/gamemenu.cpp @@ -25,7 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "build.h" #include "compat.h" -#include "mouse.h" #include "common_game.h" #include "blood.h" #include "config.h" diff --git a/source/blood/src/messages.cpp b/source/blood/src/messages.cpp index c93c0f13a..2c2ac7a2f 100644 --- a/source/blood/src/messages.cpp +++ b/source/blood/src/messages.cpp @@ -25,8 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "build.h" #include "mmulti.h" #include "compat.h" -#include "keyboard.h" -#include "control.h" #include "gamecontrol.h" #include "common_game.h" #include "blood.h" diff --git a/source/blood/src/osdcmd.cpp b/source/blood/src/osdcmd.cpp index b8d38f114..f7fa34ca6 100644 --- a/source/blood/src/osdcmd.cpp +++ b/source/blood/src/osdcmd.cpp @@ -24,8 +24,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "build.h" #include "baselayer.h" -#include "keyboard.h" -#include "control.h" #include "osd.h" #include "compat.h" #include "mmulti.h" diff --git a/source/mact/src/animlib.cpp b/source/common/animlib.cpp similarity index 100% rename from source/mact/src/animlib.cpp rename to source/common/animlib.cpp diff --git a/source/mact/include/animlib.h b/source/common/animlib.h similarity index 100% rename from source/mact/include/animlib.h rename to source/common/animlib.h diff --git a/source/common/console/c_con.cpp b/source/common/console/c_con.cpp index df40bde31..a7db2650a 100644 --- a/source/common/console/c_con.cpp +++ b/source/common/console/c_con.cpp @@ -37,7 +37,6 @@ #include "basics.h" #include "zstring.h" #include "c_bind.h" -#include "control.h" #include "gamecontrol.h" //============================================================================= @@ -198,7 +197,7 @@ char const* C_CON_GetGameFuncOnJoystick(int gameFunc) FString C_CON_GetBoundKeyForLastInput(int gameFunc) { - if (CONTROL_LastSeenInput == LastSeenInput::Joystick) + if (inputState.gamePadActive()) { FString name = C_CON_GetGameFuncOnJoystick(gameFunc); if (name.IsNotEmpty()) diff --git a/source/common/gameconfigfile.cpp b/source/common/gameconfigfile.cpp index c97a5765a..e8c360aae 100644 --- a/source/common/gameconfigfile.cpp +++ b/source/common/gameconfigfile.cpp @@ -40,14 +40,7 @@ #include "c_bind.h" #include "m_argv.h" #include "cmdlib.h" -//#include "version.h" #include "i_specialpaths.h" -//#include "v_font.h" -//#include "doomstat.h" -//#include "gi.h" -//#include "d_main.h" -#include "keyboard.h" -#include "control.h" #include "printf.h" #include "gamecontrol.h" #include "version.h" diff --git a/source/common/gamecontrol.cpp b/source/common/gamecontrol.cpp index 64122bea0..7fb1eed14 100644 --- a/source/common/gamecontrol.cpp +++ b/source/common/gamecontrol.cpp @@ -1,18 +1,36 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2019 Christoph Oelckers + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +*/ +//------------------------------------------------------------------------- + #include #include "gamecontrol.h" #include "tarray.h" #include "zstring.h" #include "name.h" -#include "control.h" -#include "keyboard.h" #include "sc_man.h" #include "c_cvars.h" #include "gameconfigfile.h" #include "gamecvars.h" #include "build.h" #include "inputstate.h" -#include "_control.h" -#include "control.h" #include "m_argv.h" #include "rts.h" #include "printf.h" @@ -261,6 +279,7 @@ int GameMain() FStringf logpath("logfile %sdemolition.log", M_GetDocumentsPath().GetChars()); C_DoCommand(logpath); I_StartupJoysticks(); + mouseInit(); #ifndef NETCODE_DISABLE gHaveNetworking = !enet_initialize(); @@ -318,13 +337,6 @@ void SetDefaultStrings() quoteMgr.InitializeQuote(84, "$FOLLOW MODE ON"); quoteMgr.InitializeQuote(85, "$AUTORUNOFF"); quoteMgr.InitializeQuote(86, "$AUTORUNON"); - #if 0 // todo: print a message - if (gAutoRun) - viewSetMessage("Auto run ON"); - else - viewSetMessage("Auto run OFF"); - - #endif } //========================================================================== @@ -337,12 +349,6 @@ int RunGame() { SetClipshapes(); - // This must be done before initializing any data, so doing it late in the startup process won't work. - if (CONTROL_Startup(controltype_keyboardandmouse, BGetTime, 120)) - { - return 1; - } - userConfig.ProcessOptions(); G_LoadConfig(); @@ -441,7 +447,6 @@ int RunGame() } TileFiles.AddArt(addArt); - CONTROL_ClearAssignments(); CONFIG_InitMouseAndController(); CONFIG_SetDefaultKeys(cl_defaultconfiguration == 1 ? "demolition/origbinds.txt" : cl_defaultconfiguration == 2 ? "demolition/leftbinds.txt" : "demolition/defbinds.txt"); diff --git a/source/common/gamecontrol.h b/source/common/gamecontrol.h index 155d86338..5899375a6 100644 --- a/source/common/gamecontrol.h +++ b/source/common/gamecontrol.h @@ -1,8 +1,5 @@ #pragma once -#include "keyboard.h" -#include "control.h" -#include "_control.h" #include "c_cvars.h" #include "zstring.h" #include "inputstate.h" diff --git a/source/common/gamecvars.cpp b/source/common/gamecvars.cpp index e6d7d2e93..65c8be757 100644 --- a/source/common/gamecvars.cpp +++ b/source/common/gamecvars.cpp @@ -39,9 +39,6 @@ #include "fx_man.h" #include "baselayer.h" #include "gameconfigfile.h" -#include "keyboard.h" -#include "control.h" -#include "_control.h" #include "gamecontrol.h" #include "m_argv.h" #include "rts.h" @@ -292,13 +289,8 @@ CUSTOM_CVARD(Int, r_fov, 90, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "change the field o CVARD(Bool, r_horizcenter, false, CVAR_ARCHIVE|CVAR_FRONTEND_BLOOD, "enable/disable centered horizon line") // only present in Blood, maybe add to others? -CUSTOM_CVARD(Bool, in_joystick, false, CVAR_ARCHIVE||CVAR_GLOBALCONFIG|CVAR_NOINITCALL, "enables input from the joystick if it is present") -{ - CONTROL_JoystickEnabled = (self && CONTROL_JoyPresent); -} - +CVARD(Bool, in_joystick, false, CVAR_ARCHIVE||CVAR_GLOBALCONFIG|CVAR_NOINITCALL, "enables input from the joystick if it is present") CVARD(Bool, in_mouse, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL, "enables input from the mouse if it is present") - CVARD(Bool, in_mousemode, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "toggles vertical mouse view") CVAR(Bool, silentmouseaimtoggle, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) diff --git a/source/common/input/i_input.cpp b/source/common/input/i_input.cpp index b6b8ce6f9..ef30d1bcc 100644 --- a/source/common/input/i_input.cpp +++ b/source/common/input/i_input.cpp @@ -33,14 +33,9 @@ ** */ -#include "compat.h" #include -//#include "doomtype.h" -//#include "doomdef.h" -//#include "doomstat.h" #include "m_argv.h" -//#include "v_video.h" #include "c_buttons.h" #include "d_event.h" @@ -49,10 +44,6 @@ #include "c_dispatch.h" #include "c_cvars.h" #include "keydef.h" -//#include "dikeys.h" -//#include "events.h" -//#include "g_game.h" -//#include "g_levellocals.h" #include "utf8.h" #include "menu/menu.h" diff --git a/source/mact/src/input.cpp b/source/common/input/input.cpp similarity index 84% rename from source/mact/src/input.cpp rename to source/common/input/input.cpp index 3687637a7..0b7f25939 100644 --- a/source/mact/src/input.cpp +++ b/source/common/input/input.cpp @@ -21,10 +21,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //------------------------------------------------------------------------- #include "gamecontrol.h" -#include "keyboard.h" -#include "mouse.h" -#include "joystick.h" -#include "control.h" #include "input.h" #include "inputstate.h" @@ -41,14 +37,15 @@ int32_t I_CheckAllInput(void) return inputState.keyBufferWaiting() || inputState.MouseGetButtons() - || JOYSTICK_GetButtons(); + //|| JOYSTICK_GetButtons() + ; } void I_ClearAllInput(void) { inputState.keyFlushChars(); inputState.ClearKeysDown(); inputState.MouseClearAllButtonss(); - JOYSTICK_ClearAllButtons(); + //JOYSTICK_ClearAllButtons(); buttonMap.ResetButtonStates(); } @@ -59,7 +56,7 @@ int32_t I_TextSubmit(void) inputState.GetKeyStatus(sc_Enter) || inputState.GetKeyStatus(sc_kpad_Enter) || mouseInactiveConditional(inputState.MouseGetButtons()&LEFT_MOUSE) - || (JOYSTICK_GetGameControllerButtons()&(1<dyaw += joyaxes[JOYAXIS_Yaw]; + info->dx += joyaxes[JOYAXIS_Side]; + info->dz += joyaxes[JOYAXIS_Forward]; + info->dpitch += joyaxes[JOYAXIS_Pitch]; + } +} + + + diff --git a/source/duke3d/CMakeLists.txt b/source/duke3d/CMakeLists.txt index b3169684e..2a969f8b6 100644 --- a/source/duke3d/CMakeLists.txt +++ b/source/duke3d/CMakeLists.txt @@ -14,7 +14,6 @@ endif() include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../build/include - ${CMAKE_CURRENT_SOURCE_DIR}/../mact/include ${CMAKE_CURRENT_SOURCE_DIR}/../audiolib/include ${CMAKE_CURRENT_SOURCE_DIR}/../libsmackerdec/include ${CMAKE_CURRENT_SOURCE_DIR}/../thirdparty/include @@ -25,6 +24,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../common/fonts ${CMAKE_CURRENT_SOURCE_DIR}/../common/2d ${CMAKE_CURRENT_SOURCE_DIR}/../common/music + ${CMAKE_CURRENT_SOURCE_DIR}/../common/input ${CMAKE_CURRENT_SOURCE_DIR}/../platform ) diff --git a/source/duke3d/src/anim.cpp b/source/duke3d/src/anim.cpp index 3af7e8d8d..081f85777 100644 --- a/source/duke3d/src/anim.cpp +++ b/source/duke3d/src/anim.cpp @@ -26,7 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "renderlayer.h" #include "duke3d.h" #include "animlib.h" -#include "mouse.h" #include "compat.h" #include "input.h" diff --git a/source/duke3d/src/duke3d.h b/source/duke3d/src/duke3d.h index 21e187a22..5153b823e 100644 --- a/source/duke3d/src/duke3d.h +++ b/source/duke3d/src/duke3d.h @@ -30,7 +30,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "cache1d.h" #include "compat.h" #include "fx_man.h" -#include "keyboard.h" #include "pragmas.h" #include "polymost.h" #include "gamecvars.h" @@ -112,7 +111,6 @@ EDUKE32_STATIC_ASSERT(7 <= MAXTILES-MAXUSERTILES); #include "actors.h" #include "common_game.h" #include "config.h" -#include "control.h" #include "gamecontrol.h" #include "game.h" #include "gamedef.h" diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 644425f06..7101a1fff 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -5434,7 +5434,6 @@ static void G_Cleanup(void) void G_Shutdown(void) { S_SoundShutdown(); - CONTROL_Shutdown(); engineUnInit(); G_Cleanup(); } diff --git a/source/duke3d/src/gamestructures.cpp b/source/duke3d/src/gamestructures.cpp index 9ea044ae4..f698b7912 100644 --- a/source/duke3d/src/gamestructures.cpp +++ b/source/duke3d/src/gamestructures.cpp @@ -1548,7 +1548,7 @@ int32_t __fastcall VM_GetUserdef(int32_t labelNum, int const lParm2) case USERDEFS_DRAW_Y: labelNum = rotatesprite_y_offset; break; case USERDEFS_DRAW_YXASPECT: labelNum = rotatesprite_yxaspect; break; case USERDEFS_FOV: labelNum = r_fov; break; - case USERDEFS_GAMEPADACTIVE: labelNum = (CONTROL_LastSeenInput == LastSeenInput::Joystick); break; + case USERDEFS_GAMEPADACTIVE: labelNum = inputState.gamePadActive(); break; default: EDUKE32_UNREACHABLE_SECTION(labelNum = -1; break); } diff --git a/source/mact/gpl-2.0.txt b/source/mact/gpl-2.0.txt deleted file mode 100644 index d159169d1..000000000 --- a/source/mact/gpl-2.0.txt +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/source/mact/include/_control.h b/source/mact/include/_control.h deleted file mode 100644 index b3198bf09..000000000 --- a/source/mact/include/_control.h +++ /dev/null @@ -1,173 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 1996, 2003 - 3D Realms Entertainment - -This file is NOT part of Duke Nukem 3D version 1.5 - Atomic Edition -However, it is either an older version of a file that is, or is -some test code written during the development of Duke Nukem 3D. -This file is provided purely for educational interest. - -Duke Nukem 3D is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms -*/ -//------------------------------------------------------------------------- - -//**************************************************************************** -// -// Private header for CONTROL.C -// -//**************************************************************************** - -#pragma once - -#ifndef control_private_h_ -#define control_private_h_ - -#include "compat.h" -#include "keyboard.h" - - -//**************************************************************************** -// -// DEFINES -// -//**************************************************************************** - -#define AXISUNDEFINED 0x7f -#define BUTTONUNDEFINED 0x7f -#define KEYUNDEFINED 0x7f - -#define THRESHOLD (0x200 * 32767 / 10000) -#define MINTHRESHOLD (0x80 * 32767 / 10000) - -#define DEFAULTMOUSESENSITIVITY 4 // 0x7000+MINIMUMMOUSESENSITIVITY - -#define INSTANT_ONOFF 0 -#define TOGGLE_ONOFF 1 - -#define MAXCONTROLVALUE 0x7fff - -// Number of Mouse buttons - -//#define MAXMOUSEBUTTONS 10 - -// Number of JOY buttons -// KEEPINSYNC duke3d/src/gamedefs.h, build/src/sdlayer.cpp -#define MAXJOYBUTTONS 32 -#define MAXJOYBUTTONSANDHATS (MAXJOYBUTTONS+4) - -// Number of JOY axes -// KEEPINSYNC duke3d/src/gamedefs.h, build/src/sdlayer.cpp -#define MAXJOYAXES 9 -#define MAXJOYDIGITAL (MAXJOYAXES*2) - -// NORMAL axis scale -#define NORMALAXISSCALE 65536 - -#define LIMITCONTROL(x) (*x = clamp(*x, -MAXCONTROLVALUE, MAXCONTROLVALUE)) - -//**************************************************************************** -// -// TYPEDEFS -// -//**************************************************************************** - -typedef enum -{ - motion_Left = -1, - motion_Up = -1, - motion_None = 0, - motion_Right = 1, - motion_Down = 1 -} motion; - - -typedef struct -{ - int32_t joyMinX; - int32_t joyMinY; - int32_t threshMinX; - int32_t threshMinY; - int32_t threshMaxX; - int32_t threshMaxY; - int32_t joyMaxX; - int32_t joyMaxY; - int32_t joyMultXL; - int32_t joyMultYL; - int32_t joyMultXH; - int32_t joyMultYH; -} JoystickDef; - -// int32_t ThrottleMin; -// int32_t RudderMin; -// int32_t ThrottlethreshMin; -// int32_t RudderthreshMin; -// int32_t ThrottlethreshMax; -// int32_t RudderthreshMax; -// int32_t ThrottleMax; -// int32_t RudderMax; -// int32_t ThrottleMultL; -// int32_t RudderMultL; -// int32_t ThrottleMultH; -// int32_t RudderMultH; - - -typedef struct -{ - uint8_t active; - uint8_t used; - uint8_t toggle; - uint8_t buttonheld; - int32_t cleared; -} controlflags; - -typedef struct -{ - kb_scancode key1; - kb_scancode key2; -} controlkeymaptype; - -typedef struct -{ - uint8_t singleclicked; - uint8_t doubleclicked; - uint16_t extra; -} controlbuttontype; - -typedef struct -{ - uint8_t analogmap; - uint8_t minmap; - uint8_t maxmap; - uint8_t extra; -} controlaxismaptype; - -typedef struct -{ - int32_t analog; - int8_t digital; - int8_t digitalClearedN, digitalClearedP; -} controlaxistype; - - -//*************************************************************************** -// -// PROTOTYPES -// -//*************************************************************************** - -#endif diff --git a/source/mact/include/control.h b/source/mact/include/control.h deleted file mode 100644 index 9756bed4c..000000000 --- a/source/mact/include/control.h +++ /dev/null @@ -1,169 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 1996, 2003 - 3D Realms Entertainment - -This file is part of Duke Nukem 3D version 1.5 - Atomic Edition - -Duke Nukem 3D is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -Original Source: 1996 - Todd Replogle -Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms -Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) -*/ -//------------------------------------------------------------------------- - -//*************************************************************************** -// -// Public header for CONTROL.C. -// -//*************************************************************************** - -#pragma once - -#ifndef control_public_h_ -#define control_public_h_ - -#include "tarray.h" -#include "inputstate.h" - -//*************************************************************************** -// -// DEFINES -// -//*************************************************************************** - -//*************************************************************************** -// -// TYPEDEFS -// -//*************************************************************************** -typedef enum - { - axis_up, - axis_down, - axis_left, - axis_right - } axisdirection; - -typedef enum - { - analog_turning=0, - analog_strafing=1, - analog_lookingupanddown=2, - analog_elevation=3, - analog_rolling=4, - analog_moving=5, - analog_maxtype - } analogcontrol; - -typedef enum - { - controltype_keyboard, - controltype_keyboardandmouse, - controltype_keyboardandjoystick - } controltype; - -typedef enum - { - controldevice_keyboard, - controldevice_mouse, - controldevice_joystick - } controldevice; - -enum GameControllerButton : int -{ - GAMECONTROLLER_BUTTON_INVALID = -1, - GAMECONTROLLER_BUTTON_A, - GAMECONTROLLER_BUTTON_B, - GAMECONTROLLER_BUTTON_X, - GAMECONTROLLER_BUTTON_Y, - GAMECONTROLLER_BUTTON_BACK, - GAMECONTROLLER_BUTTON_GUIDE, - GAMECONTROLLER_BUTTON_START, - GAMECONTROLLER_BUTTON_LEFTSTICK, - GAMECONTROLLER_BUTTON_RIGHTSTICK, - GAMECONTROLLER_BUTTON_LEFTSHOULDER, - GAMECONTROLLER_BUTTON_RIGHTSHOULDER, - GAMECONTROLLER_BUTTON_DPAD_UP, - GAMECONTROLLER_BUTTON_DPAD_DOWN, - GAMECONTROLLER_BUTTON_DPAD_LEFT, - GAMECONTROLLER_BUTTON_DPAD_RIGHT, - GAMECONTROLLER_BUTTON_MAX -}; - -enum GameControllerAxis : int -{ - GAMECONTROLLER_AXIS_INVALID = -1, - GAMECONTROLLER_AXIS_LEFTX, - GAMECONTROLLER_AXIS_LEFTY, - GAMECONTROLLER_AXIS_RIGHTX, - GAMECONTROLLER_AXIS_RIGHTY, - GAMECONTROLLER_AXIS_TRIGGERLEFT, - GAMECONTROLLER_AXIS_TRIGGERRIGHT, - GAMECONTROLLER_AXIS_MAX -}; - -enum class LastSeenInput : unsigned char -{ - Keyboard, - Joystick, -}; - -//*************************************************************************** -// -// GLOBALS -// -//*************************************************************************** - -extern bool CONTROL_Started; -extern bool CONTROL_MousePresent; -extern bool CONTROL_JoyPresent; -extern bool CONTROL_MouseEnabled; -extern bool CONTROL_JoystickEnabled; - -extern LastSeenInput CONTROL_LastSeenInput; - - -//*************************************************************************** -// -// PROTOTYPES -// -//*************************************************************************** -void CONTROL_ClearAssignments( void ); -void CONTROL_GetInput( ControlInfo *info ); - -bool CONTROL_Startup(controltype which, int32_t ( *TimeFunction )( void ), int32_t ticspersecond); -void CONTROL_Shutdown( void ); - -void CONTROL_MapAnalogAxis(int whichaxis, int whichanalog, controldevice device); -void CONTROL_MapDigitalAxis(int32_t whichaxis, int32_t whichfunction, int32_t direction, controldevice device); -void CONTROL_SetAnalogAxisScale(int32_t whichaxis, int32_t axisscale, controldevice device); -void CONTROL_SetAnalogAxisInvert(int32_t whichaxis, int32_t invert, controldevice device); - -void CONTROL_ScanForControllers(void); - -int32_t CONTROL_GetGameControllerDigitalAxisPos(int32_t axis); -int32_t CONTROL_GetGameControllerDigitalAxisNeg(int32_t axis); -void CONTROL_ClearGameControllerDigitalAxisPos(int32_t axis); -void CONTROL_ClearGameControllerDigitalAxisNeg(int32_t axis); - - -////////// KEY/MOUSE BIND STUFF ////////// - - -//////////////////// - -#endif diff --git a/source/mact/include/joystick.h b/source/mact/include/joystick.h deleted file mode 100644 index 5696ae52e..000000000 --- a/source/mact/include/joystick.h +++ /dev/null @@ -1,31 +0,0 @@ - -#ifndef __joystick_h -#define __joystick_h - - - -#define HAT_CENTERED 0x00 -#define HAT_UP 0x01 -#define HAT_RIGHT 0x02 -#define HAT_DOWN 0x04 -#define HAT_LEFT 0x08 -#define HAT_RIGHTUP (HAT_RIGHT|HAT_UP) -#define HAT_RIGHTDOWN (HAT_RIGHT|HAT_DOWN) -#define HAT_LEFTUP (HAT_LEFT|HAT_UP) -#define HAT_LEFTDOWN (HAT_LEFT|HAT_DOWN) - -int32_t JOYSTICK_GetButtons( void ); -int32_t JOYSTICK_GetGameControllerButtons( void ); -int32_t JOYSTICK_ClearButton( int32_t b ); -void JOYSTICK_ClearGameControllerButton( int32_t b ); -void JOYSTICK_ClearAllButtons( void ); - -int32_t JOYSTICK_GetHat( int32_t h ); -void JOYSTICK_ClearHat( int32_t h ); -void JOYSTICK_ClearAllHats( void ); - -int32_t JOYSTICK_GetAxis( int32_t a ); -void JOYSTICK_ClearAxis( int32_t a ); -void JOYSTICK_ClearAllAxes( void ); - -#endif /* __joystick_h */ diff --git a/source/mact/include/mouse.h b/source/mact/include/mouse.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/source/mact/src/control.cpp b/source/mact/src/control.cpp deleted file mode 100644 index 7f807772e..000000000 --- a/source/mact/src/control.cpp +++ /dev/null @@ -1,393 +0,0 @@ -/* - * control.c - * MACT library controller handling - * - * Derived from MACT386.LIB disassembly by Jonathon Fowler - * - */ - -#include "_control.h" -#include "baselayer.h" -#include "compat.h" -#include "control.h" -#include "joystick.h" -#include "keyboard.h" -#include "mouse.h" -#include "osd.h" -#include "gamecvars.h" -#include "pragmas.h" - -bool CONTROL_Started = false; -bool CONTROL_JoyPresent = false; -bool CONTROL_JoystickEnabled = false; - -LastSeenInput CONTROL_LastSeenInput; - -static int32_t CONTROL_NumMouseButtons = 0; -static int32_t CONTROL_NumJoyButtons = 0; -static int32_t CONTROL_NumJoyAxes = 0; - -// static controlkeymaptype CONTROL_KeyMapping[CONTROL_NUM_FLAGS]; - -static controlaxismaptype CONTROL_JoyAxesMap[MAXJOYAXES]; -static controlaxistype CONTROL_JoyAxes[MAXJOYAXES]; -static controlaxistype CONTROL_LastJoyAxes[MAXJOYAXES]; -static int32_t CONTROL_JoyAxesScale[MAXJOYAXES]; -static int8_t CONTROL_JoyAxesInvert[MAXJOYAXES]; - -static controlbuttontype CONTROL_JoyButtonMapping[MAXJOYBUTTONS]; - -static int32_t CONTROL_JoyButtonClicked[MAXJOYBUTTONS]; -static int32_t CONTROL_JoyButtonClickedState[MAXJOYBUTTONS]; -static int32_t CONTROL_JoyButtonClickedTime[MAXJOYBUTTONS]; -static int32_t CONTROL_JoyButtonState[MAXJOYBUTTONS]; -static uint8_t CONTROL_JoyButtonClickedCount[MAXJOYBUTTONS]; - -static int32_t(*ExtGetTime)(void); -//static int32_t ticrate; -static uint8_t CONTROL_DoubleClickSpeed; - -int32_t CONTROL_ButtonFlags[NUMKEYS]; -bool CONTROL_BindsEnabled = 0; - -#define CONTROL_CheckRange(which) ((unsigned)which >= (unsigned)NUMKEYS) - -static int32_t CONTROL_GetTime(void) -{ - static int32_t t = 0; - t += 5; - return t; -} - -void CONTROL_ClearAssignments(void) -{ - memset(CONTROL_JoyAxes, 0, sizeof(CONTROL_JoyAxes)); - memset(CONTROL_JoyAxesInvert, 0, sizeof(CONTROL_JoyAxesInvert)); - memset(CONTROL_JoyAxesMap, AXISUNDEFINED, sizeof(CONTROL_JoyAxesMap)); - memset(CONTROL_JoyButtonMapping, BUTTONUNDEFINED, sizeof(CONTROL_JoyButtonMapping)); - memset(CONTROL_LastJoyAxes, 0, sizeof(CONTROL_LastJoyAxes)); -} - -static int DoGetDeviceButtons( - int32_t buttons, int32_t tm, - int32_t NumButtons, - int32_t *DeviceButtonState, - int32_t *ButtonClickedTime, - int32_t *ButtonClickedState, - int32_t *ButtonClicked, - uint8_t *ButtonClickedCount -) -{ - int32_t i=NumButtons-1; - int retval = 0; - - for (; i>=0; i--) - { - int const bs = (buttons >> i) & 1; - - DeviceButtonState[i] = bs; - ButtonClickedState[i] = FALSE; - - if (bs) - { - retval = 1; - - if (ButtonClicked[i] == FALSE) - { - ButtonClicked[i] = TRUE; - - if (ButtonClickedCount[i] == 0 || tm > ButtonClickedTime[i]) - { - ButtonClickedTime[i] = tm + CONTROL_DoubleClickSpeed; - ButtonClickedCount[i] = 1; - } - else if (tm < ButtonClickedTime[i]) - { - ButtonClickedState[i] = TRUE; - ButtonClickedTime[i] = 0; - ButtonClickedCount[i] = 2; - } - } - else if (ButtonClickedCount[i] == 2) - { - ButtonClickedState[i] = TRUE; - } - - continue; - } - - if (ButtonClickedCount[i] == 2) - ButtonClickedCount[i] = 0; - - ButtonClicked[i] = FALSE; - } - - return retval; -} - -static void CONTROL_GetDeviceButtons(void) -{ - int32_t const t = ExtGetTime(); - - if (CONTROL_JoystickEnabled) - { - int retval = DoGetDeviceButtons( - JOYSTICK_GetButtons(), t, - CONTROL_NumJoyButtons, - CONTROL_JoyButtonState, - CONTROL_JoyButtonClickedTime, - CONTROL_JoyButtonClickedState, - CONTROL_JoyButtonClicked, - CONTROL_JoyButtonClickedCount - ); - if (retval) - CONTROL_LastSeenInput = LastSeenInput::Joystick; - } -} - -static int CONTROL_DigitizeAxis(int axis, controldevice device) -{ - controlaxistype *set, *lastset; - - switch (device) - { - case controldevice_joystick: - set = CONTROL_JoyAxes; - lastset = CONTROL_LastJoyAxes; - break; - - default: return 0; - } - - set[axis].digitalClearedN = lastset[axis].digitalClearedN; - set[axis].digitalClearedP = lastset[axis].digitalClearedP; - - if (set[axis].analog > 0) - { - set[axis].digitalClearedN = 0; - - if (set[axis].analog > THRESHOLD || (set[axis].analog > MINTHRESHOLD && lastset[axis].digital == 1)) - set[axis].digital = 1; - else - set[axis].digitalClearedP = 0; - - return 1; - } - else if (set[axis].analog < 0) - { - set[axis].digitalClearedP = 0; - - if (set[axis].analog < -THRESHOLD || (set[axis].analog < -MINTHRESHOLD && lastset[axis].digital == -1)) - set[axis].digital = -1; - else - set[axis].digitalClearedN = 0; - - return 1; - } - else - { - set[axis].digitalClearedN = 0; - set[axis].digitalClearedP = 0; - } - - return 0; -} - -static void CONTROL_ScaleAxis(int axis, controldevice device) -{ - controlaxistype *set; - int32_t *scale; - int8_t * invert; - - switch (device) - { - case controldevice_joystick: - set = CONTROL_JoyAxes; - scale = CONTROL_JoyAxesScale; - invert = CONTROL_JoyAxesInvert; - break; - - default: return; - } - - int const invertResult = !!invert[axis]; - set[axis].analog = (mulscale16(set[axis].analog, scale[axis]) ^ -invertResult) + invertResult; -} - -static void CONTROL_ApplyAxis(int axis, ControlInfo *info, controldevice device) -{ - controlaxistype *set; - controlaxismaptype *map; - - switch (device) - { - case controldevice_joystick: - set = CONTROL_JoyAxes; - map = CONTROL_JoyAxesMap; - break; - - default: return; - } - - switch (map[axis].analogmap) - { - case analog_turning: info->dyaw += set[axis].analog; break; - case analog_strafing: info->dx += set[axis].analog; break; - case analog_lookingupanddown: info->dpitch += set[axis].analog; break; - case analog_elevation: info->dy += set[axis].analog; break; - case analog_rolling: info->droll += set[axis].analog; break; - case analog_moving: info->dz += set[axis].analog; break; - default: break; - } -} - -static void CONTROL_PollDevices(ControlInfo *info) -{ - memset(info, 0, sizeof(ControlInfo)); - - if (in_mouse) - inputState.GetMouseDelta(info); - - if (CONTROL_JoystickEnabled) - { - Bmemcpy(CONTROL_LastJoyAxes, CONTROL_JoyAxes, sizeof(CONTROL_JoyAxes)); - memset(CONTROL_JoyAxes, 0, sizeof(CONTROL_JoyAxes)); - - for (int i=joystick.numAxes-1; i>=0; i--) - { - CONTROL_JoyAxes[i].analog = joystick.pAxis[i]; - - if (CONTROL_DigitizeAxis(i, controldevice_joystick)) - CONTROL_LastSeenInput = LastSeenInput::Joystick; - CONTROL_ScaleAxis(i, controldevice_joystick); - LIMITCONTROL(&CONTROL_JoyAxes[i].analog); - CONTROL_ApplyAxis(i, info, controldevice_joystick); - } - } - - CONTROL_GetDeviceButtons(); -} - -static int CONTROL_HandleAxisFunction(int32_t *p1, controlaxistype *axes, controlaxismaptype *axismap, int numAxes) -{ - int axis = numAxes - 1; - int retval = 0; - - do - { - if (!axes[axis].digital) - continue; - - int const j = (axes[axis].digital < 0) ? axismap[axis].minmap : axismap[axis].maxmap; - - if (j != AXISUNDEFINED) - { - p1[j] = 1; - retval = 1; - } - } - while (axis--); - - return retval; -} - -static void CONTROL_AxisFunctionState(int32_t *p1) -{ - if (CONTROL_NumJoyAxes) - { - if (CONTROL_HandleAxisFunction(p1, CONTROL_JoyAxes, CONTROL_JoyAxesMap, CONTROL_NumJoyAxes)) - CONTROL_LastSeenInput = LastSeenInput::Joystick; - } -} - -static void CONTROL_ButtonFunctionState(int32_t *p1) -{ - if (CONTROL_NumJoyButtons) - { - int i=CONTROL_NumJoyButtons-1, j; - int retval = 0; - - do - { - j = CONTROL_JoyButtonMapping[i].doubleclicked; - if (j != KEYUNDEFINED) - { - auto const state = CONTROL_JoyButtonClickedState[i]; - p1[j] |= state; - retval |= state; - } - - j = CONTROL_JoyButtonMapping[i].singleclicked; - if (j != KEYUNDEFINED) - { - auto const state = CONTROL_JoyButtonState[i]; - p1[j] |= state; - retval |= state; - } - } - while (i--); - - if (retval) - CONTROL_LastSeenInput = LastSeenInput::Joystick; - } -} - -static void CONTROL_GetFunctionInput(void) -{ - CONTROL_ButtonFunctionState(CONTROL_ButtonFlags); - CONTROL_AxisFunctionState(CONTROL_ButtonFlags); -} - -void CONTROL_GetInput(ControlInfo *info) -{ - CONTROL_PollDevices(info); - CONTROL_GetFunctionInput(); - inputchecked = 1; -} - -static void CONTROL_ResetJoystickValues() -{ - CONTROL_NumJoyAxes = min(MAXJOYAXES, joystick.numAxes); - CONTROL_NumJoyButtons = min(MAXJOYBUTTONS, joystick.numButtons + 4 * (joystick.numHats > 0)); - CONTROL_JoystickEnabled = CONTROL_JoyPresent = !!((inputdevices & 4) >> 2); -} - - -bool CONTROL_Startup(controltype which, int32_t(*TimeFunction)(void), int32_t ticspersecond) -{ - UNREFERENCED_PARAMETER(which); - - if (CONTROL_Started) return false; - - ExtGetTime = TimeFunction ? TimeFunction : CONTROL_GetTime; - - // what the fuck??? - CONTROL_DoubleClickSpeed = (ticspersecond * 57) / 100; - - if (CONTROL_DoubleClickSpeed <= 0) - CONTROL_DoubleClickSpeed = 1; - - if (initinput()) - return true; - - CONTROL_NumMouseButtons = MAXMOUSEBUTTONS; - mouseInit(); - - CONTROL_ResetJoystickValues(); - - CONTROL_Started = TRUE; - - return false; -} - -void CONTROL_Shutdown(void) -{ - if (!CONTROL_Started) - return; - - mouseUninit(); - uninitinput(); - - CONTROL_Started = FALSE; -} - diff --git a/source/mact/src/joystick.cpp b/source/mact/src/joystick.cpp deleted file mode 100644 index 4f2da88f3..000000000 --- a/source/mact/src/joystick.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - * joystick.c - * MACT library -to- Build Port Joystick Glue - * - * by Hendricks266 - * - * We needed raw joystick access for the Wii port. - * We only had raw mouse and keyboard access. - * I made raw joystick access. - * - */ -//------------------------------------------------------------------------- -/* -Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment - -This file is part of Duke Nukem 3D version 1.5 - Atomic Edition - -Duke Nukem 3D is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -//------------------------------------------------------------------------- - -#include "compat.h" - -#include "joystick.h" -#include "baselayer.h" - -#include "keyboard.h" -#include "_control.h" - -int32_t JOYSTICK_GetButtons(void) -{ - int32_t buttons; - - joyReadButtons(&buttons); - - if (joystick.numHats > 0) - { - int32_t hat = JOYSTICK_GetHat(0); - if (hat != 0) - buttons |= hat << min(MAXJOYBUTTONS, joystick.numButtons); - } - - return buttons; -} -int32_t JOYSTICK_GetGameControllerButtons(void) -{ - if (!joystick.isGameController) - return 0; - - int32_t buttons; - joyReadButtons(&buttons); - return buttons; -} -int32_t JOYSTICK_ClearButton(int32_t b) -{ - return (joystick.bits &= ~b); -} -void JOYSTICK_ClearGameControllerButton(int32_t b) -{ - if (!joystick.isGameController) - return; - - joystick.bits &= ~b; -} -void JOYSTICK_ClearAllButtons(void) -{ - joystick.bits = 0; -} - -int32_t JOYSTICK_GetHat(int32_t h) -{ - if (h>=0 && h=0 && h=0 && a=0 && a