mirror of
https://gitlab.com/GaryOderNichts/re3-wiiu.git
synced 2025-01-09 16:39:27 +01:00
wiiu: pro controller support
This commit is contained in:
parent
c267181e2a
commit
5d4ec23c43
@ -111,7 +111,7 @@ int32 CControllerConfigManager::GetJoyButtonJustDown()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined __WIIU__
|
#elif defined __WIIU__
|
||||||
uint32 triggerButtons = m_NewState.status.trigger;
|
uint32 triggerButtons = m_NewState.buttonsTriggered;
|
||||||
|
|
||||||
if (triggerButtons & VPAD_BUTTON_A)
|
if (triggerButtons & VPAD_BUTTON_A)
|
||||||
return 2;
|
return 2;
|
||||||
@ -2428,39 +2428,39 @@ void CControllerConfigManager::UpdateJoyButtonState(int32 padnumber)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined __WIIU__
|
#elif defined __WIIU__
|
||||||
uint32 heldButtons = m_NewState.status.hold;
|
uint32 heldButtons = m_NewState.buttonsHeld;
|
||||||
|
|
||||||
if (heldButtons & VPAD_BUTTON_A)
|
if (heldButtons & VPAD_BUTTON_A)
|
||||||
m_aButtonStates[1] = 1;
|
m_aButtonStates[1] = 1;
|
||||||
else if (heldButtons & VPAD_BUTTON_B)
|
if (heldButtons & VPAD_BUTTON_B)
|
||||||
m_aButtonStates[0] = 1;
|
m_aButtonStates[0] = 1;
|
||||||
else if (heldButtons & VPAD_BUTTON_X)
|
if (heldButtons & VPAD_BUTTON_X)
|
||||||
m_aButtonStates[2] = 1;
|
m_aButtonStates[2] = 1;
|
||||||
else if (heldButtons & VPAD_BUTTON_Y)
|
if (heldButtons & VPAD_BUTTON_Y)
|
||||||
m_aButtonStates[3] = 1;
|
m_aButtonStates[3] = 1;
|
||||||
else if (heldButtons & VPAD_BUTTON_ZL)
|
if (heldButtons & VPAD_BUTTON_ZL)
|
||||||
m_aButtonStates[6] = 1;
|
m_aButtonStates[6] = 1;
|
||||||
else if (heldButtons & VPAD_BUTTON_ZR)
|
if (heldButtons & VPAD_BUTTON_ZR)
|
||||||
m_aButtonStates[7] = 1;
|
m_aButtonStates[7] = 1;
|
||||||
else if (heldButtons & VPAD_BUTTON_MINUS)
|
if (heldButtons & VPAD_BUTTON_MINUS)
|
||||||
m_aButtonStates[8] = 1;
|
m_aButtonStates[8] = 1;
|
||||||
else if (heldButtons & VPAD_BUTTON_PLUS)
|
if (heldButtons & VPAD_BUTTON_PLUS)
|
||||||
m_aButtonStates[11] = 1;
|
m_aButtonStates[11] = 1;
|
||||||
else if (heldButtons & VPAD_BUTTON_STICK_L)
|
if (heldButtons & VPAD_BUTTON_STICK_L)
|
||||||
m_aButtonStates[9] = 1;
|
m_aButtonStates[9] = 1;
|
||||||
else if (heldButtons & VPAD_BUTTON_STICK_R)
|
if (heldButtons & VPAD_BUTTON_STICK_R)
|
||||||
m_aButtonStates[10] = 1;
|
m_aButtonStates[10] = 1;
|
||||||
else if (heldButtons & VPAD_BUTTON_UP)
|
if (heldButtons & VPAD_BUTTON_UP)
|
||||||
m_aButtonStates[12] = 1;
|
m_aButtonStates[12] = 1;
|
||||||
else if (heldButtons & VPAD_BUTTON_RIGHT)
|
if (heldButtons & VPAD_BUTTON_RIGHT)
|
||||||
m_aButtonStates[13] = 1;
|
m_aButtonStates[13] = 1;
|
||||||
else if (heldButtons & VPAD_BUTTON_DOWN)
|
if (heldButtons & VPAD_BUTTON_DOWN)
|
||||||
m_aButtonStates[14] = 1;
|
m_aButtonStates[14] = 1;
|
||||||
else if (heldButtons & VPAD_BUTTON_LEFT)
|
if (heldButtons & VPAD_BUTTON_LEFT)
|
||||||
m_aButtonStates[15] = 1;
|
m_aButtonStates[15] = 1;
|
||||||
else if (heldButtons & VPAD_BUTTON_L)
|
if (heldButtons & VPAD_BUTTON_L)
|
||||||
m_aButtonStates[4] = 1;
|
m_aButtonStates[4] = 1;
|
||||||
else if (heldButtons & VPAD_BUTTON_R)
|
if (heldButtons & VPAD_BUTTON_R)
|
||||||
m_aButtonStates[5] = 1;
|
m_aButtonStates[5] = 1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,8 @@ struct GlfwJoyState {
|
|||||||
|
|
||||||
#ifdef __WIIU__
|
#ifdef __WIIU__
|
||||||
struct WiiUJoyState {
|
struct WiiUJoyState {
|
||||||
VPADStatus status;
|
uint32 buttonsTriggered;
|
||||||
|
uint32 buttonsHeld;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -142,7 +143,7 @@ public:
|
|||||||
#if defined RW_GL3
|
#if defined RW_GL3
|
||||||
GlfwJoyState m_OldState;
|
GlfwJoyState m_OldState;
|
||||||
GlfwJoyState m_NewState;
|
GlfwJoyState m_NewState;
|
||||||
#elif __WIIU__
|
#elif defined __WIIU__
|
||||||
WiiUJoyState m_OldState;
|
WiiUJoyState m_OldState;
|
||||||
WiiUJoyState m_NewState;
|
WiiUJoyState m_NewState;
|
||||||
#else
|
#else
|
||||||
|
@ -5046,7 +5046,7 @@ CMenuManager::ProcessButtonPresses(void)
|
|||||||
ControlsManager.InitDefaultControlConfigJoyPad(devCaps.dwButtons);
|
ControlsManager.InitDefaultControlConfigJoyPad(devCaps.dwButtons);
|
||||||
}
|
}
|
||||||
#elif __WIIU__
|
#elif __WIIU__
|
||||||
// TODO wiiu
|
ControlsManager.InitDefaultControlConfigJoyPad(16);
|
||||||
#else
|
#else
|
||||||
if (PSGLOBAL(joy1id) != -1 && glfwJoystickPresent(PSGLOBAL(joy1id))) {
|
if (PSGLOBAL(joy1id) != -1 && glfwJoystickPresent(PSGLOBAL(joy1id))) {
|
||||||
int count;
|
int count;
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#include <whb/log_udp.h>
|
#include <whb/log_udp.h>
|
||||||
|
|
||||||
#include <vpad/input.h>
|
#include <vpad/input.h>
|
||||||
|
#include <padscore/kpad.h>
|
||||||
|
#include <padscore/wpad.h>
|
||||||
|
|
||||||
#include <coreinit/time.h>
|
#include <coreinit/time.h>
|
||||||
|
|
||||||
@ -615,15 +617,14 @@ psSelectDevice()
|
|||||||
|
|
||||||
void _InputInitialiseJoys()
|
void _InputInitialiseJoys()
|
||||||
{
|
{
|
||||||
|
KPADInit();
|
||||||
|
WPADEnableURCC(1);
|
||||||
|
|
||||||
// TODO: wiiu
|
ControlsManager.InitDefaultControlConfigJoyPad(16);
|
||||||
uint32 buttons = 0;
|
|
||||||
ControlsManager.InitDefaultControlConfigJoyPad(buttons);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long _InputInitialiseMouse()
|
long _InputInitialiseMouse()
|
||||||
{
|
{
|
||||||
// TODO: wiiu
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1394,26 +1395,131 @@ main(int argc, char *argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t remapProControllerButtons(uint32_t buttons)
|
||||||
|
{
|
||||||
|
uint32_t conv_buttons = 0;
|
||||||
|
|
||||||
|
if(buttons & WPAD_PRO_BUTTON_LEFT)
|
||||||
|
conv_buttons |= VPAD_BUTTON_LEFT;
|
||||||
|
|
||||||
|
if(buttons & WPAD_PRO_BUTTON_RIGHT)
|
||||||
|
conv_buttons |= VPAD_BUTTON_RIGHT;
|
||||||
|
|
||||||
|
if(buttons & WPAD_PRO_BUTTON_DOWN)
|
||||||
|
conv_buttons |= VPAD_BUTTON_DOWN;
|
||||||
|
|
||||||
|
if(buttons & WPAD_PRO_BUTTON_UP)
|
||||||
|
conv_buttons |= VPAD_BUTTON_UP;
|
||||||
|
|
||||||
|
if(buttons & WPAD_PRO_BUTTON_PLUS)
|
||||||
|
conv_buttons |= VPAD_BUTTON_PLUS;
|
||||||
|
|
||||||
|
if(buttons & WPAD_PRO_BUTTON_X)
|
||||||
|
conv_buttons |= VPAD_BUTTON_X;
|
||||||
|
|
||||||
|
if(buttons & WPAD_PRO_BUTTON_Y)
|
||||||
|
conv_buttons |= VPAD_BUTTON_Y;
|
||||||
|
|
||||||
|
if(buttons & WPAD_PRO_BUTTON_B)
|
||||||
|
conv_buttons |= VPAD_BUTTON_B;
|
||||||
|
|
||||||
|
if(buttons & WPAD_PRO_BUTTON_A)
|
||||||
|
conv_buttons |= VPAD_BUTTON_A;
|
||||||
|
|
||||||
|
if(buttons & WPAD_PRO_BUTTON_MINUS)
|
||||||
|
conv_buttons |= VPAD_BUTTON_MINUS;
|
||||||
|
|
||||||
|
if(buttons & WPAD_PRO_BUTTON_HOME)
|
||||||
|
conv_buttons |= VPAD_BUTTON_HOME;
|
||||||
|
|
||||||
|
if(buttons & WPAD_PRO_TRIGGER_ZR)
|
||||||
|
conv_buttons |= VPAD_BUTTON_ZR;
|
||||||
|
|
||||||
|
if(buttons & WPAD_PRO_TRIGGER_ZL)
|
||||||
|
conv_buttons |= VPAD_BUTTON_ZL;
|
||||||
|
|
||||||
|
if(buttons & WPAD_PRO_TRIGGER_R)
|
||||||
|
conv_buttons |= VPAD_BUTTON_R;
|
||||||
|
|
||||||
|
if(buttons & WPAD_PRO_TRIGGER_L)
|
||||||
|
conv_buttons |= VPAD_BUTTON_L;
|
||||||
|
|
||||||
|
if (buttons & WPAD_PRO_BUTTON_STICK_L)
|
||||||
|
conv_buttons |= VPAD_BUTTON_STICK_L;
|
||||||
|
|
||||||
|
if (buttons & WPAD_PRO_BUTTON_STICK_R)
|
||||||
|
conv_buttons |= VPAD_BUTTON_STICK_R;
|
||||||
|
|
||||||
|
return conv_buttons;
|
||||||
|
}
|
||||||
|
|
||||||
RwV2d leftStickPos;
|
RwV2d leftStickPos;
|
||||||
RwV2d rightStickPos;
|
RwV2d rightStickPos;
|
||||||
|
|
||||||
void CapturePad(RwInt32 padID)
|
void CapturePad(RwInt32 padID)
|
||||||
{
|
{
|
||||||
// TODO proper inputs
|
|
||||||
|
|
||||||
if (padID != 0)
|
if (padID != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int numButtons, numAxes;
|
uint32 buttonsTriggered = 0;
|
||||||
VPADStatus status;
|
uint32 buttonsHeld = 0;
|
||||||
VPADRead(VPAD_CHAN_0, &status, 1, NULL);
|
leftStickPos.x = 0.0f;
|
||||||
|
leftStickPos.y = 0.0f;
|
||||||
|
|
||||||
|
rightStickPos.x = 0.0f;
|
||||||
|
rightStickPos.y = 0.0f;
|
||||||
|
|
||||||
|
VPADStatus vpad_data{};
|
||||||
|
VPADReadError vpad_err;
|
||||||
|
VPADRead(VPAD_CHAN_0, &vpad_data, 1, &vpad_err);
|
||||||
|
if (vpad_err == VPAD_READ_SUCCESS) {
|
||||||
|
buttonsTriggered |= vpad_data.trigger;
|
||||||
|
buttonsHeld |= vpad_data.hold;
|
||||||
|
|
||||||
|
leftStickPos.x += vpad_data.leftStick.x;
|
||||||
|
leftStickPos.y += -vpad_data.leftStick.y;
|
||||||
|
|
||||||
|
rightStickPos.x += vpad_data.rightStick.x;
|
||||||
|
rightStickPos.y += -vpad_data.rightStick.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
KPADStatus kpad_data{};
|
||||||
|
int32_t kpad_err;
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
KPADReadEx((KPADChan)i, &kpad_data, 1, &kpad_err);
|
||||||
|
if (kpad_err == KPAD_ERROR_OK) {
|
||||||
|
if (kpad_data.extensionType == WPAD_EXT_PRO_CONTROLLER) {
|
||||||
|
buttonsTriggered |= remapProControllerButtons(kpad_data.pro.trigger);
|
||||||
|
buttonsHeld |= remapProControllerButtons(kpad_data.pro.hold);
|
||||||
|
|
||||||
|
leftStickPos.x += kpad_data.pro.leftStick.x;
|
||||||
|
leftStickPos.y += -kpad_data.pro.leftStick.y;
|
||||||
|
|
||||||
|
rightStickPos.x += kpad_data.pro.rightStick.x;
|
||||||
|
rightStickPos.y += -kpad_data.pro.rightStick.y;
|
||||||
|
}
|
||||||
|
/* maybe support classic controllers in the future?
|
||||||
|
what about stick l and r down? */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
leftStickPos.x = leftStickPos.x > 1.0f ? 1.0f : leftStickPos.x;
|
||||||
|
leftStickPos.x = leftStickPos.x < -1.0f ? -1.0f : leftStickPos.x;
|
||||||
|
leftStickPos.y = leftStickPos.y > 1.0f ? 1.0f : leftStickPos.y;
|
||||||
|
leftStickPos.y = leftStickPos.y < -1.0f ? -1.0f : leftStickPos.y;
|
||||||
|
|
||||||
|
rightStickPos.x = rightStickPos.x > 1.0f ? 1.0f : rightStickPos.x;
|
||||||
|
rightStickPos.x = rightStickPos.x < -1.0f ? -1.0f : rightStickPos.x;
|
||||||
|
rightStickPos.y = rightStickPos.y > 1.0f ? 1.0f : rightStickPos.y;
|
||||||
|
rightStickPos.y = rightStickPos.y < -1.0f ? -1.0f : rightStickPos.y;
|
||||||
|
|
||||||
if (ControlsManager.m_bFirstCapture == false)
|
if (ControlsManager.m_bFirstCapture == false)
|
||||||
{
|
{
|
||||||
memcpy(&ControlsManager.m_OldState, &ControlsManager.m_NewState, sizeof(ControlsManager.m_NewState));
|
memcpy(&ControlsManager.m_OldState, &ControlsManager.m_NewState, sizeof(ControlsManager.m_NewState));
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&ControlsManager.m_NewState.status, &status, sizeof(VPADStatus));
|
ControlsManager.m_NewState.buttonsTriggered = buttonsTriggered;
|
||||||
|
ControlsManager.m_NewState.buttonsHeld = buttonsHeld;
|
||||||
|
|
||||||
if (ControlsManager.m_bFirstCapture == true)
|
if (ControlsManager.m_bFirstCapture == true)
|
||||||
{
|
{
|
||||||
@ -1427,12 +1533,6 @@ void CapturePad(RwInt32 padID)
|
|||||||
|
|
||||||
RsPadEventHandler(rsPADBUTTONUP, (void *)&bs);
|
RsPadEventHandler(rsPADBUTTONUP, (void *)&bs);
|
||||||
|
|
||||||
leftStickPos.x = status.leftStick.x;
|
|
||||||
leftStickPos.y = -status.leftStick.y;
|
|
||||||
|
|
||||||
rightStickPos.x = status.rightStick.x;
|
|
||||||
rightStickPos.y = -status.rightStick.y;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
if (CPad::m_bMapPadOneToPadTwo)
|
if (CPad::m_bMapPadOneToPadTwo)
|
||||||
bs.padID = 1;
|
bs.padID = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user