mirror of
https://github.com/wiiu-env/PayloadLoaderInstaller.git
synced 2025-03-02 14:35:23 +01:00
Fix input when no gamepad is connected.
This commit is contained in:
parent
6f833c9811
commit
80110c3f4c
@ -1,6 +1,6 @@
|
|||||||
FROM wiiuenv/devkitppc:20210917
|
FROM wiiuenv/devkitppc:20210920
|
||||||
|
|
||||||
COPY --from=wiiuenv/libiosuhax:20210109 /artifacts $DEVKITPRO
|
COPY --from=wiiuenv/libiosuhax:20211008 /artifacts $DEVKITPRO
|
||||||
COPY --from=wiiuenv/devkitarm:20210917 $DEVKITPRO/devkitARM $DEVKITPRO/devkitARM
|
COPY --from=wiiuenv/devkitarm:20210917 $DEVKITPRO/devkitARM $DEVKITPRO/devkitARM
|
||||||
|
|
||||||
ENV DEVKITARM=/opt/devkitpro/devkitARM
|
ENV DEVKITARM=/opt/devkitpro/devkitARM
|
||||||
|
6
Makefile
6
Makefile
@ -35,12 +35,10 @@ BUILD := build
|
|||||||
SOURCES := source \
|
SOURCES := source \
|
||||||
source/common \
|
source/common \
|
||||||
source/utils \
|
source/utils \
|
||||||
source/fs
|
source/fs \
|
||||||
|
source/input
|
||||||
INCLUDES := include source
|
INCLUDES := include source
|
||||||
CONTENT := meta
|
|
||||||
ICON := meta/icon.jpg
|
ICON := meta/icon.jpg
|
||||||
TV_SPLASH := meta/icon.jpg
|
|
||||||
DRC_SPLASH := meta/icon.jpg
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# options for code generation
|
# options for code generation
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "ApplicationState.h"
|
#include "ApplicationState.h"
|
||||||
#include "WiiUScreen.h"
|
#include "utils/WiiUScreen.h"
|
||||||
#include "ScreenUtils.h"
|
#include "utils/ScreenUtils.h"
|
||||||
#include "StringTools.h"
|
#include "utils/StringTools.h"
|
||||||
#include "../build/safe_payload.h"
|
#include "../build/safe_payload.h"
|
||||||
#include <sysapp/launch.h>
|
#include <sysapp/launch.h>
|
||||||
#include <iosuhax.h>
|
#include <iosuhax.h>
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <input/Input.h>
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
#include "InstallerService.h"
|
#include "InstallerService.h"
|
||||||
#include "Input.h"
|
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
|
|
||||||
class ApplicationState {
|
class ApplicationState {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
#include "WiiUScreen.h"
|
#include "utils/WiiUScreen.h"
|
||||||
#include "StringTools.h"
|
#include "utils/StringTools.h"
|
||||||
#include "fs/FSUtils.h"
|
#include "fs/FSUtils.h"
|
||||||
#include "common/fst_structs.h"
|
#include "common/fst_structs.h"
|
||||||
#include "InstallerService.h"
|
#include "InstallerService.h"
|
||||||
|
@ -4,10 +4,8 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include "Input.h"
|
#include "utils/WiiUScreen.h"
|
||||||
#include "WiiUScreen.h"
|
#include "utils/ScreenUtils.h"
|
||||||
#include "ScreenUtils.h"
|
|
||||||
#include "VPADInput.h"
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class Menu {
|
class Menu {
|
||||||
|
20
source/input/CombinedInput.h
Normal file
20
source/input/CombinedInput.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
class CombinedInput : public Input {
|
||||||
|
public:
|
||||||
|
void combine(const Input &b) {
|
||||||
|
data.buttons_h |= b.data.buttons_h;
|
||||||
|
}
|
||||||
|
|
||||||
|
void process() {
|
||||||
|
data.buttons_d |= (data.buttons_h & (~lastData.buttons_h));
|
||||||
|
data.buttons_r |= (lastData.buttons_h & (~data.buttons_h));
|
||||||
|
lastData.buttons_h = data.buttons_h;
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
data.buttons_h = 0;
|
||||||
|
data.buttons_d = 0;
|
||||||
|
data.buttons_r = 0;
|
||||||
|
}
|
||||||
|
};
|
@ -11,12 +11,6 @@ public:
|
|||||||
//!Destructor
|
//!Destructor
|
||||||
virtual ~Input() = default;
|
virtual ~Input() = default;
|
||||||
|
|
||||||
void combine(const Input& b) {
|
|
||||||
data.buttons_d |= b.data.buttons_d;
|
|
||||||
data.buttons_h |= b.data.buttons_h;
|
|
||||||
data.buttons_r |= b.data.buttons_r;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum eButtons {
|
enum eButtons {
|
||||||
BUTTON_NONE = 0x0000,
|
BUTTON_NONE = 0x0000,
|
||||||
VPAD_TOUCH = 0x80000000,
|
VPAD_TOUCH = 0x80000000,
|
||||||
@ -63,4 +57,5 @@ public:
|
|||||||
|
|
||||||
PadData data{};
|
PadData data{};
|
||||||
PadData lastData{};
|
PadData lastData{};
|
||||||
|
|
||||||
};
|
};
|
@ -23,10 +23,11 @@ class VPadInput : public Input {
|
|||||||
public:
|
public:
|
||||||
//!Constructor
|
//!Constructor
|
||||||
VPadInput() {
|
VPadInput() {
|
||||||
|
memset(&vpad, 0, sizeof(vpad));
|
||||||
}
|
}
|
||||||
|
|
||||||
//!Destructor
|
//!Destructor
|
||||||
~VPadInput() override {}
|
~VPadInput() override = default;
|
||||||
|
|
||||||
bool update(int32_t width, int32_t height) {
|
bool update(int32_t width, int32_t height) {
|
||||||
lastData = data;
|
lastData = data;
|
||||||
@ -48,6 +49,8 @@ public:
|
|||||||
data.y = -(height >> 1) + (int32_t) (float) height - (((float) tpCalib.y / 720.0f) * (float) height);
|
data.y = -(height >> 1) + (int32_t) (float) height - (((float) tpCalib.y / 720.0f) * (float) height);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
data.buttons_h = 0;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
@ -31,43 +31,43 @@ public:
|
|||||||
uint32_t remapWiiMoteButtons(uint32_t buttons) {
|
uint32_t remapWiiMoteButtons(uint32_t buttons) {
|
||||||
uint32_t conv_buttons = 0;
|
uint32_t conv_buttons = 0;
|
||||||
|
|
||||||
if(buttons & WPAD_BUTTON_LEFT)
|
if (buttons & WPAD_BUTTON_LEFT)
|
||||||
conv_buttons |= Input::BUTTON_LEFT;
|
conv_buttons |= Input::BUTTON_LEFT;
|
||||||
|
|
||||||
if(buttons & WPAD_BUTTON_RIGHT)
|
if (buttons & WPAD_BUTTON_RIGHT)
|
||||||
conv_buttons |= Input::BUTTON_RIGHT;
|
conv_buttons |= Input::BUTTON_RIGHT;
|
||||||
|
|
||||||
if(buttons & WPAD_BUTTON_DOWN)
|
if (buttons & WPAD_BUTTON_DOWN)
|
||||||
conv_buttons |= Input::BUTTON_DOWN;
|
conv_buttons |= Input::BUTTON_DOWN;
|
||||||
|
|
||||||
if(buttons & WPAD_BUTTON_UP)
|
if (buttons & WPAD_BUTTON_UP)
|
||||||
conv_buttons |= Input::BUTTON_UP;
|
conv_buttons |= Input::BUTTON_UP;
|
||||||
|
|
||||||
if(buttons & WPAD_BUTTON_PLUS)
|
if (buttons & WPAD_BUTTON_PLUS)
|
||||||
conv_buttons |= Input::BUTTON_PLUS;
|
conv_buttons |= Input::BUTTON_PLUS;
|
||||||
|
|
||||||
if(buttons & WPAD_BUTTON_2)
|
if (buttons & WPAD_BUTTON_2)
|
||||||
conv_buttons |= Input::BUTTON_2;
|
conv_buttons |= Input::BUTTON_2;
|
||||||
|
|
||||||
if(buttons & WPAD_BUTTON_1)
|
if (buttons & WPAD_BUTTON_1)
|
||||||
conv_buttons |= Input::BUTTON_1;
|
conv_buttons |= Input::BUTTON_1;
|
||||||
|
|
||||||
if(buttons & WPAD_BUTTON_B)
|
if (buttons & WPAD_BUTTON_B)
|
||||||
conv_buttons |= Input::BUTTON_B;
|
conv_buttons |= Input::BUTTON_B;
|
||||||
|
|
||||||
if(buttons & WPAD_BUTTON_A)
|
if (buttons & WPAD_BUTTON_A)
|
||||||
conv_buttons |= Input::BUTTON_A;
|
conv_buttons |= Input::BUTTON_A;
|
||||||
|
|
||||||
if(buttons & WPAD_BUTTON_MINUS)
|
if (buttons & WPAD_BUTTON_MINUS)
|
||||||
conv_buttons |= Input::BUTTON_MINUS;
|
conv_buttons |= Input::BUTTON_MINUS;
|
||||||
|
|
||||||
if(buttons & WPAD_BUTTON_Z)
|
if (buttons & WPAD_BUTTON_Z)
|
||||||
conv_buttons |= Input::BUTTON_Z;
|
conv_buttons |= Input::BUTTON_Z;
|
||||||
|
|
||||||
if(buttons & WPAD_BUTTON_C)
|
if (buttons & WPAD_BUTTON_C)
|
||||||
conv_buttons |= Input::BUTTON_C;
|
conv_buttons |= Input::BUTTON_C;
|
||||||
|
|
||||||
if(buttons & WPAD_BUTTON_HOME)
|
if (buttons & WPAD_BUTTON_HOME)
|
||||||
conv_buttons |= Input::BUTTON_HOME;
|
conv_buttons |= Input::BUTTON_HOME;
|
||||||
|
|
||||||
return conv_buttons;
|
return conv_buttons;
|
||||||
@ -76,63 +76,65 @@ public:
|
|||||||
uint32_t remapClassicButtons(uint32_t buttons) {
|
uint32_t remapClassicButtons(uint32_t buttons) {
|
||||||
uint32_t conv_buttons = 0;
|
uint32_t conv_buttons = 0;
|
||||||
|
|
||||||
if(buttons & WPAD_CLASSIC_BUTTON_LEFT)
|
if (buttons & WPAD_CLASSIC_BUTTON_LEFT)
|
||||||
conv_buttons |= Input::BUTTON_LEFT;
|
conv_buttons |= Input::BUTTON_LEFT;
|
||||||
|
|
||||||
if(buttons & WPAD_CLASSIC_BUTTON_RIGHT)
|
if (buttons & WPAD_CLASSIC_BUTTON_RIGHT)
|
||||||
conv_buttons |= Input::BUTTON_RIGHT;
|
conv_buttons |= Input::BUTTON_RIGHT;
|
||||||
|
|
||||||
if(buttons & WPAD_CLASSIC_BUTTON_DOWN)
|
if (buttons & WPAD_CLASSIC_BUTTON_DOWN)
|
||||||
conv_buttons |= Input::BUTTON_DOWN;
|
conv_buttons |= Input::BUTTON_DOWN;
|
||||||
|
|
||||||
if(buttons & WPAD_CLASSIC_BUTTON_UP)
|
if (buttons & WPAD_CLASSIC_BUTTON_UP)
|
||||||
conv_buttons |= Input::BUTTON_UP;
|
conv_buttons |= Input::BUTTON_UP;
|
||||||
|
|
||||||
if(buttons & WPAD_CLASSIC_BUTTON_PLUS)
|
if (buttons & WPAD_CLASSIC_BUTTON_PLUS)
|
||||||
conv_buttons |= Input::BUTTON_PLUS;
|
conv_buttons |= Input::BUTTON_PLUS;
|
||||||
|
|
||||||
if(buttons & WPAD_CLASSIC_BUTTON_X)
|
if (buttons & WPAD_CLASSIC_BUTTON_X)
|
||||||
conv_buttons |= Input::BUTTON_X;
|
conv_buttons |= Input::BUTTON_X;
|
||||||
|
|
||||||
if(buttons & WPAD_CLASSIC_BUTTON_Y)
|
if (buttons & WPAD_CLASSIC_BUTTON_Y)
|
||||||
conv_buttons |= Input::BUTTON_Y;
|
conv_buttons |= Input::BUTTON_Y;
|
||||||
|
|
||||||
if(buttons & WPAD_CLASSIC_BUTTON_B)
|
if (buttons & WPAD_CLASSIC_BUTTON_B)
|
||||||
conv_buttons |= Input::BUTTON_B;
|
conv_buttons |= Input::BUTTON_B;
|
||||||
|
|
||||||
if(buttons & WPAD_CLASSIC_BUTTON_A)
|
if (buttons & WPAD_CLASSIC_BUTTON_A)
|
||||||
conv_buttons |= Input::BUTTON_A;
|
conv_buttons |= Input::BUTTON_A;
|
||||||
|
|
||||||
if(buttons & WPAD_CLASSIC_BUTTON_MINUS)
|
if (buttons & WPAD_CLASSIC_BUTTON_MINUS)
|
||||||
conv_buttons |= Input::BUTTON_MINUS;
|
conv_buttons |= Input::BUTTON_MINUS;
|
||||||
|
|
||||||
if(buttons & WPAD_CLASSIC_BUTTON_HOME)
|
if (buttons & WPAD_CLASSIC_BUTTON_HOME)
|
||||||
conv_buttons |= Input::BUTTON_HOME;
|
conv_buttons |= Input::BUTTON_HOME;
|
||||||
|
|
||||||
if(buttons & WPAD_CLASSIC_BUTTON_ZR)
|
if (buttons & WPAD_CLASSIC_BUTTON_ZR)
|
||||||
conv_buttons |= Input::BUTTON_ZR;
|
conv_buttons |= Input::BUTTON_ZR;
|
||||||
|
|
||||||
if(buttons & WPAD_CLASSIC_BUTTON_ZL)
|
if (buttons & WPAD_CLASSIC_BUTTON_ZL)
|
||||||
conv_buttons |= Input::BUTTON_ZL;
|
conv_buttons |= Input::BUTTON_ZL;
|
||||||
|
|
||||||
if(buttons & WPAD_CLASSIC_BUTTON_R)
|
if (buttons & WPAD_CLASSIC_BUTTON_R)
|
||||||
conv_buttons |= Input::BUTTON_R;
|
conv_buttons |= Input::BUTTON_R;
|
||||||
|
|
||||||
if(buttons & WPAD_CLASSIC_BUTTON_L)
|
if (buttons & WPAD_CLASSIC_BUTTON_L)
|
||||||
conv_buttons |= Input::BUTTON_L;
|
conv_buttons |= Input::BUTTON_L;
|
||||||
|
|
||||||
return conv_buttons;
|
return conv_buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool update(int32_t width, int32_t height) {
|
bool update(int32_t width, int32_t height) {
|
||||||
|
lastData = data;
|
||||||
WPADExtensionType type;
|
WPADExtensionType type;
|
||||||
if (WPADProbe(channel, &type) != 0) {
|
if (WPADProbe(channel, &type) != 0) {
|
||||||
|
data.buttons_h = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
KPADRead(channel, &kpad, 1);
|
KPADRead(channel, &kpad, 1);
|
||||||
|
|
||||||
if(kpad.extensionType == WPAD_EXT_CORE || kpad.extensionType == WPAD_EXT_NUNCHUK) {
|
if (kpad.extensionType == WPAD_EXT_CORE || kpad.extensionType == WPAD_EXT_NUNCHUK) {
|
||||||
data.buttons_r = remapWiiMoteButtons(kpad.release);
|
data.buttons_r = remapWiiMoteButtons(kpad.release);
|
||||||
data.buttons_h = remapWiiMoteButtons(kpad.hold);
|
data.buttons_h = remapWiiMoteButtons(kpad.hold);
|
||||||
data.buttons_d = remapWiiMoteButtons(kpad.trigger);
|
data.buttons_d = remapWiiMoteButtons(kpad.trigger);
|
||||||
@ -147,11 +149,11 @@ public:
|
|||||||
(kpad.pos.y >= -1.0f && kpad.pos.y <= 1.0f);
|
(kpad.pos.y >= -1.0f && kpad.pos.y <= 1.0f);
|
||||||
|
|
||||||
//! calculate the screen offsets if pointer is valid else leave old value
|
//! calculate the screen offsets if pointer is valid else leave old value
|
||||||
if(data.validPointer) {
|
if (data.validPointer) {
|
||||||
data.x = (width >> 1) * kpad.pos.x;
|
data.x = (width >> 1) * kpad.pos.x;
|
||||||
data.y = (height >> 1) * (-kpad.pos.y);
|
data.y = (height >> 1) * (-kpad.pos.y);
|
||||||
|
|
||||||
if(kpad.angle.y > 0.0f) {
|
if (kpad.angle.y > 0.0f) {
|
||||||
data.pointerAngle = (-kpad.angle.x + 1.0f) * 0.5f * 180.0f;
|
data.pointerAngle = (-kpad.angle.x + 1.0f) * 0.5f * 180.0f;
|
||||||
} else {
|
} else {
|
||||||
data.pointerAngle = (kpad.angle.x + 1.0f) * 0.5f * 180.0f - 180.0f;
|
data.pointerAngle = (kpad.angle.x + 1.0f) * 0.5f * 180.0f - 180.0f;
|
@ -7,18 +7,20 @@
|
|||||||
#include <iosuhax.h>
|
#include <iosuhax.h>
|
||||||
#include <iosuhax_devoptab.h>
|
#include <iosuhax_devoptab.h>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include "WiiUScreen.h"
|
#include <input/WPADInput.h>
|
||||||
|
#include <input/VPADInput.h>
|
||||||
|
#include <input/CombinedInput.h>
|
||||||
|
#include "utils/WiiUScreen.h"
|
||||||
#include "InstallerService.h"
|
#include "InstallerService.h"
|
||||||
|
|
||||||
#include "ApplicationState.h"
|
#include "ApplicationState.h"
|
||||||
#include "WPADInput.h"
|
|
||||||
#include "../build/safe_payload.h"
|
#include "../build/safe_payload.h"
|
||||||
|
|
||||||
constexpr bool strings_equal(char const *a, char const *b) {
|
constexpr bool strings_equal(char const *a, char const *b) {
|
||||||
return std::string_view(a) == b;
|
return std::string_view(a) == b;
|
||||||
}
|
}
|
||||||
|
|
||||||
static_assert(strings_equal(RPX_HASH, "cd4c1459d793a600d12afa33425f43be0cc5dfa3"), "Built with an untested root.rpx! Remove this check if you really know what you're doing.");
|
static_assert(strings_equal(RPX_HASH, "1736574cf6c949557aed0c817eb1927e35a9b820"), "Built with an untested root.rpx! Remove this check if you really know what you're doing.");
|
||||||
|
|
||||||
void initIOSUHax();
|
void initIOSUHax();
|
||||||
|
|
||||||
@ -30,6 +32,7 @@ bool sIosuhaxMount = false;
|
|||||||
int main_loop() {
|
int main_loop() {
|
||||||
DEBUG_FUNCTION_LINE("Creating state");
|
DEBUG_FUNCTION_LINE("Creating state");
|
||||||
ApplicationState state;
|
ApplicationState state;
|
||||||
|
CombinedInput baseInput;
|
||||||
VPadInput vpadInput;
|
VPadInput vpadInput;
|
||||||
WPADInput wpadInputs[4] = {
|
WPADInput wpadInputs[4] = {
|
||||||
WPAD_CHAN_0,
|
WPAD_CHAN_0,
|
||||||
@ -44,12 +47,17 @@ int main_loop() {
|
|||||||
|
|
||||||
DEBUG_FUNCTION_LINE("Entering main loop");
|
DEBUG_FUNCTION_LINE("Entering main loop");
|
||||||
while (WHBProcIsRunning()) {
|
while (WHBProcIsRunning()) {
|
||||||
vpadInput.update(1280, 720);
|
baseInput.reset();
|
||||||
for (int i = 0; i < 4; i++) {
|
if (vpadInput.update(1280, 720)) {
|
||||||
wpadInputs[i].update(1280, 720);
|
baseInput.combine(vpadInput);
|
||||||
vpadInput.combine(wpadInputs[i]);
|
|
||||||
}
|
}
|
||||||
state.update(&vpadInput);
|
for (auto &wpadInput: wpadInputs) {
|
||||||
|
if (wpadInput.update(1280, 720)) {
|
||||||
|
baseInput.combine(wpadInput);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
baseInput.process();
|
||||||
|
state.update(&baseInput);
|
||||||
state.render();
|
state.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <coreinit/screen.h>
|
#include <coreinit/screen.h>
|
||||||
#include <proc_ui/procui.h>
|
#include <proc_ui/procui.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "utils/logger.h"
|
#include "logger.h"
|
||||||
|
|
||||||
#define NUM_LINES (16)
|
#define NUM_LINES (16)
|
||||||
#define LINE_LENGTH (128)
|
#define LINE_LENGTH (128)
|
Loading…
x
Reference in New Issue
Block a user