Add Wii U GamePad support (thanks Fix94!)

This commit is contained in:
Daryl Borth 2018-09-05 19:58:04 -06:00
parent 501762e1ce
commit 242395f20b
20 changed files with 550 additions and 88 deletions

View File

@ -16,7 +16,8 @@ https://github.com/dborth/fceugx/releases
-=[ Features ]=- -=[ Features ]=-
* Wiimote, Nunchuk, Classic, Wii U Pro and Gamecube controller support * Wiimote, Nunchuk, Classic, Wii U Pro, and Gamecube controller support
* Wii U GamePad support (requires homebrew injection into Wii U VC title)
* iNES, FDS, VS, UNIF, and NSF ROM support * iNES, FDS, VS, UNIF, and NSF ROM support
* 1-4 Player Support * 1-4 Player Support
* Zapper support * Zapper support
@ -37,6 +38,11 @@ https://github.com/dborth/fceugx/releases
|0O×øo· UPDATE HISTORY ·oø×O0| |0O×øo· UPDATE HISTORY ·oø×O0|
`¨•¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨' `¨•¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨'
[3.4.1]
* Improved WiiFlow integration
* Added Wii U GamePad support (thanks Fix94!)
[3.4.0 - August 23, 2018] [3.4.0 - August 23, 2018]
* Updated to the latest FCEUX core * Updated to the latest FCEUX core

View File

@ -18,6 +18,8 @@
#include <ogcsys.h> #include <ogcsys.h>
#include <unistd.h> #include <unistd.h>
#include <wiiuse/wpad.h> #include <wiiuse/wpad.h>
#include "utils/wiidrc.h"
#include "button_mapping.h" #include "button_mapping.h"
/*** /***
@ -26,7 +28,7 @@
* and for displaying the name of said button * and for displaying the name of said button
***/ ***/
CtrlrMap ctrlr_def[5] = { CtrlrMap ctrlr_def[6] = {
// Gamecube controller btn def // Gamecube controller btn def
{ {
CTRLR_GCPAD, CTRLR_GCPAD,
@ -115,7 +117,7 @@ CtrlrMap ctrlr_def[5] = {
{WPAD_CLASSIC_BUTTON_ZR, "ZR"} {WPAD_CLASSIC_BUTTON_ZR, "ZR"}
} }
}, },
// Wii U pro controller // Wii U Pro controller
{ {
CTRLR_WUPC, CTRLR_WUPC,
15, 15,
@ -136,5 +138,27 @@ CtrlrMap ctrlr_def[5] = {
{WPAD_CLASSIC_BUTTON_ZL, "ZL"}, {WPAD_CLASSIC_BUTTON_ZL, "ZL"},
{WPAD_CLASSIC_BUTTON_ZR, "ZR"} {WPAD_CLASSIC_BUTTON_ZR, "ZR"}
} }
},
// Wii U Gamepad btn def
{
CTRLR_WIIDRC,
15,
{
{WIIDRC_BUTTON_DOWN, "DOWN"},
{WIIDRC_BUTTON_UP, "UP"},
{WIIDRC_BUTTON_LEFT, "LEFT"},
{WIIDRC_BUTTON_RIGHT, "RIGHT"},
{WIIDRC_BUTTON_A, "A"},
{WIIDRC_BUTTON_B, "B"},
{WIIDRC_BUTTON_X, "X"},
{WIIDRC_BUTTON_Y, "Y"},
{WIIDRC_BUTTON_PLUS, "PLUS"},
{WIIDRC_BUTTON_MINUS, "MINUS"},
{WIIDRC_BUTTON_HOME, "HOME"},
{WIIDRC_BUTTON_L, "L"},
{WIIDRC_BUTTON_R, "R"},
{WIIDRC_BUTTON_ZL, "ZL"},
{WIIDRC_BUTTON_ZR, "ZR"}
}
} }
}; };

View File

@ -19,11 +19,12 @@ enum {
CTRLR_WIIMOTE, CTRLR_WIIMOTE,
CTRLR_NUNCHUK, CTRLR_NUNCHUK,
CTRLR_CLASSIC, CTRLR_CLASSIC,
CTRLR_WUPC CTRLR_WUPC,
CTRLR_WIIDRC
}; };
const char ctrlrName[5][32] = const char ctrlrName[6][32] =
{ "GameCube Controller", "Wiimote", "Nunchuk + Wiimote", "Classic Controller", "Wii U Pro Controller" }; { "GameCube Controller", "Wiimote", "Nunchuk + Wiimote", "Classic Controller", "Wii U Pro Controller", "Wii U Gamepad" };
typedef struct _btn_map { typedef struct _btn_map {
u32 btn; // button 'id' u32 btn; // button 'id'
@ -36,6 +37,6 @@ typedef struct _ctrlr_map {
BtnMap map[15]; // controller button map BtnMap map[15]; // controller button map
} CtrlrMap; } CtrlrMap;
extern CtrlrMap ctrlr_def[5]; extern CtrlrMap ctrlr_def[6];
#endif #endif

View File

@ -39,6 +39,7 @@
#include "pad.h" #include "pad.h"
#include "filelist.h" #include "filelist.h"
#include "gui/gui.h" #include "gui/gui.h"
#include "utils/wiidrc.h"
#include "utils/FreeTypeGX.h" #include "utils/FreeTypeGX.h"
#ifdef USE_VM #ifdef USE_VM
#include "vmalloc.h" #include "vmalloc.h"
@ -382,6 +383,7 @@ int main(int argc, char *argv[])
SYS_SetPowerCallback(ShutdownCB); SYS_SetPowerCallback(ShutdownCB);
SYS_SetResetCallback(ResetCB); SYS_SetResetCallback(ResetCB);
WiiDRC_Init();
WPAD_Init(); WPAD_Init();
WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB); WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB);
DI_Init(); DI_Init();

View File

@ -109,6 +109,8 @@ extern const u8 icon_settings_nunchuk_png[];
extern const u32 icon_settings_nunchuk_png_size; extern const u32 icon_settings_nunchuk_png_size;
extern const u8 icon_settings_wiiupro_png[]; extern const u8 icon_settings_wiiupro_png[];
extern const u32 icon_settings_wiiupro_png_size; extern const u32 icon_settings_wiiupro_png_size;
extern const u8 icon_settings_drc_png[];
extern const u32 icon_settings_drc_png_size;
extern const u8 icon_settings_nescontroller_png[]; extern const u8 icon_settings_nescontroller_png[];
extern const u32 icon_settings_nescontroller_png_size; extern const u32 icon_settings_nescontroller_png_size;

View File

