Skip to content

Commit

Permalink
Support invent for Y gamepad axis when moving the camera
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Feb 8, 2022
1 parent ad32a51 commit 0e8e874
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/xrEngine/FDemoRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ void CDemoRecord::IR_OnControllerHold(int key, float x, float y)
{
m_angle_speed = speed;
const float scale = .05f; // psControllerSens;
OnAxisMove(x, y, scale, false); // XXX: controller axes invert
OnAxisMove(x, y, scale, psControllerInvertY.test(1));
break;
}

Expand Down
1 change: 1 addition & 0 deletions src/xrEngine/IInputReceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ ENGINE_API extern Flags32 psMouseInvert;

ENGINE_API extern float psControllerSens;
ENGINE_API extern float psControllerDeadZoneSens;
ENGINE_API extern Flags32 psControllerInvertY;

#endif
1 change: 1 addition & 0 deletions src/xrEngine/xr_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ENGINE_API Flags32 psMouseInvert = {false};

ENGINE_API float psControllerSens = 1.f;
ENGINE_API float psControllerDeadZoneSens = 0.f;
ENGINE_API Flags32 psControllerInvertY = { false };

static bool AltF4Pressed = false;

Expand Down
1 change: 1 addition & 0 deletions src/xrEngine/xr_ioc_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,7 @@ void CCC_Register()
CMD4(CCC_Float, "mouse_sens", &psMouseSens, 0.001f, 0.6f);

// Gamepad
CMD3(CCC_Mask, "gamepad_invert_y", &psControllerInvertY, 1);
psControllerSens = 0.02f;
CMD4(CCC_Float, "gamepad_sens", &psControllerSens, 0.001f, 0.6f);
psControllerDeadZoneSens = 15.f;
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/ActorInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ void CActor::IR_OnControllerPress(int cmd, float x, float y)
const float LookFactor = GetLookFactor();
CCameraBase* C = cameras[cam_active];
float scale = (cam_Active()->f_fov / g_fov) * psControllerSens * psMouseSensScale / 50.f / LookFactor; // XXX: use psControllerSensScale
OnAxisMove(x, y, scale, false); // XXX: controller axes invert
OnAxisMove(x, y, scale, psControllerInvertY.test(1));
break;
}

Expand Down Expand Up @@ -507,7 +507,7 @@ void CActor::IR_OnControllerHold(int cmd, float x, float y)
const float LookFactor = GetLookFactor();
CCameraBase* C = cameras[cam_active];
float scale = (cam_Active()->f_fov / g_fov) * psControllerSens * psMouseSensScale / 50.f / LookFactor; // XXX: use psControllerSensScale
OnAxisMove(x, y, scale, false); // XXX: controller axes invert
OnAxisMove(x, y, scale, psControllerInvertY.test(1));
break;
}

Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/CarInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ void CCar::OnControllerPress(int cmd, float x, float y)
case kLOOK_AROUND:
{
const float scale = (active_camera->f_fov / g_fov) * psControllerSens * psMouseSensScale / 50.f; // XXX: use psControllerSensScale
OnAxisMove(x, y, scale, false); // XXX: controller axes invert
OnAxisMove(x, y, scale, psControllerInvertY.test(1));
break;
}

Expand Down Expand Up @@ -299,7 +299,7 @@ void CCar::OnControllerHold(int cmd, float x, float y)
case kLOOK_AROUND:
{
const float scale = (active_camera->f_fov / g_fov) * psControllerSens * psMouseSensScale / 50.f; // XXX: use psControllerSensScale
OnAxisMove(x, y, scale, false); // XXX: controller axes invert
OnAxisMove(x, y, scale, psControllerInvertY.test(1));
break;
}

Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Spectator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void CSpectator::IR_OnKeyboardHold(int cmd)
}
}

void CSpectator::IR_OnMouseMove(int dx, int dy)
void CSpectator::IR_OnMouseMove(int dx, int dy) // XXX: Move code to OnAxisMove and support gamepad input
{
if (Remote())
return;
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/WeaponStatMgunIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void CWeaponStatMgun::OnControllerPress(int cmd, float x, float y)
case kLOOK_AROUND:
{
const float scale = psControllerSens * psMouseSensScale / 50.f; // XXX: use psControllerSensScale
OnAxisMove(x, y, scale, false); // XXX: controller axes invert
OnAxisMove(x, y, scale, psControllerInvertY.test(1));
break;
}

Expand Down Expand Up @@ -102,7 +102,7 @@ void CWeaponStatMgun::OnControllerHold(int cmd, float x, float y)
{
case kLOOK_AROUND:
const float scale = psControllerSens * psMouseSensScale / 50.f; // XXX: use psControllerSensScale
OnAxisMove(x, y, scale, false); // XXX: controller axes invert
OnAxisMove(x, y, scale, psControllerInvertY.test(1));
break;
}; // switch (cmd)
}

0 comments on commit 0e8e874

Please sign in to comment.