Skip to content

Commit 9a2243b

Browse files
authored
Add "Enable Mouse-based Gyro" setting to I/O config (#18835)
This is a continuation of my work on #18113. Addresses issue #18197. Adds a new checkbox in the I/O settings tab that enables mouse-based gyro emulation at game startup, making the feature more discoverable to users.
1 parent 97704e3 commit 9a2243b

9 files changed

Lines changed: 22 additions & 1 deletion

rpcs3/Emu/system_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ struct cfg_root : cfg::node
295295
cfg::_bool lock_overlay_input_to_player_one{this, "Lock overlay input to player one", false, true};
296296
cfg::string midi_devices{this, "Emulated Midi devices", "Keyboardßßß@@@Keyboardßßß@@@Keyboardßßß@@@"};
297297
cfg::_bool load_sdl_mappings{ this, "Load SDL GameController Mappings", true };
298+
cfg::_bool mouse_based_gyro_enabled{ this, "Mouse-based gyro enabled", false, true };
298299
cfg::_bool pad_debug_overlay{ this, "IO Debug overlay", false, true };
299300
cfg::_bool mouse_debug_overlay{ this, "Mouse Debug overlay", false, true };
300301
cfg::uint<1, 180> fake_move_rotation_cone_h{ this, "Fake Move Rotation Cone", 10, true };

rpcs3/Input/mouse_gyro_handler.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ bool mouse_gyro_handler::toggle_enabled()
2626
return m_enabled;
2727
}
2828

29+
void mouse_gyro_handler::set_enabled(bool enabled)
30+
{
31+
m_enabled = enabled;
32+
clear();
33+
}
34+
2935
void mouse_gyro_handler::set_gyro_active()
3036
{
3137
gui_log.notice("Mouse-based gyro activated");

rpcs3/Input/mouse_gyro_handler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class mouse_gyro_handler
1313
public:
1414
void clear();
1515
bool toggle_enabled();
16+
void set_enabled(bool enabled);
1617

1718
void handle_event(QEvent* ev, const QWindow& win);
1819
void apply_gyro(const std::shared_ptr<Pad>& pad);

rpcs3/Input/pad_thread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void pad_thread::Init()
8282
std::lock_guard lock(pad::g_pad_mutex);
8383

8484
// Reset mouse-based gyro state
85-
m_mouse_gyro.clear();
85+
m_mouse_gyro.set_enabled(g_cfg.io.mouse_based_gyro_enabled.get());
8686

8787
// Cache old settings if possible
8888
std::array<pad_setting, CELL_PAD_MAX_PORT_NUM> pad_settings;

rpcs3/rpcs3qt/emu_settings_type.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ const std::map<emu_settings_type, cfg_location> settings_location =
186186
{ emu_settings_type::GHLtar, get_cfg_location(local_cfg.io.ghltar) },
187187
{ emu_settings_type::MidiDevices, get_cfg_location(local_cfg.io.midi_devices) },
188188
{ emu_settings_type::SDLMappings, get_cfg_location(local_cfg.io.load_sdl_mappings) },
189+
{ emu_settings_type::MouseBasedGyro, get_cfg_location(local_cfg.io.mouse_based_gyro_enabled) },
189190
{ emu_settings_type::IoDebugOverlay, get_cfg_location(local_cfg.io.pad_debug_overlay) },
190191
{ emu_settings_type::MouseDebugOverlay, get_cfg_location(local_cfg.io.mouse_debug_overlay) },
191192

rpcs3/rpcs3qt/emu_settings_type.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ enum class emu_settings_type
178178
GHLtar,
179179
MidiDevices,
180180
SDLMappings,
181+
MouseBasedGyro,
181182
IoDebugOverlay,
182183
MouseDebugOverlay,
183184

rpcs3/rpcs3qt/settings_dialog.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,9 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
12431243
ui->loadSdlMappings->setVisible(false);
12441244
#endif
12451245

1246+
m_emu_settings->EnhanceCheckBox(ui->mouseBasedGyroBox, emu_settings_type::MouseBasedGyro);
1247+
SubscribeTooltip(ui->mouseBasedGyroBox, tooltips.settings.mouse_based_gyro);
1248+
12461249
#ifndef _WIN32
12471250
// Remove raw mouse handler
12481251
remove_item(ui->mouseHandlerBox, static_cast<int>(mouse_handler::raw), static_cast<int>(g_cfg.io.mouse.def));

rpcs3/rpcs3qt/settings_dialog.ui

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,6 +1841,13 @@
18411841
</property>
18421842
</widget>
18431843
</item>
1844+
<item>
1845+
<widget class="QCheckBox" name="mouseBasedGyroBox">
1846+
<property name="text">
1847+
<string>Enable Mouse-based Gyro</string>
1848+
</property>
1849+
</widget>
1850+
</item>
18441851
<item>
18451852
<spacer name="verticalSpacerIoAdditionalSettings">
18461853
<property name="orientation">

rpcs3/rpcs3qt/tooltips.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ class Tooltips : public QObject
255255
const QString show_move_cursor = tr("Shows the raw position of the PS Move input.\nThis can be very helpful during calibration screens.");
256256
const QString midi_devices = tr("Select up to 3 emulated MIDI devices and their types.");
257257
const QString sdl_mappings = tr("Loads the SDL GameController database for improved gamepad compatibility. Only used in the SDL pad handler.");
258+
const QString mouse_based_gyro = tr("Enables mouse-based gyro emulation at game startup. It can also be toggled at any time with the associated hotkey.\nHold the right mouse button to activate gyro input: moving the mouse maps to the X and Z motion axes, and the scroll wheel maps to the Y axis. Release the button to reset the motion values.");
258259

259260
const QString lock_overlay_input_to_player_one = tr("Locks the native overlay input to the first player.");
260261

0 commit comments

Comments
 (0)