@ -123,6 +123,16 @@ typedef struct _paddata {
u8 triggerR; u8 triggerR;
} PADData; } PADData;
typedef struct _gamepaddata {
u16 btns_d;
u16 btns_u;
u16 btns_h;
s16 stickX;
s16 stickY;
s16 substickX;
s16 substickY;
} GamePadData;
#define EFFECT_SLIDE_TOP 1 #define EFFECT_SLIDE_TOP 1
#define EFFECT_SLIDE_BOTTOM 2 #define EFFECT_SLIDE_BOTTOM 2
#define EFFECT_SLIDE_RIGHT 4 #define EFFECT_SLIDE_RIGHT 4
@ -182,22 +192,26 @@ class GuiTrigger
//!\param ch Controller channel number //!\param ch Controller channel number
//!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately //!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately
//!\param gcbtns GameCube controller trigger button(s) //!\param gcbtns GameCube controller trigger button(s)
void SetSimpleTrigger(s32 ch, u32 wiibtns, u16 gcbtns); //!\param wiidrcbtns Wii U Gamepad trigger button(s)
void SetSimpleTrigger(s32 ch, u32 wiibtns, u16 gcbtns, u16 wiidrcbtns);
//!Sets a held trigger. Requires: element is selected, and trigger button is pressed //!Sets a held trigger. Requires: element is selected, and trigger button is pressed
//!\param ch Controller channel number //!\param ch Controller channel number
//!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately //!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately
//!\param gcbtns GameCube controller trigger button(s) //!\param gcbtns GameCube controller trigger button(s)
void SetHeldTrigger(s32 ch, u32 wiibtns, u16 gcbtns); //!\param wiidrcbtns Wii U Gamepad trigger button(s)
void SetHeldTrigger(s32 ch, u32 wiibtns, u16 gcbtns, u16 wiidrcbtns);
//!Sets a button-only trigger. Requires: Trigger button is pressed //!Sets a button-only trigger. Requires: Trigger button is pressed
//!\param ch Controller channel number //!\param ch Controller channel number
//!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately //!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately
//!\param gcbtns GameCube controller trigger button(s) //!\param gcbtns GameCube controller trigger button(s)
void SetButtonOnlyTrigger(s32 ch, u32 wiibtns, u16 gcbtns); //!\param wiidrcbtns Wii U Gamepad trigger button(s)
void SetButtonOnlyTrigger(s32 ch, u32 wiibtns, u16 gcbtns, u16 wiidrcbtns);
//!Sets a button-only trigger. Requires: trigger button is pressed and parent window of element is in focus //!Sets a button-only trigger. Requires: trigger button is pressed and parent window of element is in focus
//!\param ch Controller channel number //!\param ch Controller channel number
//!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately //!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately
//!\param gcbtns GameCube controller trigger button(s) //!\param gcbtns GameCube controller trigger button(s)
void SetButtonOnlyInFocusTrigger(s32 ch, u32 wiibtns, u16 gcbtns); //!\param wiidrcbtns Wii U Gamepad trigger button(s)
void SetButtonOnlyInFocusTrigger(s32 ch, u32 wiibtns, u16 gcbtns, u16 wiidrcbtns);
//!Get X or Y value from Wii Joystick (classic, nunchuk) input //!Get X or Y value from Wii Joystick (classic, nunchuk) input
//!\param stick Controller stick (left = 0, right = 1) //!\param stick Controller stick (left = 0, right = 1)
//!\param axis Controller stick axis (x-axis = 0, y-axis = 1) //!\param axis Controller stick axis (x-axis = 0, y-axis = 1)
@ -226,6 +240,7 @@ class GuiTrigger
WPADData wpaddata; //!< Wii controller trigger data WPADData wpaddata; //!< Wii controller trigger data
PADData pad; //!< GameCube controller trigger data PADData pad; //!< GameCube controller trigger data
GamePadData wiidrcdata; //!< Wii U Gamepad trigger data
WPADData * wpad; //!< Wii controller trigger WPADData * wpad; //!< Wii controller trigger
s32 chan; //!< Trigger controller channel (0-3, -1 for all) s32 chan; //!< Trigger controller channel (0-3, -1 for all)
u8 type; //!< trigger type (TRIGGER_SIMPLE, TRIGGER_HELD, TRIGGER_BUTTON_ONLY, TRIGGER_BUTTON_ONLY_IN_FOCUS) u8 type; //!< trigger type (TRIGGER_SIMPLE, TRIGGER_HELD, TRIGGER_BUTTON_ONLY, TRIGGER_BUTTON_ONLY_IN_FOCUS)

View File

