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::map<std::string, OSDynLoad_Module> gUsedRPLs;
|
||||||
std::vector<void *> gAllocatedAddresses;
|
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 std::vector<void *> gAllocatedAddresses;
|
||||||
|
|
||||||
extern bool gNotificationModuleLoaded;
|
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) {
|
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);
|
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) {
|
if (result > 0 && ((buffer[0].hold & 0xFFFFF) == (VPAD_BUTTON_L | VPAD_BUTTON_DOWN | VPAD_BUTTON_MINUS)) && vpadPressCooldown == 0 && !configMenuOpened) {
|
||||||
wantsToOpenConfigMenu = true;
|
wantsToOpenConfigMenu = true;
|
||||||
vpadPressCooldown = 0x3C;
|
vpadPressCooldown = 0x3C;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vpadPressCooldown > 0) {
|
if (vpadPressCooldown > 0) {
|
||||||
|
@ -136,6 +136,8 @@ void ConfigUtils::displayMenu() {
|
|||||||
|
|
||||||
auto startTime = OSGetTime();
|
auto startTime = OSGetTime();
|
||||||
bool skipFirstInput = true;
|
bool skipFirstInput = true;
|
||||||
|
|
||||||
|
gOnlyAcceptFromThread = OSGetCurrentThread();
|
||||||
while (true) {
|
while (true) {
|
||||||
baseInput.reset();
|
baseInput.reset();
|
||||||
if (vpadInput.update(1280, 720)) {
|
if (vpadInput.update(1280, 720)) {
|
||||||
@ -184,6 +186,7 @@ void ConfigUtils::displayMenu() {
|
|||||||
OSSleepTicks(OSMicrosecondsToTicks(16000 - diffTime));
|
OSSleepTicks(OSMicrosecondsToTicks(16000 - diffTime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
gOnlyAcceptFromThread = nullptr;
|
||||||
|
|
||||||
for (const auto &plugin : gLoadedPlugins) {
|
for (const auto &plugin : gLoadedPlugins) {
|
||||||
const auto configData = plugin.getConfigData();
|
const auto configData = plugin.getConfigData();
|
||||||
|
Loading…
Reference in New Issue
Block a user