diff --git a/rpcs3/Emu/system_config.h b/rpcs3/Emu/system_config.h index ab0f3fffd8..89ee372a82 100644 --- a/rpcs3/Emu/system_config.h +++ b/rpcs3/Emu/system_config.h @@ -295,6 +295,7 @@ struct cfg_root : cfg::node cfg::_bool lock_overlay_input_to_player_one{this, "Lock overlay input to player one", false, true}; cfg::string midi_devices{this, "Emulated Midi devices", "Keyboardßßß@@@Keyboardßßß@@@Keyboardßßß@@@"}; cfg::_bool load_sdl_mappings{ this, "Load SDL GameController Mappings", true }; + cfg::_bool mouse_based_gyro_enabled{ this, "Mouse-based gyro enabled", false, true }; cfg::_bool pad_debug_overlay{ this, "IO Debug overlay", false, true }; cfg::_bool mouse_debug_overlay{ this, "Mouse Debug overlay", false, true }; cfg::uint<1, 180> fake_move_rotation_cone_h{ this, "Fake Move Rotation Cone", 10, true }; diff --git a/rpcs3/Input/mouse_gyro_handler.cpp b/rpcs3/Input/mouse_gyro_handler.cpp index e1b241f9cd..6d8bafd64f 100644 --- a/rpcs3/Input/mouse_gyro_handler.cpp +++ b/rpcs3/Input/mouse_gyro_handler.cpp @@ -26,6 +26,12 @@ bool mouse_gyro_handler::toggle_enabled() return m_enabled; } +void mouse_gyro_handler::set_enabled(bool enabled) +{ + m_enabled = enabled; + clear(); +} + void mouse_gyro_handler::set_gyro_active() { gui_log.notice("Mouse-based gyro activated"); diff --git a/rpcs3/Input/mouse_gyro_handler.h b/rpcs3/Input/mouse_gyro_handler.h index 9c53f574e4..90dd3d3ca4 100644 --- a/rpcs3/Input/mouse_gyro_handler.h +++ b/rpcs3/Input/mouse_gyro_handler.h @@ -13,6 +13,7 @@ class mouse_gyro_handler public: void clear(); bool toggle_enabled(); + void set_enabled(bool enabled); void handle_event(QEvent* ev, const QWindow& win); void apply_gyro(const std::shared_ptr& pad); diff --git a/rpcs3/Input/pad_thread.cpp b/rpcs3/Input/pad_thread.cpp index 6bb45e105d..6d9e4e939b 100644 --- a/rpcs3/Input/pad_thread.cpp +++ b/rpcs3/Input/pad_thread.cpp @@ -82,7 +82,7 @@ void pad_thread::Init() std::lock_guard lock(pad::g_pad_mutex); // Reset mouse-based gyro state - m_mouse_gyro.clear(); + m_mouse_gyro.set_enabled(g_cfg.io.mouse_based_gyro_enabled.get()); // Cache old settings if possible std::array pad_settings; diff --git a/rpcs3/rpcs3qt/emu_settings_type.cpp b/rpcs3/rpcs3qt/emu_settings_type.cpp index ff9340aff6..53260c2c39 100644 --- a/rpcs3/rpcs3qt/emu_settings_type.cpp +++ b/rpcs3/rpcs3qt/emu_settings_type.cpp @@ -186,6 +186,7 @@ const std::map settings_location = { emu_settings_type::GHLtar, get_cfg_location(local_cfg.io.ghltar) }, { emu_settings_type::MidiDevices, get_cfg_location(local_cfg.io.midi_devices) }, { emu_settings_type::SDLMappings, get_cfg_location(local_cfg.io.load_sdl_mappings) }, + { emu_settings_type::MouseBasedGyro, get_cfg_location(local_cfg.io.mouse_based_gyro_enabled) }, { emu_settings_type::IoDebugOverlay, get_cfg_location(local_cfg.io.pad_debug_overlay) }, { emu_settings_type::MouseDebugOverlay, get_cfg_location(local_cfg.io.mouse_debug_overlay) }, diff --git a/rpcs3/rpcs3qt/emu_settings_type.h b/rpcs3/rpcs3qt/emu_settings_type.h index c22f111c76..81f7f5e725 100644 --- a/rpcs3/rpcs3qt/emu_settings_type.h +++ b/rpcs3/rpcs3qt/emu_settings_type.h @@ -178,6 +178,7 @@ enum class emu_settings_type GHLtar, MidiDevices, SDLMappings, + MouseBasedGyro, IoDebugOverlay, MouseDebugOverlay, diff --git a/rpcs3/rpcs3qt/settings_dialog.cpp b/rpcs3/rpcs3qt/settings_dialog.cpp index 036d7c41e7..ce791f18c5 100644 --- a/rpcs3/rpcs3qt/settings_dialog.cpp +++ b/rpcs3/rpcs3qt/settings_dialog.cpp @@ -1243,6 +1243,9 @@ settings_dialog::settings_dialog(std::shared_ptr gui_settings, std ui->loadSdlMappings->setVisible(false); #endif + m_emu_settings->EnhanceCheckBox(ui->mouseBasedGyroBox, emu_settings_type::MouseBasedGyro); + SubscribeTooltip(ui->mouseBasedGyroBox, tooltips.settings.mouse_based_gyro); + #ifndef _WIN32 // Remove raw mouse handler remove_item(ui->mouseHandlerBox, static_cast(mouse_handler::raw), static_cast(g_cfg.io.mouse.def)); diff --git a/rpcs3/rpcs3qt/settings_dialog.ui b/rpcs3/rpcs3qt/settings_dialog.ui index 8e674722c0..46feb0c224 100644 --- a/rpcs3/rpcs3qt/settings_dialog.ui +++ b/rpcs3/rpcs3qt/settings_dialog.ui @@ -1841,6 +1841,13 @@ + + + + Enable Mouse-based Gyro + + + diff --git a/rpcs3/rpcs3qt/tooltips.h b/rpcs3/rpcs3qt/tooltips.h index 760bfc1509..f0f7ded85b 100644 --- a/rpcs3/rpcs3qt/tooltips.h +++ b/rpcs3/rpcs3qt/tooltips.h @@ -255,6 +255,7 @@ public: const QString show_move_cursor = tr("Shows the raw position of the PS Move input.\nThis can be very helpful during calibration screens."); const QString midi_devices = tr("Select up to 3 emulated MIDI devices and their types."); const QString sdl_mappings = tr("Loads the SDL GameController database for improved gamepad compatibility. Only used in the SDL pad handler."); + 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."); const QString lock_overlay_input_to_player_one = tr("Locks the native overlay input to the first player.");