diff --git a/source/button_mapping.c b/source/button_mapping.c index e41de22..c84bcda 100644 --- a/source/button_mapping.c +++ b/source/button_mapping.c @@ -26,7 +26,7 @@ * and for displaying the name of said button ***/ -CtrlrMap ctrlr_def[4] = { +CtrlrMap ctrlr_def[5] = { // Gamecube controller btn def { CTRLR_GCPAD, @@ -114,5 +114,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 d9d2628..ec19736 100644 --- a/source/button_mapping.h +++ b/source/button_mapping.h @@ -18,11 +18,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' @@ -35,6 +36,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 bf174de..56056a9 100644 --- a/source/filelist.h +++ b/source/filelist.h @@ -107,6 +107,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_nescontroller_png[]; extern const u32 icon_settings_nescontroller_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/menu.cpp b/source/menu.cpp index 9499b6b..48acb7a 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -2322,6 +2322,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()-30); @@ -2341,6 +2342,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); @@ -2427,6 +2446,7 @@ static int MenuSettingsMappingsController() { w.Append(&nunchukBtn); w.Append(&classicBtn); + w.Append(&wiiuproBtn); } #endif w.Append(&backBtn); @@ -2454,6 +2474,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; @@ -2507,6 +2532,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; @@ -2561,10 +2589,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/pad.cpp b/source/pad.cpp index d0548ef..3edc7a8 100644 --- a/source/pad.cpp +++ b/source/pad.cpp @@ -39,7 +39,7 @@ static unsigned int myzappers[2][3]; u32 nespadmap[11]; // Original NES controller buttons u32 zapperpadmap[11]; // Original NES Zapper controller buttons -u32 btnmap[2][4][12]; // button mapping +u32 btnmap[2][5][12]; // button mapping void ResetControls(int consoleCtrl, int wiiCtrl) { @@ -111,6 +111,23 @@ void ResetControls(int consoleCtrl, int wiiCtrl) btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_FULL_L; } + /*** Classic Controller Padmap ***/ + if(consoleCtrl == -1 || (consoleCtrl == CTRL_PAD && wiiCtrl == CTRLR_WUPC)) + { + i=0; + btnmap[CTRL_PAD][CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_Y; + 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_A; + btnmap[CTRL_PAD][CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_MINUS; + btnmap[CTRL_PAD][CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_PLUS; + 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; + btnmap[CTRL_PAD][CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_FULL_L; + } + /*** Nunchuk + wiimote Padmap ***/ if(consoleCtrl == -1 || (consoleCtrl == CTRL_PAD && wiiCtrl == CTRLR_NUNCHUK)) { @@ -366,6 +383,7 @@ static unsigned char DecodeJoy(unsigned short 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 ) @@ -468,7 +486,8 @@ static unsigned char DecodeJoy(unsigned short 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/pad.h b/source/pad.h index b4f89c2..c92c1a6 100644 --- a/source/pad.h +++ b/source/pad.h @@ -22,7 +22,7 @@ #define RAPID_B 512 extern int rumbleRequest[4]; -extern u32 btnmap[2][4][12]; +extern u32 btnmap[2][5][12]; void SetControllers(); void ResetControls(int cc = -1, int wc = -1); diff --git a/source/preferences.cpp b/source/preferences.cpp index 18c72de..3308f0b 100644 --- a/source/preferences.cpp +++ b/source/preferences.cpp @@ -173,6 +173,7 @@ preparePrefsData () createXMLController(btnmap[CTRL_PAD][CTRLR_GCPAD], "btnmap_pad_gcpad", "NES Pad - GameCube Controller"); createXMLController(btnmap[CTRL_PAD][CTRLR_WIIMOTE], "btnmap_pad_wiimote", "NES Pad - Wiimote"); createXMLController(btnmap[CTRL_PAD][CTRLR_CLASSIC], "btnmap_pad_classic", "NES Pad - Classic Controller"); + createXMLController(btnmap[CTRL_PAD][CTRLR_WUPC], "btnmap_pad_wupc", "NES Pad - Wii U Pro Controller"); createXMLController(btnmap[CTRL_PAD][CTRLR_NUNCHUK], "btnmap_pad_nunchuk", "NES Pad - Nunchuk + Wiimote"); createXMLController(btnmap[CTRL_ZAPPER][CTRLR_GCPAD], "btnmap_zapper_gcpad", "Zapper - GameCube Controller"); createXMLController(btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE], "btnmap_zapper_wiimote", "Zapper - Wiimote"); @@ -340,6 +341,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_ZAPPER][CTRLR_GCPAD], "btnmap_zapper_gcpad"); loadXMLController(btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE], "btnmap_zapper_wiimote");