mirror of
https://github.com/nzp-team/glquake.git
synced 2024-11-10 06:31:35 +00:00
Improve support for N3DS analog movement
This commit is contained in:
parent
d1b6f95a45
commit
ed4c09de73
2 changed files with 49 additions and 93 deletions
|
@ -26,8 +26,6 @@ extern int bind_grab;
|
||||||
|
|
||||||
extern bool new3ds_flag;
|
extern bool new3ds_flag;
|
||||||
|
|
||||||
circlePosition cstick;
|
|
||||||
|
|
||||||
extern cvar_t in_analog_strafe;
|
extern cvar_t in_analog_strafe;
|
||||||
extern cvar_t in_x_axis_adjust;
|
extern cvar_t in_x_axis_adjust;
|
||||||
extern cvar_t in_y_axis_adjust;
|
extern cvar_t in_y_axis_adjust;
|
||||||
|
@ -79,39 +77,29 @@ extern cvar_t scr_fov;
|
||||||
extern int original_fov, final_fov;
|
extern int original_fov, final_fov;
|
||||||
void IN_Move (usercmd_t *cmd)
|
void IN_Move (usercmd_t *cmd)
|
||||||
{
|
{
|
||||||
// naievil -- fixme this operates incorrectly
|
// TODO: Detect circle pad pro?
|
||||||
unsigned char analog_strafe = 0;
|
circlePosition left;
|
||||||
// Don't let the pitch drift back to centre if analog nub look is on.
|
circlePosition right;
|
||||||
//if (in_mlook.value)
|
|
||||||
V_StopPitchDrift();
|
V_StopPitchDrift();
|
||||||
//else {
|
|
||||||
if (in_analog_strafe.value || (in_strafe.state & 1)) {
|
|
||||||
analog_strafe = 1;
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
|
|
||||||
// Read the pad state.
|
// Read the pad states
|
||||||
circlePosition pos;
|
hidCircleRead(&left);
|
||||||
//Read the CirclePad position
|
hidCstickRead(&right);
|
||||||
hidCircleRead(&pos);
|
|
||||||
|
|
||||||
//Print the CirclePad position
|
|
||||||
|
|
||||||
// Convert the inputs to floats in the range [-1, 1].
|
// Convert the inputs to floats in the range [-1, 1].
|
||||||
// Implement the dead zone.
|
// Implement the dead zone.
|
||||||
float speed;
|
float speed;
|
||||||
float deadZone = in_tolerance.value;
|
float deadZone = in_tolerance.value;
|
||||||
float acceleration = in_acceleration.value;
|
float acceleration = in_acceleration.value;
|
||||||
int x_adjust = 0;
|
float look_x, look_y;
|
||||||
int y_adjust = 0;
|
|
||||||
|
|
||||||
//shpuld begin
|
//
|
||||||
if (!analog_strafe) {
|
// Analog look tweaks
|
||||||
|
//
|
||||||
speed = sensitivity.value;
|
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) {
|
if ((in_aimassist.value) && (sv_player->v.facingenemy == 1) && cl.stats[STAT_CURRENTMAG] > 0) {
|
||||||
speed *= 0.5;
|
speed *= 0.5;
|
||||||
}
|
}
|
||||||
|
@ -120,49 +108,24 @@ void IN_Move (usercmd_t *cmd)
|
||||||
speed *= 0.5;
|
speed *= 0.5;
|
||||||
else if (cl.stats[STAT_ZOOM] == 2)
|
else if (cl.stats[STAT_ZOOM] == 2)
|
||||||
speed *= 0.25;
|
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);
|
// Are we using the left or right stick for looking?
|
||||||
float y = IN_CalcInput(pos.dy+y_adjust, speed, deadZone, acceleration);
|
if (!new3ds_flag) { // Left
|
||||||
|
look_x = IN_CalcInput(left.dx, speed, deadZone, acceleration);
|
||||||
// Set the yaw.
|
look_y = IN_CalcInput(left.dy, speed, deadZone, acceleration);
|
||||||
|
} else { // Right
|
||||||
// naievil -- taken from ctrQuake
|
look_x = IN_CalcInput(right.dx, speed, deadZone, acceleration);
|
||||||
//cStick is only available on N3DS... Until libctru implements support for circlePad Pro
|
look_y = IN_CalcInput(right.dy, speed, deadZone, acceleration);
|
||||||
if(new3ds_flag){
|
|
||||||
hidCstickRead(&cstick);
|
|
||||||
|
|
||||||
if(m_pitch.value < 0) {
|
|
||||||
cstick.dy = -cstick.dy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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;
|
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.
|
// Set the pitch.
|
||||||
const bool invertPitch = m_pitch.value < 0;
|
const bool invertPitch = m_pitch.value < 0;
|
||||||
const float pitchScale = yawScale * (invertPitch ? -1 : 1);
|
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.
|
// Don't look too far up or down.
|
||||||
if (cl.viewangles[PITCH] > 80.0f)
|
if (cl.viewangles[PITCH] > 80.0f)
|
||||||
|
@ -170,16 +133,16 @@ void IN_Move (usercmd_t *cmd)
|
||||||
if (cl.viewangles[PITCH] < -70.0f)
|
if (cl.viewangles[PITCH] < -70.0f)
|
||||||
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;
|
||||||
|
|
||||||
}
|
speed = sv_player->v.maxspeed/210;
|
||||||
else
|
move_x = IN_CalcInput(left.dx, speed, deadZone, acceleration);
|
||||||
{
|
move_y = IN_CalcInput(left.dy, speed, deadZone, acceleration);
|
||||||
// Move using up and down.
|
|
||||||
cmd->forwardmove -= cl_forwardspeed * y;
|
cmd->sidemove += cl_sidespeed * move_x;
|
||||||
}
|
cmd->forwardmove += cl_forwardspeed * move_y;
|
||||||
} else {
|
|
||||||
cmd->sidemove += cl_sidespeed * x;
|
|
||||||
cmd->forwardmove += cl_forwardspeed * y;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1033,7 +1033,7 @@ void M_Menu_CustomMaps_Key (int key)
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
/* OPTIONS MENU */
|
/* OPTIONS MENU */
|
||||||
|
|
||||||
#define OPTIONS_ITEMS 14
|
#define OPTIONS_ITEMS 13
|
||||||
#define SLIDER_RANGE 10
|
#define SLIDER_RANGE 10
|
||||||
|
|
||||||
int options_cursor;
|
int options_cursor;
|
||||||
|
@ -1116,10 +1116,6 @@ void M_AdjustSliders (int dir)
|
||||||
case 11: // lookstrafe
|
case 11: // lookstrafe
|
||||||
Cvar_SetValue ("lookstrafe", !lookstrafe.value);
|
Cvar_SetValue ("lookstrafe", !lookstrafe.value);
|
||||||
break;
|
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_Print (16, 120, " Lookstrafe");
|
||||||
M_DrawCheckbox (220, 120, lookstrafe.value);
|
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)
|
if (vid_menudrawfn)
|
||||||
M_Print (16, 136, " Video Options");
|
M_Print (16, 136, " Video Options");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue