fixed config file incoherencies between Wii&GC version, added fast scrolling using D-PAD

This commit is contained in:
ekeeke31 2008-09-09 10:33:43 +00:00
parent 1e0bb09070
commit a2751bb7f3
4 changed files with 150 additions and 67 deletions

View File

@ -1,6 +1,12 @@
Genesis Plus for Gamecube Genesis Plus for Gamecube
------------------------------ ------------------------------
CURRENT:
---------
[NGC/Wii]
- improved menu scrolling using Wiimote D-PAD
26/08/2008: 26/08/2008:
----------- -----------
[Genesis] [Genesis]

View File

@ -42,6 +42,20 @@ void config_load()
fp = fopen("/genplus/genplus.ini", "rb"); fp = fopen("/genplus/genplus.ini", "rb");
fread(&config, sizeof(config), 1, fp); fread(&config, sizeof(config), 1, fp);
fclose(fp); fclose(fp);
#ifndef HW_RVL
/* check some specific Wii-version options */
int i;
for (i=0; i<MAX_DEVICES; i++)
{
if (config.input[i].device > 0)
{
config.input[i].device = 0;
config.input[i].port = i%4;
}
}
#endif
} }
void set_config_defaults(void) void set_config_defaults(void)

View File

@ -924,18 +924,8 @@ void ClearScreen ()
void WaitButtonA () void WaitButtonA ()
{ {
s16 p = ogc_input__getMenuButtons(); s16 p = ogc_input__getMenuButtons();
while (p & PAD_BUTTON_A) p = ogc_input__getMenuButtons();
while (p & PAD_BUTTON_A) while (!(p & PAD_BUTTON_A)) p = ogc_input__getMenuButtons();
{
VIDEO_WaitVSync();
p = ogc_input__getMenuButtons();
}
while (!(p & PAD_BUTTON_A))
{
VIDEO_WaitVSync();
p = ogc_input__getMenuButtons();
}
} }
void WaitPrompt (char *msg) void WaitPrompt (char *msg)

View File

