From 03a612487d5b840c858c900e33ce2e3bfb03d0b8 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Thu, 8 Aug 2024 19:49:11 +0200 Subject: [PATCH] cellGem: Only allow each button to be used for one action unless it's the combo button. --- rpcs3/Emu/Cell/Modules/cellGem.cpp | 31 +++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellGem.cpp b/rpcs3/Emu/Cell/Modules/cellGem.cpp index 9fd4ad8017..7ab29e3071 100644 --- a/rpcs3/Emu/Cell/Modules/cellGem.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGem.cpp @@ -914,23 +914,16 @@ static bool mouse_input_to_pad(const u32 mouse_no, be_t& digital_buttons, b return false; } + std::set pressed_buttons; const Mouse& mouse_data = ::at32(handler.GetMice(), mouse_no); - const auto is_pressed = [&mouse_data](MouseButtonCodes button) -> bool { return !!(mouse_data.buttons & button); }; + const auto is_pressed = [&mouse_data, &pressed_buttons](MouseButtonCodes button) -> bool + { + // Only allow each button to be used for one action unless it's the combo button. + return (mouse_data.buttons & button) && (button == (CELL_MOUSE_BUTTON_3 + 0u/*fix warning*/) || pressed_buttons.insert(button).second); + }; digital_buttons = 0; - if (is_pressed(CELL_MOUSE_BUTTON_1)) - digital_buttons |= CELL_GEM_CTRL_T; - - if (is_pressed(CELL_MOUSE_BUTTON_2)) - digital_buttons |= CELL_GEM_CTRL_MOVE; - - if (is_pressed(CELL_MOUSE_BUTTON_4)) - digital_buttons |= CELL_GEM_CTRL_CIRCLE; - - if (is_pressed(CELL_MOUSE_BUTTON_5)) - digital_buttons |= CELL_GEM_CTRL_CROSS; - if ((is_pressed(CELL_MOUSE_BUTTON_3) && is_pressed(CELL_MOUSE_BUTTON_1)) || is_pressed(CELL_MOUSE_BUTTON_6)) digital_buttons |= CELL_GEM_CTRL_SELECT; @@ -943,6 +936,18 @@ static bool mouse_input_to_pad(const u32 mouse_no, be_t& digital_buttons, b if (is_pressed(CELL_MOUSE_BUTTON_3) && is_pressed(CELL_MOUSE_BUTTON_5)) digital_buttons |= CELL_GEM_CTRL_SQUARE; + if (is_pressed(CELL_MOUSE_BUTTON_1)) + digital_buttons |= CELL_GEM_CTRL_T; + + if (is_pressed(CELL_MOUSE_BUTTON_2)) + digital_buttons |= CELL_GEM_CTRL_MOVE; + + if (is_pressed(CELL_MOUSE_BUTTON_4)) + digital_buttons |= CELL_GEM_CTRL_CIRCLE; + + if (is_pressed(CELL_MOUSE_BUTTON_5)) + digital_buttons |= CELL_GEM_CTRL_CROSS; + analog_t = (mouse_data.buttons & CELL_MOUSE_BUTTON_1) ? 0xFFFF : 0; return true;