@ -156,7 +156,7 @@ void GuiButton::Draw()
label[0]->Draw(); label[0]->Draw();
if(labelOver[1]) if(labelOver[1])
labelOver[1]->Draw(); labelOver[1]->Draw();
else if(label[1]) else if(label[1])
label[1]->Draw(); label[1]->Draw();
@ -254,7 +254,7 @@ void GuiButton::Update(GuiTrigger * t)
// button triggers // button triggers
if(this->IsClickable()) if(this->IsClickable())
{ {
s32 wm_btns, wm_btns_trig, cc_btns, cc_btns_trig; s32 wm_btns, wm_btns_trig, cc_btns, cc_btns_trig, wiidrc_btns, wiidrc_btns_trig;
for(int i=0; i<3; i++) for(int i=0; i<3; i++)
{ {
if(trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan)) if(trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan))
@ -267,12 +267,16 @@ void GuiButton::Update(GuiTrigger * t)
cc_btns = t->wpad->btns_d >> 16; cc_btns = t->wpad->btns_d >> 16;
cc_btns_trig = trigger[i]->wpad->btns_d >> 16; cc_btns_trig = trigger[i]->wpad->btns_d >> 16;
// Wii U Gamepad
wiidrc_btns = t->wiidrcdata.btns_d;
wiidrc_btns_trig = trigger[i]->wiidrcdata.btns_d;
if( if(
(t->wpad->btns_d > 0 && (t->wpad->btns_d > 0 &&
(wm_btns == wm_btns_trig || (wm_btns == wm_btns_trig ||
(cc_btns == cc_btns_trig && t->wpad->exp.type == EXP_CLASSIC))) || (cc_btns == cc_btns_trig && t->wpad->exp.type == EXP_CLASSIC))) ||
(t->pad.btns_d == trigger[i]->pad.btns_d && t->pad.btns_d > 0)) (t->pad.btns_d == trigger[i]->pad.btns_d && t->pad.btns_d > 0) ||
(wiidrc_btns == wiidrc_btns_trig && wiidrc_btns > 0))
{ {
if(t->chan == stateChan || stateChan == -1) if(t->chan == stateChan || stateChan == -1)
{ {
@ -304,7 +308,7 @@ void GuiButton::Update(GuiTrigger * t)
if(this->IsHoldable()) if(this->IsHoldable())
{ {
bool held = false; bool held = false;
s32 wm_btns, wm_btns_h, wm_btns_trig, cc_btns, cc_btns_h, cc_btns_trig; s32 wm_btns, wm_btns_h, wm_btns_trig, cc_btns, cc_btns_h, cc_btns_trig, wiidrc_btns, wiidrc_btns_h, wiidrc_btns_trig;
for(int i=0; i<3; i++) for(int i=0; i<3; i++)
{ {
@ -320,11 +324,17 @@ void GuiButton::Update(GuiTrigger * t)
cc_btns_h = t->wpad->btns_h >> 16; cc_btns_h = t->wpad->btns_h >> 16;
cc_btns_trig = trigger[i]->wpad->btns_h >> 16; cc_btns_trig = trigger[i]->wpad->btns_h >> 16;
// Wii U Gamepad
wiidrc_btns = t->wiidrcdata.btns_d;
wiidrc_btns_h = t->wiidrcdata.btns_h;
wiidrc_btns_trig = trigger[i]->wiidrcdata.btns_h;
if( if(
(t->wpad->btns_d > 0 && (t->wpad->btns_d > 0 &&
(wm_btns == wm_btns_trig || (wm_btns == wm_btns_trig ||
(cc_btns == cc_btns_trig && t->wpad->exp.type == EXP_CLASSIC))) || (cc_btns == cc_btns_trig && t->wpad->exp.type == EXP_CLASSIC))) ||
(t->pad.btns_d == trigger[i]->pad.btns_h && t->pad.btns_d > 0)) (t->pad.btns_d == trigger[i]->pad.btns_h && t->pad.btns_d > 0) ||
(wiidrc_btns == wiidrc_btns_trig && wiidrc_btns > 0))
{ {
if(trigger[i]->type == TRIGGER_HELD && state == STATE_SELECTED && if(trigger[i]->type == TRIGGER_HELD && state == STATE_SELECTED &&
(t->chan == stateChan || stateChan == -1)) (t->chan == stateChan || stateChan == -1))
@ -335,8 +345,8 @@ void GuiButton::Update(GuiTrigger * t)
(t->wpad->btns_h > 0 && (t->wpad->btns_h > 0 &&
(wm_btns_h == wm_btns_trig || (wm_btns_h == wm_btns_trig ||
(cc_btns_h == cc_btns_trig && t->wpad->exp.type == EXP_CLASSIC))) || (cc_btns_h == cc_btns_trig && t->wpad->exp.type == EXP_CLASSIC))) ||
(t->pad.btns_h == trigger[i]->pad.btns_h && t->pad.btns_h > 0)) (t->pad.btns_h == trigger[i]->pad.btns_h && t->pad.btns_h > 0) ||
(wiidrc_btns_h == wiidrc_btns_trig && wiidrc_btns_h > 0))
{ {
if(trigger[i]->type == TRIGGER_HELD) if(trigger[i]->type == TRIGGER_HELD)
held = true; held = true;

View File

@ -9,7 +9,7 @@
***************************************************************************/ ***************************************************************************/
#include "gui.h" #include "gui.h"
#include "filebrowser.h" #include "../filebrowser.h"
/** /**
* Constructor for the GuiFileBrowser class. * Constructor for the GuiFileBrowser class.
@ -25,12 +25,12 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
focus = 0; // allow focus focus = 0; // allow focus
trigA = new GuiTrigger; trigA = new GuiTrigger;
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A, WIIDRC_BUTTON_A);
trig2 = new GuiTrigger; trig2 = new GuiTrigger;
trig2->SetSimpleTrigger(-1, WPAD_BUTTON_2, 0); trig2->SetSimpleTrigger(-1, WPAD_BUTTON_2, 0, 0);
trigHeldA = new GuiTrigger; trigHeldA = new GuiTrigger;
trigHeldA->SetHeldTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); trigHeldA->SetHeldTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A, WIIDRC_BUTTON_A);
btnSoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, SOUND_PCM); btnSoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, SOUND_PCM);
btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM); btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM);

View File

@ -122,9 +122,9 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
keySoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM); keySoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM);
trigA = new GuiTrigger; trigA = new GuiTrigger;
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A, WIIDRC_BUTTON_A);
trig2 = new GuiTrigger; trig2 = new GuiTrigger;
trig2->SetSimpleTrigger(-1, WPAD_BUTTON_2, 0); trig2->SetSimpleTrigger(-1, WPAD_BUTTON_2, 0, 0);
keyBackImg = new GuiImage(keyMedium); keyBackImg = new GuiImage(keyMedium);
keyBackOverImg = new GuiImage(keyMediumOver); keyBackOverImg = new GuiImage(keyMediumOver);

View File

@ -25,9 +25,9 @@ GuiOptionBrowser::GuiOptionBrowser(int w, int h, OptionList * l)
focus = 0; // allow focus focus = 0; // allow focus
trigA = new GuiTrigger; trigA = new GuiTrigger;
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A, WIIDRC_BUTTON_A);
trig2 = new GuiTrigger; trig2 = new GuiTrigger;
trig2->SetSimpleTrigger(-1, WPAD_BUTTON_2, 0); trig2->SetSimpleTrigger(-1, WPAD_BUTTON_2, 0, 0);
btnSoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, SOUND_PCM); btnSoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, SOUND_PCM);
btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM); btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM);

View File

@ -9,7 +9,7 @@
***************************************************************************/ ***************************************************************************/
#include "gui.h" #include "gui.h"
#include "filebrowser.h" #include "../filebrowser.h"
/** /**
* Constructor for the GuiSaveBrowser class. * Constructor for the GuiSaveBrowser class.
@ -33,9 +33,9 @@ GuiSaveBrowser::GuiSaveBrowser(int w, int h, SaveList * s, int a)
focus = 0; // allow focus focus = 0; // allow focus
trigA = new GuiTrigger; trigA = new GuiTrigger;
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A, WIIDRC_BUTTON_A);
trig2 = new GuiTrigger; trig2 = new GuiTrigger;
trig2->SetSimpleTrigger(-1, WPAD_BUTTON_2, 0); trig2->SetSimpleTrigger(-1, WPAD_BUTTON_2, 0, 0);
btnSoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, SOUND_PCM); btnSoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, SOUND_PCM);
btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM); btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM);
@ -258,7 +258,7 @@ void GuiSaveBrowser::Update(GuiTrigger * t)
{ {
if(selectedItem == 0) if(selectedItem == 0)
{ {
if((listOffset - 2 >= 0 && action == 0) || if((listOffset - 2 >= 0 && action == 0) ||
(listOffset >= 0 && action == 1) || (listOffset >= 0 && action == 1) ||
(listOffset - 2 >= 0 && action == 2)) (listOffset - 2 >= 0 && action == 2))
{ {

View File

@ -22,6 +22,7 @@ static u32 delay[4];
GuiTrigger::GuiTrigger() GuiTrigger::GuiTrigger()
{ {
chan = -1; chan = -1;
memset(&wiidrcdata, 0, sizeof(GamePadData));
memset(&wpaddata, 0, sizeof(WPADData)); memset(&wpaddata, 0, sizeof(WPADData));
memset(&pad, 0, sizeof(PADData)); memset(&pad, 0, sizeof(PADData));
wpad = &wpaddata; wpad = &wpaddata;
@ -39,10 +40,11 @@ GuiTrigger::~GuiTrigger()
* - Element is selected * - Element is selected
* - Trigger button is pressed * - Trigger button is pressed
*/ */
void GuiTrigger::SetSimpleTrigger(s32 ch, u32 wiibtns, u16 gcbtns) void GuiTrigger::SetSimpleTrigger(s32 ch, u32 wiibtns, u16 gcbtns, u16 wiidrcbtns)
{ {
type = TRIGGER_SIMPLE; type = TRIGGER_SIMPLE;
chan = ch; chan = ch;
wiidrcdata.btns_d = wiidrcbtns;
wpaddata.btns_d = wiibtns; wpaddata.btns_d = wiibtns;
pad.btns_d = gcbtns; pad.btns_d = gcbtns;
} }
@ -52,10 +54,11 @@ void GuiTrigger::SetSimpleTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
* - Element is selected * - Element is selected
* - Trigger button is pressed and held * - Trigger button is pressed and held
*/ */
void GuiTrigger::SetHeldTrigger(s32 ch, u32 wiibtns, u16 gcbtns) void GuiTrigger::SetHeldTrigger(s32 ch, u32 wiibtns, u16 gcbtns, u16 wiidrcbtns)
{ {
type = TRIGGER_HELD; type = TRIGGER_HELD;
chan = ch; chan = ch;
wiidrcdata.btns_h = wiidrcbtns;
wpaddata.btns_h = wiibtns; wpaddata.btns_h = wiibtns;
pad.btns_h = gcbtns; pad.btns_h = gcbtns;
} }
@ -64,10 +67,11 @@ void GuiTrigger::SetHeldTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
* Sets a button trigger. Requires: * Sets a button trigger. Requires:
* - Trigger button is pressed * - Trigger button is pressed
*/ */
void GuiTrigger::SetButtonOnlyTrigger(s32 ch, u32 wiibtns, u16 gcbtns) void GuiTrigger::SetButtonOnlyTrigger(s32 ch, u32 wiibtns, u16 gcbtns, u16 wiidrcbtns)
{ {
type = TRIGGER_BUTTON_ONLY; type = TRIGGER_BUTTON_ONLY;
chan = ch; chan = ch;
wiidrcdata.btns_d = wiidrcbtns;
wpaddata.btns_d = wiibtns; wpaddata.btns_d = wiibtns;
pad.btns_d = gcbtns; pad.btns_d = gcbtns;
} }
@ -77,10 +81,11 @@ void GuiTrigger::SetButtonOnlyTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
* - Trigger button is pressed * - Trigger button is pressed
* - Parent window is in focus * - Parent window is in focus
*/ */
void GuiTrigger::SetButtonOnlyInFocusTrigger(s32 ch, u32 wiibtns, u16 gcbtns) void GuiTrigger::SetButtonOnlyInFocusTrigger(s32 ch, u32 wiibtns, u16 gcbtns, u16 wiidrcbtns)
{ {
type = TRIGGER_BUTTON_ONLY_IN_FOCUS; type = TRIGGER_BUTTON_ONLY_IN_FOCUS;
chan = ch; chan = ch;
wiidrcdata.btns_d = wiidrcbtns;
wpaddata.btns_d = wiibtns; wpaddata.btns_d = wiibtns;
pad.btns_d = gcbtns; pad.btns_d = gcbtns;
} }
@ -159,11 +164,14 @@ bool GuiTrigger::Left()
u32 wiibtn = GCSettings.WiimoteOrientation ? WPAD_BUTTON_UP : WPAD_BUTTON_LEFT; u32 wiibtn = GCSettings.WiimoteOrientation ? WPAD_BUTTON_UP : WPAD_BUTTON_LEFT;
if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_LEFT) if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_LEFT)
|| (wiidrcdata.btns_d | wiidrcdata.btns_h) & WIIDRC_BUTTON_LEFT
|| (pad.btns_d | pad.btns_h) & PAD_BUTTON_LEFT || (pad.btns_d | pad.btns_h) & PAD_BUTTON_LEFT
|| pad.stickX < -PADCAL || pad.stickX < -PADCAL
|| WPAD_StickX(0) < -PADCAL) || WPAD_StickX(0) < -PADCAL
|| wiidrcdata.stickX < -WIIDRCCAL)
{ {
if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_LEFT) if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_LEFT)
|| wiidrcdata.btns_d & WIIDRC_BUTTON_LEFT
|| pad.btns_d & PAD_BUTTON_LEFT) || pad.btns_d & PAD_BUTTON_LEFT)
{ {
prev[chan] = gettime(); prev[chan] = gettime();
@ -192,11 +200,14 @@ bool GuiTrigger::Right()
u32 wiibtn = GCSettings.WiimoteOrientation ? WPAD_BUTTON_DOWN : WPAD_BUTTON_RIGHT; u32 wiibtn = GCSettings.WiimoteOrientation ? WPAD_BUTTON_DOWN : WPAD_BUTTON_RIGHT;
if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT) if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT)
|| (wiidrcdata.btns_d | wiidrcdata.btns_h) & WIIDRC_BUTTON_RIGHT
|| (pad.btns_d | pad.btns_h) & PAD_BUTTON_RIGHT || (pad.btns_d | pad.btns_h) & PAD_BUTTON_RIGHT
|| pad.stickX > PADCAL || pad.stickX > PADCAL
|| WPAD_StickX(0) > PADCAL) || WPAD_StickX(0) > PADCAL
|| wiidrcdata.stickX > WIIDRCCAL)
{ {
if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT) if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT)
|| wiidrcdata.btns_d & WIIDRC_BUTTON_RIGHT
|| pad.btns_d & PAD_BUTTON_RIGHT) || pad.btns_d & PAD_BUTTON_RIGHT)
{ {
prev[chan] = gettime(); prev[chan] = gettime();
@ -225,11 +236,14 @@ bool GuiTrigger::Up()
u32 wiibtn = GCSettings.WiimoteOrientation ? WPAD_BUTTON_RIGHT : WPAD_BUTTON_UP; u32 wiibtn = GCSettings.WiimoteOrientation ? WPAD_BUTTON_RIGHT : WPAD_BUTTON_UP;
if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_UP) if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_UP)
|| (wiidrcdata.btns_d | wiidrcdata.btns_h) & WIIDRC_BUTTON_UP
|| (pad.btns_d | pad.btns_h) & PAD_BUTTON_UP || (pad.btns_d | pad.btns_h) & PAD_BUTTON_UP
|| pad.stickY > PADCAL || pad.stickY > PADCAL
|| WPAD_StickY(0) > PADCAL) || WPAD_StickY(0) > PADCAL
|| wiidrcdata.stickY > WIIDRCCAL)
{ {
if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_UP) if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_UP)
|| wiidrcdata.btns_d & WIIDRC_BUTTON_UP
|| pad.btns_d & PAD_BUTTON_UP) || pad.btns_d & PAD_BUTTON_UP)
{ {
prev[chan] = gettime(); prev[chan] = gettime();
@ -258,11 +272,14 @@ bool GuiTrigger::Down()
u32 wiibtn = GCSettings.WiimoteOrientation ? WPAD_BUTTON_LEFT : WPAD_BUTTON_DOWN; u32 wiibtn = GCSettings.WiimoteOrientation ? WPAD_BUTTON_LEFT : WPAD_BUTTON_DOWN;
if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN) if((wpad->btns_d | wpad->btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN)
|| (wiidrcdata.btns_d | wiidrcdata.btns_h) & WIIDRC_BUTTON_DOWN
|| (pad.btns_d | pad.btns_h) & PAD_BUTTON_DOWN || (pad.btns_d | pad.btns_h) & PAD_BUTTON_DOWN
|| pad.stickY < -PADCAL || pad.stickY < -PADCAL
|| WPAD_StickY(0) < -PADCAL) || WPAD_StickY(0) < -PADCAL
|| wiidrcdata.stickY < -WIIDRCCAL)
{ {
if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN) if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN)
|| wiidrcdata.btns_d & WIIDRC_BUTTON_DOWN
|| pad.btns_d & PAD_BUTTON_DOWN) || pad.btns_d & PAD_BUTTON_DOWN)
{ {
prev[chan] = gettime(); prev[chan] = gettime();

View File

@ -229,7 +229,7 @@ void GuiWindow::ToggleFocus(GuiTrigger * t)
} }
// change focus // change focus
else if((t->wpad->btns_d & (WPAD_BUTTON_1 | WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B)) else if((t->wpad->btns_d & (WPAD_BUTTON_1 | WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B))
|| (t->pad.btns_d & PAD_BUTTON_B)) || (t->pad.btns_d & PAD_BUTTON_B) || (t->wiidrcdata.btns_d & WIIDRC_BUTTON_B))
{ {
for (i = found; i < elemSize; ++i) for (i = found; i < elemSize; ++i)
{ {

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -858,10 +858,10 @@ static void WindowCredits(void * ptr)
Menu_Render(); Menu_Render();
if((userInput[0].wpad->btns_d || userInput[0].pad.btns_d) || if((userInput[0].wpad->btns_d || userInput[0].pad.btns_d || userInput[0].wiidrcdata.btns_d) ||
(userInput[1].wpad->btns_d || userInput[1].pad.btns_d) || (userInput[1].wpad->btns_d || userInput[1].pad.btns_d || userInput[1].wiidrcdata.btns_d) ||
(userInput[2].wpad->btns_d || userInput[2].pad.btns_d) || (userInput[2].wpad->btns_d || userInput[2].pad.btns_d || userInput[2].wiidrcdata.btns_d) ||
(userInput[3].wpad->btns_d || userInput[3].pad.btns_d)) (userInput[3].wpad->btns_d || userInput[3].pad.btns_d || userInput[3].wiidrcdata.btns_d))
{ {
exit = true; exit = true;
} }
@ -871,6 +871,7 @@ static void WindowCredits(void * ptr)
// clear buttons pressed // clear buttons pressed
for(i=0; i < 4; i++) for(i=0; i < 4; i++)
{ {
userInput[i].wiidrcdata.btns_d = 0;
userInput[i].wpad->btns_d = 0; userInput[i].wpad->btns_d = 0;
userInput[i].pad.btns_d = 0; userInput[i].pad.btns_d = 0;
} }
@ -904,7 +905,7 @@ static int MenuGameSelection()
GuiImageData bgPreviewImg(bg_preview_png); GuiImageData bgPreviewImg(bg_preview_png);
GuiTrigger trigHome; GuiTrigger trigHome;
trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0, WIIDRC_BUTTON_HOME);
GuiText settingsBtnTxt("Settings", 22, (GXColor){0, 0, 0, 255}); GuiText settingsBtnTxt("Settings", 22, (GXColor){0, 0, 0, 255});
GuiImage settingsBtnIcon(&iconSettings); GuiImage settingsBtnIcon(&iconSettings);
@ -1129,10 +1130,10 @@ static void ControllerWindow()
w->SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); w->SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
GuiTrigger trigLeft; GuiTrigger trigLeft;
trigLeft.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT); trigLeft.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT, WIIDRC_BUTTON_LEFT);
GuiTrigger trigRight; GuiTrigger trigRight;
trigRight.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT); trigRight.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT, WIIDRC_BUTTON_RIGHT);
GuiImageData arrowLeft(button_arrow_left_png); GuiImageData arrowLeft(button_arrow_left_png);
GuiImage arrowLeftImg(&arrowLeft); GuiImage arrowLeftImg(&arrowLeft);
@ -1209,7 +1210,7 @@ static int MenuGame()
GuiImageData batteryBar(battery_bar_png); GuiImageData batteryBar(battery_bar_png);
GuiTrigger trigHome; GuiTrigger trigHome;
trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0, WIIDRC_BUTTON_HOME);
GuiText saveBtnTxt("Save", 22, (GXColor){0, 0, 0, 255}); GuiText saveBtnTxt("Save", 22, (GXColor){0, 0, 0, 255});
GuiImage saveBtnImg(&btnLargeOutline); GuiImage saveBtnImg(&btnLargeOutline);
@ -1629,7 +1630,7 @@ static int MenuGameSaves(int action)
GuiImageData btnCloseOutlineOver(button_small_over_png); GuiImageData btnCloseOutlineOver(button_small_over_png);
GuiTrigger trigHome; GuiTrigger trigHome;
trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0, WIIDRC_BUTTON_HOME);
GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255}); GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255});
GuiImage backBtnImg(&btnOutline); GuiImage backBtnImg(&btnOutline);
@ -1905,7 +1906,7 @@ static int MenuGameSettings()
GuiImageData btnCloseOutlineOver(button_small_over_png); GuiImageData btnCloseOutlineOver(button_small_over_png);
GuiTrigger trigHome; GuiTrigger trigHome;
trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0, WIIDRC_BUTTON_HOME);
GuiText mappingBtnTxt("Button Mappings", 22, (GXColor){0, 0, 0, 255}); GuiText mappingBtnTxt("Button Mappings", 22, (GXColor){0, 0, 0, 255});
mappingBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30); mappingBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30);
@ -2139,7 +2140,7 @@ static int MenuGameCheats()
GuiImageData btnCloseOutlineOver(button_small_over_png); GuiImageData btnCloseOutlineOver(button_small_over_png);
GuiTrigger trigHome; GuiTrigger trigHome;
trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0, WIIDRC_BUTTON_HOME);
GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255}); GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255});
GuiImage backBtnImg(&btnOutline); GuiImage backBtnImg(&btnOutline);
@ -2328,6 +2329,7 @@ static int MenuSettingsMappingsController()
GuiImageData iconGamecube(icon_settings_gamecube_png); GuiImageData iconGamecube(icon_settings_gamecube_png);
GuiImageData iconNunchuk(icon_settings_nunchuk_png); GuiImageData iconNunchuk(icon_settings_nunchuk_png);
GuiImageData iconWiiupro(icon_settings_wiiupro_png); GuiImageData iconWiiupro(icon_settings_wiiupro_png);
GuiImageData iconDrc(icon_settings_drc_png);
GuiText gamecubeBtnTxt("GameCube Controller", 22, (GXColor){0, 0, 0, 255}); GuiText gamecubeBtnTxt("GameCube Controller", 22, (GXColor){0, 0, 0, 255});
gamecubeBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30); gamecubeBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30);
@ -2347,24 +2349,6 @@ static int MenuSettingsMappingsController()
gamecubeBtn.SetTrigger(trig2); gamecubeBtn.SetTrigger(trig2);
gamecubeBtn.SetEffectGrow(); 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}); GuiText wiimoteBtnTxt("Wiimote", 22, (GXColor){0, 0, 0, 255});
GuiImage wiimoteBtnImg(&btnLargeOutline); GuiImage wiimoteBtnImg(&btnLargeOutline);
GuiImage wiimoteBtnImgOver(&btnLargeOutlineOver); GuiImage wiimoteBtnImgOver(&btnLargeOutlineOver);
@ -2382,6 +2366,24 @@ static int MenuSettingsMappingsController()
wiimoteBtn.SetTrigger(trig2); wiimoteBtn.SetTrigger(trig2);
wiimoteBtn.SetEffectGrow(); wiimoteBtn.SetEffectGrow();
GuiText drcBtnTxt("Wii U GamePad", 22, (GXColor){0, 0, 0, 255});
drcBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30);
GuiImage drcBtnImg(&btnLargeOutline);
GuiImage drcBtnImgOver(&btnLargeOutlineOver);
GuiImage drcBtnIcon(&iconDrc);
GuiButton drcBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight());
drcBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
drcBtn.SetPosition(200, 120);
drcBtn.SetLabel(&drcBtnTxt);
drcBtn.SetImage(&drcBtnImg);
drcBtn.SetImageOver(&drcBtnImgOver);
drcBtn.SetIcon(&drcBtnIcon);
drcBtn.SetSoundOver(&btnSoundOver);
drcBtn.SetSoundClick(&btnSoundClick);
drcBtn.SetTrigger(trigA);
drcBtn.SetTrigger(trig2);
drcBtn.SetEffectGrow();
GuiText classicBtnTxt("Classic Controller", 22, (GXColor){0, 0, 0, 255}); GuiText classicBtnTxt("Classic Controller", 22, (GXColor){0, 0, 0, 255});
classicBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30); classicBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30);
GuiImage classicBtnImg(&btnLargeOutline); GuiImage classicBtnImg(&btnLargeOutline);
@ -2399,7 +2401,7 @@ static int MenuSettingsMappingsController()
classicBtn.SetTrigger(trigA); classicBtn.SetTrigger(trigA);
classicBtn.SetTrigger(trig2); classicBtn.SetTrigger(trig2);
classicBtn.SetEffectGrow(); classicBtn.SetEffectGrow();
GuiText nunchukBtnTxt1("Wiimote", 22, (GXColor){0, 0, 0, 255}); GuiText nunchukBtnTxt1("Wiimote", 22, (GXColor){0, 0, 0, 255});
GuiText nunchukBtnTxt2("&", 18, (GXColor){0, 0, 0, 255}); GuiText nunchukBtnTxt2("&", 18, (GXColor){0, 0, 0, 255});
GuiText nunchukBtnTxt3("Nunchuk", 22, (GXColor){0, 0, 0, 255}); GuiText nunchukBtnTxt3("Nunchuk", 22, (GXColor){0, 0, 0, 255});
@ -2410,7 +2412,7 @@ static int MenuSettingsMappingsController()
GuiImage nunchukBtnIcon(&iconNunchuk); GuiImage nunchukBtnIcon(&iconNunchuk);
GuiButton nunchukBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight()); GuiButton nunchukBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight());
nunchukBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); nunchukBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
nunchukBtn.SetPosition(200, 250); nunchukBtn.SetPosition(0, 250);
nunchukBtn.SetLabel(&nunchukBtnTxt1, 0); nunchukBtn.SetLabel(&nunchukBtnTxt1, 0);
nunchukBtn.SetLabel(&nunchukBtnTxt2, 1); nunchukBtn.SetLabel(&nunchukBtnTxt2, 1);
nunchukBtn.SetLabel(&nunchukBtnTxt3, 2); nunchukBtn.SetLabel(&nunchukBtnTxt3, 2);
@ -2423,6 +2425,24 @@ static int MenuSettingsMappingsController()
nunchukBtn.SetTrigger(trig2); nunchukBtn.SetTrigger(trig2);
nunchukBtn.SetEffectGrow(); nunchukBtn.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(200, 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 backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255}); GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255});
GuiImage backBtnImg(&btnOutline); GuiImage backBtnImg(&btnOutline);
GuiImage backBtnImgOver(&btnOutlineOver); GuiImage backBtnImgOver(&btnOutlineOver);
@ -2449,8 +2469,14 @@ static int MenuSettingsMappingsController()
if(mapMenuCtrlNES == CTRL_PAD) if(mapMenuCtrlNES == CTRL_PAD)
{ {
w.Append(&nunchukBtn); if(WiiDRC_Inited() && WiiDRC_Connected()) {
gamecubeBtn.SetPosition(-200, 120);
wiimoteBtn.SetPosition(0, 120);
w.Append(&drcBtn);
}
w.Append(&classicBtn); w.Append(&classicBtn);
w.Append(&nunchukBtn);
w.Append(&wiiuproBtn); w.Append(&wiiuproBtn);
} }
#endif #endif
@ -2484,6 +2510,11 @@ static int MenuSettingsMappingsController()
menu = MENU_GAMESETTINGS_MAPPINGS_MAP; menu = MENU_GAMESETTINGS_MAPPINGS_MAP;
mapMenuCtrl = CTRLR_WUPC; mapMenuCtrl = CTRLR_WUPC;
} }
else if(drcBtn.GetState() == STATE_CLICKED)
{
menu = MENU_GAMESETTINGS_MAPPINGS_MAP;
mapMenuCtrl = CTRLR_WIIDRC;
}
else if(gamecubeBtn.GetState() == STATE_CLICKED) else if(gamecubeBtn.GetState() == STATE_CLICKED)
{ {
menu = MENU_GAMESETTINGS_MAPPINGS_MAP; menu = MENU_GAMESETTINGS_MAPPINGS_MAP;
@ -2540,6 +2571,9 @@ ButtonMappingWindow()
case CTRLR_WUPC: case CTRLR_WUPC:
sprintf(msg, "Press any button on the Wii U Pro Controller now. Press Home to clear the existing mapping."); sprintf(msg, "Press any button on the Wii U Pro Controller now. Press Home to clear the existing mapping.");
break; break;
case CTRLR_WIIDRC:
sprintf(msg, "Press any button on the Wii U GamePad now. Press Home to clear the existing mapping.");
break;
case CTRLR_NUNCHUK: case CTRLR_NUNCHUK:
sprintf(msg, "Press any button on the Wiimote or Nunchuk now. Press Home to clear the existing mapping."); sprintf(msg, "Press any button on the Wiimote or Nunchuk now. Press Home to clear the existing mapping.");
break; break;
@ -2573,12 +2607,19 @@ ButtonMappingWindow()
if(userInput[0].pad.substickX < -70 || if(userInput[0].pad.substickX < -70 ||
userInput[0].pad.substickX > 70 || userInput[0].pad.substickX > 70 ||
userInput[0].pad.substickY < -70 || userInput[0].pad.substickY < -70 ||
userInput[0].pad.substickY > 70) userInput[0].pad.substickY > 70)
pressed = WPAD_BUTTON_HOME; pressed = WPAD_BUTTON_HOME;
if(userInput[0].wpad->btns_d == WPAD_BUTTON_HOME) if(userInput[0].wpad->btns_d == WPAD_BUTTON_HOME)
pressed = WPAD_BUTTON_HOME; pressed = WPAD_BUTTON_HOME;
} }
else if(mapMenuCtrl == CTRLR_WIIDRC)
{
pressed = userInput[0].wiidrcdata.btns_d;
if(pressed == WIIDRC_BUTTON_HOME)
pressed = WPAD_CLASSIC_BUTTON_HOME;
}
else else
{ {
pressed = userInput[0].wpad->btns_d; pressed = userInput[0].wpad->btns_d;
@ -2823,16 +2864,16 @@ static void ScreenZoomWindow()
w->SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); w->SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
GuiTrigger trigLeft; GuiTrigger trigLeft;
trigLeft.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT); trigLeft.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT, WIIDRC_BUTTON_LEFT);
GuiTrigger trigRight; GuiTrigger trigRight;
trigRight.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT); trigRight.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT, WIIDRC_BUTTON_RIGHT);
GuiTrigger trigUp; GuiTrigger trigUp;
trigUp.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP, PAD_BUTTON_UP); trigUp.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP, PAD_BUTTON_UP, WIIDRC_BUTTON_UP);
GuiTrigger trigDown; GuiTrigger trigDown;
trigDown.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN, PAD_BUTTON_DOWN); trigDown.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN, PAD_BUTTON_DOWN, WIIDRC_BUTTON_DOWN);
GuiImageData arrowLeft(button_arrow_left_png); GuiImageData arrowLeft(button_arrow_left_png);
GuiImage arrowLeftImg(&arrowLeft); GuiImage arrowLeftImg(&arrowLeft);
@ -2959,16 +3000,16 @@ static void ScreenPositionWindow()
w->SetPosition(0, -10); w->SetPosition(0, -10);
GuiTrigger trigLeft; GuiTrigger trigLeft;
trigLeft.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT); trigLeft.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT, WIIDRC_BUTTON_LEFT);
GuiTrigger trigRight; GuiTrigger trigRight;
trigRight.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT); trigRight.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT, WIIDRC_BUTTON_RIGHT);
GuiTrigger trigUp; GuiTrigger trigUp;
trigUp.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP, PAD_BUTTON_UP); trigUp.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP, PAD_BUTTON_UP, WIIDRC_BUTTON_UP);
GuiTrigger trigDown; GuiTrigger trigDown;
trigDown.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN, PAD_BUTTON_DOWN); trigDown.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN, PAD_BUTTON_DOWN, WIIDRC_BUTTON_DOWN);
GuiImageData arrowLeft(button_arrow_left_png); GuiImageData arrowLeft(button_arrow_left_png);
GuiImage arrowLeftImg(&arrowLeft); GuiImage arrowLeftImg(&arrowLeft);
@ -3968,9 +4009,9 @@ MainMenu (int menu)
#endif #endif
trigA = new GuiTrigger; trigA = new GuiTrigger;
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A, WIIDRC_BUTTON_A);
trig2 = new GuiTrigger; trig2 = new GuiTrigger;
trig2->SetSimpleTrigger(-1, WPAD_BUTTON_2, 0); trig2->SetSimpleTrigger(-1, WPAD_BUTTON_2, 0, 0);
} }
mainWindow = new GuiWindow(screenwidth, screenheight); mainWindow = new GuiWindow(screenwidth, screenheight);

