mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 19:45:20 +00:00
input: add horizontal mouse scroll/tilt to mouse handlers
This commit is contained in:
parent
bf85902485
commit
1600ca2c03
4 changed files with 29 additions and 19 deletions
|
@ -68,15 +68,15 @@ void MouseHandlerBase::Button(u32 index, u8 button, bool pressed)
|
|||
else
|
||||
mouse.buttons &= ~button;
|
||||
|
||||
MouseData new_data;
|
||||
MouseData new_data{};
|
||||
new_data.update = CELL_MOUSE_DATA_UPDATE;
|
||||
new_data.buttons = mouse.buttons;
|
||||
|
||||
datalist.push_back(new_data);
|
||||
datalist.push_back(std::move(new_data));
|
||||
}
|
||||
}
|
||||
|
||||
void MouseHandlerBase::Scroll(u32 index, s32 rotation)
|
||||
void MouseHandlerBase::Scroll(u32 index, s8 x, s8 y)
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
|
||||
|
@ -95,12 +95,13 @@ void MouseHandlerBase::Scroll(u32 index, s32 rotation)
|
|||
datalist.pop_front();
|
||||
}
|
||||
|
||||
MouseData new_data;
|
||||
MouseData new_data{};
|
||||
new_data.update = CELL_MOUSE_DATA_UPDATE;
|
||||
new_data.wheel = std::clamp(rotation / 120, -128, 127); // 120=event.GetWheelDelta()
|
||||
new_data.buttons = mouse.buttons;
|
||||
new_data.wheel = y;
|
||||
new_data.tilt = x;
|
||||
|
||||
datalist.push_back(new_data);
|
||||
datalist.push_back(std::move(new_data));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,7 +124,7 @@ void MouseHandlerBase::Move(u32 index, s32 x_pos_new, s32 y_pos_new, s32 x_max,
|
|||
datalist.pop_front();
|
||||
}
|
||||
|
||||
MouseData new_data;
|
||||
MouseData new_data{};
|
||||
new_data.update = CELL_MOUSE_DATA_UPDATE;
|
||||
new_data.buttons = mouse.buttons;
|
||||
|
||||
|
@ -146,7 +147,7 @@ void MouseHandlerBase::Move(u32 index, s32 x_pos_new, s32 y_pos_new, s32 x_max,
|
|||
//rawdata.data[rawdata.len % CELL_MOUSE_MAX_CODES] = 0; // (TODO)
|
||||
//rawdata.len++;
|
||||
|
||||
datalist.push_back(new_data);
|
||||
datalist.push_back(std::move(new_data));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ struct MouseData
|
|||
s8 x_axis = 0;
|
||||
s8 y_axis = 0;
|
||||
s8 wheel = 0;
|
||||
s8 tilt = 0; // (TODO)
|
||||
s8 tilt = 0;
|
||||
};
|
||||
|
||||
struct MouseTabletData
|
||||
|
@ -144,7 +144,7 @@ public:
|
|||
void save(utils::serial& ar);
|
||||
|
||||
void Button(u32 index, u8 button, bool pressed);
|
||||
void Scroll(u32 index, s32 rotation);
|
||||
void Scroll(u32 index, s8 x, s8 y);
|
||||
void Move(u32 index, s32 x_pos_new, s32 y_pos_new, s32 x_max, s32 y_max, const bool is_relative = false, s32 x_delta = 0, s32 y_delta = 0);
|
||||
|
||||
void SetIntercepted(bool intercepted);
|
||||
|
|
|
@ -103,6 +103,8 @@ bool basic_mouse_handler::eventFilter(QObject* target, QEvent* ev)
|
|||
|
||||
void basic_mouse_handler::MouseButtonDown(QMouseEvent* event)
|
||||
{
|
||||
if (!event) return;
|
||||
|
||||
const int button = event->button();
|
||||
if (const auto it = std::find_if(m_buttons.cbegin(), m_buttons.cend(), [button](const auto& entry){ return entry.second == button; });
|
||||
it != m_buttons.cend())
|
||||
|
@ -113,6 +115,8 @@ void basic_mouse_handler::MouseButtonDown(QMouseEvent* event)
|
|||
|
||||
void basic_mouse_handler::MouseButtonUp(QMouseEvent* event)
|
||||
{
|
||||
if (!event) return;
|
||||
|
||||
const int button = event->button();
|
||||
if (const auto it = std::find_if(m_buttons.cbegin(), m_buttons.cend(), [button](const auto& entry){ return entry.second == button; });
|
||||
it != m_buttons.cend())
|
||||
|
@ -123,7 +127,12 @@ void basic_mouse_handler::MouseButtonUp(QMouseEvent* event)
|
|||
|
||||
void basic_mouse_handler::MouseScroll(QWheelEvent* event)
|
||||
{
|
||||
MouseHandlerBase::Scroll(0, event->angleDelta().y());
|
||||
if (!event) return;
|
||||
|
||||
const QPoint delta = event->angleDelta();
|
||||
const s8 x = std::clamp(delta.x() / 120, -128, 127);
|
||||
const s8 y = std::clamp(delta.y() / 120, -128, 127);
|
||||
MouseHandlerBase::Scroll(0, x, y);
|
||||
}
|
||||
|
||||
bool basic_mouse_handler::get_mouse_lock_state() const
|
||||
|
@ -148,6 +157,8 @@ int basic_mouse_handler::get_mouse_button(const cfg::string& button)
|
|||
|
||||
void basic_mouse_handler::MouseMove(QMouseEvent* event)
|
||||
{
|
||||
if (!event) return;
|
||||
|
||||
if (is_time_for_update())
|
||||
{
|
||||
// get the screen dimensions
|
||||
|
|
|
@ -143,17 +143,15 @@ void raw_mouse::update_values(const RAWMOUSE& state)
|
|||
get_button_pressed(CELL_MOUSE_BUTTON_4, state.usButtonFlags);
|
||||
get_button_pressed(CELL_MOUSE_BUTTON_5, state.usButtonFlags);
|
||||
|
||||
// Get vertical mouse wheel
|
||||
// Get mouse wheel
|
||||
if ((state.usButtonFlags & RI_MOUSE_WHEEL))
|
||||
{
|
||||
m_handler->Scroll(m_index, static_cast<s16>(state.usButtonData));
|
||||
m_handler->Scroll(m_index, 0, std::clamp(static_cast<s16>(state.usButtonData) / WHEEL_DELTA, -128, 127));
|
||||
}
|
||||
else if ((state.usButtonFlags & RI_MOUSE_HWHEEL))
|
||||
{
|
||||
m_handler->Scroll(m_index, std::clamp(static_cast<s16>(state.usButtonData) / WHEEL_DELTA, -128, 127), 0);
|
||||
}
|
||||
|
||||
// Get horizontal mouse wheel. Ignored until needed.
|
||||
//if ((state.usButtonFlags & RI_MOUSE_HWHEEL))
|
||||
//{
|
||||
// m_handler->Scroll(m_index, static_cast<s16>(state.usButtonData));
|
||||
//}
|
||||
|
||||
// Get mouse movement
|
||||
if ((state.usFlags & MOUSE_MOVE_ABSOLUTE))
|
||||
|
|
Loading…
Add table
Reference in a new issue