Skip to content

Commit

Permalink
Add wuhb meta and port to FSA*
Browse files Browse the repository at this point in the history
  • Loading branch information
Xpl0itU committed Jul 7, 2023
1 parent a6a5627 commit 5cdc8bd
Show file tree
Hide file tree
Showing 11 changed files with 238 additions and 116 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ TOPDIR ?= $(CURDIR)
# APP_SHORTNAME sets the short name of the application
# APP_AUTHOR sets the author of the application
#-------------------------------------------------------------------------------
APP_NAME := compat_installer
APP_SHORTNAME := compat_installer
APP_NAME := vWii Compat Installer
APP_SHORTNAME := vWii Compat Title Installer
APP_AUTHOR := TheLordScruffy, DaThinkingChair

include $(DEVKITPRO)/wut/share/wut_rules
Expand All @@ -37,8 +37,8 @@ DATA := data
INCLUDES := include
CONTENT :=
ICON := meta/wuhb/icon.png
TV_SPLASH :=
DRC_SPLASH :=
TV_SPLASH := meta/wuhb/tv-splash.png
DRC_SPLASH := meta/wuhb/drc-splash.png

#-------------------------------------------------------------------------------
# options for code generation
Expand All @@ -53,7 +53,7 @@ CFLAGS := $(MACHDEP) $(INCLUDE) -Ofast -flto=auto -fno-fat-lto-objects \
CXXFLAGS := -std=gnu++20 $(CFLAGS)

ASFLAGS := -g $(ARCH)
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map)
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -Wno-odr

LIBS := -lwut -lmocha

Expand Down
Binary file modified meta/hbl/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion meta/hbl/meta.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<app version="1">
<name>vWii-compat-installer</name>
<name>vWii Compat Installer</name>
<coder>DaThinkingChair, TheLordScruffy</coder>
<version>1.4</version>
<url>https://github.com/Xpl0itU/vwii-compat-installer</url>
Expand Down
Binary file added meta/wuhb/drc-splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified meta/wuhb/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added meta/wuhb/tv-splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
121 changes: 121 additions & 0 deletions src/InputUtils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#include "InputUtils.h"

void Input::read() {
VPADRead(VPAD_CHAN_0, &vpad_status, 1, &vpad_error);
if (vpad_error != VPAD_READ_SUCCESS)
memset(&vpad_status, 0, sizeof(VPADStatus));

memset(&kpad_status, 0, sizeof(KPADStatus));
WPADExtensionType controllerType;
for (int i = 0; i < 4; i++) {
if (WPADProbe((WPADChan) i, &controllerType) == 0) {
KPADRead((WPADChan) i, &kpad_status, 1);
break;
}
}
}

