optimization - use a pointer for wpad data

This commit is contained in:
dborth 2009-10-13 00:40:02 +00:00
parent 49701e37f5
commit b9fdbfa8ad
11 changed files with 100 additions and 83 deletions

View File

@ -260,20 +260,11 @@ int main(int argc, char *argv[])
InitDeviceThread(); InitDeviceThread();
VIDEO_Init(); VIDEO_Init();
PAD_Init(); SetupPads();
#ifdef HW_RVL
WPAD_Init();
#endif
InitGCVideo (); // Initialise video InitGCVideo (); // Initialise video
ResetVideo_Menu (); // change to menu video mode ResetVideo_Menu (); // change to menu video mode
#ifdef HW_RVL #ifdef HW_RVL
// read wiimote accelerometer and IR data
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);
// Wii Power/Reset buttons // Wii Power/Reset buttons
WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB); WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB);
SYS_SetPowerCallback(ShutdownCB); SYS_SetPowerCallback(ShutdownCB);

View File

@ -216,7 +216,8 @@ class GuiTrigger
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)
s32 chan; //!< Trigger controller channel (0-3, -1 for all) s32 chan; //!< Trigger controller channel (0-3, -1 for all)
WPADData wpad; //!< Wii controller trigger data WPADData * wpad; //!< Wii controller trigger
WPADData wpaddata; //!< Wii controller trigger data
PADData pad; //!< GameCube controller trigger data PADData pad; //!< GameCube controller trigger data
}; };

View File

