Merge branch 'better-deadzone' into 'master'
Better Deadzones See merge request STJr/SRB2!541
This commit is contained in:
commit
2ed5617c5f
|
@ -823,6 +823,10 @@ void D_RegisterClientCommands(void)
|
||||||
CV_RegisterVar(&cv_autobrake);
|
CV_RegisterVar(&cv_autobrake);
|
||||||
CV_RegisterVar(&cv_autobrake2);
|
CV_RegisterVar(&cv_autobrake2);
|
||||||
|
|
||||||
|
// Ported from kart
|
||||||
|
CV_RegisterVar(&cv_deadzone);
|
||||||
|
CV_RegisterVar(&cv_deadzone2);
|
||||||
|
|
||||||
// s_sound.c
|
// s_sound.c
|
||||||
CV_RegisterVar(&cv_soundvolume);
|
CV_RegisterVar(&cv_soundvolume);
|
||||||
CV_RegisterVar(&cv_closedcaptioning);
|
CV_RegisterVar(&cv_closedcaptioning);
|
||||||
|
|
217
src/g_game.c
217
src/g_game.c
|
@ -275,6 +275,12 @@ static UINT8 *metalbuffer = NULL;
|
||||||
static UINT8 *metal_p;
|
static UINT8 *metal_p;
|
||||||
static UINT16 metalversion;
|
static UINT16 metalversion;
|
||||||
|
|
||||||
|
typedef struct joystickvector2_s
|
||||||
|
{
|
||||||
|
INT32 xaxis;
|
||||||
|
INT32 yaxis;
|
||||||
|
} joystickvector2_t;
|
||||||
|
|
||||||
// extra data stuff (events registered this frame while recording)
|
// extra data stuff (events registered this frame while recording)
|
||||||
static struct {
|
static struct {
|
||||||
UINT8 flags; // EZT flags
|
UINT8 flags; // EZT flags
|
||||||
|
@ -394,6 +400,11 @@ consvar_t cv_directionchar2 = {"directionchar2", "Movement", CV_SAVE|CV_CALL, di
|
||||||
consvar_t cv_autobrake = {"autobrake", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_autobrake = {"autobrake", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_autobrake2 = {"autobrake2", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake2_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_autobrake2 = {"autobrake2", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake2_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
|
static CV_PossibleValue_t deadzone_cons_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}};
|
||||||
|
consvar_t cv_deadzone = {"deadzone", "0.25", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
consvar_t cv_deadzone2 = {"deadzone2", "0.25", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
AXISNONE = 0,
|
AXISNONE = 0,
|
||||||
|
@ -401,7 +412,6 @@ typedef enum
|
||||||
AXISMOVE,
|
AXISMOVE,
|
||||||
AXISLOOK,
|
AXISLOOK,
|
||||||
AXISSTRAFE,
|
AXISSTRAFE,
|
||||||
AXISDEAD, //Axises that don't want deadzones
|
|
||||||
AXISJUMP,
|
AXISJUMP,
|
||||||
AXISSPIN,
|
AXISSPIN,
|
||||||
AXISFIRE,
|
AXISFIRE,
|
||||||
|
@ -882,12 +892,6 @@ static INT32 JoyAxis(axis_input_e axissel)
|
||||||
retaxis = -JOYAXISRANGE;
|
retaxis = -JOYAXISRANGE;
|
||||||
if (retaxis > (+JOYAXISRANGE))
|
if (retaxis > (+JOYAXISRANGE))
|
||||||
retaxis = +JOYAXISRANGE;
|
retaxis = +JOYAXISRANGE;
|
||||||
if (!Joystick.bGamepadStyle && axissel < AXISDEAD)
|
|
||||||
{
|
|
||||||
const INT32 jdeadzone = JOYAXISRANGE/4;
|
|
||||||
if (-jdeadzone < retaxis && retaxis < jdeadzone)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (flp) retaxis = -retaxis; //flip it around
|
if (flp) retaxis = -retaxis; //flip it around
|
||||||
return retaxis;
|
return retaxis;
|
||||||
}
|
}
|
||||||
|
@ -955,16 +959,75 @@ static INT32 Joy2Axis(axis_input_e axissel)
|
||||||
retaxis = -JOYAXISRANGE;
|
retaxis = -JOYAXISRANGE;
|
||||||
if (retaxis > (+JOYAXISRANGE))
|
if (retaxis > (+JOYAXISRANGE))
|
||||||
retaxis = +JOYAXISRANGE;
|
retaxis = +JOYAXISRANGE;
|
||||||
if (!Joystick2.bGamepadStyle && axissel < AXISDEAD)
|
|
||||||
{
|
|
||||||
const INT32 jdeadzone = JOYAXISRANGE/4;
|
|
||||||
if (-jdeadzone < retaxis && retaxis < jdeadzone)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (flp) retaxis = -retaxis; //flip it around
|
if (flp) retaxis = -retaxis; //flip it around
|
||||||
return retaxis;
|
return retaxis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Take a magnitude of two axes, and adjust it to take out the deadzone
|
||||||
|
// Will return a value between 0 and JOYAXISRANGE
|
||||||
|
static INT32 G_BasicDeadZoneCalculation(INT32 magnitude, fixed_t deadZone)
|
||||||
|
{
|
||||||
|
const INT32 jdeadzone = (JOYAXISRANGE * deadZone) / FRACUNIT;
|
||||||
|
INT32 deadzoneAppliedValue = 0;
|
||||||
|
|
||||||
|
if (jdeadzone > 0)
|
||||||
|
{
|
||||||
|
if (magnitude > jdeadzone)
|
||||||
|
{
|
||||||
|
INT32 adjustedMagnitude = abs(magnitude);
|
||||||
|
adjustedMagnitude = min(adjustedMagnitude, JOYAXISRANGE);
|
||||||
|
|
||||||
|
adjustedMagnitude -= jdeadzone;
|
||||||
|
|
||||||
|
deadzoneAppliedValue = (adjustedMagnitude * JOYAXISRANGE) / (JOYAXISRANGE - jdeadzone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return deadzoneAppliedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the actual sensible radial value for a joystick axis when accounting for a deadzone
|
||||||
|
static void G_HandleAxisDeadZone(UINT8 splitnum, joystickvector2_t *joystickvector)
|
||||||
|
{
|
||||||
|
INT32 gamepadStyle = Joystick.bGamepadStyle;
|
||||||
|
fixed_t deadZone = cv_deadzone.value;
|
||||||
|
|
||||||
|
if (splitnum == 1)
|
||||||
|
{
|
||||||
|
gamepadStyle = Joystick2.bGamepadStyle;
|
||||||
|
deadZone = cv_deadzone2.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// When gamepadstyle is "true" the values are just -1, 0, or 1. This is done in the interface code.
|
||||||
|
if (!gamepadStyle)
|
||||||
|
{
|
||||||
|
// Get the total magnitude of the 2 axes
|
||||||
|
INT32 magnitude = (joystickvector->xaxis * joystickvector->xaxis) + (joystickvector->yaxis * joystickvector->yaxis);
|
||||||
|
INT32 normalisedXAxis;
|
||||||
|
INT32 normalisedYAxis;
|
||||||
|
INT32 normalisedMagnitude;
|
||||||
|
double dMagnitude = sqrt((double)magnitude);
|
||||||
|
magnitude = (INT32)dMagnitude;
|
||||||
|
|
||||||
|
// Get the normalised xy values from the magnitude
|
||||||
|
normalisedXAxis = (joystickvector->xaxis * magnitude) / JOYAXISRANGE;
|
||||||
|
normalisedYAxis = (joystickvector->yaxis * magnitude) / JOYAXISRANGE;
|
||||||
|
|
||||||
|
// Apply the deadzone to the magnitude to give a correct value between 0 and JOYAXISRANGE
|
||||||
|
normalisedMagnitude = G_BasicDeadZoneCalculation(magnitude, deadZone);
|
||||||
|
|
||||||
|
// Apply the deadzone to the xy axes
|
||||||
|
joystickvector->xaxis = (normalisedXAxis * normalisedMagnitude) / JOYAXISRANGE;
|
||||||
|
joystickvector->yaxis = (normalisedYAxis * normalisedMagnitude) / JOYAXISRANGE;
|
||||||
|
|
||||||
|
// Cap the values so they don't go above the correct maximum
|
||||||
|
joystickvector->xaxis = min(joystickvector->xaxis, JOYAXISRANGE);
|
||||||
|
joystickvector->xaxis = max(joystickvector->xaxis, -JOYAXISRANGE);
|
||||||
|
joystickvector->yaxis = min(joystickvector->yaxis, JOYAXISRANGE);
|
||||||
|
joystickvector->yaxis = max(joystickvector->yaxis, -JOYAXISRANGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// G_BuildTiccmd
|
// G_BuildTiccmd
|
||||||
|
@ -985,12 +1048,13 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics)
|
||||||
{
|
{
|
||||||
boolean forcestrafe = false;
|
boolean forcestrafe = false;
|
||||||
boolean forcefullinput = false;
|
boolean forcefullinput = false;
|
||||||
INT32 tspeed, forward, side, axis, altaxis, i;
|
INT32 tspeed, forward, side, axis, strafeaxis, moveaxis, turnaxis, lookaxis, i;
|
||||||
const INT32 speed = 1;
|
const INT32 speed = 1;
|
||||||
// these ones used for multiple conditions
|
// these ones used for multiple conditions
|
||||||
boolean turnleft, turnright, strafelkey, straferkey, movefkey, movebkey, mouseaiming, analogjoystickmove, gamepadjoystickmove, thisjoyaiming;
|
boolean turnleft, turnright, strafelkey, straferkey, movefkey, movebkey, mouseaiming, analogjoystickmove, gamepadjoystickmove, thisjoyaiming;
|
||||||
player_t *player = &players[consoleplayer];
|
player_t *player = &players[consoleplayer];
|
||||||
camera_t *thiscam = &camera;
|
camera_t *thiscam = &camera;
|
||||||
|
joystickvector2_t movejoystickvector, lookjoystickvector;
|
||||||
|
|
||||||
static INT32 turnheld; // for accelerative turning
|
static INT32 turnheld; // for accelerative turning
|
||||||
static boolean keyboard_look; // true if lookup/down using keyboard
|
static boolean keyboard_look; // true if lookup/down using keyboard
|
||||||
|
@ -1030,11 +1094,16 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics)
|
||||||
localaiming = 0;
|
localaiming = 0;
|
||||||
joyaiming = thisjoyaiming;
|
joyaiming = thisjoyaiming;
|
||||||
|
|
||||||
axis = JoyAxis(AXISTURN);
|
turnaxis = JoyAxis(AXISTURN);
|
||||||
if (gamepadjoystickmove && axis != 0)
|
lookaxis = JoyAxis(AXISLOOK);
|
||||||
|
lookjoystickvector.xaxis = turnaxis;
|
||||||
|
lookjoystickvector.yaxis = lookaxis;
|
||||||
|
G_HandleAxisDeadZone(0, &lookjoystickvector);
|
||||||
|
|
||||||
|
if (gamepadjoystickmove && lookjoystickvector.xaxis != 0)
|
||||||
{
|
{
|
||||||
turnright = turnright || (axis > 0);
|
turnright = turnright || (lookjoystickvector.xaxis > 0);
|
||||||
turnleft = turnleft || (axis < 0);
|
turnleft = turnleft || (lookjoystickvector.xaxis < 0);
|
||||||
}
|
}
|
||||||
forward = side = 0;
|
forward = side = 0;
|
||||||
|
|
||||||
|
@ -1074,10 +1143,10 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics)
|
||||||
if (turnleft)
|
if (turnleft)
|
||||||
side -= sidemove[speed];
|
side -= sidemove[speed];
|
||||||
|
|
||||||
if (analogjoystickmove && axis != 0)
|
if (analogjoystickmove && lookjoystickvector.xaxis != 0)
|
||||||
{
|
{
|
||||||
// JOYAXISRANGE is supposed to be 1023 (divide by 1024)
|
// JOYAXISRANGE is supposed to be 1023 (divide by 1024)
|
||||||
side += ((axis * sidemove[1]) >> 10);
|
side += ((lookjoystickvector.xaxis * sidemove[1]) >> 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cv_analog.value) // Analog
|
else if (cv_analog.value) // Analog
|
||||||
|
@ -1094,41 +1163,44 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics)
|
||||||
else if (turnleft)
|
else if (turnleft)
|
||||||
cmd->angleturn = (INT16)(cmd->angleturn + angleturn[tspeed]);
|
cmd->angleturn = (INT16)(cmd->angleturn + angleturn[tspeed]);
|
||||||
|
|
||||||
if (analogjoystickmove && axis != 0)
|
if (analogjoystickmove && lookjoystickvector.xaxis != 0)
|
||||||
{
|
{
|
||||||
// JOYAXISRANGE should be 1023 (divide by 1024)
|
// JOYAXISRANGE should be 1023 (divide by 1024)
|
||||||
cmd->angleturn = (INT16)(cmd->angleturn - ((axis * angleturn[1]) >> 10)); // ANALOG!
|
cmd->angleturn = (INT16)(cmd->angleturn - ((lookjoystickvector.xaxis * angleturn[1]) >> 10)); // ANALOG!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
axis = JoyAxis(AXISSTRAFE);
|
strafeaxis = JoyAxis(AXISSTRAFE);
|
||||||
if (gamepadjoystickmove && axis != 0)
|
moveaxis = JoyAxis(AXISMOVE);
|
||||||
|
movejoystickvector.xaxis = strafeaxis;
|
||||||
|
movejoystickvector.yaxis = moveaxis;
|
||||||
|
G_HandleAxisDeadZone(0, &movejoystickvector);
|
||||||
|
|
||||||
|
if (gamepadjoystickmove && movejoystickvector.xaxis != 0)
|
||||||
{
|
{
|
||||||
if (axis < 0)
|
if (movejoystickvector.xaxis > 0)
|
||||||
side += sidemove[speed];
|
side += sidemove[speed];
|
||||||
else if (axis > 0)
|
else if (movejoystickvector.xaxis < 0)
|
||||||
side -= sidemove[speed];
|
side -= sidemove[speed];
|
||||||
}
|
}
|
||||||
else if (analogjoystickmove && axis != 0)
|
else if (analogjoystickmove && movejoystickvector.xaxis != 0)
|
||||||
{
|
{
|
||||||
// JOYAXISRANGE is supposed to be 1023 (divide by 1024)
|
// JOYAXISRANGE is supposed to be 1023 (divide by 1024)
|
||||||
side += ((axis * sidemove[1]) >> 10);
|
side += ((movejoystickvector.xaxis * sidemove[1]) >> 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// forward with key or button
|
// forward with key or button
|
||||||
axis = JoyAxis(AXISMOVE);
|
if (movefkey || (gamepadjoystickmove && movejoystickvector.yaxis < 0)
|
||||||
altaxis = JoyAxis(AXISLOOK);
|
|
||||||
if (movefkey || (gamepadjoystickmove && axis < 0)
|
|
||||||
|| ((player->powers[pw_carry] == CR_NIGHTSMODE)
|
|| ((player->powers[pw_carry] == CR_NIGHTSMODE)
|
||||||
&& (PLAYER1INPUTDOWN(gc_lookup) || (gamepadjoystickmove && altaxis < 0))))
|
&& (PLAYER1INPUTDOWN(gc_lookup) || (gamepadjoystickmove && lookjoystickvector.yaxis > 0))))
|
||||||
forward = forwardmove[speed];
|
forward = forwardmove[speed];
|
||||||
if (movebkey || (gamepadjoystickmove && axis > 0)
|
if (movebkey || (gamepadjoystickmove && movejoystickvector.yaxis > 0)
|
||||||
|| ((player->powers[pw_carry] == CR_NIGHTSMODE)
|
|| ((player->powers[pw_carry] == CR_NIGHTSMODE)
|
||||||
&& (PLAYER1INPUTDOWN(gc_lookdown) || (gamepadjoystickmove && altaxis > 0))))
|
&& (PLAYER1INPUTDOWN(gc_lookdown) || (gamepadjoystickmove && lookjoystickvector.yaxis < 0))))
|
||||||
forward -= forwardmove[speed];
|
forward -= forwardmove[speed];
|
||||||
|
|
||||||
if (analogjoystickmove && axis != 0)
|
if (analogjoystickmove && movejoystickvector.yaxis != 0)
|
||||||
forward -= ((axis * forwardmove[1]) >> 10); // ANALOG!
|
forward -= ((movejoystickvector.yaxis * forwardmove[1]) >> 10); // ANALOG!
|
||||||
|
|
||||||
// some people strafe left & right with mouse buttons
|
// some people strafe left & right with mouse buttons
|
||||||
// those people are weird
|
// those people are weird
|
||||||
|
@ -1211,9 +1283,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics)
|
||||||
localaiming += (mlooky<<19)*player_invert*screen_invert;
|
localaiming += (mlooky<<19)*player_invert*screen_invert;
|
||||||
}
|
}
|
||||||
|
|
||||||
axis = JoyAxis(AXISLOOK);
|
if (analogjoystickmove && joyaiming && lookjoystickvector.yaxis != 0 && cv_lookaxis.value != 0)
|
||||||
if (analogjoystickmove && joyaiming && axis != 0 && cv_lookaxis.value != 0)
|
localaiming += (lookjoystickvector.yaxis<<16) * screen_invert;
|
||||||
localaiming += (axis<<16) * screen_invert;
|
|
||||||
|
|
||||||
// spring back if not using keyboard neither mouselookin'
|
// spring back if not using keyboard neither mouselookin'
|
||||||
if (!keyboard_look && cv_lookaxis.value == 0 && !joyaiming && !mouseaiming)
|
if (!keyboard_look && cv_lookaxis.value == 0 && !joyaiming && !mouseaiming)
|
||||||
|
@ -1221,12 +1292,12 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics)
|
||||||
|
|
||||||
if (!(player->powers[pw_carry] == CR_NIGHTSMODE))
|
if (!(player->powers[pw_carry] == CR_NIGHTSMODE))
|
||||||
{
|
{
|
||||||
if (PLAYER1INPUTDOWN(gc_lookup) || (gamepadjoystickmove && axis < 0))
|
if (PLAYER1INPUTDOWN(gc_lookup) || (gamepadjoystickmove && lookjoystickvector.yaxis > 0))
|
||||||
{
|
{
|
||||||
localaiming += KB_LOOKSPEED * screen_invert;
|
localaiming += KB_LOOKSPEED * screen_invert;
|
||||||
keyboard_look = true;
|
keyboard_look = true;
|
||||||
}
|
}
|
||||||
else if (PLAYER1INPUTDOWN(gc_lookdown) || (gamepadjoystickmove && axis > 0))
|
else if (PLAYER1INPUTDOWN(gc_lookdown) || (gamepadjoystickmove && lookjoystickvector.yaxis < 0))
|
||||||
{
|
{
|
||||||
localaiming -= KB_LOOKSPEED * screen_invert;
|
localaiming -= KB_LOOKSPEED * screen_invert;
|
||||||
keyboard_look = true;
|
keyboard_look = true;
|
||||||
|
@ -1316,12 +1387,13 @@ void G_BuildTiccmd2(ticcmd_t *cmd, INT32 realtics)
|
||||||
{
|
{
|
||||||
boolean forcestrafe = false;
|
boolean forcestrafe = false;
|
||||||
boolean forcefullinput = false;
|
boolean forcefullinput = false;
|
||||||
INT32 tspeed, forward, side, axis, altaxis, i;
|
INT32 tspeed, forward, side, axis, strafeaxis, moveaxis, turnaxis, lookaxis, i;
|
||||||
const INT32 speed = 1;
|
const INT32 speed = 1;
|
||||||
// these ones used for multiple conditions
|
// these ones used for multiple conditions
|
||||||
boolean turnleft, turnright, strafelkey, straferkey, movefkey, movebkey, mouseaiming, analogjoystickmove, gamepadjoystickmove, thisjoyaiming;
|
boolean turnleft, turnright, strafelkey, straferkey, movefkey, movebkey, mouseaiming, analogjoystickmove, gamepadjoystickmove, thisjoyaiming;
|
||||||
player_t *player = &players[secondarydisplayplayer];
|
player_t *player = &players[secondarydisplayplayer];
|
||||||
camera_t *thiscam = (player->bot == 2 ? &camera : &camera2);
|
camera_t *thiscam = (player->bot == 2 ? &camera : &camera2);
|
||||||
|
joystickvector2_t movejoystickvector, lookjoystickvector;
|
||||||
|
|
||||||
static INT32 turnheld; // for accelerative turning
|
static INT32 turnheld; // for accelerative turning
|
||||||
static boolean keyboard_look; // true if lookup/down using keyboard
|
static boolean keyboard_look; // true if lookup/down using keyboard
|
||||||
|
@ -1359,11 +1431,16 @@ void G_BuildTiccmd2(ticcmd_t *cmd, INT32 realtics)
|
||||||
localaiming2 = 0;
|
localaiming2 = 0;
|
||||||
joyaiming = thisjoyaiming;
|
joyaiming = thisjoyaiming;
|
||||||
|
|
||||||
axis = Joy2Axis(AXISTURN);
|
turnaxis = Joy2Axis(AXISTURN);
|
||||||
if (gamepadjoystickmove && axis != 0)
|
lookaxis = Joy2Axis(AXISLOOK);
|
||||||
|
lookjoystickvector.xaxis = turnaxis;
|
||||||
|
lookjoystickvector.yaxis = lookaxis;
|
||||||
|
G_HandleAxisDeadZone(1, &lookjoystickvector);
|
||||||
|
|
||||||
|
if (gamepadjoystickmove && lookjoystickvector.xaxis != 0)
|
||||||
{
|
{
|
||||||
turnright = turnright || (axis > 0);
|
turnright = turnright || (lookjoystickvector.xaxis > 0);
|
||||||
turnleft = turnleft || (axis < 0);
|
turnleft = turnleft || (lookjoystickvector.xaxis < 0);
|
||||||
}
|
}
|
||||||
forward = side = 0;
|
forward = side = 0;
|
||||||
|
|
||||||
|
@ -1404,10 +1481,10 @@ void G_BuildTiccmd2(ticcmd_t *cmd, INT32 realtics)
|
||||||
if (turnleft)
|
if (turnleft)
|
||||||
side -= sidemove[speed];
|
side -= sidemove[speed];
|
||||||
|
|
||||||
if (analogjoystickmove && axis != 0)
|
if (analogjoystickmove && lookjoystickvector.xaxis != 0)
|
||||||
{
|
{
|
||||||
// JOYAXISRANGE is supposed to be 1023 (divide by 1024)
|
// JOYAXISRANGE is supposed to be 1023 (divide by 1024)
|
||||||
side += ((axis * sidemove[1]) >> 10);
|
side += ((lookjoystickvector.xaxis * sidemove[1]) >> 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cv_analog2.value) // Analog
|
else if (cv_analog2.value) // Analog
|
||||||
|
@ -1424,41 +1501,44 @@ void G_BuildTiccmd2(ticcmd_t *cmd, INT32 realtics)
|
||||||
else if (turnleft)
|
else if (turnleft)
|
||||||
cmd->angleturn = (INT16)(cmd->angleturn + angleturn[tspeed]);
|
cmd->angleturn = (INT16)(cmd->angleturn + angleturn[tspeed]);
|
||||||
|
|
||||||
if (analogjoystickmove && axis != 0)
|
if (analogjoystickmove && lookjoystickvector.xaxis != 0)
|
||||||
{
|
{
|
||||||
// JOYAXISRANGE should be 1023 (divide by 1024)
|
// JOYAXISRANGE should be 1023 (divide by 1024)
|
||||||
cmd->angleturn = (INT16)(cmd->angleturn - ((axis * angleturn[1]) >> 10)); // ANALOG!
|
cmd->angleturn = (INT16)(cmd->angleturn - ((lookjoystickvector.xaxis * angleturn[1]) >> 10)); // ANALOG!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
axis = Joy2Axis(AXISSTRAFE);
|
strafeaxis = Joy2Axis(AXISSTRAFE);
|
||||||
if (gamepadjoystickmove && axis != 0)
|
moveaxis = Joy2Axis(AXISMOVE);
|
||||||
|
movejoystickvector.xaxis = strafeaxis;
|
||||||
|
movejoystickvector.yaxis = moveaxis;
|
||||||
|
G_HandleAxisDeadZone(1, &movejoystickvector);
|
||||||
|
|
||||||
|
if (gamepadjoystickmove && movejoystickvector.xaxis != 0)
|
||||||
{
|
{
|
||||||
if (axis < 0)
|
if (movejoystickvector.xaxis > 0)
|
||||||
side += sidemove[speed];
|
side += sidemove[speed];
|
||||||
else if (axis > 0)
|
else if (movejoystickvector.xaxis < 0)
|
||||||
side -= sidemove[speed];
|
side -= sidemove[speed];
|
||||||
}
|
}
|
||||||
else if (analogjoystickmove && axis != 0)
|
else if (analogjoystickmove && movejoystickvector.xaxis != 0)
|
||||||
{
|
{
|
||||||
// JOYAXISRANGE is supposed to be 1023 (divide by 1024)
|
// JOYAXISRANGE is supposed to be 1023 (divide by 1024)
|
||||||
side += ((axis * sidemove[1]) >> 10);
|
side += ((movejoystickvector.xaxis * sidemove[1]) >> 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// forward with key or button
|
// forward with key or button
|
||||||
axis = Joy2Axis(AXISMOVE);
|
if (movefkey || (gamepadjoystickmove && movejoystickvector.yaxis < 0)
|
||||||
altaxis = Joy2Axis(AXISLOOK);
|
|
||||||
if (movefkey || (gamepadjoystickmove && axis < 0)
|
|
||||||
|| ((player->powers[pw_carry] == CR_NIGHTSMODE)
|
|| ((player->powers[pw_carry] == CR_NIGHTSMODE)
|
||||||
&& (PLAYER2INPUTDOWN(gc_lookup) || (gamepadjoystickmove && altaxis < 0))))
|
&& (PLAYER2INPUTDOWN(gc_lookup) || (gamepadjoystickmove && lookjoystickvector.yaxis > 0))))
|
||||||
forward = forwardmove[speed];
|
forward = forwardmove[speed];
|
||||||
if (movebkey || (gamepadjoystickmove && axis > 0)
|
if (movebkey || (gamepadjoystickmove && movejoystickvector.yaxis > 0)
|
||||||
|| ((player->powers[pw_carry] == CR_NIGHTSMODE)
|
|| ((player->powers[pw_carry] == CR_NIGHTSMODE)
|
||||||
&& (PLAYER2INPUTDOWN(gc_lookdown) || (gamepadjoystickmove && altaxis > 0))))
|
&& (PLAYER2INPUTDOWN(gc_lookdown) || (gamepadjoystickmove && lookjoystickvector.yaxis < 0))))
|
||||||
forward -= forwardmove[speed];
|
forward -= forwardmove[speed];
|
||||||
|
|
||||||
if (analogjoystickmove && axis != 0)
|
if (analogjoystickmove && movejoystickvector.yaxis != 0)
|
||||||
forward -= ((axis * forwardmove[1]) >> 10); // ANALOG!
|
forward -= ((movejoystickvector.yaxis * forwardmove[1]) >> 10); // ANALOG!
|
||||||
|
|
||||||
// some people strafe left & right with mouse buttons
|
// some people strafe left & right with mouse buttons
|
||||||
// those people are (still) weird
|
// those people are (still) weird
|
||||||
|
@ -1538,9 +1618,8 @@ void G_BuildTiccmd2(ticcmd_t *cmd, INT32 realtics)
|
||||||
localaiming2 += (mlook2y<<19)*player_invert*screen_invert;
|
localaiming2 += (mlook2y<<19)*player_invert*screen_invert;
|
||||||
}
|
}
|
||||||
|
|
||||||
axis = Joy2Axis(AXISLOOK);
|
if (analogjoystickmove && joyaiming && lookjoystickvector.yaxis != 0 && cv_lookaxis2.value != 0)
|
||||||
if (analogjoystickmove && joyaiming && axis != 0 && cv_lookaxis2.value != 0)
|
localaiming2 += (lookjoystickvector.yaxis<<16) * screen_invert;
|
||||||
localaiming2 += (axis<<16) * screen_invert;
|
|
||||||
|
|
||||||
// spring back if not using keyboard neither mouselookin'
|
// spring back if not using keyboard neither mouselookin'
|
||||||
if (!keyboard_look && cv_lookaxis2.value == 0 && !joyaiming && !mouseaiming)
|
if (!keyboard_look && cv_lookaxis2.value == 0 && !joyaiming && !mouseaiming)
|
||||||
|
@ -1548,12 +1627,12 @@ void G_BuildTiccmd2(ticcmd_t *cmd, INT32 realtics)
|
||||||
|
|
||||||
if (!(player->powers[pw_carry] == CR_NIGHTSMODE))
|
if (!(player->powers[pw_carry] == CR_NIGHTSMODE))
|
||||||
{
|
{
|
||||||
if (PLAYER2INPUTDOWN(gc_lookup) || (gamepadjoystickmove && axis < 0))
|
if (PLAYER2INPUTDOWN(gc_lookup) || (gamepadjoystickmove && lookjoystickvector.yaxis > 0))
|
||||||
{
|
{
|
||||||
localaiming2 += KB_LOOKSPEED * screen_invert;
|
localaiming2 += KB_LOOKSPEED * screen_invert;
|
||||||
keyboard_look = true;
|
keyboard_look = true;
|
||||||
}
|
}
|
||||||
else if (PLAYER2INPUTDOWN(gc_lookdown) || (gamepadjoystickmove && axis > 0))
|
else if (PLAYER2INPUTDOWN(gc_lookdown) || (gamepadjoystickmove && lookjoystickvector.yaxis < 0))
|
||||||
{
|
{
|
||||||
localaiming2 -= KB_LOOKSPEED * screen_invert;
|
localaiming2 -= KB_LOOKSPEED * screen_invert;
|
||||||
keyboard_look = true;
|
keyboard_look = true;
|
||||||
|
|
|
@ -72,6 +72,7 @@ extern consvar_t cv_useranalog, cv_useranalog2;
|
||||||
extern consvar_t cv_analog, cv_analog2;
|
extern consvar_t cv_analog, cv_analog2;
|
||||||
extern consvar_t cv_directionchar, cv_directionchar2;
|
extern consvar_t cv_directionchar, cv_directionchar2;
|
||||||
extern consvar_t cv_autobrake, cv_autobrake2;
|
extern consvar_t cv_autobrake, cv_autobrake2;
|
||||||
|
extern consvar_t cv_deadzone, cv_deadzone2;
|
||||||
extern consvar_t cv_sideaxis,cv_turnaxis,cv_moveaxis,cv_lookaxis,cv_jumpaxis,cv_spinaxis,cv_fireaxis,cv_firenaxis;
|
extern consvar_t cv_sideaxis,cv_turnaxis,cv_moveaxis,cv_lookaxis,cv_jumpaxis,cv_spinaxis,cv_fireaxis,cv_firenaxis;
|
||||||
extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_jumpaxis2,cv_spinaxis2,cv_fireaxis2,cv_firenaxis2;
|
extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_jumpaxis2,cv_spinaxis2,cv_fireaxis2,cv_firenaxis2;
|
||||||
extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_ghost_last, cv_ghost_guest;
|
extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_ghost_last, cv_ghost_guest;
|
||||||
|
|
|
@ -1118,6 +1118,8 @@ static menuitem_t OP_Joystick1Menu[] =
|
||||||
|
|
||||||
{IT_STRING | IT_CVAR, NULL, "First-Person Vert-Look", &cv_alwaysfreelook, 120},
|
{IT_STRING | IT_CVAR, NULL, "First-Person Vert-Look", &cv_alwaysfreelook, 120},
|
||||||
{IT_STRING | IT_CVAR, NULL, "Third-Person Vert-Look", &cv_chasefreelook, 130},
|
{IT_STRING | IT_CVAR, NULL, "Third-Person Vert-Look", &cv_chasefreelook, 130},
|
||||||
|
{IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER,
|
||||||
|
NULL, "Deadzone", &cv_deadzone, 140 },
|
||||||
};
|
};
|
||||||
|
|
||||||
static menuitem_t OP_Joystick2Menu[] =
|
static menuitem_t OP_Joystick2Menu[] =
|
||||||
|
@ -1134,6 +1136,8 @@ static menuitem_t OP_Joystick2Menu[] =
|
||||||
|
|
||||||
{IT_STRING | IT_CVAR, NULL, "First-Person Vert-Look", &cv_alwaysfreelook2,120},
|
{IT_STRING | IT_CVAR, NULL, "First-Person Vert-Look", &cv_alwaysfreelook2,120},
|
||||||
{IT_STRING | IT_CVAR, NULL, "Third-Person Vert-Look", &cv_chasefreelook2, 130},
|
{IT_STRING | IT_CVAR, NULL, "Third-Person Vert-Look", &cv_chasefreelook2, 130},
|
||||||
|
{IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER,
|
||||||
|
NULL, "Deadzone", &cv_deadzone2, 140 },
|
||||||
};
|
};
|
||||||
|
|
||||||
static menuitem_t OP_JoystickSetMenu[1+MAX_JOYSTICKS];
|
static menuitem_t OP_JoystickSetMenu[1+MAX_JOYSTICKS];
|
||||||
|
@ -3009,7 +3013,7 @@ boolean M_Responder(event_t *ev)
|
||||||
}
|
}
|
||||||
else if (ev->type == ev_joystick && ev->data1 == 0 && joywait < I_GetTime())
|
else if (ev->type == ev_joystick && ev->data1 == 0 && joywait < I_GetTime())
|
||||||
{
|
{
|
||||||
const INT32 jdeadzone = JOYAXISRANGE/4;
|
const INT32 jdeadzone = (JOYAXISRANGE * cv_deadzone.value) / FRACUNIT;
|
||||||
if (ev->data3 != INT32_MAX)
|
if (ev->data3 != INT32_MAX)
|
||||||
{
|
{
|
||||||
if (Joystick.bGamepadStyle || abs(ev->data3) > jdeadzone)
|
if (Joystick.bGamepadStyle || abs(ev->data3) > jdeadzone)
|
||||||
|
|
Loading…
Reference in New Issue