Commit c435ccbf authored by Richard Gobeille's avatar Richard Gobeille
Browse files

Duke3d: experimental game controller tweak to weight aiming movement toward...

Duke3d: experimental game controller tweak to weight aiming movement toward whichever axis has the highest input

Enable with the 'in_joyweight' cvar. Values are 1-10, 0 for disabled.
parent 07ac4ecc
......@@ -265,6 +265,7 @@ void CONFIG_SetDefaults(void)
ud.config.AutoAim = 1;
ud.config.CheckForUpdates = 1;
ud.config.FXVolume = 255;
ud.config.JoystickAimWeight = 5;
ud.config.MouseBias = 0;
ud.config.MusicDevice = ASS_AutoDetect;
ud.config.MusicToggle = 1;
......
......@@ -213,6 +213,7 @@ typedef struct {
int32_t AutoAim;
int32_t ShowWeapons;
int32_t MouseBias;
int32_t JoystickAimWeight;
// JBF 20031211: Store the input settings because
// (currently) mact can't regurgitate them
......
......@@ -979,8 +979,11 @@ static MenuEntry_t ME_JOYSTICK_DEFAULTS_PRO = MAKE_MENUENTRY( "Use Pro Layout",
static MenuLink_t MEO_JOYSTICK_DEFAULTS_CLEAR = { MENU_JOYCLEARVERIFY, MA_None, };
static MenuEntry_t ME_JOYSTICK_DEFAULTS_CLEAR = MAKE_MENUENTRY( "Clear All Settings", &MF_Redfont, &MEF_BigOptionsRtSections, &MEO_JOYSTICK_DEFAULTS_CLEAR, Link );
static MenuRangeInt32_t MEO_JOYSTICK_WEIGHTED_AIMING = MAKE_MENURANGE(&ud.config.JoystickAimWeight , &MF_Bluefont, 0, 10, 0, 11, 0 );
static MenuEntry_t ME_JOYSTICK_WEIGHTED_AIMING = MAKE_MENUENTRY( "Weighted Aiming", &MF_Redfont, &MEF_BigSliders, &MEO_JOYSTICK_WEIGHTED_AIMING, RangeInt32 );
static MenuEntry_t *MEL_JOYSTICKSETUP[] = {
&ME_JOYSTICK_ENABLE,
&ME_JOYSTICK_WEIGHTED_AIMING,
&ME_Space6_Redfont,
&ME_JOYSTICK_EDITBUTTONS,
&ME_JOYSTICK_EDITAXES,
......
......@@ -1603,6 +1603,11 @@ int32_t registerosdcommands(void)
{ "hud_hidestick", "hide the touch input stick", (void *)&droidinput.hideStick, CVAR_BOOL, 0, 1 },
#endif
{
"in_joystickaimweight", "weight joystick aiming input towards whichever axis is moving the most at any given time",
(void *)&ud.config.JoystickAimWeight, CVAR_INT, 0, 10
},
{ "in_joystick","use joystick or controller input" CVAR_BOOL_OPTSTR,(void *)&ud.setup.usejoystick, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 },
{ "in_mouse","use mouse input" CVAR_BOOL_OPTSTR,(void *)&ud.setup.usemouse, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 },
......
......@@ -3080,6 +3080,33 @@ void P_GetInput(int const playerNum)
info.mousex = tabledivide32_noinline(info.mousex, ud.config.MouseBias);
}
if (ud.config.JoystickAimWeight)
{
int const absyaw = klabs(info.dyaw);
int const abspitch = klabs(info.dpitch);
//int const origyaw = info.dyaw;
//int const origpitch = info.dpitch;
if (absyaw > abspitch)
{
if (info.dpitch > 0)
info.dpitch = max(0, info.dpitch - tabledivide32_noinline(absyaw - abspitch, 11 - ud.config.JoystickAimWeight));
else if (info.dpitch < 0)
info.dpitch = min(0, info.dpitch + tabledivide32_noinline(absyaw - abspitch, 11 - ud.config.JoystickAimWeight));
//OSD_Printf("pitch %d -> %d\n",origpitch, info.dpitch);
}
else if (abspitch > absyaw)
{
if (info.dyaw > 0)
info.dyaw = max(0, info.dyaw - tabledivide32_noinline(abspitch - absyaw, 11 - ud.config.JoystickAimWeight));
else if (info.dyaw < 0)
info.dyaw = min(0, info.dyaw + tabledivide32_noinline(abspitch - absyaw, 11 - ud.config.JoystickAimWeight));
//OSD_Printf("yaw %d -> %d\n",origyaw, info.dyaw);
}
}
// 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 turnAmount = playerRunning ? (NORMALTURN << 1) : NORMALTURN;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment