diff --git a/Makefile b/Makefile index 42eefd6..7e28f4b 100644 --- a/Makefile +++ b/Makefile @@ -127,7 +127,7 @@ export OUTPUT := $(CURDIR)/$(TARGET) #--------------------------------------------------------------------------------- $(BUILD): - @[ -d $@ ] || mkdir -p $@ + @$(shell [ ! -d $(BUILD) ] && mkdir -p $(BUILD)) @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile diff --git a/src/main.cpp b/src/main.cpp index c595a2c..ea21c3c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -57,11 +57,16 @@ extern "C" uint32_t start_wrapper(int argc, char **argv) { DEBUG_FUNCTION_LINE_VERBOSE("Hello from payload.elf multiloader"); - VPADReadError err; - VPADStatus vpad_data; - VPADRead(VPAD_CHAN_0, &vpad_data, 1, &err); - - uint32_t btn = vpad_data.hold | vpad_data.trigger; + VPADStatus vpadStatus{}; + VPADReadError vpadError = VPAD_READ_UNINITIALIZED; + int btn = 0; + do { + if (VPADRead(VPAD_CHAN_0, &vpadStatus, 1, &vpadError) > 0 && vpadError == VPAD_READ_SUCCESS) { + btn = vpadStatus.trigger | vpadStatus.hold; + } else { + OSSleepTicks(OSMillisecondsToTicks(1)); + } + } while (vpadError == VPAD_READ_NO_SAMPLES); std::map payloads = get_all_payloads("wiiu/payloads");