input: only copy relevant members to external buttons and sticks
Some checks failed
Generate Translation Template / Generate Translation Template (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (/rpcs3/.ci/build-linux.sh, gcc, rpcs3/rpcs3-ci-jammy:1.6, ubuntu-24.04) (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (a1d35836e8d45bfc6f63c26f0a3e5d46ef622fe1, rpcs3/rpcs3-binaries-linux-arm64, /rpcs3/.ci/build-linux-aarch64.sh, clang, rpcs3/rpcs3-ci-jammy-aarch64:1.6, ubuntu-24.04-arm) (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (d812f1254a1157c80fd402f94446310560f54e5f, rpcs3/rpcs3-binaries-linux, /rpcs3/.ci/build-linux.sh, clang, rpcs3/rpcs3-ci-jammy:1.6, ubuntu-24.04) (push) Has been cancelled
Build RPCS3 / RPCS3 Mac ${{ matrix.name }} (51ae32f468089a8169aaf1567de355ff4a3e0842, rpcs3/rpcs3-binaries-mac, arch -X86_64 .ci/build-mac.sh, Intel) (push) Has been cancelled
Build RPCS3 / RPCS3 Mac ${{ matrix.name }} (8e21bdbc40711a3fccd18fbf17b742348b0f4281, rpcs3/rpcs3-binaries-mac-arm64, .ci/build-mac-arm64.sh, Apple Silicon) (push) Has been cancelled
Build RPCS3 / RPCS3 Windows (push) Has been cancelled

fixes a crash in std::set, which is not thread safe
This commit is contained in:
Megamouse 2025-06-09 02:36:58 +02:00
parent 823e17288c
commit 5514d7c3d8
2 changed files with 27 additions and 5 deletions

View File

@ -379,20 +379,22 @@ enum special_button_value
struct Button struct Button
{ {
u32 m_offset = 0; u32 m_offset = 0;
std::set<u32> m_key_codes{};
u32 m_outKeyCode = 0; u32 m_outKeyCode = 0;
u16 m_value = 0; u16 m_value = 0;
bool m_pressed = false; bool m_pressed = false;
std::set<u32> m_key_codes{};
u16 m_actual_value = 0; // only used in keyboard_pad_handler u16 m_actual_value = 0; // only used in keyboard_pad_handler
bool m_analog = false; // only used in keyboard_pad_handler bool m_analog = false; // only used in keyboard_pad_handler
bool m_trigger = false; // only used in keyboard_pad_handler bool m_trigger = false; // only used in keyboard_pad_handler
std::map<u32, u16> m_pressed_keys{}; // only used in keyboard_pad_handler std::map<u32, u16> m_pressed_keys{}; // only used in keyboard_pad_handler
Button(){}
Button(u32 offset, std::set<u32> key_codes, u32 outKeyCode) Button(u32 offset, std::set<u32> key_codes, u32 outKeyCode)
: m_offset(offset) : m_offset(offset)
, m_key_codes(std::move(key_codes))
, m_outKeyCode(outKeyCode) , m_outKeyCode(outKeyCode)
, m_key_codes(std::move(key_codes))
{ {
if (offset == CELL_PAD_BTN_OFFSET_DIGITAL1) if (offset == CELL_PAD_BTN_OFFSET_DIGITAL1)
{ {
@ -419,9 +421,10 @@ struct Button
struct AnalogStick struct AnalogStick
{ {
u32 m_offset = 0; u32 m_offset = 0;
u16 m_value = 128;
std::set<u32> m_key_codes_min{}; std::set<u32> m_key_codes_min{};
std::set<u32> m_key_codes_max{}; std::set<u32> m_key_codes_max{};
u16 m_value = 128;
std::map<u32, u16> m_pressed_keys_min{}; // only used in keyboard_pad_handler std::map<u32, u16> m_pressed_keys_min{}; // only used in keyboard_pad_handler
std::map<u32, u16> m_pressed_keys_max{}; // only used in keyboard_pad_handler std::map<u32, u16> m_pressed_keys_max{}; // only used in keyboard_pad_handler

View File

@ -305,8 +305,27 @@ void pad_thread::apply_copilots()
continue; continue;
} }
pad->m_buttons_external = pad->m_buttons; pad->m_buttons_external.resize(pad->m_buttons.size());
pad->m_sticks_external = pad->m_sticks;
for (usz i = 0; i < pad->m_buttons.size(); i++)
{
const Button& src = pad->m_buttons[i];
Button& dst = pad->m_buttons_external[i];
dst.m_offset = src.m_offset;
dst.m_outKeyCode = src.m_outKeyCode;
dst.m_value = src.m_value;
dst.m_pressed = src.m_pressed;
}
for (usz i = 0; i < pad->m_sticks.size(); i++)
{
const AnalogStick& src = pad->m_sticks[i];
AnalogStick& dst = pad->m_sticks_external[i];
dst.m_offset = src.m_offset;
dst.m_value = src.m_value;
}
if (pad->copilots.empty() || pad->is_copilot()) if (pad->copilots.empty() || pad->is_copilot())
{ {