mirror of
https://github.com/retro100/dosbox-wii.git
synced 2025-01-12 18:29:07 +01:00
optimization - use a pointer for wpad data
This commit is contained in:
parent
ad69f20371
commit
314c33eada
@ -36,9 +36,6 @@ void UpdatePads()
|
||||
|
||||
for(int i=3; i >= 0; i--)
|
||||
{
|
||||
memcpy(&userInput[i].wpad, WPAD_Data(i), sizeof(WPADData));
|
||||
|
||||
userInput[i].chan = i;
|
||||
userInput[i].pad.btns_d = PAD_ButtonsDown(i);
|
||||
userInput[i].pad.btns_u = PAD_ButtonsUp(i);
|
||||
userInput[i].pad.btns_h = PAD_ButtonsHeld(i);
|
||||
@ -51,6 +48,20 @@ void UpdatePads()
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* SetupPads
|
||||
*
|
||||
* Sets up userInput triggers for use
|
||||
***************************************************************************/
|
||||
void SetupPads()
|
||||
{
|
||||
for(int i=0; i < 4; i++)
|
||||
{
|
||||
userInput[i].chan = i;
|
||||
userInput[i].wpad = WPAD_Data(i);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* ShutoffRumble
|
||||
***************************************************************************/
|
||||
|
@ -20,6 +20,7 @@ extern int rumbleRequest[4];
|
||||
|
||||
void ShutoffRumble();
|
||||
void DoRumble(int i);
|
||||
void SetupPads();
|
||||
void UpdatePads();
|
||||
bool MenuRequested();
|
||||
|
||||
|
@ -210,7 +210,8 @@ class GuiTrigger
|
||||
|
||||
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)
|
||||
WPADData wpad; //!< Wii controller trigger data
|
||||
WPADData * wpad; //!< Wii controller trigger
|
||||
WPADData wpaddata; //!< Wii controller trigger data
|
||||
PADData pad; //!< GameCube controller trigger data
|
||||
};
|
||||
|
||||
|
@ -161,9 +161,9 @@ void GuiButton::Update(GuiTrigger * t)
|
||||
|
||||
#ifdef HW_RVL
|
||||
// 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!
|
||||
{
|
||||
@ -209,24 +209,24 @@ void GuiButton::Update(GuiTrigger * t)
|
||||
if(trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan))
|
||||
{
|
||||
// higher 16 bits only (wiimote)
|
||||
wm_btns = t->wpad.btns_d << 16;
|
||||
wm_btns_trig = trigger[i]->wpad.btns_d << 16;
|
||||
wm_btns = t->wpad->btns_d << 16;
|
||||
wm_btns_trig = trigger[i]->wpad->btns_d << 16;
|
||||
|
||||
// lower 16 bits only (classic controller)
|
||||
cc_btns = t->wpad.btns_d >> 16;
|
||||
cc_btns_trig = trigger[i]->wpad.btns_d >> 16;
|
||||
cc_btns = t->wpad->btns_d >> 16;
|
||||
cc_btns_trig = trigger[i]->wpad->btns_d >> 16;
|
||||
|
||||
if(
|
||||
(t->wpad.btns_d > 0 &&
|
||||
(t->wpad->btns_d > 0 &&
|
||||
(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))
|
||||
{
|
||||
if(t->chan == stateChan || stateChan == -1)
|
||||
{
|
||||
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);
|
||||
|
||||
@ -259,19 +259,19 @@ void GuiButton::Update(GuiTrigger * t)
|
||||
if(trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan))
|
||||
{
|
||||
// higher 16 bits only (wiimote)
|
||||
wm_btns = t->wpad.btns_d << 16;
|
||||
wm_btns_h = t->wpad.btns_h << 16;
|
||||
wm_btns_trig = trigger[i]->wpad.btns_h << 16;
|
||||
wm_btns = t->wpad->btns_d << 16;
|
||||
wm_btns_h = t->wpad->btns_h << 16;
|
||||
wm_btns_trig = trigger[i]->wpad->btns_h << 16;
|
||||
|
||||
// lower 16 bits only (classic controller)
|
||||
cc_btns = t->wpad.btns_d >> 16;
|
||||
cc_btns_h = t->wpad.btns_h >> 16;
|
||||
cc_btns_trig = trigger[i]->wpad.btns_h >> 16;
|
||||
cc_btns = t->wpad->btns_d >> 16;
|
||||
cc_btns_h = t->wpad->btns_h >> 16;
|
||||
cc_btns_trig = trigger[i]->wpad->btns_h >> 16;
|
||||
|
||||
if(
|
||||
(t->wpad.btns_d > 0 &&
|
||||
(t->wpad->btns_d > 0 &&
|
||||
(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))
|
||||
{
|
||||
if(trigger[i]->type == TRIGGER_HELD && state == STATE_SELECTED &&
|
||||
@ -280,9 +280,9 @@ void GuiButton::Update(GuiTrigger * t)
|
||||
}
|
||||
|
||||
if(
|
||||
(t->wpad.btns_h > 0 &&
|
||||
(t->wpad->btns_h > 0 &&
|
||||
(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))
|
||||
{
|
||||
if(trigger[i]->type == TRIGGER_HELD)
|
||||
|
@ -69,6 +69,7 @@ GuiElement * GuiElement::GetParent()
|
||||
{
|
||||
return parentElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the left position of the GuiElement.
|
||||
* @see SetLeft()
|
||||
|
@ -18,8 +18,9 @@ static int scrollDelay = 0;
|
||||
GuiTrigger::GuiTrigger()
|
||||
{
|
||||
chan = -1;
|
||||
memset(&wpad, 0, sizeof(WPADData));
|
||||
memset(&wpaddata, 0, sizeof(WPADData));
|
||||
memset(&pad, 0, sizeof(PADData));
|
||||
wpad = &wpaddata;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -38,7 +39,7 @@ void GuiTrigger::SetSimpleTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
|
||||
{
|
||||
type = TRIGGER_SIMPLE;
|
||||
chan = ch;
|
||||
wpad.btns_d = wiibtns;
|
||||
wpaddata.btns_d = wiibtns;
|
||||
pad.btns_d = gcbtns;
|
||||
}
|
||||
|
||||
@ -51,7 +52,7 @@ void GuiTrigger::SetHeldTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
|
||||
{
|
||||
type = TRIGGER_HELD;
|
||||
chan = ch;
|
||||
wpad.btns_h = wiibtns;
|
||||
wpaddata.btns_h = wiibtns;
|
||||
pad.btns_h = gcbtns;
|
||||
}
|
||||
|
||||
@ -63,7 +64,7 @@ void GuiTrigger::SetButtonOnlyTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
|
||||
{
|
||||
type = TRIGGER_BUTTON_ONLY;
|
||||
chan = ch;
|
||||
wpad.btns_d = wiibtns;
|
||||
wpaddata.btns_d = wiibtns;
|
||||
pad.btns_d = gcbtns;
|
||||
}
|
||||
|
||||
@ -76,7 +77,7 @@ void GuiTrigger::SetButtonOnlyInFocusTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
|
||||
{
|
||||
type = TRIGGER_BUTTON_ONLY_IN_FOCUS;
|
||||
chan = ch;
|
||||
wpad.btns_d = wiibtns;
|
||||
wpaddata.btns_d = wiibtns;
|
||||
pad.btns_d = gcbtns;
|
||||
}
|
||||
|
||||
@ -91,27 +92,27 @@ s8 GuiTrigger::WPAD_Stick(u8 right, int axis)
|
||||
float mag = 0.0;
|
||||
float ang = 0.0;
|
||||
|
||||
switch (wpad.exp.type)
|
||||
switch (wpad->exp.type)
|
||||
{
|
||||
case WPAD_EXP_NUNCHUK:
|
||||
case WPAD_EXP_GUITARHERO3:
|
||||
if (right == 0)
|
||||
{
|
||||
mag = wpad.exp.nunchuk.js.mag;
|
||||
ang = wpad.exp.nunchuk.js.ang;
|
||||
mag = wpad->exp.nunchuk.js.mag;
|
||||
ang = wpad->exp.nunchuk.js.ang;
|
||||
}
|
||||
break;
|
||||
|
||||
case WPAD_EXP_CLASSIC:
|
||||
if (right == 0)
|
||||
{
|
||||
mag = wpad.exp.classic.ljs.mag;
|
||||
ang = wpad.exp.classic.ljs.ang;
|
||||
mag = wpad->exp.classic.ljs.mag;
|
||||
ang = wpad->exp.classic.ljs.ang;
|
||||
}
|
||||
else
|
||||
{
|
||||
mag = wpad.exp.classic.rjs.mag;
|
||||
ang = wpad.exp.classic.rjs.ang;
|
||||
mag = wpad->exp.classic.rjs.mag;
|
||||
ang = wpad->exp.classic.rjs.ang;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -136,12 +137,12 @@ bool GuiTrigger::Left()
|
||||
{
|
||||
u32 wiibtn = 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.stickX < -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)
|
||||
{
|
||||
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
||||
@ -165,12 +166,12 @@ bool GuiTrigger::Right()
|
||||
{
|
||||
u32 wiibtn = 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.stickX > 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)
|
||||
{
|
||||
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
||||
@ -194,12 +195,12 @@ bool GuiTrigger::Up()
|
||||
{
|
||||
u32 wiibtn = 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.stickY > 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)
|
||||
{
|
||||
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
||||
@ -223,12 +224,12 @@ bool GuiTrigger::Down()
|
||||
{
|
||||
u32 wiibtn = 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.stickY < -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)
|
||||
{
|
||||
scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
||||
|
@ -195,7 +195,7 @@ void GuiWindow::ToggleFocus(GuiTrigger * t)
|
||||
}
|
||||
}
|
||||
// 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)
|
||||
{
|
||||
for (i = found; i < _elements.size(); i++)
|
||||
|
@ -51,9 +51,9 @@ static void * UpdateGUI (void *arg)
|
||||
|
||||
for(i=3; i >= 0; i--) // so that player 1's cursor appears on top!
|
||||
{
|
||||
if(userInput[i].wpad.ir.valid)
|
||||
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);
|
||||
if(userInput[i].wpad->ir.valid)
|
||||
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);
|
||||
DoRumble(i);
|
||||
}
|
||||
|
||||
@ -274,7 +274,7 @@ static void * WindowCredits(void *arg)
|
||||
{
|
||||
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;
|
||||
}
|
||||
usleep(THREAD_SLEEP);
|
||||
@ -492,7 +492,7 @@ void HomeMenu ()
|
||||
if(WPAD_Probe(i, NULL) == WPAD_ERR_NONE)
|
||||
{
|
||||
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;
|
||||
}
|
||||
else
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "wiihardware.h"
|
||||
#include "FreeTypeGX.h"
|
||||
#include "input.h"
|
||||
#include "filelist.h"
|
||||
#include "SDL_events.h"
|
||||
|
||||
@ -205,6 +206,7 @@ void WiiInit()
|
||||
__exception_setreload(8);
|
||||
fatInitDefault();
|
||||
ASND_Init();
|
||||
SetupPads();
|
||||
InitFreeType((u8*)font_ttf, font_ttf_size);
|
||||
LWP_CreateThread (&keythread, PressKeys, NULL, NULL, 0, 65);
|
||||
appPath[0] = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user