mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-25 12:06:53 +01:00
tidy up code
This commit is contained in:
parent
58d3adde97
commit
04df044637
@ -196,11 +196,19 @@ class GuiTrigger
|
||||
//!\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);
|
||||
//!Get X/Y value from Wii Joystick (classic, nunchuk) input
|
||||
//!\param right Controller stick (left = 0, right = 1)
|
||||
//!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)
|
||||
//!\return Stick value
|
||||
s8 WPAD_Stick(u8 right, int axis);
|
||||
s8 WPAD_Stick(u8 stick, int axis);
|
||||
//!Get X value from Wii Joystick (classic, nunchuk) input
|
||||
//!\param stick Controller stick (left = 0, right = 1)
|
||||
//!\return Stick value
|
||||
s8 WPAD_StickX(u8 stick);
|
||||
//!Get Y value from Wii Joystick (classic, nunchuk) input
|
||||
//!\param stick Controller stick (left = 0, right = 1)
|
||||
//!\return Stick value
|
||||
s8 WPAD_StickY(u8 stick);
|
||||
//!Move menu selection left (via pad/joystick). Allows scroll delay and button overriding
|
||||
//!\return true if selection should be moved left, false otherwise
|
||||
bool Left();
|
||||
|
@ -87,7 +87,7 @@ void GuiTrigger::SetButtonOnlyInFocusTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
|
||||
* Get X/Y value from Wii Joystick (classic, nunchuk) input
|
||||
***************************************************************************/
|
||||
|
||||
s8 GuiTrigger::WPAD_Stick(u8 right, int axis)
|
||||
s8 GuiTrigger::WPAD_Stick(u8 stick, int axis)
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
|
||||
@ -98,7 +98,7 @@ s8 GuiTrigger::WPAD_Stick(u8 right, int axis)
|
||||
{
|
||||
case WPAD_EXP_NUNCHUK:
|
||||
case WPAD_EXP_GUITARHERO3:
|
||||
if (right == 0)
|
||||
if (stick == 0)
|
||||
{
|
||||
mag = wpad->exp.nunchuk.js.mag;
|
||||
ang = wpad->exp.nunchuk.js.ang;
|
||||
@ -106,7 +106,7 @@ s8 GuiTrigger::WPAD_Stick(u8 right, int axis)
|
||||
break;
|
||||
|
||||
case WPAD_EXP_CLASSIC:
|
||||
if (right == 0)
|
||||
if (stick == 0)
|
||||
{
|
||||
mag = wpad->exp.classic.ljs.mag;
|
||||
ang = wpad->exp.classic.ljs.ang;
|
||||
@ -139,6 +139,16 @@ s8 GuiTrigger::WPAD_Stick(u8 right, int axis)
|
||||
#endif
|
||||
}
|
||||
|
||||
s8 GuiTrigger::WPAD_StickX(u8 stick)
|
||||
{
|
||||
return WPAD_Stick(stick, 0);
|
||||
}
|
||||
|
||||
s8 GuiTrigger::WPAD_StickY(u8 stick)
|
||||
{
|
||||
return WPAD_Stick(stick, 1);
|
||||
}
|
||||
|
||||
bool GuiTrigger::Left()
|
||||
{
|
||||
u32 wiibtn = GCSettings.WiimoteOrientation ? WPAD_BUTTON_UP : WPAD_BUTTON_LEFT;
|
||||
|
@ -37,10 +37,10 @@ GuiTrigger userInput[4];
|
||||
static int rumbleCount[4] = {0,0,0,0};
|
||||
#endif
|
||||
|
||||
bool cartridgeRumble = false, possibleCartridgeRumble = false;
|
||||
int gameRumbleCount = 0, menuRumbleCount = 0, rumbleCountAlready = 0;
|
||||
static bool cartridgeRumble = false, possibleCartridgeRumble = false;
|
||||
static int gameRumbleCount = 0, menuRumbleCount = 0, rumbleCountAlready = 0;
|
||||
|
||||
unsigned int vbapadmap[10]; // VBA controller buttons
|
||||
static unsigned int vbapadmap[10]; // VBA controller buttons
|
||||
u32 btnmap[5][10]; // button mapping
|
||||
|
||||
void ResetControls(int wiiCtrl)
|
||||
@ -299,71 +299,14 @@ void systemGameRumbleOnlyFor(int OnlyRumbleForFrames) {
|
||||
gameRumbleCount = OnlyRumbleForFrames;
|
||||
}
|
||||
|
||||
void systemMenuRumble(int RumbleForFrames) {
|
||||
if (RumbleForFrames > menuRumbleCount) menuRumbleCount = RumbleForFrames;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* WPAD_Stick
|
||||
*
|
||||
* Get X/Y value from Wii Joystick (classic, nunchuk) input
|
||||
***************************************************************************/
|
||||
|
||||
s8 WPAD_Stick(u8 chan, u8 right, int axis)
|
||||
{
|
||||
float mag = 0.0;
|
||||
float ang = 0.0;
|
||||
WPADData *data = WPAD_Data(chan);
|
||||
|
||||
switch (data->exp.type)
|
||||
{
|
||||
case WPAD_EXP_NUNCHUK:
|
||||
case WPAD_EXP_GUITARHERO3:
|
||||
if (right == 0)
|
||||
{
|
||||
mag = data->exp.nunchuk.js.mag;
|
||||
ang = data->exp.nunchuk.js.ang;
|
||||
}
|
||||
break;
|
||||
|
||||
case WPAD_EXP_CLASSIC:
|
||||
if (right == 0)
|
||||
{
|
||||
mag = data->exp.classic.ljs.mag;
|
||||
ang = data->exp.classic.ljs.ang;
|
||||
}
|
||||
else
|
||||
{
|
||||
mag = data->exp.classic.rjs.mag;
|
||||
ang = data->exp.classic.rjs.ang;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* calculate x/y value (angle need to be converted into radian) */
|
||||
if (mag > 1.0) mag = 1.0;
|
||||
else if (mag < -1.0) mag = -1.0;
|
||||
double val;
|
||||
|
||||
if(axis == 0) // x-axis
|
||||
val = mag * sin((PI * ang)/180.0f);
|
||||
else // y-axis
|
||||
val = mag * cos((PI * ang)/180.0f);
|
||||
|
||||
return (s8)(val * 128.0f);
|
||||
}
|
||||
|
||||
u32 StandardMovement(unsigned short pad)
|
||||
u32 StandardMovement(unsigned short chan)
|
||||
{
|
||||
u32 J = 0;
|
||||
signed char pad_x = PAD_StickX (pad);
|
||||
signed char pad_y = PAD_StickY (pad);
|
||||
s8 pad_x = userInput[chan].pad.stickX;
|
||||
s8 pad_y = userInput[chan].pad.stickY;
|
||||
#ifdef HW_RVL
|
||||
signed char wm_ax = WPAD_Stick ((u8)pad, 0, 0);
|
||||
signed char wm_ay = WPAD_Stick ((u8)pad, 0, 1);
|
||||
s8 wm_ax = userInput[0].WPAD_StickX(0);
|
||||
s8 wm_ay = userInput[0].WPAD_StickY(0);
|
||||
#endif
|
||||
/***
|
||||
Gamecube Joystick input, same as normal
|
||||
@ -714,10 +657,10 @@ u32 DecodeNunchuk(unsigned short pad)
|
||||
{
|
||||
u32 J = 0;
|
||||
#ifdef HW_RVL
|
||||
WPADData * wp = WPAD_Data(pad);
|
||||
for (int i = 0; i < MAXJP; i++)
|
||||
{
|
||||
if ( (wp->exp.type == WPAD_EXP_NUNCHUK) && (wp->btns_h & btnmap[CTRLR_NUNCHUK][i]) )
|
||||
if ( (userInput[pad].wpad->exp.type == WPAD_EXP_NUNCHUK) &&
|
||||
(userInput[pad].wpad->btns_h & btnmap[CTRLR_NUNCHUK][i]) )
|
||||
J |= vbapadmap[i];
|
||||
}
|
||||
#endif
|
||||
@ -749,9 +692,8 @@ u32 PAD_ButtonsHeldFake(unsigned short pad)
|
||||
{
|
||||
u32 gc = 0;
|
||||
#ifdef HW_RVL
|
||||
WPADData * wp = WPAD_Data(pad);
|
||||
if (wp->exp.type == WPAD_EXP_CLASSIC) {
|
||||
gc = CCToGC(wp->btns_h);
|
||||
if (userInput[pad].wpad->exp.type == WPAD_EXP_CLASSIC) {
|
||||
gc = CCToGC(userInput[pad].wpad->btns_h);
|
||||
}
|
||||
#endif
|
||||
return gc;
|
||||
@ -760,9 +702,8 @@ u32 PAD_ButtonsDownFake(unsigned short pad)
|
||||
{
|
||||
u32 gc = 0;
|
||||
#ifdef HW_RVL
|
||||
WPADData * wp = WPAD_Data(pad);
|
||||
if (wp->exp.type == WPAD_EXP_CLASSIC) {
|
||||
gc = CCToGC(wp->btns_d);
|
||||
if (userInput[pad].wpad->exp.type == WPAD_EXP_CLASSIC) {
|
||||
gc = CCToGC(userInput[pad].wpad->btns_d);
|
||||
}
|
||||
#endif
|
||||
return gc;
|
||||
@ -771,9 +712,8 @@ u32 PAD_ButtonsUpFake(unsigned short pad)
|
||||
{
|
||||
u32 gc = 0;
|
||||
#ifdef HW_RVL
|
||||
WPADData * wp = WPAD_Data(pad);
|
||||
if (wp->exp.type == WPAD_EXP_CLASSIC) {
|
||||
gc = CCToGC(wp->btns_u);
|
||||
if (userInput[pad].wpad->exp.type == WPAD_EXP_CLASSIC) {
|
||||
gc = CCToGC(userInput[pad].wpad->btns_u);
|
||||
}
|
||||
#endif
|
||||
return gc;
|
||||
|
@ -40,7 +40,6 @@ void DoRumble(int i);
|
||||
void systemGameRumble(int RumbleForFrames);
|
||||
void systemGameRumbleOnlyFor(int OnlyRumbleForFrames);
|
||||
void updateRumbleFrame();
|
||||
s8 WPAD_Stick(u8 chan,u8 right, int axis);
|
||||
u32 GetJoy(int which);
|
||||
bool MenuRequested();
|
||||
void SetupPads();
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "audio.h"
|
||||
#include "video.h"
|
||||
#include "input.h"
|
||||
#include "gui/gui.h"
|
||||
#include "gameinput.h"
|
||||
#include "vbasupport.h"
|
||||
#include "wiiusbsupport.h"
|
||||
@ -287,8 +288,8 @@ u32 LinksAwakeningInput(unsigned short pad) // aka Zelda DX
|
||||
// but with R as the B button like in Twilight Princess
|
||||
} else if (wp->exp.type == WPAD_EXP_CLASSIC) {
|
||||
J |= StandardDPad(pad);
|
||||
signed char wm_sx = WPAD_Stick(pad,1,0); // CC right joystick
|
||||
signed char wm_sy = WPAD_Stick(pad,1,1); // CC right joystick
|
||||
s8 wm_sx = userInput[pad].WPAD_StickX(1); // CC right joystick
|
||||
s8 wm_sy = userInput[pad].WPAD_StickY(1); // CC right joystick
|
||||
static bool StickReady = true;
|
||||
ActionButton = wp->btns_h & WPAD_CLASSIC_BUTTON_A;
|
||||
SwordButton = wp->btns_h & WPAD_CLASSIC_BUTTON_B;
|
||||
@ -313,7 +314,7 @@ u32 LinksAwakeningInput(unsigned short pad) // aka Zelda DX
|
||||
// Gamecube controls are based on Twilight Princess for the Gamecube
|
||||
{
|
||||
u32 gc = PAD_ButtonsHeld(pad);
|
||||
signed char gc_px = PAD_SubStickX(pad);
|
||||
s8 gc_px = PAD_SubStickX(pad);
|
||||
if (gc_px > 70) J |= VBA_SPEED;
|
||||
ActionButton = ActionButton || gc & PAD_BUTTON_A;
|
||||
PullButton = PullButton || gc & PAD_TRIGGER_R;
|
||||
@ -619,8 +620,8 @@ static u32 ZeldaOracleInput(bool Seasons, unsigned short pad) {
|
||||
// but with R as the B button like in Twilight Princess
|
||||
} else if (wp->exp.type == WPAD_EXP_CLASSIC) {
|
||||
J |= StandardDPad(pad);
|
||||
signed char wm_sx = WPAD_Stick(pad,1,0); // CC right joystick
|
||||
signed char wm_sy = WPAD_Stick(pad,1,1); // CC right joystick
|
||||
s8 wm_sx = userInput[pad].WPAD_StickX(1); // CC right joystick
|
||||
s8 wm_sy = userInput[pad].WPAD_StickY(1); // CC right joystick
|
||||
static bool StickReady = true;
|
||||
ActionButton = wp->btns_h & WPAD_CLASSIC_BUTTON_A;
|
||||
SwordButton = wp->btns_h & WPAD_CLASSIC_BUTTON_B;
|
||||
@ -645,7 +646,7 @@ static u32 ZeldaOracleInput(bool Seasons, unsigned short pad) {
|
||||
{
|
||||
u32 gc = PAD_ButtonsHeld(pad);
|
||||
u32 pressed = PAD_ButtonsDown(pad);
|
||||
signed char gc_px = PAD_SubStickX(pad);
|
||||
s8 gc_px = PAD_SubStickX(pad);
|
||||
if (gc_px > 70) J |= VBA_SPEED;
|
||||
ActionButton = ActionButton || gc & PAD_BUTTON_A;
|
||||
PullButton = PullButton || gc & PAD_TRIGGER_R;
|
||||
@ -1214,8 +1215,8 @@ u32 MinishCapInput(unsigned short pad)
|
||||
// but with R as the B button like in Twilight Princess
|
||||
} else if (wp->exp.type == WPAD_EXP_CLASSIC) {
|
||||
J |= StandardDPad(pad);
|
||||
signed char wm_sx = WPAD_Stick(pad,1,0); // CC right joystick
|
||||
signed char wm_sy = WPAD_Stick(pad,1,1); // CC right joystick
|
||||
s8 wm_sx = userInput[pad].WPAD_StickX(1); // CC right joystick
|
||||
s8 wm_sy = userInput[pad].WPAD_StickY(1); // CC right joystick
|
||||
static bool StickReady = true;
|
||||
ActionButton = wp->btns_h & WPAD_CLASSIC_BUTTON_A;
|
||||
SwordButton = wp->btns_h & WPAD_CLASSIC_BUTTON_B;
|
||||
@ -1241,7 +1242,7 @@ u32 MinishCapInput(unsigned short pad)
|
||||
{
|
||||
u32 gc = PAD_ButtonsHeld(pad);
|
||||
u32 pressed = PAD_ButtonsDown(pad);
|
||||
signed char gc_px = PAD_SubStickX(pad);
|
||||
s8 gc_px = PAD_SubStickX(pad);
|
||||
if (gc_px > 70) J |= VBA_SPEED;
|
||||
ActionButton = ActionButton || gc & PAD_BUTTON_A;
|
||||
PullButton = PullButton || gc & PAD_TRIGGER_R;
|
||||
|
Loading…
Reference in New Issue
Block a user