View File

@ -40,7 +40,7 @@ static unsigned int myzappers[2][3];
u32 nespadmap[11]; // Original NES controller buttons u32 nespadmap[11]; // Original NES controller buttons
u32 zapperpadmap[11]; // Original NES Zapper controller buttons u32 zapperpadmap[11]; // Original NES Zapper controller buttons
u32 btnmap[2][5][12]; // button mapping u32 btnmap[2][6][12]; // button mapping
void ResetControls(int consoleCtrl, int wiiCtrl) void ResetControls(int consoleCtrl, int wiiCtrl)
{ {
@ -112,7 +112,7 @@ void ResetControls(int consoleCtrl, int wiiCtrl)
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_FULL_L; btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_FULL_L;
} }
/*** Classic Controller Padmap ***/ /*** Wii U Pro Padmap ***/
if(consoleCtrl == -1 || (consoleCtrl == CTRL_PAD && wiiCtrl == CTRLR_WUPC)) if(consoleCtrl == -1 || (consoleCtrl == CTRL_PAD && wiiCtrl == CTRLR_WUPC))
{ {
i=0; i=0;
@ -129,6 +129,24 @@ void ResetControls(int consoleCtrl, int wiiCtrl)
btnmap[CTRL_PAD][CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_FULL_L; btnmap[CTRL_PAD][CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_FULL_L;
} }
/*** Wii U Gamepad Padmap ***/
if(consoleCtrl == -1 || (consoleCtrl == CTRL_PAD && wiiCtrl == CTRLR_WIIDRC))
{
i=0;
btnmap[CTRL_PAD][CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_A;
btnmap[CTRL_PAD][CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_B;
btnmap[CTRL_PAD][CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_X;
btnmap[CTRL_PAD][CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_Y;
btnmap[CTRL_PAD][CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_L;
btnmap[CTRL_PAD][CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_R;
btnmap[CTRL_PAD][CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_PLUS;
btnmap[CTRL_PAD][CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_MINUS;
btnmap[CTRL_PAD][CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_UP;
btnmap[CTRL_PAD][CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_DOWN;
btnmap[CTRL_PAD][CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_LEFT;
btnmap[CTRL_PAD][CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_RIGHT;
}
/*** Nunchuk + wiimote Padmap ***/ /*** Nunchuk + wiimote Padmap ***/
if(consoleCtrl == -1 || (consoleCtrl == CTRL_PAD && wiiCtrl == CTRLR_NUNCHUK)) if(consoleCtrl == -1 || (consoleCtrl == CTRL_PAD && wiiCtrl == CTRLR_NUNCHUK))
{ {
@ -209,6 +227,7 @@ void
UpdatePads() UpdatePads()
{ {
#ifdef HW_RVL #ifdef HW_RVL
WiiDRC_ScanPads();
WPAD_ScanPads(); WPAD_ScanPads();
#endif #endif
@ -225,6 +244,26 @@ UpdatePads()
userInput[i].pad.substickY = PAD_SubStickY(i); userInput[i].pad.substickY = PAD_SubStickY(i);
userInput[i].pad.triggerL = PAD_TriggerL(i); userInput[i].pad.triggerL = PAD_TriggerL(i);
userInput[i].pad.triggerR = PAD_TriggerR(i); userInput[i].pad.triggerR = PAD_TriggerR(i);
#ifdef HW_RVL
userInput[i].wiidrcdata.btns_d = 0;
userInput[i].wiidrcdata.btns_u = 0;
userInput[i].wiidrcdata.btns_h = 0;
userInput[i].wiidrcdata.stickX = 0;
userInput[i].wiidrcdata.stickY = 0;
userInput[i].wiidrcdata.substickX = 0;
userInput[i].wiidrcdata.substickY = 0;
#endif
--i;
}
if(WiiDRC_Inited() && WiiDRC_Connected())
{
userInput[0].wiidrcdata.btns_d = WiiDRC_ButtonsDown();
userInput[0].wiidrcdata.btns_u = WiiDRC_ButtonsUp();
userInput[0].wiidrcdata.btns_h = WiiDRC_ButtonsHeld();
userInput[0].wiidrcdata.stickX = WiiDRC_lStickX();
userInput[0].wiidrcdata.stickY = WiiDRC_lStickY();
userInput[0].wiidrcdata.substickX = WiiDRC_rStickX();
userInput[0].wiidrcdata.substickY = WiiDRC_rStickY();
} }
} }
@ -306,6 +345,7 @@ static int pos_y = 0;
static void UpdateCursorPosition (int chan) static void UpdateCursorPosition (int chan)
{ {
#define ZAPPERPADCAL 20 #define ZAPPERPADCAL 20
#define WIIDRCZAPPERPADCAL 30
if (userInput[chan].pad.stickX > ANALOG_SENSITIVITY) if (userInput[chan].pad.stickX > ANALOG_SENSITIVITY)
{ {
@ -360,6 +400,32 @@ static void UpdateCursorPosition (int chan)
pos_y -= (wm_ay*1.0)/ZAPPERPADCAL; pos_y -= (wm_ay*1.0)/ZAPPERPADCAL;
if (pos_y < 0) pos_y = 0; if (pos_y < 0) pos_y = 0;
} }
/* Wii U Gamepad */
s16 wiidrc_ax = userInput[chan].wiidrcdata.stickX;
s16 wiidrc_ay = userInput[chan].wiidrcdata.stickY;
if (wiidrc_ax > WIIDRCZAPPERPADCAL)
{
pos_x += (wiidrc_ax*1.0)/WIIDRCZAPPERPADCAL;
if (pos_x > 256) pos_x = 256;
}
if (wiidrc_ax < -WIIDRCZAPPERPADCAL)
{
pos_x -= (wiidrc_ax*-1.0)/WIIDRCZAPPERPADCAL;
if (pos_x < 0) pos_x = 0;
}
if (wiidrc_ay < -WIIDRCZAPPERPADCAL)
{
pos_y += (wiidrc_ay*-1.0)/WIIDRCZAPPERPADCAL;
if (pos_y > 224) pos_y = 224;
}
if (wiidrc_ay > WIIDRCZAPPERPADCAL)
{
pos_y -= (wiidrc_ay*1.0)/WIIDRCZAPPERPADCAL;
if (pos_y < 0) pos_y = 0;
}
} }
#endif #endif
} }
@ -386,6 +452,10 @@ static unsigned char DecodeJoy(unsigned short chan)
u32 exp_type; u32 exp_type;
if ( WPAD_Probe(chan, &exp_type) != 0 ) if ( WPAD_Probe(chan, &exp_type) != 0 )
exp_type = WPAD_EXP_NONE; exp_type = WPAD_EXP_NONE;
s16 wiidrc_ax = userInput[chan].wiidrcdata.stickX;
s16 wiidrc_ay = userInput[chan].wiidrcdata.stickY;
u32 wiidrcp = userInput[chan].wiidrcdata.btns_h;
#endif #endif
/*** /***
@ -411,6 +481,16 @@ static unsigned char DecodeJoy(unsigned short chan)
J |= JOY_LEFT; J |= JOY_LEFT;
else if (wm_ax > ANALOG_SENSITIVITY) else if (wm_ax > ANALOG_SENSITIVITY)
J |= JOY_RIGHT; J |= JOY_RIGHT;
/* WiiU Gamepad */
if (wiidrc_ay > ANALOG_SENSITIVITY)
J |= JOY_UP;
else if (wiidrc_ay < -ANALOG_SENSITIVITY)
J |= JOY_DOWN;
if (wiidrc_ax < -ANALOG_SENSITIVITY)
J |= JOY_LEFT;
else if (wiidrc_ax > ANALOG_SENSITIVITY)
J |= JOY_RIGHT;
#endif #endif
bool zapper_triggered = false; bool zapper_triggered = false;
@ -430,6 +510,7 @@ static unsigned char DecodeJoy(unsigned short chan)
if ( (jp & btnmap[CTRL_ZAPPER][CTRLR_GCPAD][0]) // gamecube controller if ( (jp & btnmap[CTRL_ZAPPER][CTRLR_GCPAD][0]) // gamecube controller
#ifdef HW_RVL #ifdef HW_RVL
|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][0]) ) // wiimote || ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][0]) ) // wiimote
|| (wiidrcp & btnmap[CTRL_ZAPPER][CTRLR_WIIDRC][0]) // Wii U Gamepad
#endif #endif
) )
{ {
@ -442,6 +523,7 @@ static unsigned char DecodeJoy(unsigned short chan)
if ( (jp & btnmap[CTRL_ZAPPER][CTRLR_GCPAD][1]) // gamecube controller if ( (jp & btnmap[CTRL_ZAPPER][CTRLR_GCPAD][1]) // gamecube controller
#ifdef HW_RVL #ifdef HW_RVL
|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][1]) ) // wiimote || ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][1]) ) // wiimote
|| (wiidrcp & btnmap[CTRL_ZAPPER][CTRLR_WIIDRC][1]) // Wii U Gamepad
#endif #endif
) )
{ {
@ -475,6 +557,7 @@ static unsigned char DecodeJoy(unsigned short chan)
|| ( (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_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_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 || ( (exp_type == WPAD_EXP_NUNCHUK) && (wp & btnmap[CTRL_PAD][CTRLR_NUNCHUK][i]) ) // nunchuk + wiimote
|| ( (wiidrcp & btnmap[CTRL_PAD][CTRLR_WIIDRC][i]) ) // Wii U Gamepad
#endif #endif
) )
{ {
@ -524,7 +607,8 @@ bool MenuRequested()
(userInput[i].pad.substickX < -70) (userInput[i].pad.substickX < -70)
#ifdef HW_RVL #ifdef HW_RVL
|| (userInput[i].wpad->btns_h & WPAD_BUTTON_HOME) || || (userInput[i].wpad->btns_h & WPAD_BUTTON_HOME) ||
(userInput[i].wpad->btns_h & WPAD_CLASSIC_BUTTON_HOME) (userInput[i].wpad->btns_h & WPAD_CLASSIC_BUTTON_HOME) ||
(userInput[i].wiidrcdata.btns_h & WIIDRC_BUTTON_HOME)
#endif #endif
) )
{ {
@ -544,7 +628,7 @@ void GetJoy()
// Turbo mode // Turbo mode
// RIGHT on c-stick and on classic ctrlr right joystick // RIGHT on c-stick and on classic ctrlr right joystick
if(userInput[0].pad.substickX > 70 || userInput[0].WPAD_StickX(1) > 70) if(userInput[0].pad.substickX > 70 || userInput[0].WPAD_StickX(1) > 70 || userInput[0].wiidrcdata.substickX > 45)
turbomode = 1; turbomode = 1;
else else
turbomode = 0; turbomode = 0;

View File

@ -15,14 +15,17 @@
#include <gctypes.h> #include <gctypes.h>
#include <wiiuse/wpad.h> #include <wiiuse/wpad.h>
#include "utils/wiidrc.h"
#define PI 3.14159265f #define PI 3.14159265f
#define PADCAL 50 #define PADCAL 50
#define WIIDRCCAL 20
#define MAXJP 11 #define MAXJP 11
#define RAPID_A 256 #define RAPID_A 256
#define RAPID_B 512 #define RAPID_B 512
extern int rumbleRequest[4]; extern int rumbleRequest[4];
extern u32 btnmap[2][5][12]; extern u32 btnmap[2][6][12];
void SetControllers(); void SetControllers();
void ResetControls(int cc = -1, int wc = -1); void ResetControls(int cc = -1, int wc = -1);

View File

@ -174,6 +174,7 @@ preparePrefsData ()
createXMLController(btnmap[CTRL_PAD][CTRLR_WIIMOTE], "btnmap_pad_wiimote", "NES Pad - Wiimote"); 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_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_WUPC], "btnmap_pad_wupc", "NES Pad - Wii U Pro Controller");
createXMLController(btnmap[CTRL_PAD][CTRLR_WIIDRC], "btnmap_pad_wiidrc", "NES Pad - Wii U Gamepad");
createXMLController(btnmap[CTRL_PAD][CTRLR_NUNCHUK], "btnmap_pad_nunchuk", "NES Pad - Nunchuk + Wiimote"); 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_GCPAD], "btnmap_zapper_gcpad", "Zapper - GameCube Controller");
createXMLController(btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE], "btnmap_zapper_wiimote", "Zapper - Wiimote"); createXMLController(btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE], "btnmap_zapper_wiimote", "Zapper - Wiimote");
@ -342,6 +343,7 @@ decodePrefsData ()
loadXMLController(btnmap[CTRL_PAD][CTRLR_WIIMOTE], "btnmap_pad_wiimote"); loadXMLController(btnmap[CTRL_PAD][CTRLR_WIIMOTE], "btnmap_pad_wiimote");
loadXMLController(btnmap[CTRL_PAD][CTRLR_CLASSIC], "btnmap_pad_classic"); loadXMLController(btnmap[CTRL_PAD][CTRLR_CLASSIC], "btnmap_pad_classic");
loadXMLController(btnmap[CTRL_PAD][CTRLR_WUPC], "btnmap_pad_wupc"); loadXMLController(btnmap[CTRL_PAD][CTRLR_WUPC], "btnmap_pad_wupc");
loadXMLController(btnmap[CTRL_PAD][CTRLR_WIIDRC], "btnmap_pad_wiidrc");
loadXMLController(btnmap[CTRL_PAD][CTRLR_NUNCHUK], "btnmap_pad_nunchuk"); loadXMLController(btnmap[CTRL_PAD][CTRLR_NUNCHUK], "btnmap_pad_nunchuk");
loadXMLController(btnmap[CTRL_ZAPPER][CTRLR_GCPAD], "btnmap_zapper_gcpad"); loadXMLController(btnmap[CTRL_ZAPPER][CTRLR_GCPAD], "btnmap_zapper_gcpad");
loadXMLController(btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE], "btnmap_zapper_wiimote"); loadXMLController(btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE], "btnmap_zapper_wiimote");

188
source/utils/wiidrc.c Normal file
View File

@ -0,0 +1,188 @@
/*
* Copyright (C) 2017 FIX94
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
#include <gccore.h>
#include <stdio.h>
#include <string.h>
#include "wiidrc.h"
struct WiiDRCStat {
s16 xAxisLmid;
s16 xAxisRmid;
s16 yAxisLmid;
s16 yAxisRmid;
};
struct WiiDRCButtons {
u32 up;
u32 down;
u32 state;
};
static struct WiiDRCStat __WiiDRC_Status;
static struct WiiDRCData __WiiDRC_PadData;
static struct WiiDRCButtons __WiiDRC_PadButtons;
static bool __WiiDRC_ShutdownRequested;
static u32 __WiiDRC_Inited = 0;
static u8 *__WiiDRC_I2CBuf = NULL;
static u8 *__WiiDRC_DRCStateBuf = NULL;
static bool __WiiDRC_SetI2CBuf()
{
DCInvalidateRange((void*)0x938B2964, 4);
if(*(vu32*)0x938B2964 == 0x138BB004) //r569
{
__WiiDRC_I2CBuf = (u8*)0x938BB004;
return true;
}
DCInvalidateRange((void*)0x938B2564, 4);
if(*(vu32*)0x938B2564 == 0x138BB004) //r570
{
__WiiDRC_I2CBuf = (u8*)0x938BB004;
return true;
}
else if(*(vu32*)0x938B2564 == 0x138BA004) //r590
{
__WiiDRC_I2CBuf = (u8*)0x938BA004;
return true;
}
return false;
}
static bool __WiiDRC_SetDRCStateBuf()
{
//TODO r569
DCInvalidateRange((void*)0x938B563C, 4);
if(*(vu32*)0x938B563C == 0x138BE770) //r570
{
__WiiDRC_DRCStateBuf = (u8*)0x938BE770;
return true;
}
DCInvalidateRange((void*)0x938B5724, 4);
if(*(vu32*)0x938B5724 == 0x138BD770) //r590
{
__WiiDRC_DRCStateBuf = (u8*)0x938BD770;
return true;
}
return false;
}
bool WiiDRC_Init()
{
if(__WiiDRC_Inited == 1)
return false;
if(!__WiiDRC_SetI2CBuf())
return false;
//can fail on r569 for now
__WiiDRC_SetDRCStateBuf();
__WiiDRC_Inited = 1;
WiiDRC_Recalibrate(); //sets up __WiiDRC_Status
memset(&__WiiDRC_PadData,0,sizeof(struct WiiDRCData));
memset(&__WiiDRC_PadButtons,0,sizeof(struct WiiDRCButtons));
__WiiDRC_ShutdownRequested = false;
return true;
}
bool WiiDRC_Inited()
{
return !!__WiiDRC_Inited;
}
bool WiiDRC_Recalibrate()
{
if(__WiiDRC_Inited == 0)
return false;
DCInvalidateRange(__WiiDRC_I2CBuf,9);
__WiiDRC_Status.xAxisLmid = (s8)(__WiiDRC_I2CBuf[4]-0x80);
__WiiDRC_Status.yAxisLmid = (s8)(__WiiDRC_I2CBuf[5]-0x80);
__WiiDRC_Status.xAxisRmid = (s8)(__WiiDRC_I2CBuf[6]-0x80);
__WiiDRC_Status.yAxisRmid = (s8)(__WiiDRC_I2CBuf[7]-0x80);
return true;
}
bool WiiDRC_ScanPads()
{
if(__WiiDRC_Inited == 0)
return false;
DCInvalidateRange(__WiiDRC_I2CBuf,9);
__WiiDRC_ShutdownRequested = !!(__WiiDRC_I2CBuf[1]&0x80);
__WiiDRC_PadData.button = (__WiiDRC_I2CBuf[2]<<8) | (__WiiDRC_I2CBuf[3]);
__WiiDRC_PadData.xAxisL = ((s8)(__WiiDRC_I2CBuf[4]-0x80)) - __WiiDRC_Status.xAxisLmid;
__WiiDRC_PadData.yAxisL = ((s8)(__WiiDRC_I2CBuf[5]-0x80)) - __WiiDRC_Status.yAxisLmid;
__WiiDRC_PadData.xAxisR = ((s8)(__WiiDRC_I2CBuf[6]-0x80)) - __WiiDRC_Status.xAxisRmid;
__WiiDRC_PadData.yAxisR = ((s8)(__WiiDRC_I2CBuf[7]-0x80)) - __WiiDRC_Status.yAxisRmid;
__WiiDRC_PadData.extra = __WiiDRC_I2CBuf[8];
__WiiDRC_PadData.battery = (__WiiDRC_PadData.extra>>1)&7;
u16 newstate, oldstate;
newstate = __WiiDRC_PadData.button;
oldstate = __WiiDRC_PadButtons.state;
__WiiDRC_PadButtons.state = newstate;
__WiiDRC_PadButtons.up = oldstate & ~newstate;
__WiiDRC_PadButtons.down = newstate & (newstate ^ oldstate);
return true;
}
bool WiiDRC_Connected()
{
if(__WiiDRC_DRCStateBuf)
{
DCInvalidateRange(__WiiDRC_DRCStateBuf, 4);
return !!(*(vu32*)__WiiDRC_DRCStateBuf);
}
return true; //default connect
}
bool WiiDRC_ShutdownRequested()
{
return __WiiDRC_ShutdownRequested;
}
const u8 *WiiDRC_GetRawI2CAddr()
{
return __WiiDRC_I2CBuf;
}
const struct WiiDRCData *WiiDRC_Data()
{
return &__WiiDRC_PadData;
}
u32 WiiDRC_ButtonsUp()
{
return __WiiDRC_PadButtons.up;
}
u32 WiiDRC_ButtonsDown()
{
return __WiiDRC_PadButtons.down;
}
u32 WiiDRC_ButtonsHeld()
{
return __WiiDRC_PadButtons.state;
}
s16 WiiDRC_lStickX()
{
return __WiiDRC_PadData.xAxisL;
}
s16 WiiDRC_lStickY()
{
return __WiiDRC_PadData.yAxisL;
}
s16 WiiDRC_rStickX()
{
return __WiiDRC_PadData.xAxisR;
}
s16 WiiDRC_rStickY()
{
return __WiiDRC_PadData.yAxisR;
}

67
source/utils/wiidrc.h Normal file
View File

@ -0,0 +1,67 @@
/*
* Copyright (C) 2017 FIX94
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
#ifndef _WIIDRC_H_
#define _WIIDRC_H_
#ifdef __cplusplus
extern "C" {
#endif
struct WiiDRCData {
s16 xAxisL;
s16 xAxisR;
s16 yAxisL;
s16 yAxisR;
u16 button;
u8 battery;
u8 extra;
};
#define WIIDRC_BUTTON_A 0x8000
#define WIIDRC_BUTTON_B 0x4000
#define WIIDRC_BUTTON_X 0x2000
#define WIIDRC_BUTTON_Y 0x1000
#define WIIDRC_BUTTON_LEFT 0x0800
#define WIIDRC_BUTTON_RIGHT 0x0400
#define WIIDRC_BUTTON_UP 0x0200
#define WIIDRC_BUTTON_DOWN 0x0100
#define WIIDRC_BUTTON_ZL 0x0080
#define WIIDRC_BUTTON_ZR 0x0040
#define WIIDRC_BUTTON_L 0x0020
#define WIIDRC_BUTTON_R 0x0010
#define WIIDRC_BUTTON_PLUS 0x0008
#define WIIDRC_BUTTON_MINUS 0x0004
#define WIIDRC_BUTTON_HOME 0x0002
#define WIIDRC_BUTTON_SYNC 0x0001
#define WIIDRC_EXTRA_BUTTON_L3 0x80
#define WIIDRC_EXTRA_BUTTON_R3 0x40
#define WIIDRC_EXTRA_BUTTON_TV 0x20
#define WIIDRC_EXTRA_OVERLAY_TV 0x10
#define WIIDRC_EXTRA_OVERLAY_POWER 0x01
bool WiiDRC_Init();
bool WiiDRC_Inited();
bool WiiDRC_Recalibrate();
bool WiiDRC_ScanPads();
bool WiiDRC_Connected();
bool WiiDRC_ShutdownRequested();
const u8 *WiiDRC_GetRawI2CAddr();
const struct WiiDRCData *WiiDRC_Data();
u32 WiiDRC_ButtonsUp();
u32 WiiDRC_ButtonsDown();
u32 WiiDRC_ButtonsHeld();
s16 WiiDRC_lStickX();
s16 WiiDRC_lStickY();
s16 WiiDRC_rStickX();
s16 WiiDRC_rStickY();
#ifdef __cplusplus
}
#endif
#endif