Add Wii U GamePad support (thanks Fix94!)

This commit is contained in:
Daryl Borth 2018-09-05 19:59:14 -06:00
parent 93c161493b
commit c5eed33de0
20 changed files with 492 additions and 85 deletions

View File

@ -16,7 +16,8 @@ Wii homebrew is WiiBrew (www.wiibrew.org).
•˜———–—––-- - —————————––––– ———–—––-- - —————————––––– ———–—––-- - ————————•
* Based on Snes9x 1.52
* 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)
* SNES Superscope, Mouse, Justifier support
* Cheat support
* Satellaview (BS-X) support
@ -37,6 +38,7 @@ Wii homebrew is WiiBrew (www.wiibrew.org).
* Improved WiiFlow integration
* Fixed mangled image when switching between HQ2x and scanlines filters
* Added Wii U GamePad support (thanks Fix94!)
[4.3.9 - August 24, 2018]

View File

@ -17,6 +17,7 @@
#include <unistd.h>
#include <wiiuse/wpad.h>
#include "utils/wiidrc.h"
#include "button_mapping.h"
/****************************************************************************
@ -25,7 +26,7 @@
* and for displaying the name of said button
***************************************************************************/
CtrlrMap ctrlr_def[5] = {
CtrlrMap ctrlr_def[6] = {
// Gamecube controller btn def
{
CTRLR_GCPAD,
@ -114,7 +115,7 @@ CtrlrMap ctrlr_def[5] = {
{WPAD_CLASSIC_BUTTON_ZR, "ZR"}
}
},
// Wii U pro controller
// Wii U Pro controller
{
CTRLR_WUPC,
15,
@ -135,5 +136,27 @@ CtrlrMap ctrlr_def[5] = {
{WPAD_CLASSIC_BUTTON_ZL, "ZL"},
{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

@ -18,11 +18,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'
@ -35,6 +36,6 @@ typedef struct _ctrlr_map {
BtnMap map[15]; // controller button map
} 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_snescontroller_png[];
extern const u32 icon_settings_snescontroller_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

@ -60,7 +60,7 @@ static int cursor_y[5] = {0,0,0,0,0};
S9xMapButton( keycode, cmd = S9xGetCommandT(snescmd), false)
static int scopeTurbo = 0; // tracks whether superscope turbo is on or off
u32 btnmap[4][5][12]; // button mapping
u32 btnmap[4][6][12]; // button mapping
void ResetControls(int consoleCtrl, int wiiCtrl)
{
@ -136,6 +136,24 @@ void ResetControls(int consoleCtrl, int wiiCtrl)
btnmap[CTRL_PAD][CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_LEFT;
btnmap[CTRL_PAD][CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_RIGHT;
}
/*** 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 ***/
if(consoleCtrl == -1 || (consoleCtrl == CTRL_PAD && wiiCtrl == CTRLR_NUNCHUK))
@ -224,6 +242,7 @@ void
UpdatePads()
{
#ifdef HW_RVL
WiiDRC_ScanPads();
WPAD_ScanPads();
#endif
@ -407,6 +426,10 @@ static void decodepad (int chan)
u32 exp_type;
if ( WPAD_Probe(chan, &exp_type) != 0 )
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
/***
@ -439,6 +462,16 @@ static void decodepad (int chan)
wp |= (exp_type == WPAD_EXP_CLASSIC) ? WPAD_CLASSIC_BUTTON_LEFT : WPAD_BUTTON_LEFT;
else if (wm_ax > ANALOG_SENSITIVITY)
wp |= (exp_type == WPAD_EXP_CLASSIC) ? WPAD_CLASSIC_BUTTON_RIGHT : WPAD_BUTTON_RIGHT;
/* Wii U Gamepad */
if (wiidrc_ay > ANALOG_SENSITIVITY)
wiidrcp |= WIIDRC_BUTTON_UP;
else if (wiidrc_ay < -ANALOG_SENSITIVITY)
wiidrcp |= WIIDRC_BUTTON_DOWN;
if (wiidrc_ax < -ANALOG_SENSITIVITY)
wiidrcp |= WIIDRC_BUTTON_LEFT;
else if (wiidrc_ax > ANALOG_SENSITIVITY)
wiidrcp |= WIIDRC_BUTTON_RIGHT;
#endif
/*** Fix offset to pad ***/
@ -453,6 +486,7 @@ static void decodepad (int 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_WUPC][i]) ) // wii u pro controller
|| ( (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
)
S9xReportButton (offset + i, true);
@ -559,7 +593,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
)
{
@ -583,7 +618,8 @@ void ReportButtons ()
Settings.TurboMode = (
userInput[0].pad.substickX > 70 ||
userInput[0].WPAD_StickX(1) > 70
userInput[0].WPAD_StickX(1) > 70 ||
userInput[0].wiidrcdata.substickX > 45
); // RIGHT on c-stick and on classic controller right joystick
if(Settings.TurboMode) {

View File

@ -16,12 +16,14 @@
#include <gccore.h>
#include <wiiuse/wpad.h>
#include "utils/wiidrc.h"
#define PI 3.14159265f
#define PADCAL 50
#define WIIDRCCAL 20
#define MAXJP 12 // # of mappable controller buttons
extern u32 btnmap[4][5][12];
extern u32 btnmap[4][6][12];
extern int rumbleRequest[4];
void ResetControls(int cc = -1, int wc = -1);

View File

@ -851,10 +851,10 @@ 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;
}
@ -864,6 +864,7 @@ static void WindowCredits(void * ptr)
// 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;
}
@ -897,7 +898,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);
@ -1121,10 +1122,10 @@ static void ControllerWindow()
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);
GuiImageData arrowLeft(button_arrow_left_png);
GuiImage arrowLeftImg(&arrowLeft);
@ -1201,7 +1202,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);
GuiText saveBtnTxt("Save", 22, (GXColor){0, 0, 0, 255});
GuiImage saveBtnImg(&btnLargeOutline);
@ -1620,7 +1621,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);
@ -1891,7 +1892,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);
@ -2353,9 +2354,10 @@ static int MenuSettingsMappingsController()
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()-20);
gamecubeBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30);
GuiImage gamecubeBtnImg(&btnLargeOutline);
GuiImage gamecubeBtnImgOver(&btnLargeOutlineOver);
GuiImage gamecubeBtnIcon(&iconGamecube);
@ -2372,24 +2374,6 @@ static int MenuSettingsMappingsController()
gamecubeBtn.SetTrigger(trig2);
gamecubeBtn.SetEffectGrow();
GuiText wiiuproBtnTxt("Wii U Pro Controller", 22, (GXColor){0, 0, 0, 255});
wiiuproBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-20);
GuiImage wiiuproBtnImg(&btnLargeOutline);
GuiImage wiiuproBtnImgOver(&btnLargeOutlineOver);
GuiImage wiiuproBtnIcon(&iconWiiupro);
GuiButton wiiuproBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight());
wiiuproBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
wiiuproBtn.SetPosition(0, 250);
wiiuproBtn.SetLabel(&wiiuproBtnTxt);
wiiuproBtn.SetImage(&wiiuproBtnImg);
wiiuproBtn.SetImageOver(&wiiuproBtnImgOver);
wiiuproBtn.SetIcon(&wiiuproBtnIcon);
wiiuproBtn.SetSoundOver(&btnSoundOver);
wiiuproBtn.SetSoundClick(&btnSoundClick);
wiiuproBtn.SetTrigger(trigA);
wiiuproBtn.SetTrigger(trig2);
wiiuproBtn.SetEffectGrow();
GuiText wiimoteBtnTxt("Wiimote", 22, (GXColor){0, 0, 0, 255});
GuiImage wiimoteBtnImg(&btnLargeOutline);
GuiImage wiimoteBtnImgOver(&btnLargeOutlineOver);
@ -2407,8 +2391,26 @@ static int MenuSettingsMappingsController()
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()-20);
classicBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30);
GuiImage classicBtnImg(&btnLargeOutline);
GuiImage classicBtnImgOver(&btnLargeOutlineOver);
GuiImage classicBtnIcon(&iconClassic);
@ -2435,7 +2437,7 @@ static int MenuSettingsMappingsController()
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);
@ -2448,6 +2450,24 @@ static int MenuSettingsMappingsController()
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);
@ -2474,8 +2494,14 @@ static int MenuSettingsMappingsController()
if(mapMenuCtrlSNES == 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(&nunchukBtn);
w.Append(&wiiuproBtn);
}
#endif
@ -2509,6 +2535,11 @@ static int MenuSettingsMappingsController()
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;
@ -2566,6 +2597,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;
@ -2605,6 +2639,13 @@ ButtonMappingWindow()
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;
@ -2866,16 +2907,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);
@ -3002,16 +3043,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);
@ -3991,9 +4032,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

