mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-13 00:58:29 +02:00
InputCommon / DolphinQt / Core: Add a "RelativeMouse" input which provides the raw delta mouse input
Co-authored-by: Jordan Woyak <jordan.woyak@gmail.com>
This commit is contained in:
@ -197,6 +197,11 @@ KeyboardMouse::KeyboardMouse(Window window, int opcode, int pointer, int keyboar
|
||||
// Mouse Axis, X-/+ and Y-/+
|
||||
for (int i = 0; i != 4; ++i)
|
||||
AddInput(new Axis(!!(i & 2), !!(i & 1), (i & 2) ? &m_state.axis.y : &m_state.axis.x));
|
||||
|
||||
// Relative Mouse, X-/+ and Y-/+
|
||||
for (int i = 0; i != 4; ++i)
|
||||
AddInput(new RelativeMouse(!!(i & 2), !!(i & 1),
|
||||
(i & 2) ? &m_state.relative_mouse.y : &m_state.relative_mouse.x));
|
||||
}
|
||||
|
||||
KeyboardMouse::~KeyboardMouse()
|
||||
@ -302,6 +307,9 @@ void KeyboardMouse::UpdateInput()
|
||||
XFreeEventData(m_display, &event.xcookie);
|
||||
}
|
||||
|
||||
m_state.relative_mouse.x = delta_x;
|
||||
m_state.relative_mouse.y = delta_y;
|
||||
|
||||
// apply axis smoothing
|
||||
m_state.axis.x *= MOUSE_AXIS_SMOOTHING;
|
||||
m_state.axis.x += delta_x;
|
||||
@ -391,8 +399,20 @@ KeyboardMouse::Axis::Axis(u8 index, bool positive, const float* axis)
|
||||
name = fmt::format("Axis {}{}", static_cast<char>('X' + m_index), (m_positive ? '+' : '-'));
|
||||
}
|
||||
|
||||
KeyboardMouse::RelativeMouse::RelativeMouse(u8 index, bool positive, const float* axis)
|
||||
: m_axis(axis), m_index(index), m_positive(positive)
|
||||
{
|
||||
name =
|
||||
fmt::format("RelativeMouse {}{}", static_cast<char>('X' + m_index), (m_positive ? '+' : '-'));
|
||||
}
|
||||
|
||||
ControlState KeyboardMouse::Axis::GetState() const
|
||||
{
|
||||
return std::max(0.0f, *m_axis / (m_positive ? MOUSE_AXIS_SENSITIVITY : -MOUSE_AXIS_SENSITIVITY));
|
||||
}
|
||||
|
||||
ControlState KeyboardMouse::RelativeMouse::GetState() const
|
||||
{
|
||||
return std::max(0.0f, *m_axis / (m_positive ? MOUSE_AXIS_SENSITIVITY : -MOUSE_AXIS_SENSITIVITY));
|
||||
}
|
||||
} // namespace ciface::XInput2
|
||||
|
Reference in New Issue
Block a user