mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-04-09 11:01:29 -06:00
Wrapped to a hotkey
Wrapped to a hotkey
This commit is contained in:
parent
fef0bccfa0
commit
f5cf5151d9
@ -16,6 +16,13 @@ void mouse_gyro_handler::clear()
|
||||
gyro_z = DEFAULT_MOTION_Z;
|
||||
}
|
||||
|
||||
bool mouse_gyro_handler::toggle_enabled()
|
||||
{
|
||||
enabled = !enabled;
|
||||
clear();
|
||||
return enabled;
|
||||
}
|
||||
|
||||
void mouse_gyro_handler::set_gyro_active()
|
||||
{
|
||||
active = true;
|
||||
@ -46,7 +53,10 @@ void mouse_gyro_handler::set_gyro_y(s32 steps)
|
||||
|
||||
void mouse_gyro_handler::handle_event(QEvent* ev, const QWindow& win)
|
||||
{
|
||||
// Hardcoded mouse-based motion input.
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
// Mouse-based motion input.
|
||||
// Captures mouse events while the game window is focused.
|
||||
// Updates motion sensor values via mouse position and mouse wheel while RMB is held.
|
||||
// Intentionally independent of chosen pad configuration.
|
||||
@ -109,6 +119,9 @@ void mouse_gyro_handler::handle_event(QEvent* ev, const QWindow& win)
|
||||
|
||||
void mouse_gyro_handler::apply_gyro(const std::shared_ptr<Pad>& pad)
|
||||
{
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
if (!pad || !pad->is_connected())
|
||||
return;
|
||||
|
||||
|
||||
@ -11,6 +11,8 @@ class QWindow;
|
||||
class mouse_gyro_handler
|
||||
{
|
||||
private:
|
||||
atomic_t<bool> enabled = false; // Whether mouse-based gyro emulation mode has been enabled by using the associated hotkey
|
||||
|
||||
atomic_t<bool> active = false; // Whether right mouse button is currently held (gyro active)
|
||||
atomic_t<bool> reset = false; // One-shot reset request on right mouse button release
|
||||
atomic_t<s32> gyro_x = DEFAULT_MOTION_X; // Accumulated from mouse X position relative to center
|
||||
@ -24,6 +26,7 @@ private:
|
||||
|
||||
public:
|
||||
void clear();
|
||||
bool toggle_enabled();
|
||||
|
||||
void handle_event(QEvent* ev, const QWindow& win);
|
||||
void apply_gyro(const std::shared_ptr<Pad>& pad);
|
||||
|
||||
@ -403,6 +403,15 @@ void gs_frame::handle_shortcut(gui::shortcuts::shortcut shortcut_key, const QKey
|
||||
audio::change_volume(-5);
|
||||
break;
|
||||
}
|
||||
case gui::shortcuts::shortcut::gw_toggle_mouse_gyro:
|
||||
{
|
||||
if (auto* pad_thr = pad::get_pad_thread(true))
|
||||
{
|
||||
const bool mouse_gyro_enabled = pad_thr->m_mouse_gyro.toggle_enabled();
|
||||
gui_log.notice("Mouse-based gyro emulation %s", mouse_gyro_enabled ? "enabled" : "disabled");
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
|
||||
@ -37,6 +37,7 @@ void fmt_class_string<shortcut>::format(std::string& out, u64 arg)
|
||||
case shortcut::gw_mute_unmute: return "gw_mute_unmute";
|
||||
case shortcut::gw_volume_up: return "gw_volume_up";
|
||||
case shortcut::gw_volume_down: return "gw_volume_down";
|
||||
case shortcut::gw_toggle_mouse_gyro: return "gw_toggle_mouse_gyro";
|
||||
case shortcut::count: return "count";
|
||||
}
|
||||
|
||||
@ -88,6 +89,7 @@ shortcut_settings::shortcut_settings()
|
||||
{ shortcut::gw_mute_unmute, shortcut_info{ "gw_mute_unmute", tr("Mute/Unmute Audio"), "Ctrl+Shift+M", shortcut_handler_id::game_window, false } },
|
||||
{ shortcut::gw_volume_up, shortcut_info{ "gw_volume_up", tr("Volume Up"), "Ctrl+Shift++", shortcut_handler_id::game_window, true } },
|
||||
{ shortcut::gw_volume_down, shortcut_info{ "gw_volume_down", tr("Volume Down"), "Ctrl+Shift+-", shortcut_handler_id::game_window, true } },
|
||||
{ shortcut::gw_toggle_mouse_gyro, shortcut_info{ "gw_toggle_mouse_gyro", tr("Toggle Mouse-based Gyro"), "Ctrl+G", shortcut_handler_id::game_window, false } },
|
||||
})
|
||||
{
|
||||
}
|
||||
|
||||
@ -46,6 +46,7 @@ namespace gui
|
||||
gw_mute_unmute,
|
||||
gw_volume_up,
|
||||
gw_volume_down,
|
||||
gw_toggle_mouse_gyro,
|
||||
|
||||
count
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user