mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-21 20:29:17 +01:00
ConfigMenu: Block reading input from other threads while the config menu is opened
This commit is contained in:
parent
340fdddf0b
commit
a8fd0b64ac
@ -12,4 +12,6 @@ std::mutex gLoadedDataMutex;
|
||||
std::map<std::string, OSDynLoad_Module> gUsedRPLs;
|
||||
std::vector<void *> gAllocatedAddresses;
|
||||
|
||||
bool gNotificationModuleLoaded = false;
|
||||
bool gNotificationModuleLoaded = false;
|
||||
|
||||
OSThread *gOnlyAcceptFromThread = nullptr;
|
@ -26,3 +26,5 @@ extern std::map<std::string, OSDynLoad_Module> gUsedRPLs;
|
||||
extern std::vector<void *> gAllocatedAddresses;
|
||||
|
||||
extern bool gNotificationModuleLoaded;
|
||||
|
||||
extern OSThread *gOnlyAcceptFromThread;
|
@ -69,11 +69,18 @@ DECL_FUNCTION(void, OSReleaseForeground) {
|
||||
}
|
||||
|
||||
DECL_FUNCTION(int32_t, VPADRead, int32_t chan, VPADStatus *buffer, uint32_t buffer_size, int32_t *error) {
|
||||
if (configMenuOpened) {
|
||||
// Ignore reading vpad input only from other threads if the config menu is opened
|
||||
if (OSGetCurrentThread() != gOnlyAcceptFromThread) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
int32_t result = real_VPADRead(chan, buffer, buffer_size, error);
|
||||
|
||||
if (result > 0 && ((buffer[0].hold & 0xFFFFF) == (VPAD_BUTTON_L | VPAD_BUTTON_DOWN | VPAD_BUTTON_MINUS)) && vpadPressCooldown == 0 && !configMenuOpened) {
|
||||
wantsToOpenConfigMenu = true;
|
||||
vpadPressCooldown = 0x3C;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (vpadPressCooldown > 0) {
|
||||
|
@ -136,6 +136,8 @@ void ConfigUtils::displayMenu() {
|
||||
|
||||
auto startTime = OSGetTime();
|
||||
bool skipFirstInput = true;
|
||||
|
||||
gOnlyAcceptFromThread = OSGetCurrentThread();
|
||||
while (true) {
|
||||
baseInput.reset();
|
||||
if (vpadInput.update(1280, 720)) {
|
||||
@ -184,6 +186,7 @@ void ConfigUtils::displayMenu() {
|
||||
OSSleepTicks(OSMicrosecondsToTicks(16000 - diffTime));
|
||||
}
|
||||
}
|
||||
gOnlyAcceptFromThread = nullptr;
|
||||
|
||||
for (const auto &plugin : gLoadedPlugins) {
|
||||
const auto configData = plugin.getConfigData();
|
||||
|
Loading…
Reference in New Issue
Block a user