+ mouse and justifier support (mapped to GC pad and wiimote)

This commit is contained in:
michniewski 2008-08-08 02:09:02 +00:00
parent 301108bfdd
commit c3bead1447
6 changed files with 142 additions and 57 deletions

View File

@ -619,13 +619,16 @@ ConfigureButtons (u16 ctrlr_type)
int ctlrmenucount = 9; int ctlrmenucount = 9;
char ctlrmenu[][50] = { char ctlrmenu[][50] = {
// toggle:
"MultiTap", "MultiTap",
"SuperScope", "SuperScope",
"Mouse", "Snes Mice",
"Justifiers",
// config:
"Nunchuk", "Nunchuk",
"Classic Controller", "Classic Controller",
"Gamecube Pad",
"Wiimote", "Wiimote",
"Gamecube Pad",
"Save Preferences", "Save Preferences",
"Go Back" "Go Back"
}; };
@ -640,24 +643,23 @@ ConfigureControllers ()
// disable unavailable controller options if in GC mode // disable unavailable controller options if in GC mode
#ifndef HW_RVL #ifndef HW_RVL
ctlrmenu[1][0] = '\0';
ctlrmenu[2][0] = '\0';
ctlrmenu[4][0] = '\0'; ctlrmenu[4][0] = '\0';
ctlrmenu[5][0] = '\0';
ctlrmenu[6][0] = '\0';
#endif #endif
while (quit == 0) while (quit == 0)
{ {
sprintf (ctlrmenu[0], "MultiTap %s", Settings.MultiPlayer5Master == true ? " ON" : "OFF"); sprintf (ctlrmenu[0], "MultiTap %s", Settings.MultiPlayer5Master == true ? " ON" : "OFF");
if (GCSettings.Superscope > 0) if (GCSettings.Superscope > 0) sprintf (ctlrmenu[1], "Superscope: Pad %d", GCSettings.Superscope);
sprintf (ctlrmenu[1], "Superscope: Pad %d", GCSettings.Superscope); else sprintf (ctlrmenu[1], "Superscope OFF");
else
sprintf (ctlrmenu[1], "Superscope OFF");
if (GCSettings.Mouse > 0) if (GCSettings.Mouse > 0) sprintf (ctlrmenu[2], "Mice: %d", GCSettings.Mouse);
sprintf (ctlrmenu[2], "Mouse: Pad %d", GCSettings.Mouse); else sprintf (ctlrmenu[2], "Mice: OFF");
else
sprintf (ctlrmenu[2], "Mouse OFF"); if (GCSettings.Justifier > 0) sprintf (ctlrmenu[3], "Justifiers: %d", GCSettings.Justifier);
else sprintf (ctlrmenu[3], "Justifiers: OFF");
/*** Controller Config Menu ***/ /*** Controller Config Menu ***/
ret = RunMenu (ctlrmenu, ctlrmenucount, (char*)"Configure Controllers"); ret = RunMenu (ctlrmenu, ctlrmenucount, (char*)"Configure Controllers");
@ -665,11 +667,7 @@ ConfigureControllers ()
switch (ret) switch (ret)
{ {
case 0: case 0:
Settings.MultiPlayer5Master = (Settings.MultiPlayer5Master == false ? true : false); Settings.MultiPlayer5Master ^= 1;
if (Settings.MultiPlayer5Master)
S9xSetController (1, CTL_MP5, 1, 2, 3, -1);
else
S9xSetController (1, CTL_JOYPAD, 1, 0, 0, 0);
break; break;
case 1: case 1:
GCSettings.Superscope ++; GCSettings.Superscope ++;
@ -678,36 +676,42 @@ ConfigureControllers ()
break; break;
case 2: case 2:
GCSettings.Mouse ++; GCSettings.Mouse ++;
if (GCSettings.Mouse > 4) if (GCSettings.Mouse > 2)
GCSettings.Mouse = 0; GCSettings.Mouse = 0;
break; break;
case 3: case 3:
GCSettings.Justifier ++;
if (GCSettings.Justifier > 2)
GCSettings.Justifier = 0;
break;
case 4:
/*** Configure Nunchuk ***/ /*** Configure Nunchuk ***/
ConfigureButtons (CTRLR_NUNCHUK); ConfigureButtons (CTRLR_NUNCHUK);
break; break;
case 4: case 5:
/*** Configure Classic ***/ /*** Configure Classic ***/
ConfigureButtons (CTRLR_CLASSIC); ConfigureButtons (CTRLR_CLASSIC);
break; break;
case 5:
/*** Configure GC Pad ***/
ConfigureButtons (CTRLR_GCPAD);
break;
case 6: case 6:
/*** Configure Wiimote ***/ /*** Configure Wiimote ***/
ConfigureButtons (CTRLR_WIIMOTE); ConfigureButtons (CTRLR_WIIMOTE);
break; break;
case 7: case 7:
/*** Configure GC Pad ***/
ConfigureButtons (CTRLR_GCPAD);
break;
case 8:
/*** Save Preferences Now ***/ /*** Save Preferences Now ***/
quickSavePrefs(NOTSILENT); quickSavePrefs(NOTSILENT);
break; break;
case -1: /*** Button B ***/ case -1: /*** Button B ***/
case 8: case 9:
/*** Return ***/ /*** Return ***/
quit = 1; quit = 1;
break; break;
@ -724,7 +728,7 @@ int menucount = 7;
char menuitems[][50] = { char menuitems[][50] = {
"Choose Game", "Controller Configuration", "Preferences", "Choose Game", "Controller Configuration", "Preferences",
"Game Menu", "Game Menu",
"Credits", "Reset System", "Exit" "Credits", "Reset System", "Return to Loader"
}; };
void void
@ -817,8 +821,8 @@ mainmenu (int selectedMenu)
ReInitGCVideo(); // update video after reading settings ReInitGCVideo(); // update video after reading settings
Settings.SuperScopeMaster = (GCSettings.Superscope > 0 ? true : false); // update superscope settings Settings.SuperScopeMaster = (GCSettings.Superscope > 0 ? true : false);
Settings.MouseMaster = (GCSettings.Mouse > 0 ? true : false); // update mouse settings Settings.MouseMaster = (GCSettings.Mouse > 0 ? true : false);
// update mouse/justifier info? Settings.JustifierMaster = (GCSettings.Justifier > 0 ? true : false);
SetControllers(); SetControllers();
} }

View File

@ -523,6 +523,7 @@ DrawMenu (char items[][50], char *title, int maxitems, int selected, int fontsiz
int i, w = 0; int i, w = 0;
int ypos = 0; int ypos = 0;
int n = 1; int n = 1;
int line_height;
ypos = 65; ypos = 65;
@ -548,22 +549,26 @@ DrawMenu (char items[][50], char *title, int maxitems, int selected, int fontsiz
setfontsize (fontsize); // set font size setfontsize (fontsize); // set font size
line_height = (fontsize + 8);
for (i = 0; i < maxitems; i++) for (i = 0; i < maxitems; i++)
{ {
if(strlen(items[i]) > 0) if(strlen(items[i]) > 0)
{ {
if (i == selected) if ( items[i] == NULL )
ypos -= line_height;
else if (i == selected)
{ {
for( w = 0; w < (fontsize + 8); w++ ) for( w = 0; w < line_height; w++ )
DrawLineFast( 30, 610, n * (fontsize + 8) + (ypos-(fontsize + 2)) + w, 0x80, 0x80, 0x80 ); DrawLineFast( 30, 610, n * line_height + (ypos-line_height+6) + w, 0x80, 0x80, 0x80 );
setfontcolour (0xff, 0xff, 0xff); setfontcolour (0xff, 0xff, 0xff);
DrawText (x, n * (fontsize + 8) + ypos, items[i]); DrawText (x, n * line_height + ypos, items[i]);
setfontcolour (0x00, 0x00, 0x00); setfontcolour (0x00, 0x00, 0x00);
} }
else else
{ {
DrawText (x, n * (fontsize + 8) + ypos, items[i]); DrawText (x, n * line_height + ypos, items[i]);
} }
n++; n++;
} }

View File

@ -33,7 +33,7 @@ extern unsigned int ccpadmap[];
extern unsigned int ncpadmap[]; extern unsigned int ncpadmap[];
#define PREFS_FILE_NAME "snes9xGx.prf" #define PREFS_FILE_NAME "snes9xGx.prf"
#define PREFSVERSTRING "Snes9x GX 005 Prefs" #define PREFSVERSTRING "Snes9x GX 005a Prefs"
char prefscomment[2][32] = { {PREFSVERSTRING}, {"Preferences"} }; char prefscomment[2][32] = { {PREFSVERSTRING}, {"Preferences"} };

View File

@ -185,6 +185,7 @@ DefaultSettings ()
GCSettings.render = 0; GCSettings.render = 0;
GCSettings.Superscope = 0; GCSettings.Superscope = 0;
GCSettings.Mouse = 0; GCSettings.Mouse = 0;
GCSettings.Justifier = 0;
/****************** SNES9x Settings ***********************/ /****************** SNES9x Settings ***********************/
@ -197,7 +198,7 @@ DefaultSettings ()
Settings.MouseMaster = false; Settings.MouseMaster = false;
Settings.SuperScopeMaster = false; Settings.SuperScopeMaster = false;
Settings.MultiPlayer5Master = false; Settings.MultiPlayer5Master = false;
Settings.JustifierMaster = true; Settings.JustifierMaster = false;
Settings.ShutdownMaster = false; Settings.ShutdownMaster = false;
Settings.CyclesPercentage = 100; // snes9x 1.50 and earlier Settings.CyclesPercentage = 100; // snes9x 1.50 and earlier
Settings.ApplyCheats = true; Settings.ApplyCheats = true;

View File

@ -199,7 +199,9 @@ extern int FrameTimer;
extern long long prev; extern long long prev;
extern unsigned int timediffallowed; extern unsigned int timediffallowed;
int scope_x = 0; int scope_y = 0; // superscope cursor position // hold superscope/mouse/justifier cursor positions
int cursor_x[5] = {0,0,0,0,0};
int cursor_y[5] = {0,0,0,0,0};
extern void fat_enable_readahead_all(); extern void fat_enable_readahead_all();
@ -250,41 +252,47 @@ unsigned int ncpadmap[] = { WPAD_BUTTON_A, WPAD_BUTTON_B,
}; };
/*** Superscope : GC controller button mapping ***/ /*** Superscope : GC controller button mapping ***/
unsigned int gcscopemap[] = { PAD_TRIGGER_Z, PAD_BUTTON_B, unsigned int gcscopemap[] = { PAD_TRIGGER_Z, PAD_BUTTON_B,
PAD_BUTTON_A, PAD_BUTTON_Y, PAD_BUTTON_A, PAD_BUTTON_Y, PAD_BUTTON_START
PAD_BUTTON_START
}; };
/*** Superscope : wiimote button mapping ***/ /*** Superscope : wiimote button mapping ***/
unsigned int wmscopemap[] = { WPAD_BUTTON_MINUS, WPAD_BUTTON_B, unsigned int wmscopemap[] = { WPAD_BUTTON_MINUS, WPAD_BUTTON_B,
WPAD_BUTTON_A, WPAD_BUTTON_DOWN, WPAD_BUTTON_A, WPAD_BUTTON_DOWN, WPAD_BUTTON_PLUS
WPAD_BUTTON_PLUS
}; };
/*** Mouse : GC controller button mapping ***/
unsigned int gcmousemap[] = { PAD_BUTTON_A, PAD_BUTTON_B };
/*** Mouse : wiimote button mapping ***/
unsigned int wmmousemap[] = { WPAD_BUTTON_A, WPAD_BUTTON_B };
/*** Justifier : GC controller button mapping ***/
unsigned int gcjustmap[] = { PAD_BUTTON_A, PAD_BUTTON_B, PAD_BUTTON_START };
/*** Justifier : wiimote button mapping ***/
unsigned int wmjustmap[] = { WPAD_BUTTON_A, WPAD_BUTTON_B, WPAD_BUTTON_PLUS };
void UpdateCursorPosition (int pad, int &pos_x, int &pos_y) void UpdateCursorPosition (int pad, int &pos_x, int &pos_y)
{ {
// gc left joystick // gc left joystick
signed char pad_x = PAD_StickX (pad); signed char pad_x = PAD_StickX (pad);
signed char pad_y = PAD_StickY (pad); signed char pad_y = PAD_StickY (pad);
int SCOPEPADCAL = 30; int SCOPEPADCAL = 20;
#ifdef HW_RVL #ifdef HW_RVL
// wiimote ir // wiimote ir
struct ir_t ir; struct ir_t ir;
#endif #endif
if (pad_x > SCOPEPADCAL){ if (pad_x > SCOPEPADCAL){
pos_x +=4; pos_x += (pad_x*1.0)/SCOPEPADCAL;
if (pos_x > 256) pos_x = 256; if (pos_x > 256) pos_x = 256;
} }
if (pad_x < -SCOPEPADCAL){ if (pad_x < -SCOPEPADCAL){
pos_x -=4; pos_x -= (pad_x*-1.0)/SCOPEPADCAL;
if (pos_x < 0) pos_x = 0; if (pos_x < 0) pos_x = 0;
} }
if (pad_y < -SCOPEPADCAL){ if (pad_y < -SCOPEPADCAL){
pos_y +=4; pos_y += (pad_y*-1.0)/SCOPEPADCAL;
if (pos_y > 224) pos_y = 224; if (pos_y > 224) pos_y = 224;
} }
if (pad_y > SCOPEPADCAL){ if (pad_y > SCOPEPADCAL){
pos_y -=4; pos_y -= (pad_y*1.0)/SCOPEPADCAL;
if (pos_y < 0) pos_y = 0; if (pos_y < 0) pos_y = 0;
} }
@ -293,8 +301,8 @@ void UpdateCursorPosition (int pad, int &pos_x, int &pos_y)
WPAD_IR(pad, &ir); WPAD_IR(pad, &ir);
if (ir.valid) if (ir.valid)
{ {
scope_x = (ir.x * 256) / 640; pos_x = (ir.x * 256) / 640;
scope_y = (ir.y * 224) / 480; pos_y = (ir.y * 224) / 480;
} }
#endif #endif
@ -431,9 +439,51 @@ decodepad (int pad)
S9xReportButton (offset + i, false); S9xReportButton (offset + i, false);
} }
// pointer // pointer
offset = 0x60; offset = 0x80;
UpdateCursorPosition (pad, scope_x, scope_y); UpdateCursorPosition (pad, cursor_x[0], cursor_y[0]);
S9xReportPointer(offset, (u16)scope_x, (u16)scope_y); S9xReportPointer(offset, (u16)cursor_x[0], (u16)cursor_y[0]);
}
/*** Mouse ***/
else if (Settings.MouseMaster && pad < GCSettings.Mouse)
{
// buttons
offset = 0x60+(2*pad);
for (i = 0; i < 2; i++)
{
if ( jp & gcmousemap[i]
#ifdef HW_RVL
|| wp & wmmousemap[i]
#endif
)
S9xReportButton (offset + i, true);
else
S9xReportButton (offset + i, false);
}
// pointer
offset = 0x81;
UpdateCursorPosition (pad, cursor_x[1+pad], cursor_y[1+pad]);
S9xReportPointer(offset+pad, (u16)cursor_x[1+pad], (u16)cursor_y[1+pad]);
}
/*** Justifier ***/
else if (Settings.JustifierMaster && pad < GCSettings.Justifier)
{
// buttons
offset = 0x70+(3*pad);
for (i = 0; i < 3; i++)
{
if ( jp & gcjustmap[i]
#ifdef HW_RVL
|| wp & wmjustmap[i]
#endif
)
S9xReportButton (offset + i, true);
else
S9xReportButton (offset + i, false);
}
// pointer
offset = 0x83;
UpdateCursorPosition (pad, cursor_x[3+pad], cursor_y[3+pad]);
S9xReportPointer(offset+pad, (u16)cursor_x[3+pad], (u16)cursor_y[3+pad]);
} }
} }
/**************************************************************************** /****************************************************************************
@ -607,8 +657,13 @@ void SetControllers ()
} }
else if (Settings.MouseMaster == true) else if (Settings.MouseMaster == true)
{ {
S9xSetController (0, CTL_MOUSE, 0, 0, 0, 0); S9xSetController (0, CTL_JOYPAD, 0, 0, 0, 0);
S9xSetController (1, CTL_JOYPAD, 1, 0, 0, 0); S9xSetController (1, CTL_MOUSE, (GCSettings.Mouse == 2), 0, 0, 0);
}
else if (Settings.JustifierMaster == true)
{
S9xSetController(0, CTL_JOYPAD, 0, 0, 0, 0);
S9xSetController(1, CTL_JUSTIFIER, (GCSettings.Justifier == 2), 0, 0, 0);
} }
else else
{ {
@ -696,8 +751,27 @@ SetDefaultButtonMap ()
ASSIGN_BUTTON_FALSE (maxcode++, "Superscope Pause"); ASSIGN_BUTTON_FALSE (maxcode++, "Superscope Pause");
maxcode = 0x60; maxcode = 0x60;
/*** Mouse ***/
ASSIGN_BUTTON_FALSE (maxcode++, "Mouse1 L");
ASSIGN_BUTTON_FALSE (maxcode++, "Mouse1 R");
ASSIGN_BUTTON_FALSE (maxcode++, "Mouse2 L");
ASSIGN_BUTTON_FALSE (maxcode++, "Mouse2 R");
maxcode = 0x70;
/*** Justifier ***/
ASSIGN_BUTTON_FALSE (maxcode++, "Justifier1 AimOffscreen");
ASSIGN_BUTTON_FALSE (maxcode++, "Justifier1 Trigger");
ASSIGN_BUTTON_FALSE (maxcode++, "Justifier1 Start");
ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 AimOffscreen");
ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 Trigger");
ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 Start");
maxcode = 0x80;
S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Superscope"), false); S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Superscope"), false);
// add mouses here S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Mouse1"), false);
S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Mouse2"), false);
S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Justifier1"), false);
S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Justifier2"), false);
SetControllers (); SetControllers ();

View File

@ -197,6 +197,7 @@ struct SGCSettings{
u16 render; // 0 - original, 1 - no AA u16 render; // 0 - original, 1 - no AA
u16 Superscope; u16 Superscope;
u16 Mouse; u16 Mouse;
u16 Justifier;
}; };
START_EXTERN_C START_EXTERN_C