bool Input::get(ButtonState state, Button button) const {
uint32_t vpadState = 0;
uint32_t kpadState = 0;
uint32_t kpadClassicState = 0;
uint32_t kpadProState = 0;

switch (state) {
case TRIGGER:
vpadState = vpad_status.trigger;
kpadState = kpad_status.trigger;
kpadClassicState = kpad_status.classic.trigger;
kpadProState = kpad_status.pro.trigger;
break;
case HOLD:
vpadState = vpad_status.hold;
kpadState = kpad_status.hold;
kpadClassicState = kpad_status.classic.hold;
kpadProState = kpad_status.pro.hold;
break;
case RELEASE:
vpadState = vpad_status.release;
kpadState = kpad_status.release;
kpadClassicState = kpad_status.classic.release;
kpadProState = kpad_status.pro.release;
break;
}
if ((vpadState != 0) || (kpadState != 0) || (kpadClassicState != 0) || (kpadProState != 0)) {
switch (button) {
case PAD_BUTTON_A:
if (vpadState & VPAD_BUTTON_A) return true;
if (kpadState & WPAD_BUTTON_A) return true;
if (kpadClassicState & WPAD_CLASSIC_BUTTON_A) return true;
if (kpadProState & WPAD_PRO_BUTTON_A) return true;
break;
case PAD_BUTTON_B:
if (vpadState & VPAD_BUTTON_B) return true;
if (kpadState & WPAD_BUTTON_B) return true;
if (kpadClassicState & WPAD_CLASSIC_BUTTON_B) return true;
if (kpadProState & WPAD_PRO_BUTTON_B) return true;
break;
case PAD_BUTTON_X:
if (vpadState & VPAD_BUTTON_X) return true;
if (kpadState & WPAD_BUTTON_1) return true;
if (kpadClassicState & WPAD_CLASSIC_BUTTON_X) return true;
if (kpadProState & WPAD_PRO_BUTTON_X) return true;
break;
case PAD_BUTTON_UP:
if (vpadState & VPAD_BUTTON_UP) return true;
if (vpadState & VPAD_STICK_L_EMULATION_UP) return true;
if (kpadState & WPAD_BUTTON_UP) return true;
if (kpadClassicState & WPAD_CLASSIC_BUTTON_UP) return true;
if (kpadClassicState & WPAD_CLASSIC_STICK_L_EMULATION_UP) return true;
if (kpadProState & WPAD_PRO_BUTTON_UP) return true;
if (kpadProState & WPAD_PRO_STICK_L_EMULATION_UP) return true;
break;
case PAD_BUTTON_DOWN:
if (vpadState & VPAD_BUTTON_DOWN) return true;
if (vpadState & VPAD_STICK_L_EMULATION_DOWN) return true;
if (kpadState & WPAD_BUTTON_DOWN) return true;
if (kpadClassicState & WPAD_CLASSIC_BUTTON_DOWN) return true;
if (kpadClassicState & WPAD_CLASSIC_STICK_L_EMULATION_DOWN) return true;
if (kpadProState & WPAD_PRO_BUTTON_DOWN) return true;
if (kpadProState & WPAD_PRO_STICK_L_EMULATION_DOWN) return true;
break;
case PAD_BUTTON_LEFT:
if (vpadState & VPAD_BUTTON_LEFT) return true;
if (vpadState & VPAD_STICK_L_EMULATION_LEFT) return true;
if (kpadState & WPAD_BUTTON_LEFT) return true;
if (kpadClassicState & WPAD_CLASSIC_BUTTON_LEFT) return true;
if (kpadClassicState & WPAD_CLASSIC_STICK_L_EMULATION_LEFT) return true;
if (kpadProState & WPAD_PRO_BUTTON_LEFT) return true;
if (kpadProState & WPAD_PRO_STICK_L_EMULATION_LEFT) return true;
break;
case PAD_BUTTON_RIGHT:
if (vpadState & VPAD_BUTTON_RIGHT) return true;
if (vpadState & VPAD_STICK_L_EMULATION_RIGHT) return true;
if (kpadState & WPAD_BUTTON_RIGHT) return true;
if (kpadClassicState & WPAD_CLASSIC_BUTTON_RIGHT) return true;
if (kpadClassicState & WPAD_CLASSIC_STICK_L_EMULATION_RIGHT) return true;
if (kpadProState & WPAD_PRO_BUTTON_RIGHT) return true;
if (kpadProState & WPAD_PRO_STICK_L_EMULATION_RIGHT) return true;
break;
case PAD_BUTTON_L:
if (vpadState & VPAD_BUTTON_L) return true;
if (kpadState & WPAD_BUTTON_MINUS) return true;
if (kpadClassicState & WPAD_CLASSIC_BUTTON_L) return true;
if (kpadProState & WPAD_PRO_TRIGGER_L) return true;
break;
case PAD_BUTTON_R:
if (vpadState & VPAD_BUTTON_R) return true;
if (kpadState & WPAD_BUTTON_PLUS) return true;
if (kpadClassicState & WPAD_CLASSIC_BUTTON_R) return true;
if (kpadProState & WPAD_PRO_TRIGGER_R) return true;
break;
case PAD_BUTTON_ANY:
if (vpadState) return true;
if (kpadState) return true;
if (kpadClassicState) return true;
if (kpadProState) return true;
break;
}
}
return false;
}
35 changes: 35 additions & 0 deletions src/InputUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once

#include <cstring>
#include <padscore/kpad.h>
#include <vpad/input.h>

typedef enum Button {
PAD_BUTTON_A,
PAD_BUTTON_B,
PAD_BUTTON_X,
PAD_BUTTON_UP,
PAD_BUTTON_DOWN,
PAD_BUTTON_LEFT,
PAD_BUTTON_RIGHT,
PAD_BUTTON_L,
PAD_BUTTON_R,
PAD_BUTTON_ANY
} Button;

typedef enum ButtonState {
TRIGGER,
HOLD,
RELEASE
} ButtonState;

class Input {
public:
void read() __attribute__((hot));
bool get(ButtonState state, Button button) const __attribute__((hot));

private:
VPADStatus vpad_status;
VPADReadError vpad_error;
KPADStatus kpad[4], kpad_status;
};
5 changes: 4 additions & 1 deletion src/StateUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <coreinit/core.h>
#include <coreinit/dynload.h>
#include <coreinit/foreground.h>
#include <coreinit/screen.h>
#include <proc_ui/procui.h>
#include <whb/proc.h>

Expand Down Expand Up @@ -47,7 +48,9 @@ bool State::AppRunning() {
}

void State::shutdown() {
if (!aroma)
if (!aroma) {
WHBProcShutdown();
OSScreenShutdown();
}
ProcUIShutdown();
}
Loading

0 comments on commit 5cdc8bd

Please sign in to comment.