Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
320f455
Untie existing mouse logic from gyro
Irastris May 11, 2026
0d62920
A bit more mouse cleanup before I start building off it
Irastris May 11, 2026
6c5ea1d
Rebase and last bit of cleanup
Irastris May 19, 2026
624cbf4
Fix rebase mistake, don't apply invertFirstPerson to gyro or mouse input
Irastris May 19, 2026
735335d
Remove the deprecated ImGui toast system
Irastris May 20, 2026
66de774
Add Mouse Camera option in preparation for its use
Irastris May 20, 2026
8452c2d
WIP, add mouse controls for the third-person camera
Irastris May 20, 2026
3ec9078
Various helpText revisions
Irastris May 22, 2026
75e3a48
Merge branch 'main' into ira/more-mouse
Irastris May 25, 2026
7f5a332
Enable free camera on horseback
Irastris May 25, 2026
271e020
Untie mouse camera and free camera options
Irastris May 26, 2026
284aec1
Allow simultaneous C-stick and mouse input
Irastris May 27, 2026
5b3ed26
Merge branch 'main' into ira/more-mouse
Irastris May 27, 2026
5516567
Combine mouse sensitivities for both aim and camera
Irastris May 27, 2026
f609ff5
Add option for inverting mouse Y
Irastris May 27, 2026
fa6d94e
Refactor cursor visibility handling
Irastris May 28, 2026
77f6a5a
Tighten aim capture condition and constrain cursor to window region
Irastris May 28, 2026
adede6a
Tidying my trash
Irastris May 28, 2026
bd8fed4
Last bit of housekeeping so I'm satisfied
Irastris May 28, 2026
4db2f23
Don't write code while sleep deprived
Irastris May 28, 2026
b044fd6
Merge branch 'main' into ira/more-mouse
Irastris May 28, 2026
e545c39
Fix my sloppy merge and a few helpText updates
Irastris May 28, 2026
d92a305
Disable control stick aim when mouse aim is active
Irastris May 28, 2026
c97c216
Use same conditions for cursor grabbing as for capture
Irastris May 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,7 @@ set(DUSK_FILES
src/dusk/game_clock.cpp
src/dusk/globals.cpp
src/dusk/gyro.cpp
src/dusk/mouse.cpp
src/dusk/gamepad_color.cpp
src/dusk/autosave.cpp
src/dusk/http/http.hpp
Expand Down
2 changes: 1 addition & 1 deletion include/d/actor/d_a_alink.h
Original file line number Diff line number Diff line change
Expand Up @@ -4551,7 +4551,7 @@ class daAlink_c : public daPy_py_c {
#if TARGET_PC
void handleWolfHowl();
void handleQuickTransform();
bool checkGyroAimContext();
bool checkAimContext();

void onIronBallChainInterpCallback();

Expand Down
1 change: 1 addition & 0 deletions include/d/d_camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,7 @@ class dCamera_c {
bool test1Camera(s32);
bool test2Camera(s32);
#if TARGET_PC
static bool canUseFreeCam();
bool freeCamera();
bool executeDebugFlyCam();
void deactivateDebugFlyCam();
Expand Down
5 changes: 1 addition & 4 deletions include/dusk/gyro.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef DUSK_GYRO_H
#define DUSK_GYRO_H
#pragma once

namespace dusk::gyro {
void read(float dt);
Expand All @@ -14,5 +13,3 @@ bool get_sensor_keep_alive();
void set_sensor_keep_alive(bool value);
bool rollgoal_gyro_enabled();
} // namespace dusk::gyro

#endif
12 changes: 12 additions & 0 deletions include/dusk/mouse.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#include <SDL3/SDL_events.h>

namespace dusk::mouse {
void read();
void getAimDeltas(float& out_yaw, float& out_pitch);
void getCameraDeltas(float& out_yaw, float& out_pitch);
void handle_event(const SDL_Event& event) noexcept;
void onFocusLost();
void onFocusGained();
} // namespace dusk::mouse
6 changes: 5 additions & 1 deletion include/dusk/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ struct UserSettings {
ConfigVar<bool> midnasLamentNonStop;

// Input
ConfigVar<GyroMode> gyroMode;
ConfigVar<bool> enableGyroAim;
ConfigVar<bool> enableGyroRollgoal;
ConfigVar<float> gyroSensitivityX;
Expand All @@ -197,6 +196,11 @@ struct UserSettings {
ConfigVar<float> gyroDeadband;
ConfigVar<bool> gyroInvertPitch;
ConfigVar<bool> gyroInvertYaw;
ConfigVar<bool> enableMouseCamera;
ConfigVar<bool> enableMouseAim;
ConfigVar<float> mouseAimSensitivity;
ConfigVar<float> mouseCameraSensitivity;
ConfigVar<bool> invertMouseY;
ConfigVar<bool> freeCamera;
ConfigVar<bool> invertCameraXAxis;
ConfigVar<bool> invertCameraYAxis;
Expand Down
2 changes: 1 addition & 1 deletion src/d/actor/d_a_alink_dusk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void daAlink_c::handleQuickTransform() {
procCoMetamorphoseInit();
}

bool daAlink_c::checkGyroAimContext() {
bool daAlink_c::checkAimContext() {
switch (mProcID) {
case PROC_SUBJECTIVITY:
case PROC_SWIM_SUBJECTIVITY:
Expand Down
42 changes: 31 additions & 11 deletions src/d/actor/d_a_alink_link.inc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
#include "d/actor/d_a_tag_mhint.h"

#if TARGET_PC
#include "dusk/gyro.h"
#include "dusk/action_bindings.h"
#include "dusk/gyro.h"
#include "dusk/mouse.h"
#endif

bool daAlink_c::checkNoSubjectModeCamera() {
Expand Down Expand Up @@ -120,18 +121,28 @@ BOOL daAlink_c::setBodyAngleToCamera() {
var_f31 /= dComIfGp_getCameraZoomScale(field_0x317c);
}

shape_angle.y = shape_angle.y + (var_f31 * cM_ssin(mStickAngle) IF_DUSK(* (dusk::getSettings().game.invertFirstPersonXAxis ? -1.0f : 1.0f)));
sp8 = mBodyAngle.x + (var_f31 * cM_scos(mStickAngle) IF_DUSK(* (dusk::getSettings().game.invertFirstPersonYAxis ? -1.0f : 1.0f)));

if (checkNotItemSinkLimit() && sp8 > 0 && sp8 > mBodyAngle.x) {
#if TARGET_PC
if (dusk::getSettings().game.enableMouseAim && checkAimContext()) {
sp8 = mBodyAngle.x;
} else
#endif
{
shape_angle.y = shape_angle.y + (var_f31 * cM_ssin(mStickAngle) IF_DUSK(* (dusk::getSettings().game.invertFirstPersonXAxis ? -1.0f : 1.0f)));
sp8 = mBodyAngle.x + (var_f31 * cM_scos(mStickAngle) IF_DUSK(* (dusk::getSettings().game.invertFirstPersonYAxis ? -1.0f : 1.0f)));

if (checkNotItemSinkLimit() && sp8 > 0 && sp8 > mBodyAngle.x) {
sp8 = mBodyAngle.x;
}
}
} else {
sp8 = mBodyAngle.x;
}

#if TARGET_PC
if (dusk::getSettings().game.enableGyroAim && checkGyroAimContext()) {
if ((dusk::getSettings().game.enableGyroAim ||
dusk::getSettings().game.enableMouseAim) &&
checkAimContext())
{
f32 gyro_scale = 1.0f;
if (checkWolfEyeUp()) {
gyro_scale *= 0.6f;
Expand All @@ -141,12 +152,21 @@ BOOL daAlink_c::setBodyAngleToCamera() {
gyro_scale /= dComIfGp_getCameraZoomScale(field_0x317c);
}

f32 gy_yaw = 0.f;
f32 gy_pitch = 0.f;
dusk::gyro::getAimDeltas(gy_yaw, gy_pitch);
f32 final_yaw = 0.f;
f32 final_pitch = 0.f;
if (dusk::getSettings().game.enableMouseAim) {
dusk::mouse::getAimDeltas(final_yaw, final_pitch);
}
if (dusk::getSettings().game.enableGyroAim) {
f32 gyro_yaw = 0.f;
f32 gyro_pitch = 0.f;
dusk::gyro::getAimDeltas(gyro_yaw, gyro_pitch);
final_yaw += gyro_yaw;
final_pitch += gyro_pitch;
}

shape_angle.y = shape_angle.y + cM_rad2s(gy_yaw * gyro_scale);
sp8 = sp8 + cM_rad2s(gy_pitch * gyro_scale);
shape_angle.y = shape_angle.y + cM_rad2s(final_yaw * gyro_scale);
sp8 = sp8 + cM_rad2s(final_pitch * gyro_scale);

if (checkNotItemSinkLimit() && sp8 > 0 && sp8 > mBodyAngle.x) {
sp8 = mBodyAngle.x;
Expand Down
29 changes: 27 additions & 2 deletions src/d/d_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -9350,6 +9367,10 @@ bool dCamera_c::rideCamera(s32 param_0) {
mStyleSettle.mFinished = true;
}

#if TARGET_PC
freeCamera();
#endif

return true;
}

Expand Down Expand Up @@ -9479,6 +9500,10 @@ bool dCamera_c::rideCamera(s32 param_0) {
setFlag(0x400);
}

#if TARGET_PC
freeCamera();
#endif

return true;
}

Expand Down
55 changes: 2 additions & 53 deletions src/dusk/gyro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#include "dusk/ui/ui.hpp"
#include "d/actor/d_a_alink.h"

#include <aurora/lib/window.hpp>
#include <SDL3/SDL_mouse.h>
#include <cmath>

namespace dusk::gyro {
Expand All @@ -16,14 +14,11 @@ constexpr float kGravityEmaAlpha = 0.1f;
constexpr float kMinGravityProjection = 0.2f;
// Let roll contribute more strongly as the pad approaches an upright posture.
constexpr float kRollAimBoostMax = 2.0f;
constexpr float kMousePixelToRad = 0.0025f;

bool s_sensor_enabled = false;
bool s_accel_enabled = false;
bool s_was_aiming = false;
bool s_have_gravity_baseline = false;
bool s_mouse_enabled = false;
bool s_mouse_relative = false;
float s_smooth_gx = 0.0f;
float s_smooth_gy = 0.0f;
float s_smooth_gz = 0.0f;
Expand All @@ -43,7 +38,6 @@ void reset_filter_state() {
s_baseline_gravity_y = s_baseline_gravity_z = 0.0f;
s_was_aiming = false;
s_have_gravity_baseline = false;
s_mouse_enabled = false;
s_yaw_rad = s_pitch_rad = s_roll_rad = 0.0f;
s_rollgoal_ax = s_rollgoal_az = 0;
}
Expand Down Expand Up @@ -72,7 +66,7 @@ bool get_sensor_keep_alive() { return s_sensor_keep_alive; }
void set_sensor_keep_alive(bool value) { s_sensor_keep_alive = value; }

bool rollgoal_gyro_enabled() {
return getSettings().game.enableGyroRollgoal && getSettings().game.gyroMode.getValue() != GyroMode::Mouse;
return getSettings().game.enableGyroRollgoal;
}

bool queryGyroAimContext() {
Expand All @@ -85,7 +79,7 @@ bool queryGyroAimContext() {
return false;
}

return link->checkGyroAimContext() && dComIfGp_checkCameraAttentionStatus(link->field_0x317c, 0x10);
return link->checkAimContext() && dComIfGp_checkCameraAttentionStatus(link->field_0x317c, 0x10);
}

void read(float dt) {
Expand All @@ -94,26 +88,6 @@ void read(float dt) {
const bool aim_just_ended = !aim_active && s_was_aiming;
s_was_aiming = aim_active;

const bool mouse_mode = getSettings().game.gyroMode.getValue() == GyroMode::Mouse;
const bool mouse_gyro_active = !ui::any_document_visible() && mouse_mode && (aim_active || s_sensor_keep_alive);
SDL_Window* window = aurora::window::get_sdl_window();
if (window != nullptr && mouse_gyro_active != s_mouse_relative &&
SDL_SetWindowRelativeMouseMode(window, mouse_gyro_active))
{
s_mouse_relative = mouse_gyro_active;
}

if (mouse_gyro_active && !s_mouse_enabled && window != nullptr) {
const AuroraWindowSize sz = aurora::window::get_window_size();
const float cx = static_cast<float>(sz.width) * 0.5f;
const float cy = static_cast<float>(sz.height) * 0.5f;
SDL_WarpMouseInWindow(window, cx, cy);
float discard_x = 0.0f;
float discard_y = 0.0f;
SDL_GetRelativeMouseState(&discard_x, &discard_y);
}
s_mouse_enabled = mouse_gyro_active;

if (!s_sensor_keep_alive && !aim_active) {
disable_pad_sensors();
reset_filter_state();
Expand All @@ -126,31 +100,6 @@ void read(float dt) {
s_have_gravity_baseline = false;
}

if (mouse_mode && !mouse_gyro_active) {
s_pitch_rad = 0.0f;
s_yaw_rad = 0.0f;
s_roll_rad = 0.0f;
return;
}

if (mouse_mode) {
disable_pad_sensors();

float mx_rel = 0.0f;
float my_rel = 0.0f;
SDL_GetRelativeMouseState(&mx_rel, &my_rel);
// Convert pixels to radians
s_pitch_rad = my_rel * kMousePixelToRad * getSettings().game.gyroSensitivityY;
s_yaw_rad = -mx_rel * kMousePixelToRad * getSettings().game.gyroSensitivityX;
s_roll_rad = 0.0f;

s_pitch_rad = getSettings().game.gyroInvertPitch ? -s_pitch_rad : s_pitch_rad;
s_yaw_rad = getSettings().game.gyroInvertYaw ? -s_yaw_rad : s_yaw_rad;
s_yaw_rad = getSettings().game.enableMirrorMode ? -s_yaw_rad : s_yaw_rad;

return;
}

if (!s_sensor_enabled) {
if (!PADHasSensor(PAD_CHAN0, PAD_SENSOR_GYRO)) {
return;
Expand Down
Loading
Loading