mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 18:50:46 +00:00
Fix how analog axis values are used by the game code, part 2: aiming.
Mouse movement is no longer funneled through analog axis handling. git-svn-id: https://svn.eduke32.com/eduke32@7947 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
f1e67616a9
commit
c40a4b26ff
4 changed files with 25 additions and 22 deletions
|
@ -267,7 +267,7 @@ static const char * mouseclickeddefaults[MAXMOUSEBUTTONS] =
|
||||||
|
|
||||||
static const char * mouseanalogdefaults[MAXMOUSEAXES] =
|
static const char * mouseanalogdefaults[MAXMOUSEAXES] =
|
||||||
{
|
{
|
||||||
"analog_turning",
|
"analog_strafing",
|
||||||
"analog_moving",
|
"analog_moving",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2916,14 +2916,6 @@ void P_GetInput(int const playerNum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t const aimMode = (g_myAimMode) ? (int32_t)analog_lookingupanddown : ud.config.MouseAnalogueAxes[1];
|
|
||||||
|
|
||||||
if (aimMode != mouseyaxismode)
|
|
||||||
{
|
|
||||||
CONTROL_MapAnalogAxis(1, aimMode, controldevice_mouse);
|
|
||||||
mouseyaxismode = aimMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
CONTROL_GetInput(&info);
|
CONTROL_GetInput(&info);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -2952,6 +2944,9 @@ void P_GetInput(int const playerNum)
|
||||||
|
|
||||||
// JBF: Run key behaviour is selectable
|
// JBF: Run key behaviour is selectable
|
||||||
int const playerRunning = (ud.runkey_mode) ? (BUTTON(gamefunc_Run) | ud.auto_run) : (ud.auto_run ^ BUTTON(gamefunc_Run));
|
int const playerRunning = (ud.runkey_mode) ? (BUTTON(gamefunc_Run) | ud.auto_run) : (ud.auto_run ^ BUTTON(gamefunc_Run));
|
||||||
|
int const turnAmount = playerRunning ? (NORMALTURN << 1) : NORMALTURN;
|
||||||
|
int const keyMove = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE;
|
||||||
|
constexpr int const analogExtent = 10000; // KEEPINSYNC sdlayer.cpp
|
||||||
|
|
||||||
input_t input {};
|
input_t input {};
|
||||||
|
|
||||||
|
@ -2959,21 +2954,27 @@ void P_GetInput(int const playerNum)
|
||||||
{
|
{
|
||||||
static int strafeyaw;
|
static int strafeyaw;
|
||||||
|
|
||||||
input.svel = -(info.dyaw + strafeyaw) >> 3;
|
input.svel = -(info.mousex + strafeyaw) >> 3;
|
||||||
strafeyaw = (info.dyaw + strafeyaw) % 8;
|
strafeyaw = (info.mousex + strafeyaw) % 8;
|
||||||
|
|
||||||
|
input.svel -= info.dyaw * keyMove / analogExtent;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
input.q16avel = fix16_div(fix16_from_int(info.dyaw), F16(32));
|
{
|
||||||
|
input.q16avel = fix16_div(fix16_from_int(info.mousex), F16(32));
|
||||||
|
input.q16avel += fix16_from_int(info.dyaw * turnAmount / analogExtent);
|
||||||
|
}
|
||||||
|
|
||||||
input.q16horz = fix16_div(fix16_from_int(info.dpitch), F16(64));
|
if (g_myAimMode)
|
||||||
|
input.q16horz = fix16_div(fix16_from_int(info.mousey), F16(64));
|
||||||
|
else
|
||||||
|
input.fvel = -(info.mousey >> 6);
|
||||||
|
|
||||||
if (ud.mouseflip) input.q16horz = -input.q16horz;
|
if (ud.mouseflip) input.q16horz = -input.q16horz;
|
||||||
|
|
||||||
int const turnAmount = playerRunning ? (NORMALTURN << 1) : NORMALTURN;
|
input.q16horz -= fix16_from_int(info.dpitch * turnAmount / analogExtent);
|
||||||
int const keyMove = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE;
|
input.svel -= info.dx * keyMove / analogExtent;
|
||||||
|
input.fvel -= info.dz * keyMove / analogExtent;
|
||||||
input.svel -= (info.dx * keyMove / 10000);
|
|
||||||
input.fvel = -(info.dz * keyMove / 10000);
|
|
||||||
|
|
||||||
if (BUTTON(gamefunc_Strafe))
|
if (BUTTON(gamefunc_Strafe))
|
||||||
{
|
{
|
||||||
|
|
|
@ -108,6 +108,8 @@ typedef struct
|
||||||
int32_t dyaw;
|
int32_t dyaw;
|
||||||
int32_t dpitch;
|
int32_t dpitch;
|
||||||
int32_t droll;
|
int32_t droll;
|
||||||
|
int32_t mousex;
|
||||||
|
int32_t mousey;
|
||||||
} ControlInfo;
|
} ControlInfo;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
|
|
@ -105,7 +105,7 @@ void CONTROL_FreeMouseBind(int i)
|
||||||
BIND(CONTROL_KeyBinds[MAXBOUNDKEYS + i], NULL, 0, NULL);
|
BIND(CONTROL_KeyBinds[MAXBOUNDKEYS + i], NULL, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CONTROL_GetMouseDelta(void)
|
static void CONTROL_GetMouseDelta(ControlInfo * info)
|
||||||
{
|
{
|
||||||
vec2_t input;
|
vec2_t input;
|
||||||
mouseReadPos(&input.x, &input.y);
|
mouseReadPos(&input.x, &input.y);
|
||||||
|
@ -119,8 +119,8 @@ static void CONTROL_GetMouseDelta(void)
|
||||||
last = input;
|
last = input;
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTROL_MouseAxes[0].analog = Blrintf(finput.x * 4.f * CONTROL_MouseSensitivity);
|
info->mousex = Blrintf(finput.x * 4.f * CONTROL_MouseSensitivity);
|
||||||
CONTROL_MouseAxes[1].analog = Blrintf(finput.y * 4.f * CONTROL_MouseSensitivity);
|
info->mousey = Blrintf(finput.y * 4.f * CONTROL_MouseSensitivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t CONTROL_GetTime(void)
|
static int32_t CONTROL_GetTime(void)
|
||||||
|
@ -618,7 +618,7 @@ static void CONTROL_PollDevices(ControlInfo *info)
|
||||||
Bmemcpy(CONTROL_LastMouseAxes, CONTROL_MouseAxes, sizeof(CONTROL_MouseAxes));
|
Bmemcpy(CONTROL_LastMouseAxes, CONTROL_MouseAxes, sizeof(CONTROL_MouseAxes));
|
||||||
memset(CONTROL_MouseAxes, 0, sizeof(CONTROL_MouseAxes));
|
memset(CONTROL_MouseAxes, 0, sizeof(CONTROL_MouseAxes));
|
||||||
|
|
||||||
CONTROL_GetMouseDelta();
|
CONTROL_GetMouseDelta(info);
|
||||||
for (int i=MAXMOUSEAXES-1; i>=0; i--)
|
for (int i=MAXMOUSEAXES-1; i>=0; i--)
|
||||||
{
|
{
|
||||||
CONTROL_DigitizeAxis(i, controldevice_mouse);
|
CONTROL_DigitizeAxis(i, controldevice_mouse);
|
||||||
|
|
Loading…
Reference in a new issue