@ -71,6 +71,9 @@ static const u16 pad_keys[8] =
#define PAD_LEFT 2 #define PAD_LEFT 2
#define PAD_RIGHT 3 #define PAD_RIGHT 3
#define MAX_HELD_CNT 100
static u32 held_cnt = 0;
static u32 wpad_dirmap[3][4] = static u32 wpad_dirmap[3][4] =
{ {
{WPAD_BUTTON_RIGHT, WPAD_BUTTON_LEFT, WPAD_BUTTON_UP, WPAD_BUTTON_DOWN}, // WIIMOTE only {WPAD_BUTTON_RIGHT, WPAD_BUTTON_LEFT, WPAD_BUTTON_UP, WPAD_BUTTON_DOWN}, // WIIMOTE only
@ -601,6 +604,7 @@ void ogc_input__set_defaults(void)
} }
#ifdef HW_RVL #ifdef HW_RVL
u32 exp;
for (i=0; i<4; i++) for (i=0; i<4; i++)
{ {
/* WIIMOTE */ /* WIIMOTE */
@ -639,10 +643,29 @@ void ogc_input__set_defaults(void)
for (i=0; i<MAX_DEVICES; i++) for (i=0; i<MAX_DEVICES; i++)
{ {
#ifdef HW_RVL #ifdef HW_RVL
config.input[i].device = (i < 4) ? 1 : 0; if (i < 4)
{
/* detect wiimote expansion controller */
exp = 255;
if (WPAD_Probe(0, &exp) == WPAD_ERR_NONE)
{
config.input[i].device = (exp <= WPAD_EXP_CLASSIC) ? (exp + 1) : 1;
}
/* set gamepad as default */
else config.input[i].device = 0;
}
else
{
/* set gamepad if not assigned */
config.input[i].device = (config.input[i-4].device == 0) ? -1 : 0;
}
#else #else
/* set gamepad as default */
config.input[i].device = (i < 4) ? 0 : -1; config.input[i].device = (i < 4) ? 0 : -1;
#endif #endif
/* set device port */
config.input[i].port = i % 4; config.input[i].port = i % 4;
} }
} }
@ -701,7 +724,10 @@ void ogc_input__config(u8 num, u8 type, u8 padtype)
u16 ogc_input__getMenuButtons(void) u16 ogc_input__getMenuButtons(void)
{ {
/* gamecube pad */ /* slowdown input updates */
VIDEO_WaitVSync();
/* get gamepad inputs */
PAD_ScanPads(); PAD_ScanPads();
u16 p = PAD_ButtonsDown(0); u16 p = PAD_ButtonsDown(0);
s8 x = PAD_StickX(0); s8 x = PAD_StickX(0);
@ -712,37 +738,92 @@ u16 ogc_input__getMenuButtons(void)
else if (y < -60) p |= PAD_BUTTON_DOWN; else if (y < -60) p |= PAD_BUTTON_DOWN;
#ifdef HW_RVL #ifdef HW_RVL
/* wiimote support */ /* get wiimote + expansions inputs */
struct ir_t ir;
u32 exp;
WPAD_ScanPads(); WPAD_ScanPads();
if (WPAD_Probe(0, &exp) == WPAD_ERR_NONE)
{
u32 q = WPAD_ButtonsDown(0); u32 q = WPAD_ButtonsDown(0);
u32 h = WPAD_ButtonsHeld(0);
x = WPAD_StickX(0, 0); x = WPAD_StickX(0, 0);
y = WPAD_StickY(0, 0); y = WPAD_StickY(0, 0);
/* default directions */ /* is Wiimote directed toward screen (horizontal/vertical orientation) ? */
struct ir_t ir;
WPAD_IR(0, &ir); WPAD_IR(0, &ir);
if (ir.valid)
/* wiimote directions */
if (q & WPAD_BUTTON_UP)
{ {
/* Wiimote is pointed toward screen */ held_cnt = 0;
if ((q & WPAD_BUTTON_UP) || (y > 70)) p |= PAD_BUTTON_UP; p |= ir.valid ? PAD_BUTTON_UP : PAD_BUTTON_LEFT;
else if ((q & WPAD_BUTTON_DOWN) || (y < -70)) p |= PAD_BUTTON_DOWN; }
if ((q & WPAD_BUTTON_LEFT) || (x < -60)) p |= PAD_BUTTON_LEFT; else if (q & WPAD_BUTTON_DOWN)
else if ((q & WPAD_BUTTON_RIGHT) || (x > 60)) p |= PAD_BUTTON_RIGHT; {
held_cnt = 0;
p |= ir.valid ? PAD_BUTTON_DOWN : PAD_BUTTON_RIGHT;
}
else if (q & WPAD_BUTTON_LEFT)
{
held_cnt = 0;
p |= ir.valid ? PAD_BUTTON_LEFT : PAD_BUTTON_DOWN;
}
else if (q & WPAD_BUTTON_RIGHT)
{
held_cnt = 0;
p |= ir.valid ? PAD_BUTTON_RIGHT : PAD_BUTTON_UP;
}
else if (h & WPAD_BUTTON_UP)
{
held_cnt ++;
if (held_cnt == MAX_HELD_CNT)
{
held_cnt = 0;
p |= ir.valid ? PAD_BUTTON_UP : PAD_BUTTON_LEFT;
}
}
else if (h & WPAD_BUTTON_DOWN)
{
held_cnt ++;
if (held_cnt == MAX_HELD_CNT)
{
held_cnt = 0;
p |= ir.valid ? PAD_BUTTON_DOWN : PAD_BUTTON_RIGHT;
}
}
else if (h & WPAD_BUTTON_LEFT)
{
held_cnt ++;
if (held_cnt == MAX_HELD_CNT)
{
held_cnt = 0;
p |= ir.valid ? PAD_BUTTON_LEFT : PAD_BUTTON_DOWN;
}
}
else if (h & WPAD_BUTTON_RIGHT)
{
held_cnt ++;
if (held_cnt == MAX_HELD_CNT)
{
held_cnt = 0;
p |= ir.valid ? PAD_BUTTON_RIGHT : PAD_BUTTON_UP;
}
} }
else else
{ {
/* Wiimote is used horizontally */ held_cnt = 0;
if ((q & WPAD_BUTTON_RIGHT) || (y > 70)) p |= PAD_BUTTON_UP;
else if ((q & WPAD_BUTTON_LEFT) || (y < -70)) p |= PAD_BUTTON_DOWN;
if ((q & WPAD_BUTTON_UP) || (x < -60)) p |= PAD_BUTTON_LEFT;
else if ((q & WPAD_BUTTON_DOWN) || (x > 60)) p |= PAD_BUTTON_RIGHT;
} }
/* default keys */ /* analog sticks */
if (y > 70) p |= PAD_BUTTON_UP;
else if (y < -70) p |= PAD_BUTTON_DOWN;
if (x < -60) p |= PAD_BUTTON_LEFT;
else if (x > 60) p |= PAD_BUTTON_RIGHT;
/* classic controller directions */
if (q & WPAD_CLASSIC_BUTTON_UP) p |= PAD_BUTTON_UP;
else if (q & WPAD_CLASSIC_BUTTON_DOWN) p |= PAD_BUTTON_DOWN;
if (q & WPAD_CLASSIC_BUTTON_LEFT) p |= PAD_BUTTON_LEFT;
else if (q & WPAD_CLASSIC_BUTTON_RIGHT) p |= PAD_BUTTON_RIGHT;
/* wiimote keys */
if (q & WPAD_BUTTON_MINUS) p |= PAD_TRIGGER_L; if (q & WPAD_BUTTON_MINUS) p |= PAD_TRIGGER_L;
if (q & WPAD_BUTTON_PLUS) p |= PAD_TRIGGER_R; if (q & WPAD_BUTTON_PLUS) p |= PAD_TRIGGER_R;
if (q & WPAD_BUTTON_A) p |= PAD_BUTTON_A; if (q & WPAD_BUTTON_A) p |= PAD_BUTTON_A;
@ -751,22 +832,14 @@ u16 ogc_input__getMenuButtons(void)
if (q & WPAD_BUTTON_1) p |= PAD_BUTTON_B; if (q & WPAD_BUTTON_1) p |= PAD_BUTTON_B;
if (q & WPAD_BUTTON_HOME) p |= PAD_TRIGGER_Z; if (q & WPAD_BUTTON_HOME) p |= PAD_TRIGGER_Z;
/* classic controller expansion */ /* classic controller keys */
if (exp == WPAD_EXP_CLASSIC)
{
if (q & WPAD_CLASSIC_BUTTON_UP) p |= PAD_BUTTON_UP;
else if (q & WPAD_CLASSIC_BUTTON_DOWN) p |= PAD_BUTTON_DOWN;
if (q & WPAD_CLASSIC_BUTTON_LEFT) p |= PAD_BUTTON_LEFT;
else if (q & WPAD_CLASSIC_BUTTON_RIGHT) p |= PAD_BUTTON_RIGHT;
if (q & WPAD_CLASSIC_BUTTON_FULL_L) p |= PAD_TRIGGER_L; if (q & WPAD_CLASSIC_BUTTON_FULL_L) p |= PAD_TRIGGER_L;
if (q & WPAD_CLASSIC_BUTTON_FULL_R) p |= PAD_TRIGGER_R; if (q & WPAD_CLASSIC_BUTTON_FULL_R) p |= PAD_TRIGGER_R;
if (q & WPAD_CLASSIC_BUTTON_A) p |= PAD_BUTTON_A; if (q & WPAD_CLASSIC_BUTTON_A) p |= PAD_BUTTON_A;
if (q & WPAD_CLASSIC_BUTTON_B) p |= PAD_BUTTON_B; if (q & WPAD_CLASSIC_BUTTON_B) p |= PAD_BUTTON_B;
if (q & WPAD_CLASSIC_BUTTON_HOME) p |= PAD_TRIGGER_Z; if (q & WPAD_CLASSIC_BUTTON_HOME) p |= PAD_TRIGGER_Z;
}
} #endif
#endif
return p; return p;
} }