+ added controller settings menu (preliminar, code is a little bit ugly)

This commit is contained in:
ekeeke31 2009-05-02 15:00:13 +00:00
parent b1f11ed311
commit f37b3bee42
15 changed files with 874 additions and 463 deletions

View File

@ -603,7 +603,7 @@ void teamplayer_2_write (uint32 data)
uint32 jcart_read(uint32 address) uint32 jcart_read(uint32 address)
{ {
return (gamepad_read(5) | ((gamepad_read(6)&0x3f) << 8)); /* fixes Micro Machines 2 (is it correct ?) */ return (gamepad_read(2) | ((gamepad_read(3)&0x3f) << 8)); /* fixes Micro Machines 2 (is it correct ?) */
} }
void jcart_write(uint32 address, uint32 data) void jcart_write(uint32 address, uint32 data)
@ -630,67 +630,90 @@ void input_reset ()
input.pad[i] = 0; input.pad[i] = 0;
} }
for (i=0; i<2; i++) switch (input.system[0])
{ {
switch (input.system[i]) case SYSTEM_GAMEPAD:
{ if (input.max == MAX_INPUTS) return;
case SYSTEM_GAMEPAD: input.dev[0] = config.input[input.max].padtype;
input.max ++;
gamepad_reset(0);
break;
case SYSTEM_MOUSE:
if (input.max == MAX_INPUTS) return;
input.dev[0] = DEVICE_MOUSE;
input.max ++;
mouse_reset();
break;
case SYSTEM_WAYPLAY:
for (j=0; j< 4; j++)
{
if (input.max == MAX_INPUTS) return; if (input.max == MAX_INPUTS) return;
input.dev[i*4] = input.padtype[input.max]; input.dev[j] = config.input[input.max].padtype;
input.max ++; input.max ++;
gamepad_reset(i*4); gamepad_reset(j);
break; }
break;
case SYSTEM_MOUSE: case SYSTEM_TEAMPLAYER:
for (j=0; j<4; j++)
{
if (input.max == MAX_INPUTS) return; if (input.max == MAX_INPUTS) return;
input.dev[i*4] = DEVICE_MOUSE; input.dev[j] = config.input[input.max].padtype;
input.max ++; input.max ++;
mouse_reset(); }
break; teamplayer_reset(i);
break;
}
case SYSTEM_WAYPLAY: switch (input.system[1])
for (j=i*4; j< i*4+4; j++) {
{ case SYSTEM_GAMEPAD:
if (input.max == MAX_INPUTS) return; if (input.max == MAX_INPUTS) return;
input.dev[j] = input.padtype[input.max]; input.dev[4] = config.input[input.max].padtype;
input.max ++; input.max ++;
gamepad_reset(j); gamepad_reset(4);
} break;
break;
case SYSTEM_TEAMPLAYER: case SYSTEM_MOUSE:
for (j=i*4; j< i*4+4; j++) if (input.max == MAX_INPUTS) return;
{ input.dev[4] = DEVICE_MOUSE;
if (input.max == MAX_INPUTS) return; input.max ++;
input.dev[j] = input.padtype[input.max]; mouse_reset();
input.max ++; break;
}
teamplayer_reset(i);
break;
case SYSTEM_MENACER: case SYSTEM_MENACER:
if (input.max == MAX_INPUTS) return;
input.dev[4] = DEVICE_LIGHTGUN;
lightgun_reset(0);
break;
case SYSTEM_JUSTIFIER:
for (j=4; j<6; j++)
{
if (input.max == MAX_INPUTS) return; if (input.max == MAX_INPUTS) return;
input.dev[i*4] = DEVICE_LIGHTGUN; input.dev[j] = DEVICE_LIGHTGUN;
lightgun_reset(0); lightgun_reset(j - 4);
break; input.max ++;
}
case SYSTEM_JUSTIFIER: case SYSTEM_TEAMPLAYER:
for (j=i*4; j< i*4+2; j++) for (j=4; j<8; j++)
{ {
if (input.max == MAX_INPUTS) return; if (input.max == MAX_INPUTS) return;
input.dev[j] = DEVICE_LIGHTGUN; input.dev[j] = config.input[input.max].padtype;
lightgun_reset(j - i*4); input.max ++;
input.max ++; }
} teamplayer_reset(i);
break; break;
}
} }
/* J-CART: add two gamepad inputs */ /* J-CART: add two gamepad inputs */
if (j_cart) if (j_cart)
{ {
input.dev[5] = input.padtype[2]; input.dev[5] = config.input[2].padtype;
input.dev[6] = input.padtype[3]; input.dev[6] = config.input[3].padtype;
gamepad_reset(5); gamepad_reset(5);
gamepad_reset(6); gamepad_reset(6);
} }

