Improve support for N3DS analog movement

This commit is contained in:
cypress 2023-07-22 15:32:12 -04:00
parent d1b6f95a45
commit ed4c09de73
2 changed files with 49 additions and 93 deletions

View file

@ -26,8 +26,6 @@ extern int bind_grab;
extern bool new3ds_flag;
circlePosition cstick;
extern cvar_t in_analog_strafe;
extern cvar_t in_x_axis_adjust;
extern cvar_t in_y_axis_adjust;
@ -79,39 +77,29 @@ extern cvar_t scr_fov;
extern int original_fov, final_fov;
void IN_Move (usercmd_t *cmd)
{
// naievil -- fixme this operates incorrectly
unsigned char analog_strafe = 0;
// Don't let the pitch drift back to centre if analog nub look is on.
//if (in_mlook.value)
// TODO: Detect circle pad pro?
circlePosition left;
circlePosition right;
V_StopPitchDrift();
//else {
if (in_analog_strafe.value || (in_strafe.state & 1)) {
analog_strafe = 1;
}
//}
// Read the pad state.
circlePosition pos;
//Read the CirclePad position
hidCircleRead(&pos);
//Print the CirclePad position
// Read the pad states
hidCircleRead(&left);
hidCstickRead(&right);
// Convert the inputs to floats in the range [-1, 1].
// Implement the dead zone.
float speed;
float deadZone = in_tolerance.value;
float acceleration = in_acceleration.value;
int x_adjust = 0;
int y_adjust = 0;
float look_x, look_y;
//shpuld begin
if (!analog_strafe) {
//
// Analog look tweaks
//
speed = sensitivity.value;
// ==== Aim Assist + ====
// cut look speed in half when facing enemy, unless
// mag is empty
// cut look speed in half when facing enemy, unless mag is empty
if ((in_aimassist.value) && (sv_player->v.facingenemy == 1) && cl.stats[STAT_CURRENTMAG] > 0) {
speed *= 0.5;
}
@ -120,49 +108,24 @@ void IN_Move (usercmd_t *cmd)
speed *= 0.5;
else if (cl.stats[STAT_ZOOM] == 2)
speed *= 0.25;
} else {
speed = sv_player->v.maxspeed/150;
if (cl.stats[STAT_ZOOM] == 1)
speed *= 2;
else if (cl.stats[STAT_ZOOM] == 2)
speed *= 4;
}
//shpuld end
float x = IN_CalcInput(pos.dx+x_adjust, speed, deadZone, acceleration);
float y = IN_CalcInput(pos.dy+y_adjust, speed, deadZone, acceleration);
// Set the yaw.
// naievil -- taken from ctrQuake
//cStick is only available on N3DS... Until libctru implements support for circlePad Pro
if(new3ds_flag){
hidCstickRead(&cstick);
if(m_pitch.value < 0) {
cstick.dy = -cstick.dy;
// Are we using the left or right stick for looking?
if (!new3ds_flag) { // Left
look_x = IN_CalcInput(left.dx, speed, deadZone, acceleration);
look_y = IN_CalcInput(left.dy, speed, deadZone, acceleration);
} else { // Right
look_x = IN_CalcInput(right.dx, speed, deadZone, acceleration);
look_y = IN_CalcInput(right.dy, speed, deadZone, acceleration);
}
cstick.dx = abs(cstick.dx) < 10 ? 0 : cstick.dx * sensitivity.value * 0.01;
cstick.dy = abs(cstick.dy) < 10 ? 0 : cstick.dy * sensitivity.value * 0.01;
cl.viewangles[YAW] -= cstick.dx;
cl.viewangles[PITCH] += cstick.dy;
}
// Analog nub look?
if (!analog_strafe) {
const float yawScale = 30.0f;
cl.viewangles[YAW] -= yawScale * x * host_frametime;
cl.viewangles[YAW] -= yawScale * look_x * host_frametime;
if (in_mlook.value)
{
// Set the pitch.
const bool invertPitch = m_pitch.value < 0;
const float pitchScale = yawScale * (invertPitch ? -1 : 1);
cl.viewangles[PITCH] += pitchScale * y * host_frametime;
cl.viewangles[PITCH] += pitchScale * look_y * host_frametime;
// Don't look too far up or down.
if (cl.viewangles[PITCH] > 80.0f)
@ -170,16 +133,16 @@ void IN_Move (usercmd_t *cmd)
if (cl.viewangles[PITCH] < -70.0f)
cl.viewangles[PITCH] = -70.0f;
// Ability to move with the left nub on NEW model systems
if (new3ds_flag) {
float move_x, move_y;
}
else
{
// Move using up and down.
cmd->forwardmove -= cl_forwardspeed * y;
}
} else {
cmd->sidemove += cl_sidespeed * x;
cmd->forwardmove += cl_forwardspeed * y;
speed = sv_player->v.maxspeed/210;
move_x = IN_CalcInput(left.dx, speed, deadZone, acceleration);
move_y = IN_CalcInput(left.dy, speed, deadZone, acceleration);
cmd->sidemove += cl_sidespeed * move_x;
cmd->forwardmove += cl_forwardspeed * move_y;
}
}

View file

@ -1033,7 +1033,7 @@ void M_Menu_CustomMaps_Key (int key)
//=============================================================================
/* OPTIONS MENU */
#define OPTIONS_ITEMS 14
#define OPTIONS_ITEMS 13
#define SLIDER_RANGE 10
int options_cursor;
@ -1116,10 +1116,6 @@ void M_AdjustSliders (int dir)
case 11: // lookstrafe
Cvar_SetValue ("lookstrafe", !lookstrafe.value);
break;
case 12: // in_analog_strafe (Cnub aim)
Cvar_SetValue ("in_analog_strafe", !in_analog_strafe.value);
break;
}
}
@ -1196,9 +1192,6 @@ void M_Options_Draw (void)
M_Print (16, 120, " Lookstrafe");
M_DrawCheckbox (220, 120, lookstrafe.value);
M_Print (16, 128, "Analog Strafe (CNub Aim)");
M_DrawCheckbox (220, 128, in_analog_strafe.value);
if (vid_menudrawfn)
M_Print (16, 136, " Video Options");