Add mouse input option for the third-person camera (#1011)

* Untie existing mouse logic from gyro

* A bit more mouse cleanup before I start building off it

* Rebase and last bit of cleanup

* Fix rebase mistake, don't apply invertFirstPerson to gyro or mouse input

* Remove the deprecated ImGui toast system

* Add Mouse Camera option in preparation for its use

* WIP, add mouse controls for the third-person camera

* Various helpText revisions

* Enable free camera on horseback

* Untie mouse camera and free camera options
Either being enabled now allows the underlying freecam logic to run

* Allow simultaneous C-stick and mouse input

* Combine mouse sensitivities for both aim and camera

* Add option for inverting mouse Y

* Refactor cursor visibility handling

* Tighten aim capture condition and constrain cursor to window region

* Tidying my trash

* Last bit of housekeeping so I'm satisfied

* Don't write code while sleep deprived

* Fix my sloppy merge and a few helpText updates

* Disable control stick aim when mouse aim is active

* Use same conditions for cursor grabbing as for capture
This commit is contained in:
Irastris
2026-06-02 01:37:53 -04:00
committed by GitHub
parent b531936a1f
commit bd9b81f700
20 changed files with 349 additions and 238 deletions
+27 -2
View File
@@ -32,6 +32,8 @@
#include "dusk/frame_interpolation.h"
#include "dusk/logging.h"
#include "dusk/action_bindings.h"
#include "dusk/mouse.h"
#include "dusk/settings.h"
#include "imgui.h"
#endif
@@ -7638,12 +7640,16 @@ void dCamera_c::deactivateDebugFlyCam() {
mDebugFlyCam.initialized = false;
}
bool dCamera_c::canUseFreeCam() {
return dusk::getSettings().game.freeCamera || dusk::getSettings().game.enableMouseCamera;
}
bool dCamera_c::freeCamera() {
if (dusk::getSettings().game.freeCamera && mGear == 1) {
if (canUseFreeCam() && mGear == 1) {
mGear = 0;
}
if (!dusk::getSettings().game.freeCamera || mCamStyle == 70)
if (!canUseFreeCam() || mCamStyle == 70)
{
mCamParam.mManualMode = 0;
return false;
@@ -7669,6 +7675,17 @@ bool dCamera_c::freeCamera() {
mCamParam.freeYAngle += camMovement.y * magnitude * dusk::getSettings().game.freeCameraYSensitivity * 5.0f;
}
f32 yaw_rad = 0.0f;
f32 pitch_rad = 0.0f;
dusk::mouse::getCameraDeltas(yaw_rad, pitch_rad);
if (dusk::getSettings().game.enableMouseCamera && (yaw_rad != 0.0f || pitch_rad != 0.0f) &&
!dComIfGp_checkCameraAttentionStatus(dComIfGp_getPlayerCameraID(0), 0x8))
{
mCamParam.mManualMode = 1;
mCamParam.freeXAngle += MTXRadToDeg(yaw_rad);
mCamParam.freeYAngle += -MTXRadToDeg(pitch_rad);
}
fopAc_ac_c* player = dComIfGp_getPlayer(0);
if (!mCamParam.mManualMode || player == nullptr) {
return false;
@@ -9350,6 +9367,10 @@ bool dCamera_c::rideCamera(s32 param_0) {
mStyleSettle.mFinished = true;
}
#if TARGET_PC
freeCamera();
#endif
return true;
}
@@ -9479,6 +9500,10 @@ bool dCamera_c::rideCamera(s32 param_0) {
setFlag(0x400);
}
#if TARGET_PC
freeCamera();
#endif
return true;
}