From 5148fc877dfb492bff7911cdef99d0df992e8177 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Oct 2019 18:32:05 +0100 Subject: [PATCH] - consolidate the 3 instances of input.cpp. Some stuff had to be disabled to make it work but that's hardly relevant considering that the goal is to transition off MACT for input handling. --- source/CMakeLists.txt | 1 + source/blood/CMakeLists.txt | 1 - source/blood/src/input.cpp | 411 -------------------- source/blood/src/input.h | 77 ---- source/blood/src/menus.h | 3 - source/duke3d/CMakeLists.txt | 1 - source/duke3d/src/global.h | 2 - source/{duke3d/src => mact/include}/input.h | 8 +- source/{duke3d => mact}/src/input.cpp | 82 +--- source/rr/CMakeLists.txt | 3 - source/rr/src/events_defs.h | 5 - source/rr/src/gameexec.cpp | 2 - source/rr/src/gameexec.h | 1 - source/rr/src/gamestructures.cpp | 21 - source/rr/src/gamevars.cpp | 0 source/rr/src/global.h | 2 - source/rr/src/input.cpp | 351 ----------------- source/rr/src/input.h | 70 ---- 18 files changed, 23 insertions(+), 1018 deletions(-) delete mode 100644 source/blood/src/input.cpp delete mode 100644 source/blood/src/input.h rename source/{duke3d/src => mact/include}/input.h (97%) rename source/{duke3d => mact}/src/input.cpp (84%) delete mode 100644 source/rr/src/events_defs.h delete mode 100644 source/rr/src/gamestructures.cpp delete mode 100644 source/rr/src/gamevars.cpp delete mode 100644 source/rr/src/input.cpp delete mode 100644 source/rr/src/input.h diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 9373371b5..e2d458b52 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -739,6 +739,7 @@ set (PCH_SOURCES mact/src/control.cpp mact/src/joystick.cpp mact/src/keyboard.cpp + mact/src/input.cpp thirdparty/src/sjson.cpp thirdparty/src/crc32.cpp diff --git a/source/blood/CMakeLists.txt b/source/blood/CMakeLists.txt index faca5fa6d..83b8a2c10 100644 --- a/source/blood/CMakeLists.txt +++ b/source/blood/CMakeLists.txt @@ -81,7 +81,6 @@ set( PCH_SOURCES src/gib.cpp src/globals.cpp src/inifile.cpp - src/input.cpp src/iob.cpp src/levels.cpp src/loadsave.cpp diff --git a/source/blood/src/input.cpp b/source/blood/src/input.cpp deleted file mode 100644 index 2ab7a99e2..000000000 --- a/source/blood/src/input.cpp +++ /dev/null @@ -1,411 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 2010 EDuke32 developers and contributors - -This file is part of EDuke32. - -EDuke32 is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 2 -as published by the Free Software Foundation. - -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 "ns.h" // Must come before everything else! -//#include "global.h" -//#include "game.h" -#include "gamecontrol.h" -#include "keyboard.h" -#include "mouse.h" -#include "joystick.h" -#include "control.h" -#include "input.h" -#include "menus.h" -#include "gamemenu.h" -#include "inputstate.h" - -BEGIN_BLD_NS - - -int32_t I_CheckAllInput(void) -{ - return - KB_KeyWaiting() - || MOUSE_GetButtons() - || JOYSTICK_GetButtons() -#if defined EDUKE32_IOS - || g_mouseClickState == MOUSE_PRESSED -#endif - ; -} -void I_ClearAllInput(void) -{ - KB_FlushKeyboardQueue(); - KB_ClearKeysDown(); - MOUSE_ClearAllButtons(); - JOYSTICK_ClearAllButtons(); - inputState.ClearAllButtons(); -#if defined EDUKE32_IOS - mouseAdvanceClickState(); -#endif -} - - -int32_t I_TextSubmit(void) -{ - return - KB_KeyPressed(sc_Enter) - || KB_KeyPressed(sc_kpad_Enter) -#if !defined EDUKE32_TOUCH_DEVICES - || MOUSEINACTIVECONDITIONAL(MOUSE_GetButtons()&LEFT_MOUSE) -#endif - || (JOYSTICK_GetGameControllerButtons()&(1< 0) - { - inputloc--; - *(t+inputloc) = 0; - } - } - else - { - if (ch == asc_Enter) - { - I_AdvanceTriggerClear(); - return 1; - } - else if (ch == asc_Escape) - { - I_ReturnTriggerClear(); - return -1; - } - else if (ch >= 32 && inputloc < maxlength && ch < 127) - { - if (!(flags & INPUT_NUMERIC) || (ch >= '0' && ch <= '9')) - { - // JBF 20040508: so we can have numeric only if we want - *(t+inputloc) = ch; - *(t+inputloc+1) = 0; - inputloc++; - } - } - } - } - - if (I_TextSubmit()) - { - I_TextSubmitClear(); - return 1; - } - if (I_ReturnTrigger()) - { - I_ReturnTriggerClear(); - return -1; - } - - return 0; -} - -END_BLD_NS diff --git a/source/blood/src/input.h b/source/blood/src/input.h deleted file mode 100644 index dbbda1814..000000000 --- a/source/blood/src/input.h +++ /dev/null @@ -1,77 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 2010 EDuke32 developers and contributors - -This file is part of EDuke32. - -EDuke32 is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 2 -as published by the Free Software Foundation. - -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. -*/ -//------------------------------------------------------------------------- - -#ifndef input_h_ -#define input_h_ - -BEGIN_BLD_NS - -#define WIN_IS_PRESSED ( inputState.WinPressed() ) -#define ALT_IS_PRESSED ( inputState.AltPressed() ) -#define SHIFTS_IS_PRESSED ( inputState.ShiftPressed() ) - -extern int32_t I_CheckAllInput(void); -extern void I_ClearAllInput(void); - -// Advance = Selecting a menu option || Saying "Yes" || Going forward in Help/Credits -// Return = Closing a sub-menu || Saying "No" -// General = Advance + Return = Skipping screens -// Escape = Opening the menu in-game (should not be any gamefuncs) - -extern int32_t I_AdvanceTrigger(void); -extern void I_AdvanceTriggerClear(void); -extern int32_t I_ReturnTrigger(void); -extern void I_ReturnTriggerClear(void); -extern int32_t I_GeneralTrigger(void); -extern void I_GeneralTriggerClear(void); -extern int32_t I_EscapeTrigger(void); -extern void I_EscapeTriggerClear(void); - -extern int32_t I_MenuUp(void); -extern void I_MenuUpClear(void); -extern int32_t I_MenuDown(void); -extern void I_MenuDownClear(void); -extern int32_t I_MenuLeft(void); -extern void I_MenuLeftClear(void); -extern int32_t I_MenuRight(void); -extern void I_MenuRightClear(void); - -extern int32_t I_PanelUp(void); -extern void I_PanelUpClear(void); -extern int32_t I_PanelDown(void); -extern void I_PanelDownClear(void); - -extern int32_t I_SliderLeft(void); -extern void I_SliderLeftClear(void); -extern int32_t I_SliderRight(void); -extern void I_SliderRightClear(void); - - -enum EnterTextFlags_t { - INPUT_NUMERIC = 0x00000001, -}; - -extern int32_t I_EnterText(char *t, int32_t maxlength, int32_t flags); - -END_BLD_NS - -#endif diff --git a/source/blood/src/menus.h b/source/blood/src/menus.h index 1a2b6c2d6..553adadcc 100644 --- a/source/blood/src/menus.h +++ b/source/blood/src/menus.h @@ -532,9 +532,6 @@ extern MenuGameplayStemEntry g_MenuGameplayEntries[MAXMENUGAMEPLAYENTRIES]; extern MenuEntry_t ME_NEWGAMECUSTOMENTRIES[MAXMENUGAMEPLAYENTRIES]; extern MenuEntry_t ME_NEWGAMECUSTOMSUBENTRIES[MAXMENUGAMEPLAYENTRIES][MAXMENUGAMEPLAYENTRIES]; -#define TYPEBUFSIZE 141 -extern char typebuf[TYPEBUFSIZE]; - END_BLD_NS #endif diff --git a/source/duke3d/CMakeLists.txt b/source/duke3d/CMakeLists.txt index 1dcabc3d6..153ad1f71 100644 --- a/source/duke3d/CMakeLists.txt +++ b/source/duke3d/CMakeLists.txt @@ -56,7 +56,6 @@ set( PCH_SOURCES src/gamevars.cpp src/global.cpp src/grpscan.cpp - src/input.cpp src/menus.cpp src/namesdyn.cpp src/network.cpp diff --git a/source/duke3d/src/global.h b/source/duke3d/src/global.h index 6892fb6fd..64c4d8f00 100644 --- a/source/duke3d/src/global.h +++ b/source/duke3d/src/global.h @@ -76,8 +76,6 @@ G_EXTERN char pus,pub; G_EXTERN char ready2send; #define MAXPLAYERNAME 32 G_EXTERN char tempbuf[MAXSECTORS<<1],packbuf[PACKBUF_SIZE],buf[1024]; -#define TYPEBUFSIZE 141 -G_EXTERN char typebuf[TYPEBUFSIZE]; G_EXTERN input_t localInput; diff --git a/source/duke3d/src/input.h b/source/mact/include/input.h similarity index 97% rename from source/duke3d/src/input.h rename to source/mact/include/input.h index fe9bab2cd..1028331e0 100644 --- a/source/duke3d/src/input.h +++ b/source/mact/include/input.h @@ -23,7 +23,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef input_h_ #define input_h_ -BEGIN_DUKE_NS + +enum { + TYPEBUFSIZE = 141 +}; +extern char typebuf[TYPEBUFSIZE]; extern int32_t I_CheckAllInput(void); @@ -69,6 +73,4 @@ enum EnterTextFlags_t { extern int32_t I_EnterText(char *t, int32_t maxlength, int32_t flags); -END_DUKE_NS - #endif diff --git a/source/duke3d/src/input.cpp b/source/mact/src/input.cpp similarity index 84% rename from source/duke3d/src/input.cpp rename to source/mact/src/input.cpp index 1859b88bb..f4be1fbc8 100644 --- a/source/duke3d/src/input.cpp +++ b/source/mact/src/input.cpp @@ -20,20 +20,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //------------------------------------------------------------------------- -#include "ns.h" // Must come before everything else! - -#include "global.h" -#include "game.h" #include "gamecontrol.h" #include "keyboard.h" #include "mouse.h" #include "joystick.h" #include "control.h" #include "input.h" -#include "menus.h" #include "inputstate.h" -BEGIN_DUKE_NS +char typebuf[TYPEBUFSIZE]; + int32_t I_CheckAllInput(void) @@ -41,11 +37,7 @@ int32_t I_CheckAllInput(void) return KB_KeyWaiting() || MOUSE_GetButtons() - || JOYSTICK_GetButtons() -#if defined EDUKE32_IOS - || g_mouseClickState == MOUSE_PRESSED -#endif - ; + || JOYSTICK_GetButtons(); } void I_ClearAllInput(void) { @@ -54,9 +46,6 @@ void I_ClearAllInput(void) MOUSE_ClearAllButtons(); JOYSTICK_ClearAllButtons(); inputState.ClearAllButtons(); -#if defined EDUKE32_IOS - mouseAdvanceClickState(); -#endif } @@ -65,14 +54,8 @@ int32_t I_TextSubmit(void) return KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) -#if !defined EDUKE32_TOUCH_DEVICES - || MOUSEINACTIVECONDITIONAL(MOUSE_GetButtons()&LEFT_MOUSE) -#endif - || (JOYSTICK_GetGameControllerButtons()&(1< 0) - { - inputloc--; - *(t+inputloc) = 0; - } - } - else - { - if (ch == asc_Enter) - { - I_AdvanceTriggerClear(); - return 1; - } - else if (ch == asc_Escape) - { - I_ReturnTriggerClear(); - return -1; - } - else if (ch >= 32 && inputloc < maxlength && ch < 127) - { - if (!(flags & INPUT_NUMERIC) || (ch >= '0' && ch <= '9')) - { - // JBF 20040508: so we can have numeric only if we want - *(t+inputloc) = ch; - *(t+inputloc+1) = 0; - inputloc++; - } - } - } - } - - // All gamefuncs (and *only* _gamefuncs_) in I_ReturnTriggerClear() should be replicated here. - inputState.ClearButton(gamefunc_Crouch); - if (I_ReturnTrigger()) - { - I_ReturnTriggerClear(); - return -1; - } - - return 0; -} -END_RR_NS diff --git a/source/rr/src/input.h b/source/rr/src/input.h deleted file mode 100644 index d1112b78f..000000000 --- a/source/rr/src/input.h +++ /dev/null @@ -1,70 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 2010 EDuke32 developers and contributors - -This file is part of EDuke32. - -EDuke32 is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 2 -as published by the Free Software Foundation. - -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. -*/ -//------------------------------------------------------------------------- - -#ifndef input_h_ -#define input_h_ - -BEGIN_RR_NS - -extern int32_t I_CheckAllInput(void); -extern void I_ClearAllInput(void); - -// Advance = Selecting a menu option || Saying "Yes" || Going forward in Help/Credits -// Return = Closing a sub-menu || Saying "No" -// Escape = Opening the menu in-game (should not be any gamefuncs) - -extern int32_t I_AdvanceTrigger(void); -extern void I_AdvanceTriggerClear(void); -extern int32_t I_ReturnTrigger(void); -extern void I_ReturnTriggerClear(void); -extern int32_t I_EscapeTrigger(void); -extern void I_EscapeTriggerClear(void); - -extern int32_t I_MenuUp(void); -extern void I_MenuUpClear(void); -extern int32_t I_MenuDown(void); -extern void I_MenuDownClear(void); -extern int32_t I_MenuLeft(void); -extern void I_MenuLeftClear(void); -extern int32_t I_MenuRight(void); -extern void I_MenuRightClear(void); - -extern int32_t I_PanelUp(void); -extern void I_PanelUpClear(void); -extern int32_t I_PanelDown(void); -extern void I_PanelDownClear(void); - -extern int32_t I_SliderLeft(void); -extern void I_SliderLeftClear(void); -extern int32_t I_SliderRight(void); -extern void I_SliderRightClear(void); - - -enum EnterTextFlags_t { - INPUT_NUMERIC = 0x00000001, -}; - -extern int32_t I_EnterText(char *t, int32_t maxlength, int32_t flags); - -END_RR_NS - -#endif