From 996517eefbc40a67365ac58e499ce20c9e026c3c Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 30 May 2019 08:59:33 +0200 Subject: [PATCH] add new StartPause event (e.g. useful for combos) fix some code --- src/common/KeyMap.hxx | 1 - src/common/PKeyboardHandler.cxx | 2 +- src/emucore/Event.hxx | 4 +++- src/emucore/EventHandler.cxx | 38 +++++++++++++++++++-------------- src/emucore/EventHandler.hxx | 4 ++-- 5 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/common/KeyMap.hxx b/src/common/KeyMap.hxx index dd7c76681..831c885db 100644 --- a/src/common/KeyMap.hxx +++ b/src/common/KeyMap.hxx @@ -19,7 +19,6 @@ #define KEYMAP_HXX #include - #include "Event.hxx" #include "EventHandlerConstants.hxx" diff --git a/src/common/PKeyboardHandler.cxx b/src/common/PKeyboardHandler.cxx index 2fa28a20c..c82883998 100644 --- a/src/common/PKeyboardHandler.cxx +++ b/src/common/PKeyboardHandler.cxx @@ -142,7 +142,7 @@ void PhysicalKeyboardHandler::setDefaultMapping(Event::Type event, EventMode mod setDefaultKey(Event::LoadState , KBDK_F11); setDefaultKey(Event::TakeSnapshot , KBDK_F12); setDefaultKey(Event::Fry , KBDK_BACKSPACE); - setDefaultKey(Event::PauseMode , KBDK_PAUSE); + setDefaultKey(Event::TogglePauseMode , KBDK_PAUSE); setDefaultKey(Event::OptionsMenuMode , KBDK_TAB); setDefaultKey(Event::CmdMenuMode , KBDK_BACKSLASH); setDefaultKey(Event::TimeMachineMode , KBDK_T); diff --git a/src/emucore/Event.hxx b/src/emucore/Event.hxx index ae10360d9..5f8bb6448 100644 --- a/src/emucore/Event.hxx +++ b/src/emucore/Event.hxx @@ -74,7 +74,7 @@ class Event MouseButtonLeftValue, MouseButtonRightValue, ChangeState, LoadState, SaveState, TakeSnapshot, Quit, - PauseMode, OptionsMenuMode, CmdMenuMode, TimeMachineMode, DebuggerMode, ExitMode, + TogglePauseMode, OptionsMenuMode, CmdMenuMode, TimeMachineMode, DebuggerMode, ExitMode, Fry, VolumeDecrease, VolumeIncrease, SoundToggle, VidmodeDecrease, VidmodeIncrease, Rewind, Unwind, @@ -103,6 +103,8 @@ class Event Rewind1Menu, Rewind10Menu, RewindAllMenu, Unwind1Menu, Unwind10Menu, UnwindAllMenu, + StartPauseMode, + LastType }; diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index d9de7a218..41d37964c 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -662,7 +662,7 @@ void EventHandler::handleEvent(Event::Type event, bool pressed) switch (myState) { case EventHandlerState::PAUSE: - if (pressed) changeStateByEvent(Event::PauseMode); + if (pressed) changeStateByEvent(Event::TogglePauseMode); return; case EventHandlerState::CMDMENU: @@ -704,6 +704,11 @@ void EventHandler::handleEvent(Event::Type event, bool pressed) } return; + case Event::StartPauseMode: + if (pressed && myState == EventHandlerState::EMULATION) + setState(EventHandlerState::PAUSE); + return; + //////////////////////////////////////////////////////////////////////// // A combo event is simply multiple calls to handleEvent, once for // each event it contains @@ -772,7 +777,7 @@ void EventHandler::handleEvent(Event::Type event, bool pressed) if (myIs7800) myOSystem.frameBuffer().showMessage("Pause pressed"); } - break; + return; case Event::ConsoleLeftDiffA: if(pressed) @@ -780,14 +785,14 @@ void EventHandler::handleEvent(Event::Type event, bool pressed) myEvent.set(Event::ConsoleLeftDiffB, 0); myOSystem.frameBuffer().showMessage(GUI::LEFT_DIFFICULTY + " A"); } - break; + return; case Event::ConsoleLeftDiffB: if(pressed) { myEvent.set(Event::ConsoleLeftDiffA, 0); myOSystem.frameBuffer().showMessage(GUI::LEFT_DIFFICULTY + " B"); } - break; + return; case Event::ConsoleLeftDiffToggle: if(pressed) { @@ -813,14 +818,14 @@ void EventHandler::handleEvent(Event::Type event, bool pressed) myEvent.set(Event::ConsoleRightDiffB, 0); myOSystem.frameBuffer().showMessage(GUI::RIGHT_DIFFICULTY + " A"); } - break; + return; case Event::ConsoleRightDiffB: if(pressed) { myEvent.set(Event::ConsoleRightDiffA, 0); myOSystem.frameBuffer().showMessage(GUI::RIGHT_DIFFICULTY + " B"); } - break; + return; case Event::ConsoleRightDiffToggle: if(pressed) { @@ -909,7 +914,7 @@ bool EventHandler::changeStateByEvent(Event::Type type) switch(type) { - case Event::PauseMode: + case Event::TogglePauseMode: if(myState == EventHandlerState::EMULATION) setState(EventHandlerState::PAUSE); else if(myState == EventHandlerState::PAUSE) @@ -1528,10 +1533,10 @@ void EventHandler::setState(EventHandlerState state) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EventHandler::ActionList EventHandler::ourEmulActionList[EMUL_ACTIONLIST_SIZE] = { { Event::Quit, "Quit", "", false }, - { Event::ExitMode, "Exit current Stella mode", "", false }, - { Event::OptionsMenuMode, "Enter options menu UI", "", false }, - { Event::CmdMenuMode, "Toggle command menu UI", "", false }, - { Event::DebuggerMode, "Toggle debugger mode", "", false }, + { Event::ExitMode, "Exit current Stella menu/mode", "", false }, + { Event::OptionsMenuMode, "Enter Options menu UI", "", false }, + { Event::CmdMenuMode, "Toggle Commands menu UI", "", false }, + { Event::DebuggerMode, "Toggle Debugger mode", "", false }, { Event::ConsoleSelect, "Select", "", true }, { Event::ConsoleReset, "Reset", "", true }, @@ -1541,15 +1546,16 @@ EventHandler::ActionList EventHandler::ourEmulActionList[EMUL_ACTIONLIST_SIZE] = { Event::Console7800Pause, "7800 Pause Key", "", true }, { Event::ConsoleLeftDiffA, "P0 Difficulty A", "", true }, { Event::ConsoleLeftDiffB, "P0 Difficulty B", "", true }, - { Event::ConsoleLeftDiffToggle, "P0 swap Difficulty", "", true }, + { Event::ConsoleLeftDiffToggle, "P0 Swap Difficulty", "", true }, { Event::ConsoleRightDiffA, "P1 Difficulty A", "", true }, { Event::ConsoleRightDiffB, "P1 Difficulty B", "", true }, - { Event::ConsoleRightDiffToggle, "P1 swap Difficulty", "", true }, + { Event::ConsoleRightDiffToggle, "P1 Swap Difficulty", "", true }, { Event::SaveState, "Save state", "", false }, { Event::ChangeState, "Change state", "", false }, { Event::LoadState, "Load state", "", false }, { Event::TakeSnapshot, "Snapshot", "", false }, - { Event::PauseMode, "Pause", "", false }, + { Event::TogglePauseMode, "Toggle pause mode", "", true }, + { Event::StartPauseMode, "Start pause mode", "", true }, { Event::JoystickZeroUp, "P0 Joystick Up", "", true }, { Event::JoystickZeroDown, "P0 Joystick Down", "", true }, @@ -1670,11 +1676,11 @@ EventHandler::ActionList EventHandler::ourEmulActionList[EMUL_ACTIONLIST_SIZE] = #endif { Event::ToggleTimeMachine, "Toggle 'Time Machine' mode", "", false }, { Event::TimeMachineMode, "Toggle 'Time Machine' UI", "", false }, - { Event::Rewind, "Rewind game one state", "", false }, + { Event::Rewind, "Rewind game one state", "", true }, { Event::Rewind1Menu, "Rewind one state & enter TM UI", "", false }, { Event::Rewind10Menu, "Rewind 10 states & enter TM UI", "", false }, { Event::RewindAllMenu, "Rewind all states & enter TM UI", "", false }, - { Event::Unwind, "Unwind game one state", "", false }, + { Event::Unwind, "Unwind game one state", "", true }, { Event::Unwind1Menu, "Unwind one state & enter TM UI", "", false }, { Event::Unwind10Menu, "Unwind 10 states & enter TM UI", "", false }, { Event::UnwindAllMenu, "Unwind all states & enter TM UI", "", false }, diff --git a/src/emucore/EventHandler.hxx b/src/emucore/EventHandler.hxx index ca14c20e9..6f4acefac 100644 --- a/src/emucore/EventHandler.hxx +++ b/src/emucore/EventHandler.hxx @@ -368,9 +368,9 @@ class EventHandler COMBO_SIZE = 16, EVENTS_PER_COMBO = 8, #ifdef PNG_SUPPORT - EMUL_ACTIONLIST_SIZE = 135 + COMBO_SIZE, + EMUL_ACTIONLIST_SIZE = 136 + COMBO_SIZE, #else - EMUL_ACTIONLIST_SIZE = 135 - 2 + COMBO_SIZE, + EMUL_ACTIONLIST_SIZE = 136 - 2 + COMBO_SIZE, #endif MENU_ACTIONLIST_SIZE = 18 ;