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

Duke3d: experimental game controller tweak to level the player's view while moving

parent c435ccbf
......@@ -266,6 +266,7 @@ void CONFIG_SetDefaults(void)
ud.config.CheckForUpdates = 1;
ud.config.FXVolume = 255;
ud.config.JoystickAimWeight = 5;
ud.config.JoystickViewLeveling = 1;
ud.config.MouseBias = 0;
ud.config.MusicDevice = ASS_AutoDetect;
ud.config.MusicToggle = 1;
......
......@@ -214,6 +214,7 @@ typedef struct {
int32_t ShowWeapons;
int32_t MouseBias;
int32_t JoystickAimWeight;
int32_t JoystickViewLeveling;
// JBF 20031211: Store the input settings because
// (currently) mact can't regurgitate them
......
......@@ -981,9 +981,14 @@ static MenuEntry_t ME_JOYSTICK_DEFAULTS_CLEAR = MAKE_MENUENTRY( "Clear All Setti
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 MenuRangeInt32_t MEO_JOYSTICK_VIEW_LEVELING = MAKE_MENURANGE(&ud.config.JoystickViewLeveling , &MF_Bluefont, 0, 10, 0, 6, 0 );
static MenuEntry_t ME_JOYSTICK_VIEW_LEVELING = MAKE_MENUENTRY( "View Leveling", &MF_Redfont, &MEF_BigSliders, &MEO_JOYSTICK_VIEW_LEVELING, RangeInt32 );
static MenuEntry_t *MEL_JOYSTICKSETUP[] = {
&ME_JOYSTICK_ENABLE,
&ME_JOYSTICK_WEIGHTED_AIMING,
&ME_JOYSTICK_VIEW_LEVELING,
&ME_Space6_Redfont,
&ME_JOYSTICK_EDITBUTTONS,
&ME_JOYSTICK_EDITAXES,
......
......@@ -1608,6 +1608,11 @@ int32_t registerosdcommands(void)
(void *)&ud.config.JoystickAimWeight, CVAR_INT, 0, 10
},
{
"in_joystickviewleveling", "automatically level the player view vertically when moving while using a controller",
(void *)&ud.config.JoystickViewLeveling, 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 },
......
......@@ -3152,6 +3152,16 @@ void P_GetInput(int const playerNum)
input.svel -= lrint(scaleToInterval(info.dx * keyMove / analogExtent));
input.fvel -= lrint(scaleToInterval(info.dz * keyMove / analogExtent));
if (ud.config.JoystickViewLeveling && !input.q16avel && !input.q16horz && input.fvel && CONTROL_LastSeenInput == LastSeenInput::Joystick)
{
if (pPlayer->q16horiz >= F16(99) && pPlayer->q16horiz <= F16(100))
thisPlayer.horizRecenter = true;
else if (pPlayer->q16horiz < F16(99))
input.q16horz = fix16_add(input.q16horz, fix16_from_float(scaleToInterval(ud.config.JoystickViewLeveling)));
else if (pPlayer->q16horiz > F16(100))
input.q16horz = fix16_sub(input.q16horz, fix16_from_float(scaleToInterval(ud.config.JoystickViewLeveling)));
}
if (BUTTON(gamefunc_Strafe))
{
if (!localInput.svel)
......
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