diff --git a/source/button_mapping.c b/source/button_mapping.c index b3c5ff1..cb1d979 100644 --- a/source/button_mapping.c +++ b/source/button_mapping.c @@ -25,7 +25,7 @@ * and for displaying the name of said button ***************************************************************************/ -CtrlrMap ctrlr_def[4] = { +CtrlrMap ctrlr_def[5] = { // Gamecube controller btn def { CTRLR_GCPAD, @@ -113,5 +113,27 @@ CtrlrMap ctrlr_def[4] = { {WPAD_CLASSIC_BUTTON_ZL, "ZL"}, {WPAD_CLASSIC_BUTTON_ZR, "ZR"} } +}, +// Wii U pro controller +{ + CTRLR_WUPC, + 15, + { + {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"} + } } }; diff --git a/source/button_mapping.h b/source/button_mapping.h index ed5ee1f..d7fed54 100644 --- a/source/button_mapping.h +++ b/source/button_mapping.h @@ -17,11 +17,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][32] = +{ "GameCube Controller", "Wiimote", "Nunchuk + Wiimote", "Classic Controller", "Wii U Pro Controller" }; typedef struct _btn_map { u32 btn; // button 'id' @@ -34,6 +35,6 @@ typedef struct _ctrlr_map { BtnMap map[15]; // controller button map } CtrlrMap; -extern CtrlrMap ctrlr_def[4]; +extern CtrlrMap ctrlr_def[5]; #endif diff --git a/source/filelist.h b/source/filelist.h index e2a1609..fcde07b 100644 --- a/source/filelist.h +++ b/source/filelist.h @@ -106,6 +106,8 @@ extern const u8 icon_settings_gamecube_png[]; extern const u32 icon_settings_gamecube_png_size; extern const u8 icon_settings_nunchuk_png[]; extern const u32 icon_settings_nunchuk_png_size; +extern const u8 icon_settings_wiiupro_png[]; +extern const u32 icon_settings_wiiupro_png_size; extern const u8 icon_settings_snescontroller_png[]; extern const u32 icon_settings_snescontroller_png_size; diff --git a/source/images/icon_settings_wiiupro.png b/source/images/icon_settings_wiiupro.png new file mode 100644 index 0000000..e9fdad8 Binary files /dev/null and b/source/images/icon_settings_wiiupro.png differ diff --git a/source/input.cpp b/source/input.cpp index fd6ae18..f8c7913 100644 --- a/source/input.cpp +++ b/source/input.cpp @@ -59,7 +59,7 @@ static int cursor_y[5] = {0,0,0,0,0}; S9xMapButton( keycode, cmd = S9xGetCommandT(snescmd), false) static int scopeTurbo = 0; // tracks whether superscope turbo is on or off -u32 btnmap[4][4][12]; // button mapping +u32 btnmap[4][5][12]; // button mapping void ResetControls(int consoleCtrl, int wiiCtrl) { @@ -117,6 +117,24 @@ void ResetControls(int consoleCtrl, int wiiCtrl) btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_LEFT; btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_RIGHT; } + + /*** Wii U Pro Padmap ***/ + if(consoleCtrl == -1 || (consoleCtrl == CTRL_PAD && wiiCtrl == CTRLR_WUPC)) + { + i=0; + btnmap[CTRL_PAD][CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_A; + btnmap[CTRL_PAD][CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_B; + btnmap[CTRL_PAD][CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_X; + btnmap[CTRL_PAD][CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_Y; + btnmap[CTRL_PAD][CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_FULL_L; + btnmap[CTRL_PAD][CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_FULL_R; + btnmap[CTRL_PAD][CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_PLUS; + btnmap[CTRL_PAD][CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_MINUS; + btnmap[CTRL_PAD][CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_UP; + btnmap[CTRL_PAD][CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_DOWN; + btnmap[CTRL_PAD][CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_LEFT; + btnmap[CTRL_PAD][CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_RIGHT; + } /*** Nunchuk + wiimote Padmap ***/ if(consoleCtrl == -1 || (consoleCtrl == CTRL_PAD && wiiCtrl == CTRLR_NUNCHUK)) @@ -382,6 +400,7 @@ static void decodepad (int chan) s8 wm_ax = userInput[chan].WPAD_StickX(0); s8 wm_ay = userInput[chan].WPAD_StickY(0); u32 wp = userInput[chan].wpad->btns_h; + bool isWUPC = userInput[chan].wpad->exp.classic.type == 2; u32 exp_type; if ( WPAD_Probe(chan, &exp_type) != 0 ) @@ -441,7 +460,8 @@ static void decodepad (int chan) if ( (jp & btnmap[CTRL_PAD][CTRLR_GCPAD][i]) // gamecube controller #ifdef HW_RVL || ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_PAD][CTRLR_WIIMOTE][i]) ) // wiimote - || ( (exp_type == WPAD_EXP_CLASSIC) && (wp & btnmap[CTRL_PAD][CTRLR_CLASSIC][i]) ) // classic controller + || ( (exp_type == WPAD_EXP_CLASSIC && !isWUPC) && (wp & btnmap[CTRL_PAD][CTRLR_CLASSIC][i]) ) // classic controller + || ( (exp_type == WPAD_EXP_CLASSIC && isWUPC) && (wp & btnmap[CTRL_PAD][CTRLR_WUPC][i]) ) // wii u pro controller || ( (exp_type == WPAD_EXP_NUNCHUK) && (wp & btnmap[CTRL_PAD][CTRLR_NUNCHUK][i]) ) // nunchuk + wiimote #endif ) diff --git a/source/input.h b/source/input.h index 2309871..e17e195 100644 --- a/source/input.h +++ b/source/input.h @@ -21,7 +21,7 @@ #define PADCAL 50 #define MAXJP 12 // # of mappable controller buttons -extern u32 btnmap[4][4][12]; +extern u32 btnmap[4][5][12]; extern int rumbleRequest[4]; void ResetControls(int cc = -1, int wc = -1); diff --git a/source/menu.cpp b/source/menu.cpp index b3ec73f..6778da0 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -2347,6 +2347,7 @@ static int MenuSettingsMappingsController() 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()-20); @@ -2366,6 +2367,24 @@ static int MenuSettingsMappingsController() 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); GuiImage wiimoteBtnImgOver(&btnLargeOutlineOver); @@ -2452,6 +2471,7 @@ static int MenuSettingsMappingsController() { w.Append(&nunchukBtn); w.Append(&classicBtn); + w.Append(&wiiuproBtn); } #endif w.Append(&backBtn); @@ -2479,6 +2499,11 @@ static int MenuSettingsMappingsController() 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; @@ -2533,6 +2558,9 @@ ButtonMappingWindow() case CTRLR_CLASSIC: sprintf(msg, "Press any button on the Classic Controller now. Press Home to clear the existing mapping."); 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_NUNCHUK: sprintf(msg, "Press any button on the Wiimote or Nunchuk now. Press Home to clear the existing mapping."); break; @@ -2587,10 +2615,16 @@ ButtonMappingWindow() break; case CTRLR_CLASSIC: - if(userInput[0].wpad->exp.type != WPAD_EXP_CLASSIC) + if(userInput[0].wpad->exp.type != WPAD_EXP_CLASSIC && userInput[0].wpad->exp.classic.type < 2) pressed = 0; // not a valid input else if(pressed <= 0x1000) + pressed = 0; + break; + case CTRLR_WUPC: + if(userInput[0].wpad->exp.type != WPAD_EXP_CLASSIC && userInput[0].wpad->exp.classic.type == 2) pressed = 0; // not a valid input + else if(pressed <= 0x1000) + pressed = 0; break; case CTRLR_NUNCHUK: diff --git a/source/preferences.cpp b/source/preferences.cpp index df3f113..6753e34 100644 --- a/source/preferences.cpp +++ b/source/preferences.cpp @@ -172,6 +172,7 @@ preparePrefsData () #ifdef HW_RVL createXMLController(btnmap[CTRL_PAD][CTRLR_WIIMOTE], "btnmap_pad_wiimote", "SNES Pad - Wiimote"); createXMLController(btnmap[CTRL_PAD][CTRLR_CLASSIC], "btnmap_pad_classic", "SNES Pad - Classic Controller"); + createXMLController(btnmap[CTRL_PAD][CTRLR_WUPC], "btnmap_pad_wupc", "SNES Pad - Wii U Pro Controller"); createXMLController(btnmap[CTRL_PAD][CTRLR_NUNCHUK], "btnmap_pad_nunchuk", "SNES Pad - Nunchuk + Wiimote"); #endif createXMLController(btnmap[CTRL_SCOPE][CTRLR_GCPAD], "btnmap_scope_gcpad", "Superscope - GameCube Controller"); @@ -354,6 +355,7 @@ decodePrefsData () loadXMLController(btnmap[CTRL_PAD][CTRLR_GCPAD], "btnmap_pad_gcpad"); loadXMLController(btnmap[CTRL_PAD][CTRLR_WIIMOTE], "btnmap_pad_wiimote"); loadXMLController(btnmap[CTRL_PAD][CTRLR_CLASSIC], "btnmap_pad_classic"); + loadXMLController(btnmap[CTRL_PAD][CTRLR_WUPC], "btnmap_pad_wupc"); loadXMLController(btnmap[CTRL_PAD][CTRLR_NUNCHUK], "btnmap_pad_nunchuk"); loadXMLController(btnmap[CTRL_SCOPE][CTRLR_GCPAD], "btnmap_scope_gcpad"); loadXMLController(btnmap[CTRL_SCOPE][CTRLR_WIIMOTE], "btnmap_scope_wiimote");