@ -173,6 +173,7 @@ preparePrefsData ()
createXMLController(btnmap[CTRL_PAD][CTRLR_WIIMOTE], "btnmap_pad_wiimote", "SNES Pad - Wiimote");
createXMLController(btnmap[CTRL_PAD][CTRLR_CLASSIC], "btnmap_pad_classic", "SNES Pad - Classic Controller");
createXMLController(btnmap[CTRL_PAD][CTRLR_WUPC], "btnmap_pad_wupc", "SNES Pad - Wii U Pro Controller");
createXMLController(btnmap[CTRL_PAD][CTRLR_WIIDRC], "btnmap_pad_wiidrc", "SNES Pad - Wii U Gamepad");
createXMLController(btnmap[CTRL_PAD][CTRLR_NUNCHUK], "btnmap_pad_nunchuk", "SNES Pad - Nunchuk + Wiimote");
#endif
createXMLController(btnmap[CTRL_SCOPE][CTRLR_GCPAD], "btnmap_scope_gcpad", "Superscope - GameCube Controller");
@ -356,6 +357,7 @@ decodePrefsData ()
loadXMLController(btnmap[CTRL_PAD][CTRLR_WIIMOTE], "btnmap_pad_wiimote");
loadXMLController(btnmap[CTRL_PAD][CTRLR_CLASSIC], "btnmap_pad_classic");
loadXMLController(btnmap[CTRL_PAD][CTRLR_WUPC], "btnmap_pad_wupc");
loadXMLController(btnmap[CTRL_PAD][CTRLR_WIIDRC], "btnmap_pad_wiidrc");
loadXMLController(btnmap[CTRL_PAD][CTRLR_NUNCHUK], "btnmap_pad_nunchuk");
loadXMLController(btnmap[CTRL_SCOPE][CTRLR_GCPAD], "btnmap_scope_gcpad");
loadXMLController(btnmap[CTRL_SCOPE][CTRLR_WIIMOTE], "btnmap_scope_wiimote");

View File

@ -43,6 +43,7 @@
#include "filebrowser.h"
#include "input.h"
#include "mem2.h"
#include "utils/wiidrc.h"
#include "utils/FreeTypeGX.h"
#include "snes9x/snes9x.h"
@ -421,6 +422,7 @@ int main(int argc, char *argv[])
SYS_SetPowerCallback(ShutdownCB);
SYS_SetResetCallback(ResetCB);
WiiDRC_Init();
WPAD_Init();
WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB);
DI_Init();

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