mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-12-26 19:21:50 +01:00
more code tidy
This commit is contained in:
parent
88f0952d71
commit
16e4b64b1c
@ -196,11 +196,19 @@ class GuiTrigger
|
|||||||
//!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately
|
//!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately
|
||||||
//!\param gcbtns GameCube controller trigger button(s)
|
//!\param gcbtns GameCube controller trigger button(s)
|
||||||
void SetButtonOnlyInFocusTrigger(s32 ch, u32 wiibtns, u16 gcbtns);
|
void SetButtonOnlyInFocusTrigger(s32 ch, u32 wiibtns, u16 gcbtns);
|
||||||
//!Get X/Y value from Wii Joystick (classic, nunchuk) input
|
//!Get X or Y value from Wii Joystick (classic, nunchuk) input
|
||||||
//!\param right Controller stick (left = 0, right = 1)
|
//!\param stick Controller stick (left = 0, right = 1)
|
||||||
//!\param axis Controller stick axis (x-axis = 0, y-axis = 1)
|
//!\param axis Controller stick axis (x-axis = 0, y-axis = 1)
|
||||||
//!\return Stick value
|
//!\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
|
//!Move menu selection left (via pad/joystick). Allows scroll delay and button overriding
|
||||||
//!\return true if selection should be moved left, false otherwise
|
//!\return true if selection should be moved left, false otherwise
|
||||||
bool Left();
|
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
|
* 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
|
#ifdef HW_RVL
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ s8 GuiTrigger::WPAD_Stick(u8 right, int axis)
|
|||||||
{
|
{
|
||||||
case WPAD_EXP_NUNCHUK:
|
case WPAD_EXP_NUNCHUK:
|
||||||
case WPAD_EXP_GUITARHERO3:
|
case WPAD_EXP_GUITARHERO3:
|
||||||
if (right == 0)
|
if (stick == 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;
|
||||||
@ -106,7 +106,7 @@ s8 GuiTrigger::WPAD_Stick(u8 right, int axis)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WPAD_EXP_CLASSIC:
|
case WPAD_EXP_CLASSIC:
|
||||||
if (right == 0)
|
if (stick == 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;
|
||||||
@ -139,6 +139,16 @@ s8 GuiTrigger::WPAD_Stick(u8 right, int axis)
|
|||||||
#endif
|
#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()
|
bool GuiTrigger::Left()
|
||||||
{
|
{
|
||||||
u32 wiibtn = GCSettings.WiimoteOrientation ? WPAD_BUTTON_UP : WPAD_BUTTON_LEFT;
|
u32 wiibtn = GCSettings.WiimoteOrientation ? WPAD_BUTTON_UP : WPAD_BUTTON_LEFT;
|
||||||
|
@ -55,7 +55,7 @@ static int cursor_y[5] = {0,0,0,0,0};
|
|||||||
#define ASSIGN_BUTTON_FALSE( keycode, snescmd ) \
|
#define ASSIGN_BUTTON_FALSE( keycode, snescmd ) \
|
||||||
S9xMapButton( keycode, cmd = S9xGetCommandT(snescmd), false)
|
S9xMapButton( keycode, cmd = S9xGetCommandT(snescmd), false)
|
||||||
|
|
||||||
int scopeTurbo = 0; // tracks whether superscope turbo is on or off
|
static int scopeTurbo = 0; // tracks whether superscope turbo is on or off
|
||||||
u32 btnmap[4][4][12]; // button mapping
|
u32 btnmap[4][4][12]; // button mapping
|
||||||
|
|
||||||
void ResetControls(int consoleCtrl, int wiiCtrl)
|
void ResetControls(int consoleCtrl, int wiiCtrl)
|
||||||
@ -289,26 +289,30 @@ void DoRumble(int i)
|
|||||||
*
|
*
|
||||||
* Updates X/Y coordinates for Superscope/mouse/justifier position
|
* Updates X/Y coordinates for Superscope/mouse/justifier position
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
void UpdateCursorPosition (int chan, int &pos_x, int &pos_y)
|
static void UpdateCursorPosition (int chan, int &pos_x, int &pos_y)
|
||||||
{
|
{
|
||||||
#define SCOPEPADCAL 20
|
#define SCOPEPADCAL 20
|
||||||
|
|
||||||
// gc left joystick
|
// gc left joystick
|
||||||
|
|
||||||
if (userInput[chan].pad.stickX > SCOPEPADCAL){
|
if (userInput[chan].pad.stickX > SCOPEPADCAL)
|
||||||
|
{
|
||||||
pos_x += (userInput[chan].pad.stickX*1.0)/SCOPEPADCAL;
|
pos_x += (userInput[chan].pad.stickX*1.0)/SCOPEPADCAL;
|
||||||
if (pos_x > 256) pos_x = 256;
|
if (pos_x > 256) pos_x = 256;
|
||||||
}
|
}
|
||||||
if (userInput[chan].pad.stickX < -SCOPEPADCAL){
|
if (userInput[chan].pad.stickX < -SCOPEPADCAL)
|
||||||
|
{
|
||||||
pos_x -= (userInput[chan].pad.stickX*-1.0)/SCOPEPADCAL;
|
pos_x -= (userInput[chan].pad.stickX*-1.0)/SCOPEPADCAL;
|
||||||
if (pos_x < 0) pos_x = 0;
|
if (pos_x < 0) pos_x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userInput[chan].pad.stickY < -SCOPEPADCAL){
|
if (userInput[chan].pad.stickY < -SCOPEPADCAL)
|
||||||
|
{
|
||||||
pos_y += (userInput[chan].pad.stickY*-1.0)/SCOPEPADCAL;
|
pos_y += (userInput[chan].pad.stickY*-1.0)/SCOPEPADCAL;
|
||||||
if (pos_y > 224) pos_y = 224;
|
if (pos_y > 224) pos_y = 224;
|
||||||
}
|
}
|
||||||
if (userInput[chan].pad.stickY > SCOPEPADCAL){
|
if (userInput[chan].pad.stickY > SCOPEPADCAL)
|
||||||
|
{
|
||||||
pos_y -= (userInput[chan].pad.stickY*1.0)/SCOPEPADCAL;
|
pos_y -= (userInput[chan].pad.stickY*1.0)/SCOPEPADCAL;
|
||||||
if (pos_y < 0) pos_y = 0;
|
if (pos_y < 0) pos_y = 0;
|
||||||
}
|
}
|
||||||
@ -321,23 +325,27 @@ void UpdateCursorPosition (int chan, int &pos_x, int &pos_y)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
signed char wm_ax = userInput[chan].WPAD_Stick(0,0);
|
s8 wm_ax = userInput[chan].WPAD_StickX(0);
|
||||||
signed char wm_ay = userInput[chan].WPAD_Stick(0,1);
|
s8 wm_ay = userInput[chan].WPAD_StickY(0);
|
||||||
|
|
||||||
if (wm_ax > SCOPEPADCAL){
|
if (wm_ax > SCOPEPADCAL)
|
||||||
|
{
|
||||||
pos_x += (wm_ax*1.0)/SCOPEPADCAL;
|
pos_x += (wm_ax*1.0)/SCOPEPADCAL;
|
||||||
if (pos_x > 256) pos_x = 256;
|
if (pos_x > 256) pos_x = 256;
|
||||||
}
|
}
|
||||||
if (wm_ax < -SCOPEPADCAL){
|
if (wm_ax < -SCOPEPADCAL)
|
||||||
|
{
|
||||||
pos_x -= (wm_ax*-1.0)/SCOPEPADCAL;
|
pos_x -= (wm_ax*-1.0)/SCOPEPADCAL;
|
||||||
if (pos_x < 0) pos_x = 0;
|
if (pos_x < 0) pos_x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wm_ay < -SCOPEPADCAL){
|
if (wm_ay < -SCOPEPADCAL)
|
||||||
|
{
|
||||||
pos_y += (wm_ay*-1.0)/SCOPEPADCAL;
|
pos_y += (wm_ay*-1.0)/SCOPEPADCAL;
|
||||||
if (pos_y > 224) pos_y = 224;
|
if (pos_y > 224) pos_y = 224;
|
||||||
}
|
}
|
||||||
if (wm_ay > SCOPEPADCAL){
|
if (wm_ay > SCOPEPADCAL)
|
||||||
|
{
|
||||||
pos_y -= (wm_ay*1.0)/SCOPEPADCAL;
|
pos_y -= (wm_ay*1.0)/SCOPEPADCAL;
|
||||||
if (pos_y < 0) pos_y = 0;
|
if (pos_y < 0) pos_y = 0;
|
||||||
}
|
}
|
||||||
@ -352,7 +360,7 @@ void UpdateCursorPosition (int chan, int &pos_x, int &pos_y)
|
|||||||
* Reads the changes (buttons pressed, etc) from a controller and reports
|
* Reads the changes (buttons pressed, etc) from a controller and reports
|
||||||
* these changes to Snes9x
|
* these changes to Snes9x
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
void decodepad (int chan)
|
static void decodepad (int chan)
|
||||||
{
|
{
|
||||||
int i, offset;
|
int i, offset;
|
||||||
float t;
|
float t;
|
||||||
@ -362,12 +370,9 @@ void decodepad (int chan)
|
|||||||
u32 jp = userInput[chan].pad.btns_h;
|
u32 jp = userInput[chan].pad.btns_h;
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
s8 wm_ax = 0;
|
s8 wm_ax = userInput[chan].WPAD_StickX(0);
|
||||||
s8 wm_ay = 0;
|
s8 wm_ay = userInput[chan].WPAD_StickY(0);
|
||||||
u32 wp = 0;
|
u32 wp = userInput[chan].wpad->btns_h;
|
||||||
wm_ax = userInput[chan].WPAD_Stick(0,0);
|
|
||||||
wm_ay = userInput[chan].WPAD_Stick(0,1);
|
|
||||||
wp = userInput[chan].wpad->btns_h;
|
|
||||||
|
|
||||||
u32 exp_type;
|
u32 exp_type;
|
||||||
if ( WPAD_Probe(chan, &exp_type) != 0 )
|
if ( WPAD_Probe(chan, &exp_type) != 0 )
|
||||||
@ -607,7 +612,7 @@ void NGCReportButtons ()
|
|||||||
|
|
||||||
Settings.TurboMode = (
|
Settings.TurboMode = (
|
||||||
userInput[0].pad.substickX > 70 ||
|
userInput[0].pad.substickX > 70 ||
|
||||||
userInput[0].WPAD_Stick(1,0) > 70
|
userInput[0].WPAD_StickX(1) > 70
|
||||||
); // RIGHT on c-stick and on classic controller right joystick
|
); // RIGHT on c-stick and on classic controller right joystick
|
||||||
|
|
||||||
/* Check for menu:
|
/* Check for menu:
|
||||||
|
@ -27,9 +27,6 @@ extern int rumbleRequest[4];
|
|||||||
void ResetControls(int cc = -1, int wc = -1);
|
void ResetControls(int cc = -1, int wc = -1);
|
||||||
void ShutoffRumble();
|
void ShutoffRumble();
|
||||||
void DoRumble(int i);
|
void DoRumble(int i);
|
||||||
s8 WPAD_Stick(u8 chan, u8 right, int axis);
|
|
||||||
void UpdateCursorPosition (int pad, int &pos_x, int &pos_y);
|
|
||||||
void decodepad (int pad);
|
|
||||||
void NGCReportButtons ();
|
void NGCReportButtons ();
|
||||||
void SetControllers ();
|
void SetControllers ();
|
||||||
void SetDefaultButtonMap ();
|
void SetDefaultButtonMap ();
|
||||||
|
Loading…
Reference in New Issue
Block a user