"Turbo mode (do not try to sleep between frames)", 0 },
{ "conf", 'c', POPT_ARG_STRING, 0, 10,
"Extra configuration file to load", "FILE" },
+ { "mouse", 'm', POPT_ARG_INT | POPT_ARGFLAG_OPTIONAL, 0, 11,
+ "Enable mouse on controller NUM", "NUM"},
+ { "superscope", 'e', POPT_ARG_NONE, 0, 12,
+ "Enable SuperScope", 0},
{ "scancode", '\0', POPT_ARG_INT, 0, 100,
"Scancode to map", "CODE" },
{ "button", '\0', POPT_ARG_STRING, 0, 101,
Settings.Mouse = FALSE;
Settings.SuperScope = FALSE;
Settings.MultiPlayer5 = FALSE;
- // Settings.ControllerOption = SNES_MULTIPLAYER5;
- Settings.ControllerOption = 0;
+ Settings.ControllerOption = SNES_JOYPAD;
Settings.ForceTransparency = FALSE;
Settings.Transparency = FALSE;
Settings.ApplyCheats = FALSE;
Settings.TurboMode = FALSE;
Settings.TurboSkipFrames = 15;
- Settings.ThreadSound = FALSE;
- Settings.SoundSync = FALSE;
+ //Settings.ThreadSound = FALSE;
+ //Settings.SoundSync = FALSE;
//Settings.NoPatch = true;
-
- Settings.ApplyCheats = FALSE;
- Settings.TurboMode = FALSE;
Settings.ForcePAL = FALSE;
Settings.ForceNTSC = FALSE;
unsigned char scancode = 0;
while ((rc = poptGetNextOpt(optCon)) > 0) {
+ const char * val;
switch (rc) {
case 1:
Config.enableAudio = false;
case 10:
loadConfig(optCon, poptGetOptArg(optCon));
break;
+ case 11:
+ val = poptGetOptArg(optCon);
+ Settings.Mouse = TRUE;
+ if (!val || atoi(val) <= 1) {
+ // Enable mouse on first controller
+ Settings.ControllerOption = SNES_MOUSE_SWAPPED;
+ } else {
+ // Enable mouse on second controller
+ Settings.ControllerOption = SNES_MOUSE;
+ }
+ break;
+ case 12:
+ Settings.SuperScope = TRUE;
+ Settings.ControllerOption = SNES_SUPERSCOPE;
+ break;
case 100:
scancode = atoi(poptGetOptArg(optCon));
break;
#define kPollEveryNFrames 3
static uint32 joypads[2];
+static struct {
+ unsigned x;
+ unsigned y;
+ bool pressed;
+} mouse;
static void processEvent(const SDL_Event& event)
{
case SDL_KEYUP:
joypads[0] &= ~Config.joypad1Mapping[event.key.keysym.scancode];
break;
+ case SDL_MOUSEBUTTONUP:
+ case SDL_MOUSEBUTTONDOWN:
+ mouse.x = event.button.x;
+ mouse.y = event.button.y;
+ if (Config.xsp) {
+ mouse.x /= 2;
+ mouse.y /= 2;
+ }
+ mouse.pressed = event.button.state == SDL_PRESSED;
+ break;
+ case SDL_MOUSEMOTION:
+ mouse.x = event.motion.x;
+ mouse.y = event.motion.y;
+ if (Config.xsp) {
+ mouse.x /= 2;
+ mouse.y /= 2;
+ }
+ break;
case SDL_QUIT:
Config.quitting = true;
break;
if (which < 0 || which > 2) {
return 0;
}
-
+
return joypads[which];
}
-bool8 S9xReadMousePosition (int /* which1 */, int &/* x */, int & /* y */,
- uint32 & /* buttons */)
+bool8 S9xReadMousePosition(int which1, int& x, int& y, uint32& buttons)
{
- return FALSE;
+ if (which1 != 0) return FALSE;
+
+ x = mouse.x;
+ y = mouse.y;
+ buttons = mouse.pressed ? 1 : 0;
+
+ return TRUE;
}
-bool8 S9xReadSuperScopePosition (int & /* x */, int & /* y */,
- uint32 & /* buttons */)
+bool8 S9xReadSuperScopePosition(int& x, int& y, uint32& buttons)
{
- return FALSE;
+ x = mouse.x;
+ y = mouse.y;
+ buttons = mouse.pressed ? 8 : 0;
+
+ return TRUE;
}
void S9xProcessEvents(bool8_32 block)
{
SDL_Event event;
-
+
if (block) {
SDL_WaitEvent(&event);
processEvent(event);
void S9xInitInputDevices()
{
- joypads[0] = 0x80000000UL;
+ joypads[0] = 0;
joypads[1] = 0;
-
- printf("Input: 1 joypad, hw keyboard input only\n");
+
+ switch (Settings.ControllerOption) {
+ case SNES_JOYPAD:
+ joypads[0] = 0x80000000UL;
+ printf("Input: 1 joypad, keyboard only\n");
+ break;
+ case SNES_MOUSE:
+ joypads[0] = 0x80000000UL;
+ printf("Input: 1 joypad + mouse\n");
+ break;
+ case SNES_MOUSE_SWAPPED:
+ printf("Input: mouse\n");
+ break;
+ case SNES_SUPERSCOPE:
+ joypads[0] = 0x80000000UL;
+ printf("Input: 1 joypad + superscope\n");
+ break;
+ default:
+ printf("Input: unknown\n");
+ break;
+ }
}