Merge pull request #2 from nzp-team/ryan_cnub

3ds: Add support for analog strafe option in config file
This commit is contained in:
Ian 2023-02-27 10:31:32 -05:00 committed by GitHub
commit 2315c6f07f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 12 deletions

View file

@ -24,6 +24,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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;
@ -31,7 +35,7 @@ extern cvar_t in_mlook; //Heffo - mlook cvar
void IN_Init (void)
{
Cvar_RegisterVariable (&in_analog_strafe);
}
void IN_Shutdown (void)
@ -78,13 +82,13 @@ 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)
V_StopPitchDrift();
else {
//if (in_mlook.value)
V_StopPitchDrift();
//else {
if (in_analog_strafe.value || (in_strafe.state & 1)) {
analog_strafe = 1;
}
}
//}
// Read the pad state.
circlePosition pos;
@ -130,6 +134,23 @@ void IN_Move (usercmd_t *cmd)
// 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;
}
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;
@ -158,7 +179,7 @@ void IN_Move (usercmd_t *cmd)
}
} else {
cmd->sidemove += cl_sidespeed * x;
cmd->forwardmove -= cl_forwardspeed * y;
cmd->forwardmove += cl_forwardspeed * y;
}
}

View file

@ -1031,7 +1031,7 @@ void M_Menu_CustomMaps_Key (int key)
//=============================================================================
/* OPTIONS MENU */
#define OPTIONS_ITEMS 13
#define OPTIONS_ITEMS 14
#define SLIDER_RANGE 10
int options_cursor;
@ -1114,6 +1114,10 @@ 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;
}
}
@ -1190,8 +1194,11 @@ 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, 128, " Video Options");
M_Print (16, 136, " Video Options");
// cursor
M_DrawCharacter (200, 32 + options_cursor*8, 12+((int)(realtime*4)&1));
@ -1217,7 +1224,7 @@ void M_Options_Key (int k)
case 2:
Cbuf_AddText ("exec default.cfg\n");
break;
case 12:
case 13:
M_Menu_Video_f ();
break;
default:
@ -1257,10 +1264,10 @@ void M_Options_Key (int k)
break;
}
if (options_cursor == 12 && vid_menudrawfn == NULL)
if (options_cursor == 13 && vid_menudrawfn == NULL)
{
if (k == K_UPARROW)
options_cursor = 11;
options_cursor = 12;
else
options_cursor = 0;
}

View file

@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
int __stacksize__ = 4 * 1024 * 1024;
u32 __ctru_linear_heap_size = 28 * 1024 * 1024;
bool new3ds_flag;
extern void Touch_Init();
extern void Touch_Update();
@ -286,7 +287,7 @@ int main (int argc, char **argv)
{
static float time, oldtime;
static quakeparms_t parms;
bool new3ds_flag = false;
new3ds_flag = false;
osSetSpeedupEnable(true);