@ -161,9 +161,9 @@ void GuiButton::Update(GuiTrigger * t)
#ifdef HW_RVL #ifdef HW_RVL
// cursor // cursor
if(t->wpad.ir.valid && t->chan >= 0) if(t->wpad->ir.valid && t->chan >= 0)
{ {
if(this->IsInside(t->wpad.ir.x, t->wpad.ir.y)) if(this->IsInside(t->wpad->ir.x, t->wpad->ir.y))
{ {
if(state == STATE_DEFAULT) // we weren't on the button before! if(state == STATE_DEFAULT) // we weren't on the button before!
{ {
@ -209,24 +209,24 @@ void GuiButton::Update(GuiTrigger * t)
if(trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan)) if(trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan))
{ {
// higher 16 bits only (wiimote) // higher 16 bits only (wiimote)
wm_btns = t->wpad.btns_d << 16; wm_btns = t->wpad->btns_d << 16;
wm_btns_trig = trigger[i]->wpad.btns_d << 16; wm_btns_trig = trigger[i]->wpad->btns_d << 16;
// lower 16 bits only (classic controller) // lower 16 bits only (classic controller)
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;
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))
{ {
if(t->chan == stateChan || stateChan == -1) if(t->chan == stateChan || stateChan == -1)
{ {
if(state == STATE_SELECTED) if(state == STATE_SELECTED)
{ {
if(!t->wpad.ir.valid || this->IsInside(t->wpad.ir.x, t->wpad.ir.y)) if(!t->wpad->ir.valid || this->IsInside(t->wpad->ir.x, t->wpad->ir.y))
{ {
this->SetState(STATE_CLICKED, t->chan); this->SetState(STATE_CLICKED, t->chan);
@ -259,19 +259,19 @@ void GuiButton::Update(GuiTrigger * t)
if(trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan)) if(trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan))
{ {
// higher 16 bits only (wiimote) // higher 16 bits only (wiimote)
wm_btns = t->wpad.btns_d << 16; wm_btns = t->wpad->btns_d << 16;
wm_btns_h = t->wpad.btns_h << 16; wm_btns_h = t->wpad->btns_h << 16;
wm_btns_trig = trigger[i]->wpad.btns_h << 16; wm_btns_trig = trigger[i]->wpad->btns_h << 16;
// lower 16 bits only (classic controller) // lower 16 bits only (classic controller)
cc_btns = t->wpad.btns_d >> 16; cc_btns = t->wpad->btns_d >> 16;
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;
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))
{ {
if(trigger[i]->type == TRIGGER_HELD && state == STATE_SELECTED && if(trigger[i]->type == TRIGGER_HELD && state == STATE_SELECTED &&
@ -280,9 +280,9 @@ void GuiButton::Update(GuiTrigger * t)
} }
if( if(
(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))
{ {
if(trigger[i]->type == TRIGGER_HELD) if(trigger[i]->type == TRIGGER_HELD)

View File

@ -239,12 +239,12 @@ void GuiFileBrowser::Update(GuiTrigger * t)
// move the file listing to respond to wiimote cursor movement // move the file listing to respond to wiimote cursor movement
if(scrollbarBoxBtn->GetState() == STATE_HELD && if(scrollbarBoxBtn->GetState() == STATE_HELD &&
scrollbarBoxBtn->GetStateChan() == t->chan && scrollbarBoxBtn->GetStateChan() == t->chan &&
t->wpad.ir.valid && t->wpad->ir.valid &&
browser.numEntries > FILE_PAGESIZE browser.numEntries > FILE_PAGESIZE
) )
{ {
scrollbarBoxBtn->SetPosition(0,0); scrollbarBoxBtn->SetPosition(0,0);
positionWiimote = t->wpad.ir.y - 60 - scrollbarBoxBtn->GetTop(); positionWiimote = t->wpad->ir.y - 60 - scrollbarBoxBtn->GetTop();
if(positionWiimote < scrollbarBoxBtn->GetMinY()) if(positionWiimote < scrollbarBoxBtn->GetMinY())
positionWiimote = scrollbarBoxBtn->GetMinY(); positionWiimote = scrollbarBoxBtn->GetMinY();
@ -267,13 +267,13 @@ void GuiFileBrowser::Update(GuiTrigger * t)
if(arrowDownBtn->GetState() == STATE_HELD && arrowDownBtn->GetStateChan() == t->chan) if(arrowDownBtn->GetState() == STATE_HELD && arrowDownBtn->GetStateChan() == t->chan)
{ {
t->wpad.btns_h |= WPAD_BUTTON_DOWN; t->wpad->btns_h |= WPAD_BUTTON_DOWN;
if(!this->IsFocused()) if(!this->IsFocused())
((GuiWindow *)this->GetParent())->ChangeFocus(this); ((GuiWindow *)this->GetParent())->ChangeFocus(this);
} }
else if(arrowUpBtn->GetState() == STATE_HELD && arrowUpBtn->GetStateChan() == t->chan) else if(arrowUpBtn->GetState() == STATE_HELD && arrowUpBtn->GetStateChan() == t->chan)
{ {
t->wpad.btns_h |= WPAD_BUTTON_UP; t->wpad->btns_h |= WPAD_BUTTON_UP;
if(!this->IsFocused()) if(!this->IsFocused())
((GuiWindow *)this->GetParent())->ChangeFocus(this); ((GuiWindow *)this->GetParent())->ChangeFocus(this);
} }
@ -395,7 +395,7 @@ void GuiFileBrowser::Update(GuiTrigger * t)
int currChan = t->chan; int currChan = t->chan;
if(t->wpad.ir.valid && !fileList[i]->IsInside(t->wpad.ir.x, t->wpad.ir.y)) if(t->wpad->ir.valid && !fileList[i]->IsInside(t->wpad->ir.x, t->wpad->ir.y))
t->chan = -1; t->chan = -1;
fileList[i]->Update(t); fileList[i]->Update(t);

View File

@ -245,7 +245,7 @@ void GuiOptionBrowser::Update(GuiTrigger * t)
arrowDownBtn->Update(t); arrowDownBtn->Update(t);
next = listOffset; next = listOffset;
if(listChanged) if(listChanged)
{ {
listChanged = false; listChanged = false;
@ -281,7 +281,7 @@ void GuiOptionBrowser::Update(GuiTrigger * t)
int currChan = t->chan; int currChan = t->chan;
if(t->wpad.ir.valid && !optionBtn[i]->IsInside(t->wpad.ir.x, t->wpad.ir.y)) if(t->wpad->ir.valid && !optionBtn[i]->IsInside(t->wpad->ir.x, t->wpad->ir.y))
t->chan = -1; t->chan = -1;
optionBtn[i]->Update(t); optionBtn[i]->Update(t);

View File

@ -389,11 +389,11 @@ void GuiSaveBrowser::Update(GuiTrigger * t)
else if(focus && i == selectedItem && saveBtn[i]->GetState() == STATE_DEFAULT) else if(focus && i == selectedItem && saveBtn[i]->GetState() == STATE_DEFAULT)
saveBtn[selectedItem]->SetState(STATE_SELECTED, t->chan); saveBtn[selectedItem]->SetState(STATE_SELECTED, t->chan);
if(t->wpad.ir.valid) if(t->wpad->ir.valid)
{ {
if(!saveBtnLastOver[i] && saveBtn[i]->IsInside(t->wpad.ir.x, t->wpad.ir.y)) if(!saveBtnLastOver[i] && saveBtn[i]->IsInside(t->wpad->ir.x, t->wpad->ir.y))
saveBtn[i]->ResetState(); saveBtn[i]->ResetState();
saveBtnLastOver[i] = saveBtn[i]->IsInside(t->wpad.ir.x, t->wpad.ir.y); saveBtnLastOver[i] = saveBtn[i]->IsInside(t->wpad->ir.x, t->wpad->ir.y);
} }
saveBtn[i]->Update(t); saveBtn[i]->Update(t);

View File

@ -18,8 +18,9 @@ static int scrollDelay = 0;
GuiTrigger::GuiTrigger() GuiTrigger::GuiTrigger()
{ {
chan = -1; chan = -1;
memset(&wpad, 0, sizeof(WPADData)); memset(&wpaddata, 0, sizeof(WPADData));
memset(&pad, 0, sizeof(PADData)); memset(&pad, 0, sizeof(PADData));
wpad = &wpaddata;
} }
/** /**
@ -38,7 +39,7 @@ void GuiTrigger::SetSimpleTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
{ {
type = TRIGGER_SIMPLE; type = TRIGGER_SIMPLE;
chan = ch; chan = ch;
wpad.btns_d = wiibtns; wpaddata.btns_d = wiibtns;
pad.btns_d = gcbtns; pad.btns_d = gcbtns;
} }
@ -51,7 +52,7 @@ void GuiTrigger::SetHeldTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
{ {
type = TRIGGER_HELD; type = TRIGGER_HELD;
chan = ch; chan = ch;
wpad.btns_h = wiibtns; wpaddata.btns_h = wiibtns;
pad.btns_h = gcbtns; pad.btns_h = gcbtns;
} }
@ -63,7 +64,7 @@ void GuiTrigger::SetButtonOnlyTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
{ {
type = TRIGGER_BUTTON_ONLY; type = TRIGGER_BUTTON_ONLY;
chan = ch; chan = ch;
wpad.btns_d = wiibtns; wpaddata.btns_d = wiibtns;
pad.btns_d = gcbtns; pad.btns_d = gcbtns;
} }
@ -76,7 +77,7 @@ void GuiTrigger::SetButtonOnlyInFocusTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
{ {
type = TRIGGER_BUTTON_ONLY_IN_FOCUS; type = TRIGGER_BUTTON_ONLY_IN_FOCUS;
chan = ch; chan = ch;
wpad.btns_d = wiibtns; wpaddata.btns_d = wiibtns;
pad.btns_d = gcbtns; pad.btns_d = gcbtns;
} }
@ -93,27 +94,27 @@ s8 GuiTrigger::WPAD_Stick(u8 right, int axis)
float mag = 0.0; float mag = 0.0;
float ang = 0.0; float ang = 0.0;
switch (wpad.exp.type) switch (wpad->exp.type)
{ {
case WPAD_EXP_NUNCHUK: case WPAD_EXP_NUNCHUK:
case WPAD_EXP_GUITARHERO3: case WPAD_EXP_GUITARHERO3:
if (right == 0) if (right == 0)
{ {
mag = wpad.exp.nunchuk.js.mag; mag = wpad->exp.nunchuk.js.mag;
ang = wpad.exp.nunchuk.js.ang; ang = wpad->exp.nunchuk.js.ang;
} }
break; break;
case WPAD_EXP_CLASSIC: case WPAD_EXP_CLASSIC:
if (right == 0) if (right == 0)
{ {
mag = wpad.exp.classic.ljs.mag; mag = wpad->exp.classic.ljs.mag;
ang = wpad.exp.classic.ljs.ang; ang = wpad->exp.classic.ljs.ang;
} }
else else
{ {
mag = wpad.exp.classic.rjs.mag; mag = wpad->exp.classic.rjs.mag;
ang = wpad.exp.classic.rjs.ang; ang = wpad->exp.classic.rjs.ang;
} }
break; break;
@ -142,12 +143,12 @@ 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)
|| (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_Stick(0,0) < -PADCAL) || WPAD_Stick(0,0) < -PADCAL)
{ {
if(wpad.btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_LEFT) if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_LEFT)
|| pad.btns_d & PAD_BUTTON_LEFT) || pad.btns_d & PAD_BUTTON_LEFT)
{ {
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay. scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
@ -171,12 +172,12 @@ 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)
|| (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_Stick(0,0) > PADCAL) || WPAD_Stick(0,0) > PADCAL)
{ {
if(wpad.btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT) if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT)
|| pad.btns_d & PAD_BUTTON_RIGHT) || pad.btns_d & PAD_BUTTON_RIGHT)
{ {
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay. scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
@ -200,12 +201,12 @@ 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)
|| (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_Stick(0,1) > PADCAL) || WPAD_Stick(0,1) > PADCAL)
{ {
if(wpad.btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_UP) if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_UP)
|| pad.btns_d & PAD_BUTTON_UP) || pad.btns_d & PAD_BUTTON_UP)
{ {
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay. scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
@ -229,12 +230,12 @@ 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)
|| (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_Stick(0,1) < -PADCAL) || WPAD_Stick(0,1) < -PADCAL)
{ {
if(wpad.btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN) if(wpad->btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN)
|| pad.btns_d & PAD_BUTTON_DOWN) || pad.btns_d & PAD_BUTTON_DOWN)
{ {
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay. scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.

View File

@ -195,7 +195,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)
{ {
for (i = found; i < _elements.size(); i++) for (i = found; i < _elements.size(); i++)

View File

@ -272,9 +272,9 @@ UpdateGUI (void *arg)
#ifdef HW_RVL #ifdef HW_RVL
for(i=3; i >= 0; i--) // so that player 1's cursor appears on top! for(i=3; i >= 0; i--) // so that player 1's cursor appears on top!
{ {
if(userInput[i].wpad.ir.valid) if(userInput[i].wpad->ir.valid)
Menu_DrawImg(userInput[i].wpad.ir.x-48, userInput[i].wpad.ir.y-48, Menu_DrawImg(userInput[i].wpad->ir.x-48, userInput[i].wpad->ir.y-48,
96, 96, pointer[i]->GetImage(), userInput[i].wpad.ir.angle, 1, 1, 255); 96, 96, pointer[i]->GetImage(), userInput[i].wpad->ir.angle, 1, 1, 255);
DoRumble(i); DoRumble(i);
} }
#endif #endif
@ -855,9 +855,9 @@ static void WindowCredits(void * ptr)
for(i=3; i >= 0; i--) for(i=3; i >= 0; i--)
{ {
#ifdef HW_RVL #ifdef HW_RVL
if(userInput[i].wpad.ir.valid) if(userInput[i].wpad->ir.valid)
Menu_DrawImg(userInput[i].wpad.ir.x-48, userInput[i].wpad.ir.y-48, Menu_DrawImg(userInput[i].wpad->ir.x-48, userInput[i].wpad->ir.y-48,
96, 96, pointer[i]->GetImage(), userInput[i].wpad.ir.angle, 1, 1, 255); 96, 96, pointer[i]->GetImage(), userInput[i].wpad->ir.angle, 1, 1, 255);
DoRumble(i); DoRumble(i);
#endif #endif
} }
@ -866,7 +866,7 @@ static void WindowCredits(void * ptr)
for(i=0; i < 4; i++) for(i=0; i < 4; i++)
{ {
if(userInput[i].wpad.btns_d || userInput[i].pad.btns_d) if(userInput[i].wpad->btns_d || userInput[i].pad.btns_d)
exit = true; exit = true;
} }
usleep(THREAD_SLEEP); usleep(THREAD_SLEEP);
@ -875,7 +875,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].wpad.btns_d = 0; userInput[i].wpad->btns_d = 0;
userInput[i].pad.btns_d = 0; userInput[i].pad.btns_d = 0;
} }
@ -1361,7 +1361,7 @@ static int MenuGame()
if(WPAD_Probe(i, NULL) == WPAD_ERR_NONE) if(WPAD_Probe(i, NULL) == WPAD_ERR_NONE)
{ {
newStatus = true; newStatus = true;
newLevel = (userInput[i].wpad.battery_level / 100.0) * 4; newLevel = (userInput[i].wpad->battery_level / 100.0) * 4;
if(newLevel > 4) newLevel = 4; if(newLevel > 4) newLevel = 4;
} }
else else
@ -2448,12 +2448,12 @@ ButtonMappingWindow()
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 else
{ {
pressed = userInput[0].wpad.btns_d; pressed = userInput[0].wpad->btns_d;
// always allow Home button to be pressed to cancel // always allow Home button to be pressed to cancel
if(pressed != WPAD_BUTTON_HOME) if(pressed != WPAD_BUTTON_HOME)
@ -2466,14 +2466,14 @@ ButtonMappingWindow()
break; break;
case CTRLR_CLASSIC: case CTRLR_CLASSIC:
if(userInput[0].wpad.exp.type != WPAD_EXP_CLASSIC) if(userInput[0].wpad->exp.type != WPAD_EXP_CLASSIC)
pressed = 0; // not a valid input pressed = 0; // not a valid input
else if(pressed <= 0x1000) else if(pressed <= 0x1000)
pressed = 0; // not a valid input pressed = 0; // not a valid input
break; break;
case CTRLR_NUNCHUK: case CTRLR_NUNCHUK:
if(userInput[0].wpad.exp.type != WPAD_EXP_NUNCHUK) if(userInput[0].wpad->exp.type != WPAD_EXP_NUNCHUK)
pressed = 0; // not a valid input pressed = 0; // not a valid input
break; break;
} }

View File

@ -183,9 +183,10 @@ void SetControllers()
/**************************************************************************** /****************************************************************************
* UpdatePads * UpdatePads
* *
* called by postRetraceCallback in InitGCVideo - scans pad and wpad * Scans pad and wpad
***************************************************************************/ ***************************************************************************/
void UpdatePads() void
UpdatePads()
{ {
#ifdef HW_RVL #ifdef HW_RVL
WPAD_ScanPads(); WPAD_ScanPads();
@ -194,11 +195,6 @@ void UpdatePads()
for(int i=3; i >= 0; i--) for(int i=3; i >= 0; i--)
{ {
#ifdef HW_RVL
memcpy(&userInput[i].wpad, WPAD_Data(i), sizeof(WPADData));
#endif
userInput[i].chan = i;
userInput[i].pad.btns_d = PAD_ButtonsDown(i); userInput[i].pad.btns_d = PAD_ButtonsDown(i);
userInput[i].pad.btns_u = PAD_ButtonsUp(i); userInput[i].pad.btns_u = PAD_ButtonsUp(i);
userInput[i].pad.btns_h = PAD_ButtonsHeld(i); userInput[i].pad.btns_h = PAD_ButtonsHeld(i);
@ -211,6 +207,33 @@ void UpdatePads()
} }
} }
/****************************************************************************
* SetupPads
*
* Sets up userInput triggers for use
***************************************************************************/
void
SetupPads()
{
PAD_Init();
#ifdef HW_RVL
WPAD_Init();
// read wiimote accelerometer and IR data
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);
#endif
for(int i=0; i < 4; i++)
{
userInput[i].chan = i;
#ifdef HW_RVL
userInput[i].wpad = WPAD_Data(i);
#endif
}
}
#ifdef HW_RVL #ifdef HW_RVL
/**************************************************************************** /****************************************************************************
@ -603,8 +626,8 @@ bool MenuRequested()
userInput[i].pad.btns_h & PAD_BUTTON_B && userInput[i].pad.btns_h & PAD_BUTTON_B &&
userInput[i].pad.btns_h & PAD_TRIGGER_Z userInput[i].pad.btns_h & PAD_TRIGGER_Z
) || ) ||
(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)
) )
{ {
return true; return true;

View File

@ -33,6 +33,7 @@ s8 WPAD_StickY(u8 chan, u8 right);
void GetJoy(); void GetJoy();
void DrawCursor(); void DrawCursor();
bool MenuRequested(); bool MenuRequested();
void SetupPads();
void UpdatePads(); void UpdatePads();
#endif #endif