mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-14 13:26:09 +00:00
Migrate to aurora submodule
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "Runtime/Input/CDolphinController.hpp"
|
||||
|
||||
#include <dolphin/si.h>
|
||||
|
||||
namespace metaforce {
|
||||
CDolphinController::CDolphinController() {
|
||||
static bool sIsInitialized = false;
|
||||
@@ -31,35 +33,35 @@ float CDolphinController::GetAnalogStickMaxValue(EJoyAxis axis) {
|
||||
void CDolphinController::ReadDevices() {
|
||||
std::array<PADStatus, 4> status{};
|
||||
PADRead(status.data());
|
||||
if (status[0].xa_err == PAD::ERR_NONE) {
|
||||
if (status[0].err == PAD_ERR_NONE) {
|
||||
PADClamp(status.data());
|
||||
x4_status = status;
|
||||
} else {
|
||||
x4_status[0].xa_err = status[0].xa_err;
|
||||
x4_status[1].xa_err = status[1].xa_err;
|
||||
x4_status[2].xa_err = status[2].xa_err;
|
||||
x4_status[3].xa_err = status[3].xa_err;
|
||||
x4_status[0].err = status[0].err;
|
||||
x4_status[1].err = status[1].err;
|
||||
x4_status[2].err = status[2].err;
|
||||
x4_status[3].err = status[3].err;
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < 4; ++i) {
|
||||
if (x4_status[i].xa_err != PAD::ERR_NOT_READY) {
|
||||
if (x4_status[i].xa_err == PAD::ERR_NONE) {
|
||||
if (x4_status[i].err != PAD_ERR_NOT_READY) {
|
||||
if (x4_status[i].err == PAD_ERR_NONE) {
|
||||
x34_gamepadStates[i].SetDeviceIsPresent(true);
|
||||
} else if (x4_status[i].xa_err == PAD::ERR_NO_CONTROLLER) {
|
||||
x1c8_invalidControllers |= PAD::CHAN0_BIT >> i;
|
||||
} else if (x4_status[i].err == PAD_ERR_NO_CONTROLLER) {
|
||||
x1c8_invalidControllers |= PAD_CHAN0_BIT >> i;
|
||||
x34_gamepadStates[i].SetDeviceIsPresent(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (x1b4_controllerTypePollTime[i] == 0) {
|
||||
const auto type = SIProbe(i);
|
||||
if ((type & (SI::ERROR_NO_RESPONSE | SI::ERROR_UNKNOWN | SI::ERROR_BUSY)) == 0) {
|
||||
if ((type & (SI_ERROR_NO_RESPONSE | SI_ERROR_UNKNOWN | SI_ERROR_BUSY)) == 0) {
|
||||
x1b4_controllerTypePollTime[i] = 0x3c;
|
||||
if (type == SI::GC_WIRELESS) {
|
||||
if (type == SI_GC_WIRELESS) {
|
||||
x1a4_controllerTypes[i] = skTypeWavebird;
|
||||
} else if (type == SI::GBA) { /* here for completeness, the GameCube adapter does not support GBA */
|
||||
} else if (type == SI_GBA) { /* here for completeness, the GameCube adapter does not support GBA */
|
||||
x1a4_controllerTypes[i] = skTypeGBA;
|
||||
} else if (type == SI::GC_STANDARD) {
|
||||
} else if (type == SI_GC_STANDARD) {
|
||||
x1a4_controllerTypes[i] = skTypeStandard;
|
||||
}
|
||||
} else {
|
||||
@@ -94,13 +96,13 @@ void CDolphinController::ProcessAxis(u32 controller, EJoyAxis axis) {
|
||||
|
||||
float axisValue = 0.f;
|
||||
if (axis == EJoyAxis::LeftX) {
|
||||
axisValue = x4_status[controller].x2_stickX;
|
||||
axisValue = x4_status[controller].stickX;
|
||||
} else if (axis == EJoyAxis::LeftY) {
|
||||
axisValue = x4_status[controller].x3_stickY;
|
||||
axisValue = x4_status[controller].stickY;
|
||||
} else if (axis == EJoyAxis::RightX) {
|
||||
axisValue = x4_status[controller].x4_substickX;
|
||||
axisValue = x4_status[controller].substickX;
|
||||
} else if (axis == EJoyAxis::RightY) {
|
||||
axisValue = x4_status[controller].x5_substickY;
|
||||
axisValue = x4_status[controller].substickY;
|
||||
}
|
||||
axisValue *= 1.f / maxAxisValue;
|
||||
float absolute = zeus::clamp(kAbsoluteMinimum, axisValue, kAbsoluteMaximum);
|
||||
@@ -110,8 +112,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::BUTTON_UP, PAD::BUTTON_RIGHT, PAD::BUTTON_DOWN, PAD::BUTTON_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) {
|
||||
@@ -119,17 +121,19 @@ void CDolphinController::ProcessButtons(u32 controller) {
|
||||
ProcessDigitalButton(controller, x34_gamepadStates[controller].GetButton(EButton(i)), mButtonMapping[i]);
|
||||
}
|
||||
|
||||
ProcessAnalogButton(x4_status[controller].x6_triggerL,
|
||||
ProcessAnalogButton(x4_status[controller].triggerL,
|
||||
x34_gamepadStates[controller].GetAnalogButton(EAnalogButton::Left));
|
||||
ProcessAnalogButton(x4_status[controller].x7_triggerR,
|
||||
ProcessAnalogButton(x4_status[controller].triggerR,
|
||||
x34_gamepadStates[controller].GetAnalogButton(EAnalogButton::Right));
|
||||
}
|
||||
|
||||
void CDolphinController::ProcessDigitalButton(u32 controller, CControllerButton& button, u16 mapping) {
|
||||
bool btnPressed = (x4_status[controller].x0_buttons & mapping) != 0;
|
||||
bool btnPressed = (x4_status[controller].button & mapping) != 0;
|
||||
button.SetPressEvent(PADButtonDown(button.GetIsPressed(), btnPressed));
|
||||
button.SetReleaseEvent(PADButtonUp(button.GetIsPressed(), btnPressed));
|
||||
button.SetIsPressed(btnPressed);
|
||||
}
|
||||
|
||||
void CDolphinController::ProcessAnalogButton(float value, CControllerAxis& axis) {
|
||||
float absolute = value * (1 / 150.f);
|
||||
if (value * (1 / 150.f) > kAbsoluteMaximum) {
|
||||
@@ -168,4 +172,4 @@ bool CDolphinController::Initialize() {
|
||||
Poll();
|
||||
return true;
|
||||
}
|
||||
} // namespace metaforce
|
||||
} // namespace metaforce
|
||||
|
||||
Reference in New Issue
Block a user