Add Wii U GamePad support (thanks Fix94!)

This commit is contained in:
Daryl Borth 2018-09-05 20:00:21 -06:00
parent 53cf729fa8
commit 41a80cd6f9
20 changed files with 547 additions and 128 deletions

View File

@ -15,7 +15,8 @@ https://github.com/dborth/vbagx/releases
-=[ Features ]=-
* Wiimote, Nunchuk, Classic, 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)
* Rotation sensors, Solar sensors, and Rumble support
* Optional special Wii controls built-in for some games
* SRAM and State saving
@ -31,7 +32,6 @@ https://github.com/dborth/vbagx/releases
* Screenshots can be displayed on the main menu
* Fixed pixel ratio mode (1x, 2x, and 3x)
* Borders (from Super Game Boy games or custom from .png)
* Wii U Pro Controller support
* 240p support
×—–­—–­—–­—–­ –­—–­—–­—–­—–­—–­—–­—–­—–­—–­— ­—–­—–­—–­—–­—–­—–­—–­—-­—–­-–•¬
@ -43,6 +43,8 @@ https://github.com/dborth/vbagx/releases
* Restored changes lost from 2.3.0 core upgrade (GameCube virtual memory,
optimizations from dancinninjac, GB color palettes, rotation/tilt for
WarioWare Twisted, in-game rumble)
* Improved WiiFlow integration
* Added Wii U GamePad support (thanks Fix94!)
[2.3.7 - August 28, 2018]

View File

