diff --git a/source/button_mapping.c b/source/button_mapping.c index 84543fc..a5f7d25 100644 --- a/source/button_mapping.c +++ b/source/button_mapping.c @@ -24,7 +24,7 @@ * and for displaying the name of said button ***************************************************************************/ -CtrlrMap ctrlr_def[4] = { +CtrlrMap ctrlr_def[5] = { // Gamecube controller btn def { { @@ -112,5 +112,27 @@ CtrlrMap ctrlr_def[4] = { }, 15, CTRLR_CLASSIC +}, +// Wii U pro controller +{ + { + {WPAD_CLASSIC_BUTTON_DOWN, "DOWN"}, + {WPAD_CLASSIC_BUTTON_UP, "UP"}, + {WPAD_CLASSIC_BUTTON_LEFT, "LEFT"}, + {WPAD_CLASSIC_BUTTON_RIGHT, "RIGHT"}, + {WPAD_CLASSIC_BUTTON_A, "A"}, + {WPAD_CLASSIC_BUTTON_B, "B"}, + {WPAD_CLASSIC_BUTTON_X, "X"}, + {WPAD_CLASSIC_BUTTON_Y, "Y"}, + {WPAD_CLASSIC_BUTTON_PLUS, "PLUS"}, + {WPAD_CLASSIC_BUTTON_MINUS, "MINUS"}, + {WPAD_CLASSIC_BUTTON_HOME, "HOME"}, + {WPAD_CLASSIC_BUTTON_FULL_L, "L"}, + {WPAD_CLASSIC_BUTTON_FULL_R, "R"}, + {WPAD_CLASSIC_BUTTON_ZL, "ZL"}, + {WPAD_CLASSIC_BUTTON_ZR, "ZR"} + }, + 15, + CTRLR_WUPC } }; diff --git a/source/button_mapping.h b/source/button_mapping.h index 151274a..b4dcd08 100644 --- a/source/button_mapping.h +++ b/source/button_mapping.h @@ -16,11 +16,12 @@ enum { CTRLR_GCPAD, CTRLR_WIIMOTE, CTRLR_NUNCHUK, - CTRLR_CLASSIC + CTRLR_CLASSIC, + CTRLR_WUPC }; -const char ctrlrName[4][20] = -{ "GameCube Controller", "Wiimote", "Nunchuk + Wiimote", "Classic Controller" }; +const char ctrlrName[5][0x20] = +{ "GameCube Controller", "Wiimote", "Nunchuk + Wiimote", "Classic Controller", "Wii U Pro Controller" }; typedef struct _btn_map { u32 btn; // button 'id' @@ -33,6 +34,6 @@ typedef struct _ctrlr_map { u16 type; // controller type } CtrlrMap; -extern CtrlrMap ctrlr_def[4]; +extern CtrlrMap ctrlr_def[5]; #endif diff --git a/source/images/icon_settings_wiiupro.png b/source/images/icon_settings_wiiupro.png new file mode 100644 index 0000000..69eeeed Binary files /dev/null and b/source/images/icon_settings_wiiupro.png differ diff --git a/source/input.cpp b/source/input.cpp index e3dc389..90e4217 100644 --- a/source/input.cpp +++ b/source/input.cpp @@ -43,7 +43,7 @@ static bool cartridgeRumble = false, possibleCartridgeRumble = false; static int gameRumbleCount = 0, menuRumbleCount = 0, rumbleCountAlready = 0; static unsigned int vbapadmap[10]; // VBA controller buttons -u32 btnmap[4][10]; // button mapping +u32 btnmap[5][10]; // button mapping void ResetControls(int wiiCtrl) { @@ -126,6 +126,21 @@ void ResetControls(int wiiCtrl) btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_2; btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_1; } + /*** Wii U Pro Padmap ***/ + if(wiiCtrl == CTRLR_WUPC || wiiCtrl == -1) + { + i=0; + btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_Y; + btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_B; + btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_MINUS; + btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_PLUS; + btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_UP; + btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_DOWN; + btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_LEFT; + btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_RIGHT; + btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_FULL_L; + btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_FULL_R; + } } /**************************************************************************** @@ -538,9 +553,17 @@ u32 DecodeClassic(unsigned short pad) u32 wpad_btns_h = wp->btns_h; if(wp->exp.type == WPAD_EXP_CLASSIC){ - for (u32 i = 0; i < MAXJP; ++i){ - if (wpad_btns_h & btnmap[CTRLR_CLASSIC][i] ) - J |= vbapadmap[i]; + if (wp->exp.classic.type == 2) { + for (u32 i = 0; i < MAXJP; ++i){ + if (wpad_btns_h & btnmap[CTRLR_WUPC][i] ) + J |= vbapadmap[i]; + } + } + else { + for (u32 i = 0; i < MAXJP; ++i){ + if (wpad_btns_h & btnmap[CTRLR_CLASSIC][i] ) + J |= vbapadmap[i]; + } } } #endif @@ -551,11 +574,12 @@ u32 DecodeNunchuk(unsigned short pad) { u32 J = 0; #ifdef HW_RVL - u32 wpad_btns_h = userInput[pad].wpad->btns_h; + WPADData * wp = WPAD_Data(pad); + u32 wpad_btns_h = wp->btns_h; - if(userInput[pad].wpad->exp.type == WPAD_EXP_NUNCHUK){ + if(wp->exp.type == WPAD_EXP_NUNCHUK){ for (u32 i = 0; i < MAXJP; ++i){ - if (wpad_btns_h & btnmap[CTRLR_NUNCHUK][i] ) + if (wpad_btns_h & btnmap[WPAD_EXP_NUNCHUK][i] ) J |= vbapadmap[i]; } } @@ -830,6 +854,7 @@ static u32 DecodeJoy(unsigned short pad) #ifdef HW_RVL u32 wpad_btns_h = userInput[pad].wpad->btns_h; int wpad_exp_type = userInput[pad].wpad->exp.type; + bool isWUPC = userInput[pad].wpad->exp.classic.type == 2; if(wpad_exp_type == WPAD_EXP_NONE) { // wiimote @@ -853,7 +878,17 @@ static u32 DecodeJoy(unsigned short pad) } } + else if(wpad_exp_type == WPAD_EXP_CLASSIC && isWUPC) + { // wii u pro + for (u32 i =0; i < MAXJP; ++i) + { + if ((pad_btns_h & btnmap[CTRLR_GCPAD][i]) // gamecube controller + || ( (wpad_btns_h & btnmap[CTRLR_WUPC][i]) )) + J |= vbapadmap[i]; + } + + } else if(wpad_exp_type == WPAD_EXP_NUNCHUK) { // nunchuk + wiimote diff --git a/source/input.h b/source/input.h index 5fc20cd..02c442f 100644 --- a/source/input.h +++ b/source/input.h @@ -32,7 +32,7 @@ #define VBA_CAPTURE 2048 extern int rumbleRequest[4]; -extern u32 btnmap[4][10]; +extern u32 btnmap[5][10]; void ResetControls(int wc = -1); void ShutoffRumble(); diff --git a/source/menu.cpp b/source/menu.cpp index ec6cfe5..03918ba 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -2082,7 +2082,7 @@ static int MenuSettingsMappings() GuiImageData iconClassic(icon_settings_classic_png); GuiImageData iconGamecube(icon_settings_gamecube_png); GuiImageData iconNunchuk(icon_settings_nunchuk_png); - + GuiImageData iconWiiupro(icon_settings_wiiupro_png); GuiText gamecubeBtnTxt("GameCube Controller", 22, (GXColor){0, 0, 0, 255}); gamecubeBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30); GuiImage gamecubeBtnImg(&btnLargeOutline); @@ -2100,6 +2100,24 @@ static int MenuSettingsMappings() gamecubeBtn.SetTrigger(trigA); gamecubeBtn.SetTrigger(trig2); gamecubeBtn.SetEffectGrow(); + + GuiText wiiuproBtnTxt("Wii U Pro Controller", 22, (GXColor){0, 0, 0, 255}); + wiiuproBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-20); + GuiImage wiiuproBtnImg(&btnLargeOutline); + GuiImage wiiuproBtnImgOver(&btnLargeOutlineOver); + GuiImage wiiuproBtnIcon(&iconWiiupro); + GuiButton wiiuproBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight()); + wiiuproBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + wiiuproBtn.SetPosition(0, 250); + wiiuproBtn.SetLabel(&wiiuproBtnTxt); + wiiuproBtn.SetImage(&wiiuproBtnImg); + wiiuproBtn.SetImageOver(&wiiuproBtnImgOver); + wiiuproBtn.SetIcon(&wiiuproBtnIcon); + wiiuproBtn.SetSoundOver(&btnSoundOver); + wiiuproBtn.SetSoundClick(&btnSoundClick); + wiiuproBtn.SetTrigger(trigA); + wiiuproBtn.SetTrigger(trig2); + wiiuproBtn.SetEffectGrow(); GuiText wiimoteBtnTxt("Wiimote", 22, (GXColor){0, 0, 0, 255}); GuiImage wiimoteBtnImg(&btnLargeOutline); @@ -2183,6 +2201,7 @@ static int MenuSettingsMappings() w.Append(&wiimoteBtn); w.Append(&nunchukBtn); w.Append(&classicBtn); + w.Append(&wiiuproBtn); #endif w.Append(&backBtn); @@ -2209,6 +2228,11 @@ static int MenuSettingsMappings() menu = MENU_GAMESETTINGS_MAPPINGS_MAP; mapMenuCtrl = CTRLR_CLASSIC; } + else if(wiiuproBtn.GetState() == STATE_CLICKED) + { + menu = MENU_GAMESETTINGS_MAPPINGS_MAP; + mapMenuCtrl = CTRLR_WUPC; + } else if(gamecubeBtn.GetState() == STATE_CLICKED) { menu = MENU_GAMESETTINGS_MAPPINGS_MAP; @@ -2256,6 +2280,9 @@ ButtonMappingWindow() sprintf(msg, "Press any button on the GameCube Controller now. Press the C-Stick in any direction to clear the existing mapping."); #endif break; + case CTRLR_WUPC: + sprintf(msg, "Press any button on the Wii U Pro Controller now. Press Home to clear the existing mapping."); + break; case CTRLR_WIIMOTE: sprintf(msg, "Press any button on the Wiimote now. Press Home to clear the existing mapping."); break; @@ -2317,6 +2344,7 @@ ButtonMappingWindow() break; case CTRLR_CLASSIC: + case CTRLR_WUPC: if(userInput[0].wpad->exp.type != WPAD_EXP_CLASSIC) pressed = 0; // not a valid input else if(pressed <= 0x1000) diff --git a/source/preferences.cpp b/source/preferences.cpp index 714a0a5..1b18691 100644 --- a/source/preferences.cpp +++ b/source/preferences.cpp @@ -222,6 +222,7 @@ preparePrefsData () createXMLController(btnmap[CTRLR_WIIMOTE], "wmpadmap", "Wiimote"); createXMLController(btnmap[CTRLR_CLASSIC], "ccpadmap", "Classic Controller"); createXMLController(btnmap[CTRLR_NUNCHUK], "ncpadmap", "Nunchuk"); + createXMLController(btnmap[CTRLR_WUPC], "wupcpadmap", "Wii U Pro Controller"); createXMLSection("Emulation", "Emulation Settings"); @@ -530,6 +531,7 @@ decodePrefsData () loadXMLController(btnmap[CTRLR_WIIMOTE], "wmpadmap"); loadXMLController(btnmap[CTRLR_CLASSIC], "ccpadmap"); loadXMLController(btnmap[CTRLR_NUNCHUK], "ncpadmap"); + loadXMLController(btnmap[CTRLR_WUPC], "wupcpadmap"); // Emulation Settings