mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Lock around plugin key data, don't set it unless a plugin is enabled
This commit is contained in:
parent
15a0474d40
commit
2c35c351f2
3 changed files with 14 additions and 2 deletions
|
@ -16,6 +16,7 @@
|
|||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include <set>
|
||||
#include <mutex>
|
||||
|
||||
#include "Common/Data/Format/IniFile.h"
|
||||
#include "Common/File/FileUtil.h"
|
||||
|
@ -30,6 +31,7 @@
|
|||
|
||||
namespace HLEPlugins {
|
||||
|
||||
std::mutex g_inputMutex;
|
||||
float PluginDataAxis[JOYSTICK_AXIS_MAX];
|
||||
std::map<int, uint8_t> PluginDataKeys;
|
||||
|
||||
|
@ -190,6 +192,8 @@ bool Load() {
|
|||
started = true;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(g_inputMutex);
|
||||
PluginDataKeys.clear();
|
||||
return started;
|
||||
}
|
||||
|
||||
|
@ -200,6 +204,8 @@ void Unload() {
|
|||
void Shutdown() {
|
||||
prxPlugins.clear();
|
||||
anyEnabled = false;
|
||||
std::lock_guard<std::mutex> guard(g_inputMutex);
|
||||
PluginDataKeys.clear();
|
||||
}
|
||||
|
||||
void DoState(PointerWrap &p) {
|
||||
|
@ -217,8 +223,14 @@ bool HasEnabled() {
|
|||
|
||||
void SetKey(int key, uint8_t value) {
|
||||
if (anyEnabled) {
|
||||
std::lock_guard<std::mutex> guard(g_inputMutex);
|
||||
PluginDataKeys[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t GetKey(int key) {
|
||||
std::lock_guard<std::mutex> guard(g_inputMutex);
|
||||
return PluginDataKeys[key];
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -35,8 +35,8 @@ void DoState(PointerWrap &p);
|
|||
bool HasEnabled();
|
||||
|
||||
void SetKey(int key, uint8_t value);
|
||||
uint8_t GetKey(int key);
|
||||
|
||||
extern float PluginDataAxis[JOYSTICK_AXIS_MAX];
|
||||
extern std::map<int, uint8_t> PluginDataKeys;
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -2072,7 +2072,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
return 0;
|
||||
case EMULATOR_DEVCTL__GET_VKEY:
|
||||
if (Memory::IsValidAddress(outPtr) && (argAddr >= 0 && argAddr < NKCODE_MAX)) {
|
||||
Memory::Write_U8(HLEPlugins::PluginDataKeys[argAddr], outPtr);
|
||||
Memory::Write_U8(HLEPlugins::GetKey(argAddr), outPtr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue