Fix Pro Controller support of WUPSConfigItemButtonCombo

This commit is contained in:
Maschell 2023-01-22 16:15:24 +01:00
parent 0bd1feb1ff
commit bf8867a107
3 changed files with 64 additions and 4 deletions

View File

@ -106,8 +106,8 @@ bool WUPSConfigItemButtonCombo_callCallback(void *context) {
void checkForHold(ConfigItemButtonCombo *item) {
uint32_t lastHold = 0;
uint32_t holdFor = 0;
uint32_t holdForTarget = item->holdDurationInMs >> 3;
uint32_t holdAbortTarget = item->abortButtonHoldDurationInMs >> 3;
uint32_t holdForTarget = item->holdDurationInMs >> 4;
uint32_t holdAbortTarget = item->abortButtonHoldDurationInMs >> 4;
auto mask = VPAD_BUTTON_A | VPAD_BUTTON_B | VPAD_BUTTON_X | VPAD_BUTTON_Y | VPAD_BUTTON_L | VPAD_BUTTON_R |
VPAD_BUTTON_ZL | VPAD_BUTTON_ZR | VPAD_BUTTON_UP | VPAD_BUTTON_DOWN | VPAD_BUTTON_LEFT | VPAD_BUTTON_RIGHT |
@ -131,6 +131,8 @@ void checkForHold(ConfigItemButtonCombo *item) {
if (kpad_error == KPAD_ERROR_OK && kpad_data.extensionType != 0xFF) {
if (kpad_data.extensionType == WPAD_EXT_CORE || kpad_data.extensionType == WPAD_EXT_NUNCHUK) {
buttonsHold |= remapWiiMoteButtons(kpad_data.hold);
} else if (kpad_data.extensionType == WPAD_EXT_PRO_CONTROLLER) {
buttonsHold |= remapProButtons(kpad_data.pro.hold);
} else {
buttonsHold |= remapClassicButtons(kpad_data.classic.hold);
}
@ -157,7 +159,7 @@ void checkForHold(ConfigItemButtonCombo *item) {
item->value = lastHold;
break;
}
OSSleepTicks(OSMillisecondsToTicks(8));
OSSleepTicks(OSMillisecondsToTicks(16));
}
}

View File

@ -215,3 +215,60 @@ uint32_t remapClassicButtons(uint32_t buttons) {
}
return conv_buttons;
}
uint32_t remapProButtons(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;
}

View File

@ -11,3 +11,4 @@ uint32_t remapVPADtoPro(uint32_t buttons);
uint32_t remapWiiMoteButtons(uint32_t buttons);
uint32_t remapClassicButtons(uint32_t buttons);
uint32_t remapProButtons(uint32_t buttons);