mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-03-10 07:24:54 +01:00
input: Add some logging to mouse_gyro_handler
This commit is contained in:
parent
064c006339
commit
bc93fdf9f4
|
|
@ -1,3 +1,4 @@
|
|||
#include "stdafx.h"
|
||||
#include "mouse_gyro_handler.h"
|
||||
|
||||
#include <QEvent>
|
||||
|
|
@ -7,53 +8,57 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
LOG_CHANNEL(gui_log, "GUI");
|
||||
|
||||
void mouse_gyro_handler::clear()
|
||||
{
|
||||
active = false;
|
||||
reset = false;
|
||||
gyro_x = DEFAULT_MOTION_X;
|
||||
gyro_y = DEFAULT_MOTION_Y;
|
||||
gyro_z = DEFAULT_MOTION_Z;
|
||||
m_active = false;
|
||||
m_reset = false;
|
||||
m_gyro_x = DEFAULT_MOTION_X;
|
||||
m_gyro_y = DEFAULT_MOTION_Y;
|
||||
m_gyro_z = DEFAULT_MOTION_Z;
|
||||
}
|
||||
|
||||
bool mouse_gyro_handler::toggle_enabled()
|
||||
{
|
||||
enabled = !enabled;
|
||||
m_enabled = !m_enabled;
|
||||
clear();
|
||||
return enabled;
|
||||
return m_enabled;
|
||||
}
|
||||
|
||||
void mouse_gyro_handler::set_gyro_active()
|
||||
{
|
||||
active = true;
|
||||
gui_log.notice("Mouse-based gyro activated");
|
||||
m_active = true;
|
||||
}
|
||||
|
||||
void mouse_gyro_handler::set_gyro_reset()
|
||||
{
|
||||
active = false;
|
||||
reset = true;
|
||||
gui_log.notice("Mouse-based gyro deactivated");
|
||||
m_active = false;
|
||||
m_reset = true;
|
||||
}
|
||||
|
||||
void mouse_gyro_handler::set_gyro_xz(s32 off_x, s32 off_y)
|
||||
{
|
||||
if (!active)
|
||||
if (!m_active)
|
||||
return;
|
||||
|
||||
gyro_x = static_cast<u16>(std::clamp(off_x, 0, DEFAULT_MOTION_X * 2 - 1));
|
||||
gyro_z = static_cast<u16>(std::clamp(off_y, 0, DEFAULT_MOTION_Z * 2 - 1));
|
||||
m_gyro_x = static_cast<u16>(std::clamp(off_x, 0, DEFAULT_MOTION_X * 2 - 1));
|
||||
m_gyro_z = static_cast<u16>(std::clamp(off_y, 0, DEFAULT_MOTION_Z * 2 - 1));
|
||||
}
|
||||
|
||||
void mouse_gyro_handler::set_gyro_y(s32 steps)
|
||||
{
|
||||
if (!active)
|
||||
if (!m_active)
|
||||
return;
|
||||
|
||||
gyro_y = static_cast<u16>(std::clamp(gyro_y + steps, 0, DEFAULT_MOTION_Y * 2 - 1));
|
||||
m_gyro_y = static_cast<u16>(std::clamp(m_gyro_y + steps, 0, DEFAULT_MOTION_Y * 2 - 1));
|
||||
}
|
||||
|
||||
void mouse_gyro_handler::handle_event(QEvent* ev, const QWindow& win)
|
||||
{
|
||||
if (!enabled)
|
||||
if (!m_enabled)
|
||||
return;
|
||||
|
||||
// Mouse-based motion input.
|
||||
|
|
@ -119,15 +124,12 @@ 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())
|
||||
if (!m_enabled || !pad || !pad->is_connected())
|
||||
return;
|
||||
|
||||
// Inject mouse-based motion sensor values into pad sensors for gyro emulation.
|
||||
// The Qt frontend maps cursor offset and wheel input to absolute motion values while RMB is held.
|
||||
if (reset)
|
||||
if (m_reset)
|
||||
{
|
||||
// RMB released → reset motion
|
||||
pad->m_sensors[0].m_value = DEFAULT_MOTION_X;
|
||||
|
|
@ -139,8 +141,8 @@ void mouse_gyro_handler::apply_gyro(const std::shared_ptr<Pad>& pad)
|
|||
{
|
||||
// RMB held → accumulate motion
|
||||
// Axes have been chosen as tested in Sly 4 minigames. Top-down view motion uses X/Z axes.
|
||||
pad->m_sensors[0].m_value = gyro_x; // Mouse X → Motion X
|
||||
pad->m_sensors[1].m_value = gyro_y; // Mouse Wheel → Motion Y
|
||||
pad->m_sensors[2].m_value = gyro_z; // Mouse Y → Motion Z
|
||||
pad->m_sensors[0].m_value = m_gyro_x; // Mouse X → Motion X
|
||||
pad->m_sensors[1].m_value = m_gyro_y; // Mouse Wheel → Motion Y
|
||||
pad->m_sensors[2].m_value = m_gyro_z; // Mouse Y → Motion Z
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,24 +10,23 @@ class QWindow;
|
|||
// Mouse-based motion sensor emulation state.
|
||||
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
|
||||
atomic_t<s32> gyro_y = DEFAULT_MOTION_Y; // Accumulated from mouse wheel delta
|
||||
atomic_t<s32> gyro_z = DEFAULT_MOTION_Z; // Accumulated from mouse Y position relative to center
|
||||
|
||||
void set_gyro_active();
|
||||
void set_gyro_reset();
|
||||
void set_gyro_xz(s32 off_x, s32 off_y);
|
||||
void set_gyro_y(s32 steps);
|
||||
|
||||
public:
|
||||
void clear();
|
||||
bool toggle_enabled();
|
||||
|
||||
void handle_event(QEvent* ev, const QWindow& win);
|
||||
void apply_gyro(const std::shared_ptr<Pad>& pad);
|
||||
|
||||
private:
|
||||
atomic_t<bool> m_enabled = false; // Whether mouse-based gyro emulation mode has been enabled by using the associated hotkey
|
||||
atomic_t<bool> m_active = false; // Whether right mouse button is currently held (gyro active)
|
||||
atomic_t<bool> m_reset = false; // One-shot reset request on right mouse button release
|
||||
atomic_t<s32> m_gyro_x = DEFAULT_MOTION_X; // Accumulated from mouse X position relative to center
|
||||
atomic_t<s32> m_gyro_y = DEFAULT_MOTION_Y; // Accumulated from mouse wheel delta
|
||||
atomic_t<s32> m_gyro_z = DEFAULT_MOTION_Z; // Accumulated from mouse Y position relative to center
|
||||
|
||||
void set_gyro_active();
|
||||
void set_gyro_reset();
|
||||
void set_gyro_xz(s32 off_x, s32 off_y);
|
||||
void set_gyro_y(s32 steps);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue