From 4d0179174aa4b68b4ac6bf15b97470b2eac6480d Mon Sep 17 00:00:00 2001 From: Megamouse Date: Fri, 30 Jul 2021 00:46:49 +0200 Subject: [PATCH] cellGem: add more mouse buttons --- rpcs3/Emu/Cell/Modules/cellGem.cpp | 32 ++++++++++++++++++++--------- rpcs3/Input/basic_mouse_handler.cpp | 12 +++++++++++ 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellGem.cpp b/rpcs3/Emu/Cell/Modules/cellGem.cpp index 8ee58d9894..9c27f9e1f2 100644 --- a/rpcs3/Emu/Cell/Modules/cellGem.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGem.cpp @@ -299,20 +299,32 @@ static bool mouse_input_to_pad(const u32 mouse_no, be_t& digital_buttons, b } const auto& mouse_data = handler.GetMice().at(0); + const auto is_pressed = [&mouse_data](MouseButtonCodes button) -> bool { return !!(mouse_data.buttons & button); }; digital_buttons = 0; - if ((mouse_data.buttons & CELL_MOUSE_BUTTON_1) && (mouse_data.buttons & CELL_MOUSE_BUTTON_2)) - digital_buttons |= CELL_GEM_CTRL_CIRCLE; - if (mouse_data.buttons & CELL_MOUSE_BUTTON_3) - digital_buttons |= CELL_GEM_CTRL_CROSS; - if (mouse_data.buttons & CELL_MOUSE_BUTTON_2) - digital_buttons |= CELL_GEM_CTRL_MOVE; - if ((mouse_data.buttons & CELL_MOUSE_BUTTON_1) && (mouse_data.buttons & CELL_MOUSE_BUTTON_3)) - digital_buttons |= CELL_GEM_CTRL_START; - if (mouse_data.buttons & CELL_MOUSE_BUTTON_1) + if (is_pressed(CELL_MOUSE_BUTTON_1)) digital_buttons |= CELL_GEM_CTRL_T; - if ((mouse_data.buttons & CELL_MOUSE_BUTTON_2) && (mouse_data.buttons & CELL_MOUSE_BUTTON_3)) + + if (is_pressed(CELL_MOUSE_BUTTON_2)) + digital_buttons |= CELL_GEM_CTRL_MOVE; + + if (is_pressed(CELL_MOUSE_BUTTON_3)) + digital_buttons |= CELL_GEM_CTRL_CROSS; + + if (is_pressed(CELL_MOUSE_BUTTON_4)) + digital_buttons |= CELL_GEM_CTRL_SELECT; + + if (is_pressed(CELL_MOUSE_BUTTON_5)) + digital_buttons |= CELL_GEM_CTRL_START; + + if (is_pressed(CELL_MOUSE_BUTTON_6) || (is_pressed(CELL_MOUSE_BUTTON_1) && is_pressed(CELL_MOUSE_BUTTON_2))) + digital_buttons |= CELL_GEM_CTRL_CIRCLE; + + if (is_pressed(CELL_MOUSE_BUTTON_7) || (is_pressed(CELL_MOUSE_BUTTON_1) && is_pressed(CELL_MOUSE_BUTTON_3))) + digital_buttons |= CELL_GEM_CTRL_SQUARE; + + if (is_pressed(CELL_MOUSE_BUTTON_8) || (is_pressed(CELL_MOUSE_BUTTON_2) && is_pressed(CELL_MOUSE_BUTTON_3))) digital_buttons |= CELL_GEM_CTRL_TRIANGLE; analog_t = (mouse_data.buttons & CELL_MOUSE_BUTTON_1) ? 0xFFFF : 0; diff --git a/rpcs3/Input/basic_mouse_handler.cpp b/rpcs3/Input/basic_mouse_handler.cpp index e6a11a7736..476b4554ec 100644 --- a/rpcs3/Input/basic_mouse_handler.cpp +++ b/rpcs3/Input/basic_mouse_handler.cpp @@ -85,6 +85,12 @@ void basic_mouse_handler::MouseButtonDown(QMouseEvent* event) if (event->button() == Qt::LeftButton) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_1, true); else if (event->button() == Qt::RightButton) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_2, true); else if (event->button() == Qt::MiddleButton) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_3, true); + // TODO: verify these + else if (event->button() == Qt::ExtraButton1) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_4, true); + else if (event->button() == Qt::ExtraButton2) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_5, true); + else if (event->button() == Qt::ExtraButton3) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_6, true); + else if (event->button() == Qt::ExtraButton4) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_7, true); + else if (event->button() == Qt::ExtraButton5) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_8, true); } void basic_mouse_handler::MouseButtonUp(QMouseEvent* event) @@ -92,6 +98,12 @@ void basic_mouse_handler::MouseButtonUp(QMouseEvent* event) if (event->button() == Qt::LeftButton) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_1, false); else if (event->button() == Qt::RightButton) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_2, false); else if (event->button() == Qt::MiddleButton) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_3, false); + // TODO: verify these + else if (event->button() == Qt::ExtraButton1) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_4, false); + else if (event->button() == Qt::ExtraButton2) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_5, false); + else if (event->button() == Qt::ExtraButton3) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_6, false); + else if (event->button() == Qt::ExtraButton4) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_7, false); + else if (event->button() == Qt::ExtraButton5) MouseHandlerBase::Button(CELL_MOUSE_BUTTON_8, false); } void basic_mouse_handler::MouseScroll(QWheelEvent* event)