mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- moved the application of in_mousebias and in_mousedeadzone into the backend code.
This piece was repeated 6x for each call to CONTROL_GetInput, creating quite a bit of redundancy.
This commit is contained in:
parent
fb5d944170
commit
c561255018
6 changed files with 23 additions and 127 deletions
|
@ -150,27 +150,6 @@ void ctrlGetInput(void)
|
||||||
|
|
||||||
CONTROL_GetInput(&info);
|
CONTROL_GetInput(&info);
|
||||||
|
|
||||||
if (in_mousedeadzone)
|
|
||||||
{
|
|
||||||
if (info.mousey > 0)
|
|
||||||
info.mousey = max(info.mousey - in_mousedeadzone, 0);
|
|
||||||
else if (info.mousey < 0)
|
|
||||||
info.mousey = min(info.mousey + in_mousedeadzone, 0);
|
|
||||||
|
|
||||||
if (info.mousex > 0)
|
|
||||||
info.mousex = max(info.mousex - in_mousedeadzone, 0);
|
|
||||||
else if (info.mousex < 0)
|
|
||||||
info.mousex = min(info.mousex + in_mousedeadzone, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_mousebias)
|
|
||||||
{
|
|
||||||
if (klabs(info.mousex) > klabs(info.mousey))
|
|
||||||
info.mousey = tabledivide32_noinline(info.mousey, in_mousebias);
|
|
||||||
else
|
|
||||||
info.mousex = tabledivide32_noinline(info.mousex, in_mousebias);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gQuitRequest)
|
if (gQuitRequest)
|
||||||
gInput.keyFlags.quit = 1;
|
gInput.keyFlags.quit = 1;
|
||||||
|
|
||||||
|
|
|
@ -97,8 +97,8 @@ EXTERN_CVAR(Bool, in_mouseflip)
|
||||||
EXTERN_CVAR(Bool, in_mousemode)
|
EXTERN_CVAR(Bool, in_mousemode)
|
||||||
EXTERN_CVAR(Bool, in_mousesmoothing)
|
EXTERN_CVAR(Bool, in_mousesmoothing)
|
||||||
EXTERN_CVAR(Float, in_mousesensitivity)
|
EXTERN_CVAR(Float, in_mousesensitivity)
|
||||||
EXTERN_CVAR(Int, in_mousescalex)
|
EXTERN_CVAR(Float, in_mousescalex)
|
||||||
EXTERN_CVAR(Int, in_mousescaley)
|
EXTERN_CVAR(Float, in_mousescaley)
|
||||||
extern int32_t g_MyAimMode;
|
extern int32_t g_MyAimMode;
|
||||||
EXTERN_CVAR(Bool, in_mousemode)
|
EXTERN_CVAR(Bool, in_mousemode)
|
||||||
EXTERN_CVAR(String, wchoice)
|
EXTERN_CVAR(String, wchoice)
|
||||||
|
|
|
@ -47,6 +47,27 @@ void InputState::GetMouseDelta(ControlInfo * info)
|
||||||
//info->mousex = int(finput.x * (4.f) * in_mousesensitivity * in_mouseside);
|
//info->mousex = int(finput.x * (4.f) * in_mousesensitivity * in_mouseside);
|
||||||
//info->mousey = int(finput.y * (4.f) * in_mousesensitivity * in_mouseforward);
|
//info->mousey = int(finput.y * (4.f) * in_mousesensitivity * in_mouseforward);
|
||||||
|
|
||||||
|
if (in_mousedeadzone)
|
||||||
|
{
|
||||||
|
if (info->mousey > 0)
|
||||||
|
info->mousey = max(info->mousey - in_mousedeadzone, 0);
|
||||||
|
else if (info->mousey < 0)
|
||||||
|
info->mousey = min(info->mousey + in_mousedeadzone, 0);
|
||||||
|
|
||||||
|
if (info->mousex > 0)
|
||||||
|
info->mousex = max(info->mousex - in_mousedeadzone, 0);
|
||||||
|
else if (info->mousex < 0)
|
||||||
|
info->mousex = min(info->mousex + in_mousedeadzone, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_mousebias)
|
||||||
|
{
|
||||||
|
if (abs(info->mousex) > abs(info->mousey))
|
||||||
|
info->mousey = tabledivide32_noinline(info->mousey, in_mousebias);
|
||||||
|
else
|
||||||
|
info->mousex = tabledivide32_noinline(info->mousex, in_mousebias);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputState::AddEvent(const event_t *ev)
|
void InputState::AddEvent(const event_t *ev)
|
||||||
|
|
|
@ -2926,27 +2926,6 @@ void P_GetInput(int const playerNum)
|
||||||
|
|
||||||
CONTROL_GetInput(&info);
|
CONTROL_GetInput(&info);
|
||||||
|
|
||||||
if (in_mousedeadzone)
|
|
||||||
{
|
|
||||||
if (info.mousey > 0)
|
|
||||||
info.mousey = max(info.mousey - in_mousedeadzone, 0);
|
|
||||||
else if (info.mousey < 0)
|
|
||||||
info.mousey = min(info.mousey + in_mousedeadzone, 0);
|
|
||||||
|
|
||||||
if (info.mousex > 0)
|
|
||||||
info.mousex = max(info.mousex - in_mousedeadzone, 0);
|
|
||||||
else if (info.mousex < 0)
|
|
||||||
info.mousex = min(info.mousex + in_mousedeadzone, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_mousebias)
|
|
||||||
{
|
|
||||||
if (klabs(info.mousex) > klabs(info.mousey))
|
|
||||||
info.mousey = tabledivide32_noinline(info.mousey, in_mousebias);
|
|
||||||
else
|
|
||||||
info.mousex = tabledivide32_noinline(info.mousex, in_mousebias);
|
|
||||||
}
|
|
||||||
|
|
||||||
// JBF: Run key behaviour is selectable
|
// JBF: Run key behaviour is selectable
|
||||||
int const playerRunning = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
|
int const playerRunning = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
|
||||||
int const turnAmount = playerRunning ? (NORMALTURN << 1) : NORMALTURN;
|
int const turnAmount = playerRunning ? (NORMALTURN << 1) : NORMALTURN;
|
||||||
|
|
|
@ -2774,26 +2774,6 @@ void P_GetInput(int playerNum)
|
||||||
|
|
||||||
CONTROL_GetInput(&info);
|
CONTROL_GetInput(&info);
|
||||||
|
|
||||||
if (in_mousedeadzone)
|
|
||||||
{
|
|
||||||
if (info.mousey > 0)
|
|
||||||
info.mousey = max(info.mousey - in_mousedeadzone, 0);
|
|
||||||
else if (info.mousey < 0)
|
|
||||||
info.mousey = min(info.mousey + in_mousedeadzone, 0);
|
|
||||||
|
|
||||||
if (info.mousex > 0)
|
|
||||||
info.mousex = max(info.mousex - in_mousedeadzone, 0);
|
|
||||||
else if (info.mousex < 0)
|
|
||||||
info.mousex = min(info.mousex + in_mousedeadzone, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_mousebias)
|
|
||||||
{
|
|
||||||
if (klabs(info.mousex) > klabs(info.mousey))
|
|
||||||
info.mousey = tabledivide32_noinline(info.mousey, in_mousebias);
|
|
||||||
else
|
|
||||||
info.mousex = tabledivide32_noinline(info.mousex, in_mousebias);
|
|
||||||
}
|
|
||||||
|
|
||||||
// JBF: Run key behaviour is selectable
|
// JBF: Run key behaviour is selectable
|
||||||
|
|
||||||
|
@ -3080,27 +3060,6 @@ void P_GetInputMotorcycle(int playerNum)
|
||||||
|
|
||||||
CONTROL_GetInput(&info);
|
CONTROL_GetInput(&info);
|
||||||
|
|
||||||
if (in_mousedeadzone)
|
|
||||||
{
|
|
||||||
if (info.mousey > 0)
|
|
||||||
info.mousey = max(info.mousey - in_mousedeadzone, 0);
|
|
||||||
else if (info.mousey < 0)
|
|
||||||
info.mousey = min(info.mousey + in_mousedeadzone, 0);
|
|
||||||
|
|
||||||
if (info.mousex > 0)
|
|
||||||
info.mousex = max(info.mousex - in_mousedeadzone, 0);
|
|
||||||
else if (info.mousex < 0)
|
|
||||||
info.mousex = min(info.mousex + in_mousedeadzone, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_mousebias)
|
|
||||||
{
|
|
||||||
if (klabs(info.mousex) > klabs(info.mousey))
|
|
||||||
info.mousey = tabledivide32_noinline(info.mousey, in_mousebias);
|
|
||||||
else
|
|
||||||
info.mousex = tabledivide32_noinline(info.mousex, in_mousebias);
|
|
||||||
}
|
|
||||||
|
|
||||||
// JBF: Run key behaviour is selectable
|
// JBF: Run key behaviour is selectable
|
||||||
int const playerRunning = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
|
int const playerRunning = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
|
||||||
constexpr int const analogTurnAmount = (NORMALTURN << 1);
|
constexpr int const analogTurnAmount = (NORMALTURN << 1);
|
||||||
|
@ -3378,27 +3337,6 @@ void P_GetInputBoat(int playerNum)
|
||||||
|
|
||||||
CONTROL_GetInput(&info);
|
CONTROL_GetInput(&info);
|
||||||
|
|
||||||
if (in_mousedeadzone)
|
|
||||||
{
|
|
||||||
if (info.mousey > 0)
|
|
||||||
info.mousey = max(info.mousey - in_mousedeadzone, 0);
|
|
||||||
else if (info.mousey < 0)
|
|
||||||
info.mousey = min(info.mousey + in_mousedeadzone, 0);
|
|
||||||
|
|
||||||
if (info.mousex > 0)
|
|
||||||
info.mousex = max(info.mousex - in_mousedeadzone, 0);
|
|
||||||
else if (info.mousex < 0)
|
|
||||||
info.mousex = min(info.mousex + in_mousedeadzone, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_mousebias)
|
|
||||||
{
|
|
||||||
if (klabs(info.mousex) > klabs(info.mousey))
|
|
||||||
info.mousey = tabledivide32_noinline(info.mousey, in_mousebias);
|
|
||||||
else
|
|
||||||
info.mousex = tabledivide32_noinline(info.mousex, in_mousebias);
|
|
||||||
}
|
|
||||||
|
|
||||||
// JBF: Run key behaviour is selectable
|
// JBF: Run key behaviour is selectable
|
||||||
int const playerRunning = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
|
int const playerRunning = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
|
||||||
constexpr int const analogTurnAmount = (NORMALTURN << 1);
|
constexpr int const analogTurnAmount = (NORMALTURN << 1);
|
||||||
|
|
|
@ -3545,27 +3545,6 @@ void getinput(SW_PACKET *loc)
|
||||||
ControlInfo info;
|
ControlInfo info;
|
||||||
CONTROL_GetInput(&info);
|
CONTROL_GetInput(&info);
|
||||||
|
|
||||||
if (in_mousedeadzone)
|
|
||||||
{
|
|
||||||
if (info.mousey > 0)
|
|
||||||
info.mousey = max(info.mousey - in_mousedeadzone, 0);
|
|
||||||
else if (info.mousey < 0)
|
|
||||||
info.mousey = min(info.mousey + in_mousedeadzone, 0);
|
|
||||||
|
|
||||||
if (info.mousex > 0)
|
|
||||||
info.mousex = max(info.mousex - in_mousedeadzone, 0);
|
|
||||||
else if (info.mousex < 0)
|
|
||||||
info.mousex = min(info.mousex + in_mousedeadzone, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_mousebias)
|
|
||||||
{
|
|
||||||
if (klabs(info.mousex) > klabs(info.mousey))
|
|
||||||
info.mousey = tabledivide32_noinline(info.mousey, in_mousebias);
|
|
||||||
else
|
|
||||||
info.mousex = tabledivide32_noinline(info.mousex, in_mousebias);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//info.dz = (info.dz * move_scale)>>8;
|
//info.dz = (info.dz * move_scale)>>8;
|
||||||
//info.dyaw = (info.dyaw * turn_scale)>>8;
|
//info.dyaw = (info.dyaw * turn_scale)>>8;
|
||||||
|
|
Loading…
Reference in a new issue