View File

@ -62,7 +62,6 @@ typedef struct
{ {
uint8 dev[MAX_DEVICES]; /* Can be any of the DEVICE_* values */ uint8 dev[MAX_DEVICES]; /* Can be any of the DEVICE_* values */
uint32 pad[MAX_DEVICES]; /* Can be any of the INPUT_* bitmasks */ uint32 pad[MAX_DEVICES]; /* Can be any of the INPUT_* bitmasks */
uint8 padtype[MAX_DEVICES]; /* 3BUTTONS or 6BUTTONS gamepad */
uint8 system[2]; /* Can be any of the SYSTEM_* bitmasks */ uint8 system[2]; /* Can be any of the SYSTEM_* bitmasks */
uint8 max; /* maximum number of connected devices */ uint8 max; /* maximum number of connected devices */
uint8 current; /* current PAD number (4WAYPLAY) */ uint8 current; /* current PAD number (4WAYPLAY) */

View File

@ -90,7 +90,8 @@ void config_default(void)
/* controllers options */ /* controllers options */
gx_input_SetDefault(); gx_input_SetDefault();
config.gun_cursor = 1; config.gun_cursor[0] = 1;
config.gun_cursor[1] = 1;
config.invert_mouse = 0; config.invert_mouse = 0;
/* menu options */ /* menu options */
@ -106,5 +107,9 @@ void config_default(void)
/* restore saved configuration */ /* restore saved configuration */
config_load(); config_load();
input.system[0] = SYSTEM_GAMEPAD;
input.system[1] = SYSTEM_GAMEPAD;
io_reset();
} }

View File

@ -49,11 +49,11 @@ typedef struct
uint8 render; uint8 render;
uint8 ntsc; uint8 ntsc;
uint8 bilinear; uint8 bilinear;
uint8 gun_cursor; uint8 gun_cursor[2];
uint8 invert_mouse; uint8 invert_mouse;
uint16 pad_keymap[4][MAX_KEYS]; uint16 pad_keymap[4][MAX_KEYS];
uint32 wpad_keymap[4*3][MAX_KEYS]; uint32 wpad_keymap[4*3][MAX_KEYS];
t_input_config input[MAX_DEVICES]; t_input_config input[MAX_INPUTS];
int8 bg_color; int8 bg_color;
float bgm_volume; float bgm_volume;
float sfx_volume; float sfx_volume;

View File

@ -312,7 +312,7 @@ int FileSelector(unsigned char *buffer)
/* draw wiimote pointer */ /* draw wiimote pointer */
WPAD_Orientation(0,&orient); WPAD_Orientation(0,&orient);
gxResetAngle(orient.roll); gxResetAngle(orient.roll);
gxDrawTexture(w_pointer, x-w_pointer->width/2, y-w_pointer->height/2, w_pointer->width, w_pointer->height,255); gxDrawTexture(w_pointer, x, y, w_pointer->width, w_pointer->height,255);
gxResetAngle(0.0); gxResetAngle(0.0);
/* find selected item */ /* find selected item */

File diff suppressed because it is too large Load Diff

View File

