Commandline arguments 'holdxxx' now work correctly (fixes #209).

This commit is contained in:
Stephen Anthony 2017-08-22 14:15:30 -02:30
parent 5661b245c7
commit 21bf401836
5 changed files with 76 additions and 59 deletions

View File

@ -12,11 +12,17 @@
Release History
===========================================================================
5.0.2 to 5.0.3
5.0.2 to 5.0.3: (August xx, 2017)
* Fixed Genesis controller autodetect (Stay Frosty 2, Scramble, etc.)
* Fixed a bug in ystart autodetection that could cause screen jumps
* Fixed a bug in ystart autodetection that could cause screen jumps.
* Fixed several bugs in holdselect, holdreset and holdjoyX commandline
arguments; these now work as expected.
-Have fun!
5.0.1 to 5.0.2: (August 20, 2017)
@ -55,8 +61,6 @@
* Reverted joystick changes for Decathlon ROMs from last release, as
it was added by mistake.
-Have fun!
5.0 to 5.0.1: (July 23, 2017)

View File

@ -2296,23 +2296,29 @@
<tr>
<td><pre>-holdjoy0 &lt;U,D,L,R,F&gt;</pre></td>
<td>Start the emulator with the left joystick direction/button held down
(ie, use 'UF' for up and fire).</td>
(ie, use 'UF' for up and fire). After entering the emulation, you will
have to press and release the direction again to release the event.</td>
</tr>
<tr>
<td><pre>-holdjoy1 &lt;U,D,L,R,F&gt;</pre></td>
<td>Start the emulator with the right joystick direction/button held down
(ie, use 'UF' for up and fire).</td>
(ie, use 'UF' for up and fire). After entering the emulation, you will
have to press and release the direction again to release the event.</td>
</tr>
<tr>
<td><pre>-holdselect</pre></td>
<td>Start the emulator with the Game Select switch held down.</td>
<td>Start the emulator with the Game Select switch held down. After entering
the emulation, you will have to press and release 'Select' to release the
event.</td>
</tr>
<tr>
<td><pre>-holdreset</pre></td>
<td>Start the emulator with the Game Reset switch held down.</td>
<td>Start the emulator with the Game Reset switch held down. After entering
the emulation, you will have to press and release 'Reset' to release the
event.</td>
</tr>
<tr>

View File

@ -119,12 +119,6 @@ void EventHandler::reset(State state)
myOSystem.state().reset();
setContinuousSnapshots(0);
// Reset events almost immediately after starting emulation mode
// We wait a little while, since 'hold' events may be present, and we want
// time for the ROM to process them
if(state == S_EMULATE)
SDL_AddTimer(500, resetEventsCallback, static_cast<void*>(this));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1100,6 +1094,56 @@ void EventHandler::handleEvent(Event::Type event, int state)
myEvent.set(event, state);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::handleConsoleStartupEvents()
{
bool update = false;
if(myOSystem.settings().getBool("holdreset"))
{
handleEvent(Event::ConsoleReset, 1);
update = true;
}
if(myOSystem.settings().getBool("holdselect"))
{
handleEvent(Event::ConsoleSelect, 1);
update = true;
}
const string& holdjoy0 = myOSystem.settings().getString("holdjoy0");
update = update || holdjoy0 != "";
if(BSPF::containsIgnoreCase(holdjoy0, "U"))
handleEvent(Event::JoystickZeroUp, 1);
if(BSPF::containsIgnoreCase(holdjoy0, "D"))
handleEvent(Event::JoystickZeroDown, 1);
if(BSPF::containsIgnoreCase(holdjoy0, "L"))
handleEvent(Event::JoystickZeroLeft, 1);
if(BSPF::containsIgnoreCase(holdjoy0, "R"))
handleEvent(Event::JoystickZeroRight, 1);
if(BSPF::containsIgnoreCase(holdjoy0, "F"))
handleEvent(Event::JoystickZeroFire, 1);
const string& holdjoy1 = myOSystem.settings().getString("holdjoy1");
update = update || holdjoy1 != "";
if(BSPF::containsIgnoreCase(holdjoy1, "U"))
handleEvent(Event::JoystickOneUp, 1);
if(BSPF::containsIgnoreCase(holdjoy1, "D"))
handleEvent(Event::JoystickOneDown, 1);
if(BSPF::containsIgnoreCase(holdjoy1, "L"))
handleEvent(Event::JoystickOneLeft, 1);
if(BSPF::containsIgnoreCase(holdjoy1, "R"))
handleEvent(Event::JoystickOneRight, 1);
if(BSPF::containsIgnoreCase(holdjoy1, "F"))
handleEvent(Event::JoystickOneFire, 1);
if(update)
myOSystem.console().riot().update();
#ifdef DEBUGGER_SUPPORT
if(myOSystem.settings().getBool("debug"))
enterDebugMode();
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool EventHandler::eventStateChange(Event::Type type)
{
@ -2064,6 +2108,7 @@ void EventHandler::setEventState(State state)
case S_LAUNCHER:
myOverlay = &myOSystem.launcher();
enableTextEvents(true);
myEvent.clear();
break;
#ifdef DEBUGGER_SUPPORT
@ -2085,21 +2130,11 @@ void EventHandler::setEventState(State state)
if(myOSystem.hasConsole())
myOSystem.console().stateChanged(myState);
// Always clear any pending events when changing states
myEvent.clear();
// Sometimes an extraneous mouse motion event is generated
// after a state change, which should be supressed
mySkipMouseMotion = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 EventHandler::resetEventsCallback(uInt32 interval, void* param)
{
(static_cast<EventHandler*>(param))->myEvent.clear();
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventHandler::ActionList EventHandler::ourEmulActionList[kEmulActionListSize] = {
{ Event::ConsoleSelect, "Select", "", true },

View File

@ -199,6 +199,12 @@ class EventHandler
*/
void handleEvent(Event::Type type, Int32 value);
/**
Handle events that must be processed each time a new console is
created. Typically, these are events set by commandline arguments.
*/
void handleConsoleStartupEvents();
bool frying() const { return myFryingFlag; }
StringList getActionList(EventMode mode) const;
@ -536,9 +542,6 @@ class EventHandler
void setEventState(State state);
// Callback function invoked by the event-reset timer
static uInt32 resetEventsCallback(uInt32 interval, void* param);
private:
// Structure used for action menu items
struct ActionList {

View File

@ -361,38 +361,7 @@ string OSystem::createConsole(const FilesystemNode& rom, const string& md5sum,
// Also check if certain virtual buttons should be held down
// These must be checked each time a new console is being created
if(mySettings->getBool("holdreset"))
myEventHandler->handleEvent(Event::ConsoleReset, 1);
if(mySettings->getBool("holdselect"))
myEventHandler->handleEvent(Event::ConsoleSelect, 1);
const string& holdjoy0 = mySettings->getString("holdjoy0");
if(BSPF::containsIgnoreCase(holdjoy0, "U"))
myEventHandler->handleEvent(Event::JoystickZeroUp, 1);
if(BSPF::containsIgnoreCase(holdjoy0, "D"))
myEventHandler->handleEvent(Event::JoystickZeroDown, 1);
if(BSPF::containsIgnoreCase(holdjoy0, "L"))
myEventHandler->handleEvent(Event::JoystickZeroLeft, 1);
if(BSPF::containsIgnoreCase(holdjoy0, "R"))
myEventHandler->handleEvent(Event::JoystickZeroRight, 1);
if(BSPF::containsIgnoreCase(holdjoy0, "F"))
myEventHandler->handleEvent(Event::JoystickZeroFire, 1);
const string& holdjoy1 = mySettings->getString("holdjoy1");
if(BSPF::containsIgnoreCase(holdjoy1, "U"))
myEventHandler->handleEvent(Event::JoystickOneUp, 1);
if(BSPF::containsIgnoreCase(holdjoy1, "D"))
myEventHandler->handleEvent(Event::JoystickOneDown, 1);
if(BSPF::containsIgnoreCase(holdjoy1, "L"))
myEventHandler->handleEvent(Event::JoystickOneLeft, 1);
if(BSPF::containsIgnoreCase(holdjoy1, "R"))
myEventHandler->handleEvent(Event::JoystickOneRight, 1);
if(BSPF::containsIgnoreCase(holdjoy1, "F"))
myEventHandler->handleEvent(Event::JoystickOneFire, 1);
#ifdef DEBUGGER_SUPPORT
if(mySettings->getBool("debug"))
myEventHandler->enterDebugMode();
#endif
myEventHandler->handleConsoleStartupEvents();
}
return EmptyString;
}