Skip to content

Commit

Permalink
PAD: Fix race on shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
TellowKrinkle committed Mar 26, 2022
1 parent 39ab3e9 commit 49d5671
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pcsx2/PAD/Linux/PAD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ HostKeyEvent event;

static HostKeyEvent s_event;
std::string s_padstrLogPath("logs/");
#ifndef PCSX2_CORE
// PADclose is called from the core thread but PADupdate is called from the main thread
// I kind of hate this solution but it only needs to be here until we switch to Qt so whatever
static std::mutex s_pad_lock;
#endif

KeyStatus g_key_status;

Expand Down Expand Up @@ -96,6 +101,9 @@ s32 PADopen(const WindowInfo& wi)

void PADclose()
{
#ifndef PCSX2_CORE
std::lock_guard<std::mutex> guard(s_pad_lock);
#endif
device_manager.devices.clear();
}

Expand Down Expand Up @@ -267,6 +275,9 @@ void PADupdate(int pad)
}
#endif

#ifndef PCSX2_CORE
std::lock_guard<std::mutex> guard(s_pad_lock);
#endif
// Actually PADupdate is always call with pad == 0. So you need to update both
// pads -- Gregory
device_manager.Update();
Expand Down

0 comments on commit 49d5671

Please sign in to comment.