@ -33,6 +33,8 @@
/* GUI Buttons state */ /* GUI Buttons state */
/*****************************************************************************/ /*****************************************************************************/
#define BUTTON_VISIBLE 0x01 #define BUTTON_VISIBLE 0x01
#define BUTTON_SHIFT 0x02
#define BUTTON_ACTIVE 0x04
#define BUTTON_OVER_SFX 0x10 #define BUTTON_OVER_SFX 0x10
#define BUTTON_SELECT_SFX 0x20 #define BUTTON_SELECT_SFX 0x20
@ -49,35 +51,34 @@
/* GUI png data */ /* GUI png data */
/*****************************************************************************/ /*****************************************************************************/
/* Generic backgrounds */
extern const u8 Bg_intro_c1_png[]; extern const u8 Bg_intro_c1_png[];
extern const u8 Bg_intro_c2_png[]; extern const u8 Bg_intro_c2_png[];
extern const u8 Bg_intro_c3_png[]; extern const u8 Bg_intro_c3_png[];
extern const u8 Bg_intro_c4_png[]; extern const u8 Bg_intro_c4_png[];
extern const u8 Bg_main_png[]; extern const u8 Bg_main_png[];
extern const u8 Bg_overlay_png[]; extern const u8 Bg_overlay_png[];
extern const u8 Main_logo_png[];
extern const u8 Banner_main_png[]; extern const u8 Banner_main_png[];
extern const u8 Banner_bottom_png[]; extern const u8 Banner_bottom_png[];
extern const u8 Banner_top_png[]; extern const u8 Banner_top_png[];
extern const u8 Main_logo_png[];
/* Generic frames */
extern const u8 Frame_s1_png[]; extern const u8 Frame_s1_png[];
extern const u8 Frame_s2_png[]; extern const u8 Frame_s2_png[];
extern const u8 Frame_s3_png[]; extern const u8 Frame_s3_png[];
extern const u8 Frame_s4_png[];
extern const u8 Frame_s1_title_png[]; extern const u8 Frame_s1_title_png[];
extern const u8 Frame_s3_title_png[];
/* ROM Browser */
extern const u8 Overlay_bar_png[]; extern const u8 Overlay_bar_png[];
extern const u8 Browser_dir_png[]; extern const u8 Browser_dir_png[];
extern const u8 Star_full_png[]; extern const u8 Star_full_png[];
extern const u8 Star_empty_png[]; extern const u8 Star_empty_png[];
extern const u8 Snap_empty_png[]; extern const u8 Snap_empty_png[];
extern const u8 Snap_frame_png[]; extern const u8 Snap_frame_png[];
/* Main menu */
extern const u8 Main_load_png[]; extern const u8 Main_load_png[];
extern const u8 Main_options_png[]; extern const u8 Main_options_png[];
extern const u8 Main_quit_png[]; extern const u8 Main_quit_png[];
@ -92,12 +93,14 @@ extern const u8 Main_play_wii_png[];
extern const u8 Main_play_gcn_png[]; extern const u8 Main_play_gcn_png[];
#endif #endif
/* Options menu */
extern const u8 Option_menu_png[]; extern const u8 Option_menu_png[];
extern const u8 Option_ctrl_png[]; extern const u8 Option_ctrl_png[];
extern const u8 Option_sound_png[]; extern const u8 Option_sound_png[];
extern const u8 Option_video_png[]; extern const u8 Option_video_png[];
extern const u8 Option_system_png[]; extern const u8 Option_system_png[];
/* Load ROM menu */
extern const u8 Load_recent_png[]; extern const u8 Load_recent_png[];
extern const u8 Load_sd_png[]; extern const u8 Load_sd_png[];
extern const u8 Load_dvd_png[]; extern const u8 Load_dvd_png[];
@ -105,16 +108,44 @@ extern const u8 Load_dvd_png[];
extern const u8 Load_usb_png[]; extern const u8 Load_usb_png[];
#endif #endif
/* Generic Buttons */
extern const u8 Button_text_png[]; extern const u8 Button_text_png[];
extern const u8 Button_text_over_png[]; extern const u8 Button_text_over_png[];
extern const u8 Button_icon_png[]; extern const u8 Button_icon_png[];
extern const u8 Button_icon_over_png[]; extern const u8 Button_icon_over_png[];
extern const u8 Button_icon_sm_png[];
extern const u8 Button_icon_sm_over_png[];
extern const u8 Button_up_png[]; extern const u8 Button_up_png[];
extern const u8 Button_down_png[]; extern const u8 Button_down_png[];
extern const u8 Button_up_over_png[]; extern const u8 Button_up_over_png[];
extern const u8 Button_down_over_png[]; extern const u8 Button_down_over_png[];
/* Controller Settings */
extern const u8 Ctrl_4wayplay_png[];
extern const u8 Ctrl_gamepad_png[];
extern const u8 Ctrl_justifiers_png[];
extern const u8 Ctrl_menacer_png[];
extern const u8 Ctrl_mouse_png[];
extern const u8 Ctrl_none_png[];
extern const u8 Ctrl_teamplayer_png[];
extern const u8 Ctrl_pad3b_png[];
extern const u8 Ctrl_pad6b_png[];
extern const u8 Ctrl_config_png[];
extern const u8 Ctrl_player_png[];
extern const u8 Ctrl_player_over_png[];
extern const u8 Ctrl_player_none_png[];
extern const u8 ctrl_option_off_png[];
extern const u8 ctrl_option_on_png[];
extern const u8 ctrl_gamecube_png[];
#ifdef HW_RVL #ifdef HW_RVL
extern const u8 ctrl_classic_png[];
extern const u8 ctrl_nunchuk_png[];
extern const u8 ctrl_wiimote_png[];
#endif
/* Generic images*/
#ifdef HW_RVL
extern const u8 generic_point_png[];
extern const u8 Key_A_wii_png[]; extern const u8 Key_A_wii_png[];
extern const u8 Key_B_wii_png[]; extern const u8 Key_B_wii_png[];
#else #else
@ -122,10 +153,7 @@ extern const u8 Key_A_gcn_png[];
extern const u8 Key_B_gcn_png[]; extern const u8 Key_B_gcn_png[];
#endif #endif
#ifdef HW_RVL /* Generic sounds */
extern const u8 generic_point_png[];
#endif
extern const u8 button_select_pcm[]; extern const u8 button_select_pcm[];
extern const u32 button_select_pcm_size; extern const u32 button_select_pcm_size;
extern const u8 button_over_pcm[]; extern const u8 button_over_pcm[];
@ -170,7 +198,7 @@ typedef struct
{ {
butn_data *data; /* pointer to button image/texture data */ butn_data *data; /* pointer to button image/texture data */
u8 state; /* button state (ACTIVE,VISIBLE,SELECTED...) */ u8 state; /* button state (ACTIVE,VISIBLE,SELECTED...) */
u8 shift[2]; /* up & down direction offsets */ u8 shift[4]; /* direction offsets */
u16 x; /* button image X position (upper left corner) */ u16 x; /* button image X position (upper left corner) */
u16 y; /* button image Y position (upper left corner) */ u16 y; /* button image Y position (upper left corner) */
u16 w; /* button image pixels width */ u16 w; /* button image pixels width */

View File

@ -94,6 +94,13 @@ static void pad_config(int chan, int max_keys)
{ {
sprintf(msg, "PAD #%d is not connected !", chan+1); sprintf(msg, "PAD #%d is not connected !", chan+1);
WaitPrompt(msg); WaitPrompt(msg);
/* remove any pending keys */
while (PAD_ButtonsHeld(chan))
{
VIDEO_WaitVSync();
PAD_ScanPads();
}
return; return;
} }
@ -141,6 +148,13 @@ static void pad_config(int chan, int max_keys)
if (key !=0xff) config.pad_keymap[chan][i] = key; if (key !=0xff) config.pad_keymap[chan][i] = key;
} }
/* remove any pending keys */
while (PAD_ButtonsHeld(chan))
{
VIDEO_WaitVSync();
PAD_ScanPads();
}
/* restore inputs update callback */ /* restore inputs update callback */
VIDEO_SetPostRetraceCallback(gx_input_UpdateMenu); VIDEO_SetPostRetraceCallback(gx_input_UpdateMenu);
VIDEO_Flush(); VIDEO_Flush();
@ -321,6 +335,14 @@ static void wpad_config(u8 chan, u8 exp, u8 max_keys)
if (exp == WPAD_EXP_NUNCHUK) sprintf(msg, "NUNCHUK #%d is not connected !", chan+1); if (exp == WPAD_EXP_NUNCHUK) sprintf(msg, "NUNCHUK #%d is not connected !", chan+1);
if (exp == WPAD_EXP_CLASSIC) sprintf(msg, "CLASSIC #%d is not connected !", chan+1); if (exp == WPAD_EXP_CLASSIC) sprintf(msg, "CLASSIC #%d is not connected !", chan+1);
WaitPrompt(msg); WaitPrompt(msg);
/* remove any pending buttons */
while (WPAD_ButtonsHeld(chan))
{
WPAD_ScanPads();
VIDEO_WaitVSync();
}
return; return;
} }
@ -404,6 +426,13 @@ static void wpad_config(u8 chan, u8 exp, u8 max_keys)
if (key != 0xff) config.wpad_keymap[exp + (chan * 3)][i] = key; if (key != 0xff) config.wpad_keymap[exp + (chan * 3)][i] = key;
} }
/* remove any pending buttons */
while (WPAD_ButtonsHeld(chan))
{
WPAD_ScanPads();
VIDEO_WaitVSync();
}
/* restore inputs update callback */ /* restore inputs update callback */
VIDEO_SetPostRetraceCallback(gx_input_UpdateMenu); VIDEO_SetPostRetraceCallback(gx_input_UpdateMenu);
VIDEO_Flush(); VIDEO_Flush();
@ -637,8 +666,9 @@ void gx_input_SetDefault(void)
for (i=0; i<MAX_DEVICES; i++) for (i=0; i<MAX_DEVICES; i++)
{ {
/* set gamepad by default */ /* set gamepad by default */
config.input[i].device = (i < 4) ? 0 : -1; config.input[i].device = (i < 4) ? 0 : -1;
config.input[i].port = i%4; config.input[i].port = i%4;
config.input[i].padtype = 0;
} }
#ifdef HW_RVL #ifdef HW_RVL
@ -707,7 +737,7 @@ void gx_input_UpdateEmu(void)
WPAD_ScanPads(); WPAD_ScanPads();
#endif #endif
for (i=0; i<MAX_INPUTS; i++) for (i=0; i<MAX_DEVICES; i++)
{ {
/* clear key status */ /* clear key status */
input.pad[i] = 0; input.pad[i] = 0;

View File

@ -42,6 +42,7 @@ typedef struct
{ {
s8 device; s8 device;
u8 port; u8 port;
u8 padtype;
} t_input_config; } t_input_config;

View File

@ -445,11 +445,11 @@ static void gxResetScale(u32 width, u32 height)
int temp = 0; int temp = 0;
int xscale, yscale, xshift, yshift; int xscale, yscale, xshift, yshift;
/* aspect Ratio (depends on current configuration) */ /* Aspect Ratio (depends on current configuration) */
if (config.aspect) if (config.aspect)
{ {
/* original aspect ratio */ /* original aspect ratio */
/* the following values have been detected from comparison with a real 50/60hz Mega Drive */ /* the following values have been deducted from comparison with a real 50/60hz Mega Drive */
if (config.overscan) if (config.overscan)
{ {
/* borders are emulated */ /* borders are emulated */
@ -700,6 +700,7 @@ void gxDrawScreenshot(u8 alpha)
{ {
if (!rmode) return; if (!rmode) return;
/* retrieve gamescreen texture */
GXTexObj texobj; GXTexObj texobj;
GX_InitTexObj(&texobj, texturemem, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); GX_InitTexObj(&texobj, texturemem, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE);
GX_LoadTexObj(&texobj, GX_TEXMAP0); GX_LoadTexObj(&texobj, GX_TEXMAP0);
@ -720,7 +721,7 @@ void gxDrawScreenshot(u8 alpha)
h = h * 2; h = h * 2;
} }
/* Draw textured quad */ /* draw textured quad */
GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position2s16(x,y+h); GX_Position2s16(x,y+h);
GX_Color4u8(0xff,0xff,0xff,alpha); GX_Color4u8(0xff,0xff,0xff,alpha);
@ -740,7 +741,7 @@ void gxDrawScreenshot(u8 alpha)
void gxCopyScreenshot(gx_texture *texture) void gxCopyScreenshot(gx_texture *texture)
{ {
/* current game texture */ /* retrieve gamescreen texture */
gxClearScreen((GXColor)BLACK); gxClearScreen((GXColor)BLACK);
GXTexObj texobj; GXTexObj texobj;
GX_InitTexObj(&texobj, texturemem, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); GX_InitTexObj(&texobj, texturemem, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE);
@ -753,7 +754,7 @@ void gxCopyScreenshot(gx_texture *texture)
s32 x = -w/2; s32 x = -w/2;
s32 y = -(240+ 2*bitmap.viewport.y); s32 y = -(240+ 2*bitmap.viewport.y);
/* render gamescreen to EFB */ /* draw textured quad */
GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position2s16(x,y+h); GX_Position2s16(x,y+h);
GX_Color4u8(0xff,0xff,0xff,0xff); GX_Color4u8(0xff,0xff,0xff,0xff);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -235,14 +235,6 @@ static void getrominfo (char *romheader)
for (i = 0; i < 14; i++) for (i = 0; i < 14; i++)
for (j=0; j < 14; j++) for (j=0; j < 14; j++)
if (rominfo.io_support[i] == peripheralinfo[j].pID[0]) peripherals |= (1 << j); if (rominfo.io_support[i] == peripheralinfo[j].pID[0]) peripherals |= (1 << j);
for (i = 0; i < 8; i++)
{
input.padtype[i] = (peripherals & P6BUTTONS) ? DEVICE_6BUTTON : DEVICE_3BUTTON;
#ifdef HW_RVL
if (config.input[i].device == 1) input.padtype[i] = DEVICE_3BUTTON;
#endif
}
} }
/* SMD (interleaved) rom support */ /* SMD (interleaved) rom support */