diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index eb152ae8a..99addcf4a 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -43,11 +43,6 @@ bool bSilentAim = false; int iTurnCount = 0; -int32_t GetTime(void) -{ - return (int32_t)totalclock; -} - void ctrlInit(void) { } diff --git a/source/build/include/baselayer.h b/source/build/include/baselayer.h index 3133dc055..62e9abed6 100644 --- a/source/build/include/baselayer.h +++ b/source/build/include/baselayer.h @@ -45,64 +45,14 @@ int32_t videoUpdatePalette(int32_t start, int32_t num); void videoBeginDrawing(void); - -#define GAMMA_CALC ((int32_t)(min(max((float)((vid_gamma - 1.0f) * 10.0f), 0.f), 15.f))) - -#ifdef USE_OPENGL -extern int osdcmd_glinfo(osdcmdptr_t parm); - - -#endif - -vec2_t CONSTEXPR const g_defaultVideoModes [] -= { { 2560, 1440 }, { 2560, 1200 }, { 2560, 1080 }, { 1920, 1440 }, { 1920, 1200 }, { 1920, 1080 }, { 1680, 1050 }, - { 1600, 1200 }, { 1600, 900 }, { 1366, 768 }, { 1280, 1024 }, { 1280, 960 }, { 1280, 720 }, { 1152, 864 }, - { 1024, 768 }, { 1024, 600 }, { 800, 600 }, { 640, 480 }, { 640, 400 }, { 512, 384 }, { 480, 360 }, - { 400, 300 }, { 320, 240 }, { 320, 200 }, { 0, 0 } }; - -extern char inputdevices; - -// keys -#define KEYFIFOSIZ 64 - -// mouse - -// joystick - -typedef struct -{ - int32_t *pAxis; - int32_t *pHat; - void (*pCallback)(int32_t, int32_t); - int32_t bits; - int32_t numAxes; - int32_t numBalls; - int32_t numButtons; - int32_t numHats; - int32_t isGameController; -} controllerinput_t; - -extern controllerinput_t joystick; - extern int32_t qsetmode; #define in3dmode() (qsetmode==200) extern int32_t g_logFlushWindow; -void I_StartTic(); - -inline int32_t handleevents(void) -{ - timerUpdateClock(); - I_StartTic(); - return 0; -} - void mouseGrabInput(bool grab); -extern int32_t inputchecked; - void getScreen(uint8_t* imgBuf); diff --git a/source/build/src/baselayer.cpp b/source/build/src/baselayer.cpp index e6ccc17b3..11f4d3680 100644 --- a/source/build/src/baselayer.cpp +++ b/source/build/src/baselayer.cpp @@ -12,20 +12,8 @@ #include "d_event.h" #include "../../glbackend/glbackend.h" -int32_t g_borderless=2; int GUICapture = false; -// input -char inputdevices = 0; - - -bool g_mouseEnabled; -bool g_mouseGrabbed; -bool g_mouseInsideWindow = 1; -bool g_mouseLockedToWindow = 1; - -controllerinput_t joystick; - // Calculate ylookup[] and call setvlinebpl() void calc_ylookup(int32_t bpl, int32_t lastyidx) diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp index 42531b83f..8f124b3d8 100644 --- a/source/build/src/sdlayer.cpp +++ b/source/build/src/sdlayer.cpp @@ -72,13 +72,9 @@ unsigned char syncstate; //#define SDL_WM_GrabInput(x) SDL_WM_GrabInput(SDL_GRAB_OFF) //#define SDL_ShowCursor(x) SDL_ShowCursor(SDL_ENABLE) -#define SURFACE_FLAGS (SDL_SWSURFACE|SDL_HWPALETTE|SDL_HWACCEL) - // undefine to restrict windowed resolutions to conventional sizes #define ANY_WINDOWED_SIZE -// fix for mousewheel -int32_t inputchecked = 0; bool screenshot_requested; char appactive=1, novideo=0; diff --git a/source/common/console/d_event.cpp b/source/common/console/d_event.cpp index aa1772d18..bcfe7e42e 100644 --- a/source/common/console/d_event.cpp +++ b/source/common/console/d_event.cpp @@ -132,21 +132,12 @@ void D_PostEvent (const event_t *ev) return; } - if (ev->type == EV_Mouse && GUICapture == 0 && appactive && g_mouseGrabbed) + if (ev->type == EV_Mouse && GUICapture == 0 && appactive) { inputState.MouseAddToPos(ev->x / 3, -ev->y / 2); return; } - else if (ev->type == EV_GUI_Event && ev->subtype == EV_GUI_MouseMove && appactive && GUICapture == 0 && !g_mouseGrabbed) - { - inputState.MouseSetAbs(ev->data1, ev->data2); - return; - } - // Add the key to the global keyboard state. - // This is probably the biggest roadblock with the input system as it undermines a proper event driven approach. - // Too much code depends on just checking this instead of waiting for events to happen. - // Here's also definitely not the best place to maintain the keyboard state but right now it's unavoidable to do this outside the event processing because so much code depends on it. inputState.AddEvent(ev); // Also add it to the event queue. diff --git a/source/common/inputstate.cpp b/source/common/inputstate.cpp index 4376b1f56..e46bbd90c 100644 --- a/source/common/inputstate.cpp +++ b/source/common/inputstate.cpp @@ -3,26 +3,10 @@ #include "build.h" #include "gamecvars.h" -int32_t InputState::mouseReadAbs(vec2_t * const pResult) -{ - auto pInput = &g_mouseAbs; - if (!g_mouseEnabled || !appactive || !g_mouseInsideWindow || GUICapture) - return 0; - - int32_t const xwidth = max(scale(240<<16, screen->GetWidth(), screen->GetHeight()), 320<<16); - - pResult->x = scale(pInput->x, xwidth, xres) - ((xwidth>>1) - (320<<15)); - pResult->y = scale(pInput->y, 200<<16, yres); - - pResult->y = divscale16(pResult->y - (200<<15), rotatesprite_yxaspect) + (200<<15) - rotatesprite_y_offset; - - return 1; -} - void InputState::GetMouseDelta(ControlInfo * info) { vec2_t input; - if (!g_mouseEnabled || !g_mouseGrabbed || !appactive) + if (!appactive) { input = {0,0}; return; @@ -78,3 +62,56 @@ void InputState::AddEvent(const event_t *ev) if (ev->data2) keySetChar(ev->data2); } } + +void I_StartTic(); + +int32_t handleevents(void) +{ + timerUpdateClock(); + + // The mouse wheel is not a real key so in order to be "pressed" it may only be cleared at the end of the tic (or the start of the next.) + if (inputState.GetKeyStatus(KEY_MWHEELUP)) + { + event_t ev = { EV_KeyUp, 0, (int16_t)KEY_MWHEELUP }; + D_PostEvent(&ev); + } + if (inputState.GetKeyStatus(KEY_MWHEELDOWN)) + { + event_t ev = { EV_KeyUp, 0, (int16_t)KEY_MWHEELDOWN }; + D_PostEvent(&ev); + } + if (inputState.GetKeyStatus(KEY_MWHEELLEFT)) + { + event_t ev = { EV_KeyUp, 0, (int16_t)KEY_MWHEELLEFT }; + D_PostEvent(&ev); + } + if (inputState.GetKeyStatus(KEY_MWHEELRIGHT)) + { + event_t ev = { EV_KeyUp, 0, (int16_t)KEY_MWHEELRIGHT }; + D_PostEvent(&ev); + } + + I_StartTic(); + return 0; +} + +void CONTROL_GetInput(ControlInfo* info) +{ + memset(info, 0, sizeof(ControlInfo)); + + if (in_mouse) + inputState.GetMouseDelta(info); + + if (in_joystick) + { + // Handle joysticks/game controllers. + float joyaxes[NUM_JOYAXIS]; + + I_GetAxes(joyaxes); + + info->dyaw += joyaxes[JOYAXIS_Yaw]; + info->dx += joyaxes[JOYAXIS_Side]; + info->dz += joyaxes[JOYAXIS_Forward]; + info->dpitch += joyaxes[JOYAXIS_Pitch]; + } +} diff --git a/source/common/inputstate.h b/source/common/inputstate.h index fc42f2dff..d43b4818e 100644 --- a/source/common/inputstate.h +++ b/source/common/inputstate.h @@ -17,39 +17,6 @@ extern int GUICapture; // This encapsulates the entire game-readable input state which previously was spread out across several files. -enum -{ - MAXMOUSEBUTTONS = 10, -}; - -extern bool g_mouseGrabbed; -extern bool g_mouseEnabled; -extern bool g_mouseInsideWindow; -extern bool g_mouseLockedToWindow; - - - -enum EMouseBits -{ - LEFT_MOUSE = 1, - RIGHT_MOUSE = 2, - MIDDLE_MOUSE = 4, - THUMB_MOUSE = 8, - WHEELUP_MOUSE = 16, - WHEELDOWN_MOUSE= 32, - THUMB2_MOUSE = 64, - WHEELLEFT_MOUSE = 128, - WHEELRIGHT_MOUSE = 256, -}; - -enum -{ - MOUSE_IDLE = 0, - MOUSE_PRESSED, - MOUSE_HELD, - MOUSE_RELEASED, -}; - struct ControlInfo { int32_t dx; @@ -82,7 +49,6 @@ class InputState kb_scancode KB_LastScan; vec2_t g_mousePos; - vec2_t g_mouseAbs; public: @@ -241,17 +207,12 @@ public: g_mousePos.x += x; g_mousePos.y += y; } - void MouseSetAbs(int x, int y) - { - g_mouseAbs = { x, y }; - } bool gamePadActive() { // fixme: This needs to be tracked. return false; } - int32_t mouseReadAbs(vec2_t* const pResult); void GetMouseDelta(ControlInfo* info); void ClearAllInput() @@ -273,26 +234,9 @@ public: extern InputState inputState; -inline void CONTROL_GetInput(ControlInfo* info) -{ - memset(info, 0, sizeof(ControlInfo)); +void CONTROL_GetInput(ControlInfo* info); +int32_t handleevents(void); - if (in_mouse) - inputState.GetMouseDelta(info); - - if (in_joystick) - { - // Handle joysticks/game controllers. - float joyaxes[NUM_JOYAXIS]; - - I_GetAxes(joyaxes); - - info->dyaw += joyaxes[JOYAXIS_Yaw]; - info->dx += joyaxes[JOYAXIS_Side]; - info->dz += joyaxes[JOYAXIS_Forward]; - info->dpitch += joyaxes[JOYAXIS_Pitch]; - } -} #define WIN_IS_PRESSED ( inputState.WinPressed() ) #define ALT_IS_PRESSED ( inputState.AltPressed() ) diff --git a/source/sw/CMakeLists.txt b/source/sw/CMakeLists.txt index d64f1b649..dbee7430c 100644 --- a/source/sw/CMakeLists.txt +++ b/source/sw/CMakeLists.txt @@ -83,7 +83,6 @@ set( PCH_SOURCES src/scrip2.cpp src/sector.cpp src/serp.cpp - src/setup.cpp src/skel.cpp src/skull.cpp src/slidor.cpp diff --git a/source/sw/src/setup.cpp b/source/sw/src/setup.cpp deleted file mode 100644 index fe8e17c1d..000000000 --- a/source/sw/src/setup.cpp +++ /dev/null @@ -1,85 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 1997, 2005 - 3D Realms Entertainment - -This file is part of Shadow Warrior version 1.2 - -Shadow Warrior 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: 1997 - Frank Maddin and Jim Norwood -Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms -*/ -//------------------------------------------------------------------------- -#include "ns.h" -#include "build.h" - -#include "keys.h" -#include "game.h" - -#include "mytypes.h" -#include "gamedefs.h" - -#include "config.h" -#include "sounds.h" -#include "gamecontrol.h" - -#include "rts.h" - -BEGIN_SW_NS - -void CenterCenter(void) -{ - printf("\nCenter the joystick and press a button\n"); -} - -void UpperLeft(void) -{ - printf("Move joystick to upper-left corner and press a button\n"); -} - -void LowerRight(void) -{ - printf("Move joystick to lower-right corner and press a button\n"); -} - -void CenterThrottle(void) -{ - printf("Center the throttle control and press a button\n"); -} - -void CenterRudder(void) -{ - printf("Center the rudder control and press a button\n"); -} - -/* -=================== -= -= GetTime -= -=================== -*/ - -static int32_t timert; - -int32_t GetTime(void) -{ - return (int32_t) totalclock; - //return timert++; -} - - -END_SW_NS