mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-03-03 15:31:11 +00:00
- change mouse input from int to float and adjust games accordingly.
* Calculate game-side mousex/mousey divisions into the calculations performed in `InputState::GetMouseDelta()`. * Fix mouse speed when `in_mousesmoothing` is true (wasn't factoring in / 3.f division used in non-true vector. * Standard mouse forward/side movement speeds in Exhumed & SW with that of other games. * Remove `strafeyaw` code from Duke/Exhumed/RR as it's not necessary and was leading to situations where the player would continually keep moving sideways even without input. * Change mouse forward/side velocities to -= current value as is done with controller input and the player's angle/aim velocities.
This commit is contained in:
parent
bb57590d34
commit
c70cc474a0
7 changed files with 42 additions and 60 deletions
|
@ -366,16 +366,12 @@ void ctrlGetInput(void)
|
||||||
|
|
||||||
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
||||||
{
|
{
|
||||||
static int strafeyaw;
|
input.strafe -= info.mousex * 32.f;
|
||||||
|
|
||||||
input.strafe = -(info.mousex + strafeyaw) >> 3;
|
|
||||||
strafeyaw = (info.mousex + strafeyaw) % 8;
|
|
||||||
|
|
||||||
input.strafe -= scaleAdjustmentToInterval(info.dyaw * keyMove);
|
input.strafe -= scaleAdjustmentToInterval(info.dyaw * keyMove);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
input.q16turn = fix16_sadd(input.q16turn, fix16_sdiv(fix16_from_int(info.mousex), fix16_from_int(32)));
|
input.q16turn = fix16_sadd(input.q16turn, fix16_from_float(info.mousex));
|
||||||
input.q16turn = fix16_sadd(input.q16turn, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw)));
|
input.q16turn = fix16_sadd(input.q16turn, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,9 +379,9 @@ void ctrlGetInput(void)
|
||||||
input.forward -= scaleAdjustmentToInterval(info.dz * keyMove);
|
input.forward -= scaleAdjustmentToInterval(info.dz * keyMove);
|
||||||
|
|
||||||
if (mouseaim)
|
if (mouseaim)
|
||||||
input.q16mlook = fix16_sadd(input.q16mlook, fix16_sdiv(fix16_from_int(info.mousey), fix16_from_float(mlookScale * 64.f)));
|
input.q16mlook = fix16_sadd(input.q16mlook, fix16_from_float(info.mousey / mlookScale));
|
||||||
else
|
else
|
||||||
input.forward -= info.mousey;
|
input.forward -= info.mousey * 64.f;
|
||||||
if (!in_mouseflip)
|
if (!in_mouseflip)
|
||||||
input.q16mlook = -input.q16mlook;
|
input.q16mlook = -input.q16mlook;
|
||||||
|
|
||||||
|
|
|
@ -46,22 +46,24 @@
|
||||||
|
|
||||||
void InputState::GetMouseDelta(ControlInfo * info)
|
void InputState::GetMouseDelta(ControlInfo * info)
|
||||||
{
|
{
|
||||||
vec2_t input;
|
vec2f_t input, finput;
|
||||||
|
|
||||||
input = g_mousePos;
|
input = g_mousePos;
|
||||||
g_mousePos = {};
|
g_mousePos = {};
|
||||||
|
|
||||||
vec2f_t finput = { float(input.x) / 3.0f, float(input.y) };
|
|
||||||
|
|
||||||
if (in_mousesmoothing)
|
if (in_mousesmoothing)
|
||||||
{
|
{
|
||||||
static vec2_t last;
|
static vec2f_t last;
|
||||||
finput = { float(input.x + last.x) * 0.5f, float(input.y + last.y) * 0.5f };
|
finput = { (input.x + last.x) * 0.5f, (input.y + last.y) * 0.5f };
|
||||||
last = input;
|
last = input;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
finput = { input.x, input.y };
|
||||||
|
}
|
||||||
|
|
||||||
info->mousex = int(finput.x * (16.f) * in_mousesensitivity * in_mousescalex);
|
info->mousex = finput.x * (16.f / 32.f) * in_mousesensitivity * in_mousescalex / 3.f;
|
||||||
info->mousey = int(finput.y * (16.f) * in_mousesensitivity * in_mousescaley);
|
info->mousey = finput.y * (16.f / 64.f) * in_mousesensitivity * in_mousescaley;
|
||||||
|
|
||||||
// todo: Use these when the mouse is used for moving instead of turning.
|
// todo: Use these when the mouse is used for moving instead of turning.
|
||||||
//info->mousex = int(finput.x * (4.f) * in_mousesensitivity * in_mouseside);
|
//info->mousex = int(finput.x * (4.f) * in_mousesensitivity * in_mouseside);
|
||||||
|
@ -69,7 +71,7 @@ void InputState::GetMouseDelta(ControlInfo * info)
|
||||||
|
|
||||||
if (in_mousebias)
|
if (in_mousebias)
|
||||||
{
|
{
|
||||||
if (abs(info->mousex) > abs(info->mousey))
|
if (fabs(info->mousex) > fabs(info->mousey))
|
||||||
info->mousey /= in_mousebias;
|
info->mousey /= in_mousebias;
|
||||||
else
|
else
|
||||||
info->mousex /= in_mousebias;
|
info->mousex /= in_mousebias;
|
||||||
|
|
|
@ -21,8 +21,8 @@ struct ControlInfo
|
||||||
float dyaw;
|
float dyaw;
|
||||||
float dpitch;
|
float dpitch;
|
||||||
float droll;
|
float droll;
|
||||||
int32_t mousex;
|
float mousex;
|
||||||
int32_t mousey;
|
float mousey;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class InputState
|
||||||
uint8_t g_keyAsciiPos;
|
uint8_t g_keyAsciiPos;
|
||||||
uint8_t g_keyAsciiEnd;
|
uint8_t g_keyAsciiEnd;
|
||||||
|
|
||||||
vec2_t g_mousePos;
|
vec2f_t g_mousePos;
|
||||||
|
|
||||||
void keySetState(int32_t key, int32_t state);
|
void keySetState(int32_t key, int32_t state);
|
||||||
|
|
||||||
|
@ -140,11 +140,11 @@ public:
|
||||||
|
|
||||||
void AddEvent(const event_t* ev);
|
void AddEvent(const event_t* ev);
|
||||||
|
|
||||||
void MouseSetPos(int x, int y)
|
void MouseSetPos(float x, float y)
|
||||||
{
|
{
|
||||||
g_mousePos = { x, y };
|
g_mousePos = { x, y };
|
||||||
}
|
}
|
||||||
void MouseAddToPos(int x, int y)
|
void MouseAddToPos(float x, float y)
|
||||||
{
|
{
|
||||||
g_mousePos.x += x;
|
g_mousePos.x += x;
|
||||||
g_mousePos.y += y;
|
g_mousePos.y += y;
|
||||||
|
|
|
@ -3090,23 +3090,19 @@ void P_GetInput(int const playerNum)
|
||||||
|
|
||||||
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
||||||
{
|
{
|
||||||
static int strafeyaw;
|
input.svel -= info.mousex * 4.f;
|
||||||
|
|
||||||
input.svel = -(info.mousex + strafeyaw) >> 3;
|
|
||||||
strafeyaw = (info.mousex + strafeyaw) % 8;
|
|
||||||
|
|
||||||
input.svel -= scaleAdjustmentToInterval(info.dyaw * keyMove);
|
input.svel -= scaleAdjustmentToInterval(info.dyaw * keyMove);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), F16(32)));
|
input.q16avel = fix16_sadd(input.q16avel, fix16_from_float(info.mousex));
|
||||||
input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw)));
|
input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mouseaim)
|
if (mouseaim)
|
||||||
input.q16horz = fix16_sadd(input.q16horz, fix16_sdiv(fix16_from_int(info.mousey), F16(64)));
|
input.q16horz = fix16_sadd(input.q16horz, fix16_from_float(info.mousey));
|
||||||
else
|
else
|
||||||
input.fvel = -(info.mousey >> 3);
|
input.fvel -= info.mousey * 8.f;
|
||||||
|
|
||||||
if (!in_mouseflip) input.q16horz = -input.q16horz;
|
if (!in_mouseflip) input.q16horz = -input.q16horz;
|
||||||
|
|
||||||
|
|
|
@ -191,25 +191,21 @@ void PlayerInterruptKeys()
|
||||||
|
|
||||||
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
||||||
{
|
{
|
||||||
static int strafeyaw;
|
input.xVel -= info.mousex * 4.f;
|
||||||
|
|
||||||
input.xVel = -(info.mousex + strafeyaw) >> 6;
|
|
||||||
strafeyaw = (info.mousex + strafeyaw) % 64;
|
|
||||||
|
|
||||||
input.xVel -= info.dyaw * keyMove;
|
input.xVel -= info.dyaw * keyMove;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
input.nAngle = fix16_sadd(input.nAngle, fix16_sdiv(fix16_from_int(info.mousex), fix16_from_int(32)));
|
input.nAngle = fix16_sadd(input.nAngle, fix16_from_float(info.mousex));
|
||||||
input.nAngle = fix16_sadd(input.nAngle, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw)));
|
input.nAngle = fix16_sadd(input.nAngle, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw)));
|
||||||
}
|
}
|
||||||
|
|
||||||
g_MyAimMode = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming);
|
g_MyAimMode = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming);
|
||||||
|
|
||||||
if (g_MyAimMode)
|
if (g_MyAimMode)
|
||||||
input.horizon = fix16_sadd(input.horizon, fix16_sdiv(fix16_from_int(info.mousey), fix16_from_int(64)));
|
input.horizon = fix16_sadd(input.horizon, fix16_from_float(info.mousey));
|
||||||
else
|
else
|
||||||
input.yVel = -(info.mousey >> 6);
|
input.yVel -= info.mousey * 8.f;
|
||||||
|
|
||||||
if (!in_mouseflip) input.horizon = -input.horizon;
|
if (!in_mouseflip) input.horizon = -input.horizon;
|
||||||
|
|
||||||
|
|
|
@ -3260,23 +3260,19 @@ void P_GetInput(int const playerNum)
|
||||||
|
|
||||||
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
||||||
{
|
{
|
||||||
static int strafeyaw;
|
input.svel -= info.mousex * 4.f;
|
||||||
|
|
||||||
input.svel = -(info.mousex + strafeyaw) >> 3;
|
|
||||||
strafeyaw = (info.mousex + strafeyaw) % 8;
|
|
||||||
|
|
||||||
input.svel -= scaleAdjustmentToInterval(info.dyaw * keyMove);
|
input.svel -= scaleAdjustmentToInterval(info.dyaw * keyMove);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), F16(32)));
|
input.q16avel = fix16_sadd(input.q16avel, fix16_from_float(info.mousex));
|
||||||
input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw)));
|
input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mouseaim)
|
if (mouseaim)
|
||||||
input.q16horz = fix16_sadd(input.q16horz, fix16_sdiv(fix16_from_int(info.mousey), F16(64)));
|
input.q16horz = fix16_sadd(input.q16horz, fix16_from_float(info.mousey));
|
||||||
else
|
else
|
||||||
input.fvel = -(info.mousey >> 3);
|
input.fvel -= info.mousey * 8.f;
|
||||||
|
|
||||||
if (!in_mouseflip) input.q16horz = -input.q16horz;
|
if (!in_mouseflip) input.q16horz = -input.q16horz;
|
||||||
|
|
||||||
|
@ -3671,7 +3667,7 @@ void P_GetInputMotorcycle(int playerNum)
|
||||||
|
|
||||||
input_t input {};
|
input_t input {};
|
||||||
|
|
||||||
input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), F16(32)));
|
input.q16avel = fix16_sadd(input.q16avel, fix16_from_float(info.mousex));
|
||||||
input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw)));
|
input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw)));
|
||||||
|
|
||||||
input.svel -= scaleAdjustmentToInterval(info.dx * keyMove);
|
input.svel -= scaleAdjustmentToInterval(info.dx * keyMove);
|
||||||
|
@ -3920,7 +3916,7 @@ void P_GetInputBoat(int playerNum)
|
||||||
|
|
||||||
input_t input {};
|
input_t input {};
|
||||||
|
|
||||||
input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), F16(32)));
|
input.q16avel = fix16_sadd(input.q16avel, fix16_from_float(info.mousex));
|
||||||
input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw)));
|
input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw)));
|
||||||
|
|
||||||
input.svel -= scaleAdjustmentToInterval(info.dx * keyMove);
|
input.svel -= scaleAdjustmentToInterval(info.dx * keyMove);
|
||||||
|
@ -4162,23 +4158,19 @@ void P_DHGetInput(int const playerNum)
|
||||||
|
|
||||||
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
||||||
{
|
{
|
||||||
static int strafeyaw;
|
input.svel -= info.mousex * 4.f;
|
||||||
|
|
||||||
input.svel = -(info.mousex + strafeyaw) >> 3;
|
|
||||||
strafeyaw = (info.mousex + strafeyaw) % 8;
|
|
||||||
|
|
||||||
input.svel -= scaleAdjustmentToInterval(info.dyaw * keyMove);
|
input.svel -= scaleAdjustmentToInterval(info.dyaw * keyMove);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), F16(32)));
|
input.q16avel = fix16_sadd(input.q16avel, fix16_from_float(info.mousex));
|
||||||
input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw)));
|
input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mouseaim)
|
if (mouseaim)
|
||||||
input.q16horz = fix16_sadd(input.q16horz, fix16_sdiv(fix16_from_int(info.mousey), F16(64)));
|
input.q16horz = fix16_sadd(input.q16horz, fix16_from_float(info.mousey));
|
||||||
else
|
else
|
||||||
input.fvel = -(info.mousey >> 3);
|
input.fvel -= info.mousey * 8.f;
|
||||||
|
|
||||||
if (!in_mouseflip) input.q16horz = -input.q16horz;
|
if (!in_mouseflip) input.q16horz = -input.q16horz;
|
||||||
|
|
||||||
|
|
|
@ -3030,19 +3030,19 @@ getinput(SW_PACKET *loc, SWBOOL tied)
|
||||||
|
|
||||||
if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop)
|
if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop)
|
||||||
{
|
{
|
||||||
svel = -info.mousex;
|
svel -= (info.mousex * ticrateScale) * 4.f;
|
||||||
svel -= info.dyaw * keymove;
|
svel -= info.dyaw * keymove;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
q16angvel = fix16_div(fix16_from_int(info.mousex), fix16_from_float(angvelScale * 32.f));
|
q16angvel = fix16_sadd(q16angvel, fix16_from_float(info.mousex / angvelScale));
|
||||||
q16angvel += fix16_from_dbl(scaleAdjustmentToInterval((info.dyaw * ticrateScale) / angvelScale));
|
q16angvel = fix16_sadd(q16angvel, fix16_from_dbl(scaleAdjustmentToInterval((info.dyaw * ticrateScale) / angvelScale)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mouseaim)
|
if (mouseaim)
|
||||||
q16aimvel = -fix16_div(fix16_from_int(info.mousey), fix16_from_float(aimvelScale * 64.f));
|
q16aimvel = fix16_ssub(q16aimvel, fix16_from_float(info.mousey / aimvelScale));
|
||||||
else
|
else
|
||||||
vel = -(info.mousey >> 6);
|
vel -= (info.mousey * ticrateScale) * 8.f;
|
||||||
|
|
||||||
if (in_mouseflip)
|
if (in_mouseflip)
|
||||||
q16aimvel = -q16aimvel;
|
q16aimvel = -q16aimvel;
|
||||||
|
|
Loading…
Reference in a new issue