2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-14 10:06:10 +00:00

Initial virtual PAD API

This commit is contained in:
2022-03-20 00:45:45 -07:00
parent a96fe24260
commit 9cedce737f
8 changed files with 222 additions and 33 deletions

View File

@@ -1,24 +1,5 @@
#include "Runtime/Input/CDolphinController.hpp"
namespace PAD {
// clang-format off
enum BUTTON : u16 {
LEFT = 0x0001,
RIGHT = 0x0002,
DOWN = 0x0004,
UP = 0x0008,
TRIGGER_Z = 0x0010,
TRIGGER_R = 0x0020,
TRIGGER_L = 0x0040,
BUTTON_A = 0x0100,
BUTTON_B = 0x0200,
BUTTON_X = 0x0400,
BUTTON_Y = 0x0800,
BUTTON_START = 0x1000,
};
// clang-format on
} // namespace PAD
namespace metaforce {
CDolphinController::CDolphinController() {
static bool sIsInitialized = false;
@@ -77,8 +58,8 @@ void CDolphinController::ProcessAxis(u32 controller, EJoyAxis axis) {
}
static constexpr std::array<u16, size_t(EButton::MAX)> mButtonMapping{
PAD::BUTTON_A, PAD::BUTTON_B, PAD::BUTTON_X, PAD::BUTTON_Y, PAD::BUTTON_START, PAD::TRIGGER_Z,
PAD::UP, PAD::RIGHT, PAD::DOWN, PAD::LEFT, PAD::TRIGGER_L, PAD::TRIGGER_R,
PAD::BUTTON_A, PAD::BUTTON_B, PAD::BUTTON_X, PAD::BUTTON_Y, PAD::BUTTON_START, PAD::TRIGGER_Z,
PAD::BUTTON_UP, PAD::BUTTON_RIGHT, PAD::BUTTON_DOWN, PAD::BUTTON_LEFT, PAD::TRIGGER_L, PAD::TRIGGER_R,
};
void CDolphinController::ProcessButtons(u32 controller) {

View File

@@ -2,19 +2,8 @@
#include "Runtime/Input/IController.hpp"
namespace metaforce {
struct PADStatus {
u16 x0_buttons;
s8 x2_stickX;
s8 x3_stickY;
s8 x4_substickX;
s8 x5_substickY;
u8 x6_triggerL;
u8 x7_triggerR;
u8 x8_analogA;
u8 x9_analogB;
s8 xa_err;
};
class CDolphinController : public IController {

View File

@@ -6,6 +6,7 @@
#include <magic_enum.hpp>
namespace metaforce {
static logvisor::Module Log("CInputGenerator");
void CInputGenerator::Update(float dt, CArchitectureQueue& queue) {
if (m_firstFrame) {

View File

@@ -1,4 +1,5 @@
set(INPUT_SOURCES
PAD.hpp
IController.hpp DolphinIController.cpp
CControllerAxis.hpp
CControllerButton.hpp

View File

@@ -1,4 +1,6 @@
#pragma once
#include "Runtime/Input/PAD.hpp"
namespace metaforce {
enum class EIOPort {

6
Runtime/Input/PAD.hpp Normal file
View File

@@ -0,0 +1,6 @@
#pragma once
#include "aurora/pad.hpp"
using PADStatus = PAD::Status;
using PADButton = PAD::BUTTON;