@ -16,6 +16,7 @@
#include <unistd.h>
#include <wiiuse/wpad.h>
#include "utils/wiidrc.h"
#include "button_mapping.h"
/****************************************************************************
@ -24,7 +25,7 @@
* and for displaying the name of said button
***************************************************************************/
CtrlrMap ctrlr_def[5] = {
CtrlrMap ctrlr_def[6] = {
// Gamecube controller btn def
{
{
@ -134,5 +135,27 @@ CtrlrMap ctrlr_def[5] = {
},
15,
CTRLR_WUPC
},
// Wii U Gamepad btn def
{
{
{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"}
},
15,
CTRLR_WIIDRC
}
};

View File

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

View File

@ -108,6 +108,8 @@ 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_drc_png[];
extern const u32 icon_settings_drc_png_size;
extern const u8 icon_settings_file_png[];
extern const u32 icon_settings_file_png_size;

View File

@ -123,6 +123,16 @@ typedef struct _paddata {
u8 triggerR;
} 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_BOTTOM 2
#define EFFECT_SLIDE_RIGHT 4
@ -182,22 +192,26 @@ class GuiTrigger
//!\param ch Controller channel number
//!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately
//!\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
//!\param ch Controller channel number
//!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately
//!\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
//!\param ch Controller channel number
//!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately
//!\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
//!\param ch Controller channel number
//!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately
//!\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
//!\param stick Controller stick (left = 0, right = 1)
//!\param axis Controller stick axis (x-axis = 0, y-axis = 1)
@ -226,6 +240,7 @@ class GuiTrigger
WPADData wpaddata; //!< Wii controller trigger data
PADData pad; //!< GameCube controller trigger data
GamePadData wiidrcdata; //!< Wii U Gamepad trigger data
WPADData * wpad; //!< Wii controller trigger
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)

View File

@ -156,8 +156,7 @@ void GuiButton::Draw()
label[0]->Draw();
if(labelOver[1])
labelOver[1]->Draw();
labelOver[1]->Draw();
else if(label[1])
label[1]->Draw();
@ -255,7 +254,7 @@ void GuiButton::Update(GuiTrigger * t)
// button triggers
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++)
{
if(trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan))
@ -268,12 +267,16 @@ void GuiButton::Update(GuiTrigger * t)
cc_btns = t->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(
(t->wpad->btns_d > 0 &&
(wm_btns == wm_btns_trig ||
(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)
{
@ -305,7 +308,7 @@ void GuiButton::Update(GuiTrigger * t)
if(this->IsHoldable())
{
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++)
{
@ -320,12 +323,18 @@ void GuiButton::Update(GuiTrigger * t)
cc_btns = t->wpad->btns_d >> 16;
cc_btns_h = t->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(
(t->wpad->btns_d > 0 &&
(wm_btns == wm_btns_trig ||
(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 &&
(t->chan == stateChan || stateChan == -1))
@ -336,8 +345,8 @@ void GuiButton::Update(GuiTrigger * t)
(t->wpad->btns_h > 0 &&
(wm_btns_h == wm_btns_trig ||
(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)
held = true;

View File

@ -25,12 +25,12 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
focus = 0; // allow focus
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->SetSimpleTrigger(-1, WPAD_BUTTON_2, 0);
trig2->SetSimpleTrigger(-1, WPAD_BUTTON_2, 0, 0);
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);
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);
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->SetSimpleTrigger(-1, WPAD_BUTTON_2, 0);
trig2->SetSimpleTrigger(-1, WPAD_BUTTON_2, 0, 0);
keyBackImg = new GuiImage(keyMedium);
keyBackOverImg = new GuiImage(keyMediumOver);

View File

@ -25,9 +25,9 @@ GuiOptionBrowser::GuiOptionBrowser(int w, int h, OptionList * l)
focus = 0; // allow focus
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->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);
btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM);

View File

@ -33,9 +33,9 @@ GuiSaveBrowser::GuiSaveBrowser(int w, int h, SaveList * s, int a)
focus = 0; // allow focus
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->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);
btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM);

View File

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

View File

@ -229,7 +229,7 @@ void GuiWindow::ToggleFocus(GuiTrigger * t)
}
// change focus
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)
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -44,7 +44,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[5][10]; // button mapping
u32 btnmap[6][10]; // button mapping
void ResetControls(int wiiCtrl)
{
@ -127,6 +127,7 @@ 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)
{
@ -142,6 +143,22 @@ void ResetControls(int wiiCtrl)
btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_FULL_L;
btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_FULL_R;
}
/*** Wii U Gamepad Padmap ***/
if(wiiCtrl == CTRLR_WIIDRC || wiiCtrl == -1)
{
i=0;
btnmap[CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_Y;
btnmap[CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_B;
btnmap[CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_MINUS;
btnmap[CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_PLUS;
btnmap[CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_UP;
btnmap[CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_DOWN;
btnmap[CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_LEFT;
btnmap[CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_RIGHT;
btnmap[CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_L;
btnmap[CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_R;
}
}
/****************************************************************************
@ -154,6 +171,7 @@ void
UpdatePads()
{
#ifdef HW_RVL
WiiDRC_ScanPads();
WPAD_ScanPads();
#endif
@ -170,8 +188,27 @@ UpdatePads()
userInput[i].pad.substickY = PAD_SubStickY(i);
userInput[i].pad.triggerL = PAD_TriggerL(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;
} while(i >= 0);
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();
}
}
/****************************************************************************
@ -325,6 +362,8 @@ u32 StandardMovement(unsigned short chan)
#ifdef HW_RVL
s8 wm_ax = userInput[0].WPAD_StickX(0);
s8 wm_ay = userInput[0].WPAD_StickY(0);
s16 wiidrc_ax = userInput[chan].wiidrcdata.stickX;
s16 wiidrc_ay = userInput[chan].wiidrcdata.stickY;
#endif
/***
@ -350,6 +389,16 @@ u32 StandardMovement(unsigned short chan)
J |= VBA_LEFT;
else if (wm_ax > ANALOG_SENSITIVITY)
J |= VBA_RIGHT;
/* Wii U Gamepad */
if (wiidrc_ay > ANALOG_SENSITIVITY)
J |= VBA_UP;
else if (wiidrc_ay < -ANALOG_SENSITIVITY)
J |= VBA_DOWN;
if (wiidrc_ax < -ANALOG_SENSITIVITY)
J |= VBA_LEFT;
else if (wiidrc_ax > ANALOG_SENSITIVITY)
J |= VBA_RIGHT;
#endif
return J;
}
@ -365,33 +414,41 @@ u32 StandardDPad(unsigned short pad)
u32 wp = userInput[pad].wpad->btns_h;
if (wp & WPAD_BUTTON_RIGHT)
J |= VBA_RIGHT;
if (wp & WPAD_BUTTON_LEFT)
else if (wp & WPAD_BUTTON_LEFT)
J |= VBA_LEFT;
if (wp & WPAD_BUTTON_UP)
J |= VBA_UP;
if (wp & WPAD_BUTTON_DOWN)
else if (wp & WPAD_BUTTON_DOWN)
J |= VBA_DOWN;
if (exp_type == WPAD_EXP_CLASSIC)
{
if (wp & WPAD_CLASSIC_BUTTON_UP)
J |= VBA_UP;
if (wp & WPAD_CLASSIC_BUTTON_DOWN)
else if (wp & WPAD_CLASSIC_BUTTON_DOWN)
J |= VBA_DOWN;
if (wp & WPAD_CLASSIC_BUTTON_LEFT)
J |= VBA_LEFT;
if (wp & WPAD_CLASSIC_BUTTON_RIGHT)
else if (wp & WPAD_CLASSIC_BUTTON_RIGHT)
J |= VBA_RIGHT;
}
/* Wii U Gamepad */
u32 wiidrcp = userInput[pad].wiidrcdata.btns_h;
if (wiidrcp & WIIDRC_BUTTON_UP)
J |= VBA_UP;
else if (wiidrcp & WIIDRC_BUTTON_DOWN)
J |= VBA_DOWN;
if (wiidrcp & WIIDRC_BUTTON_LEFT)
J |= VBA_LEFT;
else if (wiidrcp & WIIDRC_BUTTON_RIGHT)
J |= VBA_RIGHT;
#endif
if (jp & PAD_BUTTON_UP)
J |= VBA_UP;
if (jp & PAD_BUTTON_DOWN)
else if (jp & PAD_BUTTON_DOWN)
J |= VBA_DOWN;
if (jp & PAD_BUTTON_LEFT)
J |= VBA_LEFT;
if (jp & PAD_BUTTON_RIGHT)
else if (jp & PAD_BUTTON_RIGHT)
J |= VBA_RIGHT;
return J;
}
@ -404,11 +461,11 @@ u32 StandardSideways(unsigned short pad)
if (wp & WPAD_BUTTON_RIGHT)
J |= VBA_UP;
if (wp & WPAD_BUTTON_LEFT)
else if (wp & WPAD_BUTTON_LEFT)
J |= VBA_DOWN;
if (wp & WPAD_BUTTON_UP)
J |= VBA_LEFT;
if (wp & WPAD_BUTTON_DOWN)
else if (wp & WPAD_BUTTON_DOWN)
J |= VBA_RIGHT;
if (wp & WPAD_BUTTON_PLUS)
@ -444,11 +501,11 @@ u32 StandardClassic(unsigned short pad)
if (wp & WPAD_CLASSIC_BUTTON_RIGHT)
J |= VBA_RIGHT;
if (wp & WPAD_CLASSIC_BUTTON_LEFT)
else if (wp & WPAD_CLASSIC_BUTTON_LEFT)
J |= VBA_LEFT;
if (wp & WPAD_CLASSIC_BUTTON_UP)
J |= VBA_UP;
if (wp & WPAD_CLASSIC_BUTTON_DOWN)
else if (wp & WPAD_CLASSIC_BUTTON_DOWN)
J |= VBA_DOWN;
if (wp & WPAD_CLASSIC_BUTTON_PLUS)
@ -477,11 +534,11 @@ u32 StandardGamecube(unsigned short pad)
u32 jp = userInput[pad].pad.btns_h;
if (jp & PAD_BUTTON_UP)
J |= VBA_UP;
if (jp & PAD_BUTTON_DOWN)
else if (jp & PAD_BUTTON_DOWN)
J |= VBA_DOWN;
if (jp & PAD_BUTTON_LEFT)
J |= VBA_LEFT;
if (jp & PAD_BUTTON_RIGHT)
else if (jp & PAD_BUTTON_RIGHT)
J |= VBA_RIGHT;
if (jp & PAD_BUTTON_A)
J |= VBA_BUTTON_A;
@ -588,9 +645,9 @@ static u32 CCToGC(u32 w) {
if (w & WPAD_CLASSIC_BUTTON_FULL_L) gc |= PAD_TRIGGER_L;
if (w & WPAD_CLASSIC_BUTTON_FULL_R) gc |= PAD_TRIGGER_R;
if (w & WPAD_CLASSIC_BUTTON_UP) gc |= PAD_BUTTON_UP;
if (w & WPAD_CLASSIC_BUTTON_DOWN) gc |= PAD_BUTTON_DOWN;
else if (w & WPAD_CLASSIC_BUTTON_DOWN) gc |= PAD_BUTTON_DOWN;
if (w & WPAD_CLASSIC_BUTTON_LEFT) gc |= PAD_BUTTON_LEFT;
if (w & WPAD_CLASSIC_BUTTON_RIGHT) gc |= PAD_BUTTON_RIGHT;
else if (w & WPAD_CLASSIC_BUTTON_RIGHT) gc |= PAD_BUTTON_RIGHT;
return gc;
}
#endif
@ -833,12 +890,14 @@ static u32 DecodeJoy(unsigned short pad)
u32 J = StandardMovement(pad);
// Turbo feature
if(userInput[0].pad.substickX > 70 || userInput[0].WPAD_Stick(1,0) > 70)
if(userInput[0].pad.substickX > 70 ||
userInput[0].WPAD_Stick(1,0) > 70 ||
userInput[0].wiidrcdata.substickX > 45)
J |= VBA_SPEED;
// Report pressed buttons (gamepads)
u32 pad_btns_h = userInput[pad].pad.btns_h; // GCN
u32 wiidrcp_btns_h = userInput[pad].wiidrcdata.btns_h;
#ifdef HW_RVL
u32 wpad_btns_h = userInput[pad].wpad->btns_h;
int wpad_exp_type = userInput[pad].wpad->exp.type;
@ -850,6 +909,7 @@ static u32 DecodeJoy(unsigned short pad)
for (u32 i =0; i < MAXJP; ++i)
{
if ((pad_btns_h & btnmap[CTRLR_GCPAD][i]) // gamecube controller
|| ( wiidrcp_btns_h & btnmap[CTRLR_WIIDRC][i] ) //wii u gamepad
|| ( (wpad_btns_h & btnmap[CTRLR_WIIMOTE][i]) ))
J |= vbapadmap[i];
}
@ -857,22 +917,15 @@ static u32 DecodeJoy(unsigned short pad)
}
else if(wpad_exp_type == WPAD_EXP_CLASSIC)
{ // classic controller
if (isWUPC) {
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 {
for (u32 i =0; i < MAXJP; ++i)
{
if ((pad_btns_h & btnmap[CTRLR_GCPAD][i]) // gamecube controller
|| ( (wpad_btns_h & btnmap[CTRLR_CLASSIC][i]) ))
J |= vbapadmap[i];
}
for (u32 i =0; i < MAXJP; ++i)
{
if ((pad_btns_h & btnmap[CTRLR_GCPAD][i]) // gamecube controller
|| ( wiidrcp_btns_h & btnmap[CTRLR_WIIDRC][i] ) //wiiu gamepad
|| ( (wpad_btns_h & btnmap[CTRLR_CLASSIC][i]) ))
J |= vbapadmap[i];
}
}
else if(wpad_exp_type == WPAD_EXP_NUNCHUK)
{ // nunchuk + wiimote
@ -884,7 +937,6 @@ static u32 DecodeJoy(unsigned short pad)
J |= vbapadmap[i];
}
}
else
// Check out this trickery!
// If all else fails OR if HW_RVL is undefined, the result is the same
@ -892,11 +944,10 @@ static u32 DecodeJoy(unsigned short pad)
{
for (u32 i = 0; i < MAXJP; ++i)
{
if ((pad_btns_h & btnmap[CTRLR_GCPAD][i]))
if ((pad_btns_h & btnmap[CTRLR_GCPAD][i]) || (wiidrcp_btns_h & btnmap[CTRLR_WIIDRC][i]))
J |= vbapadmap[i];
}
}
return J;
}
@ -907,7 +958,8 @@ bool MenuRequested()
(userInput[i].pad.substickX < -70)
#ifdef HW_RVL
|| (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
)
{

View File

@ -13,9 +13,10 @@
#include <gccore.h>
#include <wiiuse/wpad.h>
#include "utils/wiidrc.h"
#define PI 3.14159265f
#define PADCAL 50
#define WIIDRCCAL 20
#define MAXJP 10 // # of mappable controller buttons
#define VBA_BUTTON_A 1
@ -32,7 +33,7 @@
#define VBA_CAPTURE 2048
extern int rumbleRequest[4];
extern u32 btnmap[5][10];
extern u32 btnmap[6][10];
void ResetControls(int wc = -1);
void ShutoffRumble();

View File

@ -832,19 +832,20 @@ static void WindowCredits(void * ptr)
Menu_Render();
if((userInput[0].wpad->btns_d || userInput[0].pad.btns_d) ||
(userInput[1].wpad->btns_d || userInput[1].pad.btns_d) ||
(userInput[2].wpad->btns_d || userInput[2].pad.btns_d) ||
(userInput[3].wpad->btns_d || userInput[3].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].wiidrcdata.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].wiidrcdata.btns_d))
{
exit = true;
}
exit = true;
}
usleep(THREAD_SLEEP);
}
// clear buttons pressed
for(i=0; i < 4; i++)
{
userInput[i].wiidrcdata.btns_d = 0;
userInput[i].wpad->btns_d = 0;
userInput[i].pad.btns_d = 0;
}
@ -878,7 +879,7 @@ static int MenuGameSelection()
GuiImageData bgPreviewImg(bg_preview_png);
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});
GuiImage settingsBtnIcon(&iconSettings);
@ -1097,7 +1098,7 @@ static int MenuGame()
GuiImageData batteryBar(battery_bar_png);
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);
int xOffset=125;
if (isBoktai)
@ -1596,7 +1597,7 @@ static int MenuGameSaves(int action)
GuiImageData btnCloseOutlineOver(button_small_over_png);
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});
GuiImage backBtnImg(&btnOutline);
@ -1876,7 +1877,7 @@ static int MenuGameSettings()
GuiImageData btnCloseOutlineOver(button_small_over_png);
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});
mappingBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30);
@ -2081,6 +2082,8 @@ static int MenuSettingsMappings()
GuiImageData iconGamecube(icon_settings_gamecube_png);
GuiImageData iconNunchuk(icon_settings_nunchuk_png);
GuiImageData iconWiiupro(icon_settings_wiiupro_png);
GuiImageData iconDrc(icon_settings_drc_png);
GuiText gamecubeBtnTxt("GameCube Controller", 22, (GXColor){0, 0, 0, 255});
gamecubeBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30);
GuiImage gamecubeBtnImg(&btnLargeOutline);
@ -2099,24 +2102,6 @@ static int MenuSettingsMappings()
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);
@ -2134,6 +2119,24 @@ static int MenuSettingsMappings()
wiimoteBtn.SetTrigger(trig2);
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});
classicBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30);
GuiImage classicBtnImg(&btnLargeOutline);
@ -2162,7 +2165,7 @@ static int MenuSettingsMappings()
GuiImage nunchukBtnIcon(&iconNunchuk);
GuiButton nunchukBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight());
nunchukBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
nunchukBtn.SetPosition(200, 250);
nunchukBtn.SetPosition(0, 250);
nunchukBtn.SetLabel(&nunchukBtnTxt1, 0);
nunchukBtn.SetLabel(&nunchukBtnTxt2, 1);
nunchukBtn.SetLabel(&nunchukBtnTxt3, 2);
@ -2175,6 +2178,24 @@ static int MenuSettingsMappings()
nunchukBtn.SetTrigger(trig2);
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});
GuiImage backBtnImg(&btnOutline);
GuiImage backBtnImgOver(&btnOutlineOver);
@ -2197,8 +2218,15 @@ static int MenuSettingsMappings()
w.Append(&gamecubeBtn);
#ifdef HW_RVL
w.Append(&wiimoteBtn);
w.Append(&nunchukBtn);
if(WiiDRC_Inited() && WiiDRC_Connected()) {
gamecubeBtn.SetPosition(-200, 120);
wiimoteBtn.SetPosition(0, 120);
w.Append(&drcBtn);
}
w.Append(&classicBtn);
w.Append(&nunchukBtn);
w.Append(&wiiuproBtn);
#endif
w.Append(&backBtn);
@ -2231,6 +2259,11 @@ static int MenuSettingsMappings()
menu = MENU_GAMESETTINGS_MAPPINGS_MAP;
mapMenuCtrl = CTRLR_WUPC;
}
else if(drcBtn.GetState() == STATE_CLICKED)
{
menu = MENU_GAMESETTINGS_MAPPINGS_MAP;
mapMenuCtrl = CTRLR_WIIDRC;
}
else if(gamecubeBtn.GetState() == STATE_CLICKED)
{
menu = MENU_GAMESETTINGS_MAPPINGS_MAP;
@ -2287,6 +2320,9 @@ ButtonMappingWindow()
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_WIIDRC:
sprintf(msg, "Press any button on the Wii U GamePad 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;
@ -2321,12 +2357,19 @@ ButtonMappingWindow()
if(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)
pressed = WPAD_BUTTON_HOME;
if(userInput[0].wpad->btns_d == 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
{
pressed = userInput[0].wpad->btns_d;
@ -2569,16 +2612,16 @@ static void ScreenZoomWindow()
w->SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
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;
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;
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;
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);
GuiImage arrowLeftImg(&arrowLeft);
@ -2731,16 +2774,16 @@ static void ScreenPositionWindow()
w->SetPosition(0, -10);
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;
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;
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;
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);
GuiImage arrowLeftImg(&arrowLeft);
@ -4127,7 +4170,7 @@ static int MenuPalette()
GuiImageData btnCloseOutlineOver(button_small_over_png);
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 bg0BtnTxt("BG 0", 24, GetCol(0));
GuiImage bg0BtnImg(&btnCloseOutline);
@ -4609,9 +4652,9 @@ MainMenu (int menu)
#endif
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->SetSimpleTrigger(-1, WPAD_BUTTON_2, 0);
trig2->SetSimpleTrigger(-1, WPAD_BUTTON_2, 0, 0);
}
mainWindow = new GuiWindow(screenwidth, screenheight);

View File

@ -217,12 +217,13 @@ preparePrefsData ()
createXMLSection("Controller", "Controller Settings");
createXMLSetting("WiiControls", "Match Wii Game", toStr(GCSettings.WiiControls));
createXMLController(btnmap[CTRLR_GCPAD], "gcpadmap", "GameCube Pad");
createXMLSetting("WiiControls", "Match Wii Game", toStr(GCSettings.WiiControls));
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");
createXMLController(btnmap[CTRLR_WIIDRC], "drcpadmap", "Wii U Gamepad");
createXMLSection("Emulation", "Emulation Settings");
@ -525,21 +526,19 @@ decodePrefsData ()
loadXMLSetting(&GCSettings.PreviewImage, "PreviewImage");
// Controller Settings
loadXMLSetting(&GCSettings.WiiControls, "WiiControls");
loadXMLController(btnmap[CTRLR_GCPAD], "gcpadmap");
loadXMLSetting(&GCSettings.WiiControls, "WiiControls");
loadXMLController(btnmap[CTRLR_WIIMOTE], "wmpadmap");
loadXMLController(btnmap[CTRLR_CLASSIC], "ccpadmap");
loadXMLController(btnmap[CTRLR_NUNCHUK], "ncpadmap");
loadXMLController(btnmap[CTRLR_WUPC], "wupcpadmap");
loadXMLController(btnmap[CTRLR_WIIDRC], "drcpadmap");
// Emulation Settings
loadXMLSetting(&GCSettings.OffsetMinutesUTC, "OffsetMinutesUTC");
loadXMLSetting(&GCSettings.GBHardware, "GBHardware");
loadXMLSetting(&GCSettings.SGBBorder, "SGBBorder");
loadXMLSetting(&GCSettings.BasicPalette, "BasicPalette");
}
mxmlDelete(xml);
}

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

View File

@ -34,6 +34,7 @@
#include "video.h"
#include "gamesettings.h"
#include "mem2.h"
#include "utils/wiidrc.h"
#include "utils/FreeTypeGX.h"
#include "vba/gba/Globals.h"
@ -54,8 +55,6 @@ int ResetRequested = 0;
int ExitRequested = 0;
char appPath[1024] = { 0 };
/****************************************************************************
* Shutdown / Reboot / Exit
***************************************************************************/
@ -358,6 +357,7 @@ int main(int argc, char *argv[])
SYS_SetPowerCallback(ShutdownCB);
SYS_SetResetCallback(ResetCB);
WiiDRC_Init();
WPAD_Init();
WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB);
DI_Init();