Skip to content

Commit

Permalink
re-added inp_grab to support old mouse warping input. closes #1910
Browse files Browse the repository at this point in the history
  • Loading branch information
oy committed Dec 24, 2018
1 parent 35aa848 commit 8f2f42e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/engine/client/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <base/system.h>
#include <engine/shared/config.h>
#include <engine/console.h>
#include <engine/graphics.h>
#include <engine/input.h>
#include <engine/keys.h>
Expand Down Expand Up @@ -48,6 +49,7 @@ CInput::CInput()
void CInput::Init()
{
m_pGraphics = Kernel()->RequestInterface<IEngineGraphics>();
m_pConsole = Kernel()->RequestInterface<IConsole>();
// FIXME: unicode handling: use SDL_StartTextInput/SDL_StopTextInput on inputs

MouseModeRelative();
Expand Down Expand Up @@ -83,6 +85,10 @@ void CInput::MouseModeRelative()
{
m_InputGrabbed = 1;
SDL_ShowCursor(SDL_DISABLE);
if(SDL_SetHintWithPriority(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, g_Config.m_InpGrab ? "0" : "1", SDL_HINT_OVERRIDE) == SDL_FALSE)
{
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "input", "unable to switch relative mouse mode");
}
SDL_SetRelativeMouseMode(SDL_TRUE);
SDL_GetRelativeMouseState(NULL, NULL);
}
Expand Down
1 change: 1 addition & 0 deletions src/engine/client/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
class CInput : public IEngineInput
{
IEngineGraphics *m_pGraphics;
IConsole *m_pConsole;

int m_InputGrabbed;

Expand Down
1 change: 1 addition & 0 deletions src/engine/shared/config_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ MACRO_CONFIG_INT(GfxAsyncRender, gfx_asyncrender, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_
MACRO_CONFIG_INT(GfxMaxFps, gfx_maxfps, 144, 30, 2000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Maximum fps (when limit fps is enabled)")
MACRO_CONFIG_INT(GfxLimitFps, gfx_limitfps, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Limit fps")

MACRO_CONFIG_INT(InpGrab, inp_grab, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Use forceful input grabbing method")
MACRO_CONFIG_INT(InpMousesens, inp_mousesens, 100, 5, 100000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Mouse sensitivity")

MACRO_CONFIG_STR(SvName, sv_name, 128, "unnamed server", CFGFLAG_SAVE|CFGFLAG_SERVER, "Server name")
Expand Down

1 comment on commit 8f2f42e

@ChillerDragon
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yay

Please sign in to comment.