refactored/renamed key state parameters (pressed vs. released)

This commit is contained in:
thrust26 2019-03-29 23:49:29 +01:00
parent 0666be24e6
commit 39884db86f
12 changed files with 102 additions and 101 deletions

View File

@ -123,7 +123,7 @@ void EventHandlerSDL2::pollEvent()
case SDL_JOYBUTTONDOWN:
{
handleJoyBtnEvent(myEvent.jbutton.which, myEvent.jbutton.button,
myEvent.jbutton.state == SDL_PRESSED ? 1 : 0);
myEvent.jbutton.state == SDL_PRESSED);
break;
}
@ -165,7 +165,7 @@ void EventHandlerSDL2::pollEvent()
case SDL_QUIT:
{
handleEvent(Event::Quit, 1);
handleEvent(Event::Quit);
break; // SDL_QUIT
}

View File

@ -528,9 +528,9 @@ void PhysicalJoystickHandler::handleAxisEvent(int stick, int axis, int value)
{
// Otherwise, we know the event is digital
if(value > Joystick::deadzone())
myHandler.handleEvent(eventAxisPos, 1);
myHandler.handleEvent(eventAxisPos);
else if(value < -Joystick::deadzone())
myHandler.handleEvent(eventAxisNeg, 1);
myHandler.handleEvent(eventAxisNeg);
else
{
// Treat any deadzone value as zero
@ -542,8 +542,8 @@ void PhysicalJoystickHandler::handleAxisEvent(int stick, int axis, int value)
{
// Turn off both events, since we don't know exactly which one
// was previously activated.
myHandler.handleEvent(eventAxisNeg, 0);
myHandler.handleEvent(eventAxisPos, 0);
myHandler.handleEvent(eventAxisNeg, false);
myHandler.handleEvent(eventAxisPos, false);
}
}
j->axisLastValue[axis] = value;
@ -593,7 +593,7 @@ void PhysicalJoystickHandler::handleAxisEvent(int stick, int axis, int value)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalJoystickHandler::handleBtnEvent(int stick, int button, uInt8 state)
void PhysicalJoystickHandler::handleBtnEvent(int stick, int button, bool pressed)
{
const PhysicalJoystickPtr j = joy(stick);
if(!j) return;
@ -603,14 +603,14 @@ void PhysicalJoystickHandler::handleBtnEvent(int stick, int button, uInt8 state)
{
case PhysicalJoystick::JT_REGULAR:
// Handle buttons which switch eventhandler state
if(state && myHandler.changeStateByEvent(j->btnTable[button][kEmulationMode]))
if(pressed && myHandler.changeStateByEvent(j->btnTable[button][kEmulationMode]))
return;
// Determine which mode we're in, then send the event to the appropriate place
if(myHandler.state() == EventHandlerState::EMULATION)
myHandler.handleEvent(j->btnTable[button][kEmulationMode], state);
myHandler.handleEvent(j->btnTable[button][kEmulationMode], pressed);
else if(myHandler.hasOverlay())
myHandler.overlay().handleJoyBtnEvent(stick, button, state);
myHandler.overlay().handleJoyBtnEvent(stick, button, pressed);
break; // Regular button
// These events don't have to pass through handleEvent, since
@ -620,7 +620,7 @@ void PhysicalJoystickHandler::handleBtnEvent(int stick, int button, uInt8 state)
// The 'type-2' here refers to the fact that 'PhysicalJoystick::JT_STELLADAPTOR_LEFT'
// and 'PhysicalJoystick::JT_STELLADAPTOR_RIGHT' are at index 2 and 3 in the JoyType
// enum; subtracting two gives us Controller 0 and 1
if(button < 2) myEvent.set(SA_Button[j->type-2][button], state);
if(button < 2) myEvent.set(SA_Button[j->type-2][button], pressed ? 1 : 0);
break; // Stelladaptor button
case PhysicalJoystick::JT_2600DAPTOR_LEFT:
case PhysicalJoystick::JT_2600DAPTOR_RIGHT:
@ -632,18 +632,18 @@ void PhysicalJoystickHandler::handleBtnEvent(int stick, int button, uInt8 state)
switch(myOSystem.console().leftController().type())
{
case Controller::Keyboard:
if(button < 12) myEvent.set(SA_Key[j->type-4][button], state);
if(button < 12) myEvent.set(SA_Key[j->type-4][button], pressed ? 1 : 0);
break;
default:
if(button < 4) myEvent.set(SA_Button[j->type-4][button], state);
if(button < 4) myEvent.set(SA_Button[j->type-4][button], pressed ? 1 : 0);
}
switch(myOSystem.console().rightController().type())
{
case Controller::Keyboard:
if(button < 12) myEvent.set(SA_Key[j->type-4][button], state);
if(button < 12) myEvent.set(SA_Key[j->type-4][button], pressed ? 1 : 0);
break;
default:
if(button < 4) myEvent.set(SA_Button[j->type-4][button], state);
if(button < 4) myEvent.set(SA_Button[j->type-4][button], pressed ? 1 : 0);
}
}
break; // 2600DAPTOR button

View File

@ -80,7 +80,7 @@ class PhysicalJoystickHandler
/** Handle a physical joystick event. */
void handleAxisEvent(int stick, int axis, int value);
void handleBtnEvent(int stick, int button, uInt8 state);
void handleBtnEvent(int stick, int button, bool pressed);
void handleHatEvent(int stick, int hat, int value);
Event::Type eventForAxis(int stick, int axis, int value, EventMode mode) const {

View File

@ -237,7 +237,7 @@ bool PhysicalKeyboardHandler::addMapping(Event::Type event, EventMode mode,
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalKeyboardHandler::handleEvent(StellaKey key, StellaMod mod, bool state)
void PhysicalKeyboardHandler::handleEvent(StellaKey key, StellaMod mod, bool pressed)
{
// Swallow KBDK_TAB under certain conditions
// See commments on 'myAltKeyCounter' for more information
@ -253,17 +253,17 @@ void PhysicalKeyboardHandler::handleEvent(StellaKey key, StellaMod mod, bool sta
EventHandlerState estate = myHandler.state();
// Immediately store the key state
myEvent.setKey(key, state);
myEvent.setKey(key, pressed);
// An attempt to speed up event processing; we quickly check for
// Control or Alt/Cmd combos first
if(StellaModTest::isAlt(mod) && state)
if(StellaModTest::isAlt(mod) && pressed)
{
#ifdef BSPF_MACOS
// These keys work in all states
if(key == KBDK_Q)
{
myHandler.handleEvent(Event::Quit, 1);
myHandler.handleEvent(Event::Quit);
}
else
#endif
@ -283,11 +283,12 @@ void PhysicalKeyboardHandler::handleEvent(StellaKey key, StellaMod mod, bool sta
switch(key)
{
case KBDK_LEFT: // Alt-left(-shift) rewinds 1(10) states
myHandler.enterTimeMachineMenuMode((StellaModTest::isShift(mod) && state) ? 10 : 1, false);
//if (!myEvent.getKeys()[KBDK_SPACE])
myHandler.enterTimeMachineMenuMode((StellaModTest::isShift(mod) && pressed) ? 10 : 1, false);
break;
case KBDK_RIGHT: // Alt-right(-shift) unwinds 1(10) states
myHandler.enterTimeMachineMenuMode((StellaModTest::isShift(mod) && state) ? 10 : 1, true);
myHandler.enterTimeMachineMenuMode((StellaModTest::isShift(mod) && pressed) ? 10 : 1, true);
break;
case KBDK_DOWN: // Alt-down rewinds to start of list
@ -471,12 +472,12 @@ void PhysicalKeyboardHandler::handleEvent(StellaKey key, StellaMod mod, bool sta
else
handled = false;
}
else if(StellaModTest::isControl(mod) && state && myUseCtrlKeyFlag)
else if(StellaModTest::isControl(mod) && pressed && myUseCtrlKeyFlag)
{
// These keys work in all states
if(key == KBDK_Q)
{
myHandler.handleEvent(Event::Quit, 1);
myHandler.handleEvent(Event::Quit);
}
// These only work when in emulation mode
else if(estate == EventHandlerState::EMULATION || estate == EventHandlerState::PAUSE)
@ -539,7 +540,7 @@ void PhysicalKeyboardHandler::handleEvent(StellaKey key, StellaMod mod, bool sta
{
// Special handling for Escape key
// Basically, exit whichever mode we're currently in
if(state && key == KBDK_ESCAPE)
if(pressed && key == KBDK_ESCAPE)
{
switch(estate)
{
@ -563,7 +564,7 @@ void PhysicalKeyboardHandler::handleEvent(StellaKey key, StellaMod mod, bool sta
}
// Handle keys which switch eventhandler state
if(!state && myHandler.changeStateByEvent(myKeyTable[key][kEmulationMode]))
if(!pressed && myHandler.changeStateByEvent(myKeyTable[key][kEmulationMode]))
return;
}
@ -571,7 +572,7 @@ void PhysicalKeyboardHandler::handleEvent(StellaKey key, StellaMod mod, bool sta
switch(estate)
{
case EventHandlerState::EMULATION:
myHandler.handleEvent(myKeyTable[key][kEmulationMode], state);
myHandler.handleEvent(myKeyTable[key][kEmulationMode], pressed);
break;
case EventHandlerState::PAUSE:
@ -579,7 +580,7 @@ void PhysicalKeyboardHandler::handleEvent(StellaKey key, StellaMod mod, bool sta
{
case Event::TakeSnapshot:
case Event::DebuggerMode:
myHandler.handleEvent(myKeyTable[key][kEmulationMode], state);
myHandler.handleEvent(myKeyTable[key][kEmulationMode], pressed);
break;
default:
@ -589,7 +590,7 @@ void PhysicalKeyboardHandler::handleEvent(StellaKey key, StellaMod mod, bool sta
default:
if(myHandler.hasOverlay())
myHandler.overlay().handleKeyEvent(key, mod, state);
myHandler.overlay().handleKeyEvent(key, mod, pressed);
break;
}
}

View File

@ -52,7 +52,7 @@ class PhysicalKeyboardHandler
bool addMapping(Event::Type event, EventMode mode, StellaKey key);
/** Handle a physical keyboard event. */
void handleEvent(StellaKey key, StellaMod mod, bool state);
void handleEvent(StellaKey key, StellaMod mod, bool pressed);
Event::Type eventForKey(StellaKey key, EventMode mode) const {
return myKeyTable[key][mode];

View File

@ -154,7 +154,7 @@ bool Debugger::startWithFatalError(const string& message)
void Debugger::quit(bool exitrom)
{
if(exitrom)
myOSystem.eventHandler().handleEvent(Event::LauncherMode, 1);
myOSystem.eventHandler().handleEvent(Event::LauncherMode, true);
else
{
myOSystem.eventHandler().leaveDebugMode();

View File

@ -160,10 +160,10 @@ class Event
/**
Set the value associated with the event of the specified type.
*/
void setKey(StellaKey key, bool state) {
void setKey(StellaKey key, bool pressed) {
std::lock_guard<std::mutex> lock(myMutex);
myKeyTable[key] = state;
myKeyTable[key] = pressed;
}
/**

View File

@ -312,7 +312,7 @@ void EventHandler::handleSystemEvent(SystemEvent e, int, int)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::handleEvent(Event::Type event, Int32 state)
void EventHandler::handleEvent(Event::Type event, bool pressed)
{
// Take care of special events that aren't part of the emulation core
// or need to be preprocessed before passing them on
@ -321,93 +321,93 @@ void EventHandler::handleEvent(Event::Type event, Int32 state)
////////////////////////////////////////////////////////////////////////
// If enabled, make sure 'impossible' joystick directions aren't allowed
case Event::JoystickZeroUp:
if(!myAllowAllDirectionsFlag && state)
if(!myAllowAllDirectionsFlag && pressed)
myEvent.set(Event::JoystickZeroDown, 0);
break;
case Event::JoystickZeroDown:
if(!myAllowAllDirectionsFlag && state)
if(!myAllowAllDirectionsFlag && pressed)
myEvent.set(Event::JoystickZeroUp, 0);
break;
case Event::JoystickZeroLeft:
if(!myAllowAllDirectionsFlag && state)
if(!myAllowAllDirectionsFlag && pressed)
myEvent.set(Event::JoystickZeroRight, 0);
break;
case Event::JoystickZeroRight:
if(!myAllowAllDirectionsFlag && state)
if(!myAllowAllDirectionsFlag && pressed)
myEvent.set(Event::JoystickZeroLeft, 0);
break;
case Event::JoystickOneUp:
if(!myAllowAllDirectionsFlag && state)
if(!myAllowAllDirectionsFlag && pressed)
myEvent.set(Event::JoystickOneDown, 0);
break;
case Event::JoystickOneDown:
if(!myAllowAllDirectionsFlag && state)
if(!myAllowAllDirectionsFlag && pressed)
myEvent.set(Event::JoystickOneUp, 0);
break;
case Event::JoystickOneLeft:
if(!myAllowAllDirectionsFlag && state)
if(!myAllowAllDirectionsFlag && pressed)
myEvent.set(Event::JoystickOneRight, 0);
break;
case Event::JoystickOneRight:
if(!myAllowAllDirectionsFlag && state)
if(!myAllowAllDirectionsFlag && pressed)
myEvent.set(Event::JoystickOneLeft, 0);
break;
////////////////////////////////////////////////////////////////////////
case Event::Fry:
if(myPKeyHandler->useCtrlKey()) myFryingFlag = bool(state);
if(myPKeyHandler->useCtrlKey()) myFryingFlag = bool(pressed);
return;
case Event::VolumeDecrease:
if(state) myOSystem.sound().adjustVolume(-1);
if(pressed) myOSystem.sound().adjustVolume(-1);
return;
case Event::VolumeIncrease:
if(state) myOSystem.sound().adjustVolume(+1);
if(pressed) myOSystem.sound().adjustVolume(+1);
return;
case Event::SoundToggle:
if(state) myOSystem.sound().toggleMute();
if(pressed) myOSystem.sound().toggleMute();
return;
case Event::SaveState:
if(state) myOSystem.state().saveState();
if(pressed) myOSystem.state().saveState();
return;
case Event::ChangeState:
if(state) myOSystem.state().changeState();
if(pressed) myOSystem.state().changeState();
return;
case Event::LoadState:
if(state) myOSystem.state().loadState();
if(pressed) myOSystem.state().loadState();
return;
case Event::TakeSnapshot:
if(state) myOSystem.frameBuffer().tiaSurface().saveSnapShot();
if(pressed) myOSystem.frameBuffer().tiaSurface().saveSnapShot();
return;
case Event::LauncherMode:
if((myState == EventHandlerState::EMULATION || myState == EventHandlerState::CMDMENU ||
myState == EventHandlerState::DEBUGGER) && state)
myState == EventHandlerState::DEBUGGER) && pressed)
{
// Go back to the launcher, or immediately quit
if(myOSystem.settings().getBool("exitlauncher") ||
myOSystem.launcherUsed())
myOSystem.createLauncher();
else
handleEvent(Event::Quit, 1);
handleEvent(Event::Quit);
}
return;
case Event::Quit:
if(state)
if(pressed)
{
saveKeyMapping();
saveJoyMapping();
@ -436,28 +436,28 @@ void EventHandler::handleEvent(Event::Type event, Int32 state)
case Event::Combo16:
for(int i = 0, combo = event - Event::Combo1; i < kEventsPerCombo; ++i)
if(myComboTable[combo][i] != Event::NoType)
handleEvent(myComboTable[combo][i], state);
handleEvent(myComboTable[combo][i], pressed);
return;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// Events which relate to switches()
case Event::ConsoleColor:
if(state)
if(pressed)
{
myEvent.set(Event::ConsoleBlackWhite, 0);
myOSystem.frameBuffer().showMessage(myIs7800 ? "Pause released" : "Color Mode");
}
break;
case Event::ConsoleBlackWhite:
if(state)
if(pressed)
{
myEvent.set(Event::ConsoleColor, 0);
myOSystem.frameBuffer().showMessage(myIs7800 ? "Pause pushed" : "B/W Mode");
}
break;
case Event::ConsoleColorToggle:
if(state)
if(pressed)
{
if(myOSystem.console().switches().tvColor())
{
@ -476,7 +476,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 state)
return;
case Event::Console7800Pause:
if(state)
if(pressed)
{
myEvent.set(Event::ConsoleBlackWhite, 0);
myEvent.set(Event::ConsoleColor, 0);
@ -486,21 +486,21 @@ void EventHandler::handleEvent(Event::Type event, Int32 state)
break;
case Event::ConsoleLeftDiffA:
if(state)
if(pressed)
{
myEvent.set(Event::ConsoleLeftDiffB, 0);
myOSystem.frameBuffer().showMessage("Left Difficulty A");
}
break;
case Event::ConsoleLeftDiffB:
if(state)
if(pressed)
{
myEvent.set(Event::ConsoleLeftDiffA, 0);
myOSystem.frameBuffer().showMessage("Left Difficulty B");
}
break;
case Event::ConsoleLeftDiffToggle:
if(state)
if(pressed)
{
if(myOSystem.console().switches().leftDifficultyA())
{
@ -519,21 +519,21 @@ void EventHandler::handleEvent(Event::Type event, Int32 state)
return;
case Event::ConsoleRightDiffA:
if(state)
if(pressed)
{
myEvent.set(Event::ConsoleRightDiffB, 0);
myOSystem.frameBuffer().showMessage("Right Difficulty A");
}
break;
case Event::ConsoleRightDiffB:
if(state)
if(pressed)
{
myEvent.set(Event::ConsoleRightDiffA, 0);
myOSystem.frameBuffer().showMessage("Right Difficulty B");
}
break;
case Event::ConsoleRightDiffToggle:
if(state)
if(pressed)
{
if(myOSystem.console().switches().rightDifficultyA())
{
@ -560,7 +560,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 state)
}
// Otherwise, pass it to the emulation core
myEvent.set(event, state);
myEvent.set(event, pressed);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -569,40 +569,40 @@ void EventHandler::handleConsoleStartupEvents()
bool update = false;
if(myOSystem.settings().getBool("holdreset"))
{
handleEvent(Event::ConsoleReset, 1);
handleEvent(Event::ConsoleReset);
update = true;
}
if(myOSystem.settings().getBool("holdselect"))
{
handleEvent(Event::ConsoleSelect, 1);
handleEvent(Event::ConsoleSelect);
update = true;
}
const string& holdjoy0 = myOSystem.settings().getString("holdjoy0");
update = update || holdjoy0 != "";
if(BSPF::containsIgnoreCase(holdjoy0, "U"))
handleEvent(Event::JoystickZeroUp, 1);
handleEvent(Event::JoystickZeroUp);
if(BSPF::containsIgnoreCase(holdjoy0, "D"))
handleEvent(Event::JoystickZeroDown, 1);
handleEvent(Event::JoystickZeroDown);
if(BSPF::containsIgnoreCase(holdjoy0, "L"))
handleEvent(Event::JoystickZeroLeft, 1);
handleEvent(Event::JoystickZeroLeft);
if(BSPF::containsIgnoreCase(holdjoy0, "R"))
handleEvent(Event::JoystickZeroRight, 1);
handleEvent(Event::JoystickZeroRight);
if(BSPF::containsIgnoreCase(holdjoy0, "F"))
handleEvent(Event::JoystickZeroFire, 1);
handleEvent(Event::JoystickZeroFire);
const string& holdjoy1 = myOSystem.settings().getString("holdjoy1");
update = update || holdjoy1 != "";
if(BSPF::containsIgnoreCase(holdjoy1, "U"))
handleEvent(Event::JoystickOneUp, 1);
handleEvent(Event::JoystickOneUp);
if(BSPF::containsIgnoreCase(holdjoy1, "D"))
handleEvent(Event::JoystickOneDown, 1);
handleEvent(Event::JoystickOneDown);
if(BSPF::containsIgnoreCase(holdjoy1, "L"))
handleEvent(Event::JoystickOneLeft, 1);
handleEvent(Event::JoystickOneLeft);
if(BSPF::containsIgnoreCase(holdjoy1, "R"))
handleEvent(Event::JoystickOneRight, 1);
handleEvent(Event::JoystickOneRight);
if(BSPF::containsIgnoreCase(holdjoy1, "F"))
handleEvent(Event::JoystickOneFire, 1);
handleEvent(Event::JoystickOneFire);
if(update)
myOSystem.console().riot().update();

View File

@ -115,7 +115,7 @@ class EventHandler
/**
This method indicates that the system should terminate.
*/
void quit() { handleEvent(Event::Quit, 1); }
void quit() { handleEvent(Event::Quit, true); }
/**
Sets the mouse axes and buttons to act as the controller specified in
@ -137,10 +137,10 @@ class EventHandler
Send an event directly to the event handler.
These events cannot be remapped.
@param type The event
@param value The value for the event
@param type The event
@param pressed Pressed (true) or released (false)
*/
void handleEvent(Event::Type type, Int32 value);
void handleEvent(Event::Type type, bool pressed = true);
/**
Handle events that must be processed each time a new console is
@ -314,11 +314,11 @@ class EventHandler
void handleTextEvent(char text);
void handleMouseMotionEvent(int x, int y, int xrel, int yrel);
void handleMouseButtonEvent(MouseButton b, bool pressed, int x, int y);
void handleKeyEvent(StellaKey key, StellaMod mod, bool state) {
myPKeyHandler->handleEvent(key, mod, state);
void handleKeyEvent(StellaKey key, StellaMod mod, bool pressed) {
myPKeyHandler->handleEvent(key, mod, pressed);
}
void handleJoyBtnEvent(int stick, int button, uInt8 state) {
myPJoyHandler->handleBtnEvent(stick, button, state);
void handleJoyBtnEvent(int stick, int button, bool pressed) {
myPJoyHandler->handleBtnEvent(stick, button, pressed);
}
void handleJoyAxisEvent(int stick, int axis, int value) {
myPJoyHandler->handleAxisEvent(stick, axis, value);

View File

@ -185,7 +185,7 @@ void CommandDialog::handleCommand(CommandSender* sender, int cmd,
case kSnapshotCmd:
instance().eventHandler().leaveMenuMode();
instance().eventHandler().handleEvent(Event::TakeSnapshot, 1);
instance().eventHandler().handleEvent(Event::TakeSnapshot);
break;
case kTimeMachineCmd:
@ -194,7 +194,7 @@ void CommandDialog::handleCommand(CommandSender* sender, int cmd,
break;
case kExitCmd:
instance().eventHandler().handleEvent(Event::LauncherMode, 1);
instance().eventHandler().handleEvent(Event::LauncherMode);
break;
// Column 3
@ -227,18 +227,18 @@ void CommandDialog::handleCommand(CommandSender* sender, int cmd,
break;
}
// Console commands show be performed right away, after leaving the menu
// Console commands should be performed right away, after leaving the menu
// State commands require you to exit the menu manually
if(consoleCmd)
{
instance().eventHandler().leaveMenuMode();
instance().eventHandler().handleEvent(event, 1);
instance().eventHandler().handleEvent(event);
instance().console().switches().update();
instance().console().tia().update();
instance().eventHandler().handleEvent(event, 0);
instance().eventHandler().handleEvent(event, false);
}
else if(stateCmd)
instance().eventHandler().handleEvent(event, 1);
instance().eventHandler().handleEvent(event);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -175,14 +175,14 @@ void DialogContainer::handleTextEvent(char text)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DialogContainer::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
void DialogContainer::handleKeyEvent(StellaKey key, StellaMod mod, bool pressed)
{
if(myDialogStack.empty())
return;
// Send the event to the dialog box on the top of the stack
Dialog* activeDialog = myDialogStack.top();
if(state)
if(pressed)
{
myCurrentKeyDown.key = key;
myCurrentKeyDown.mod = mod;
@ -290,7 +290,7 @@ void DialogContainer::handleMouseButtonEvent(MouseButton b, bool pressed,
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DialogContainer::handleJoyBtnEvent(int stick, int button, uInt8 state)
void DialogContainer::handleJoyBtnEvent(int stick, int button, bool pressed)
{
if(myDialogStack.empty())
return;
@ -298,7 +298,7 @@ void DialogContainer::handleJoyBtnEvent(int stick, int button, uInt8 state)
// Send the event to the dialog box on the top of the stack
Dialog* activeDialog = myDialogStack.top();
if(state == 1)
if(pressed)
{
myCurrentButtonDown.stick = stick;
myCurrentButtonDown.button = button;

View File

@ -68,11 +68,11 @@ class DialogContainer
/**
Handle a keyboard single-key event.
@param key Actual key symbol
@param mod Modifiers
@param state Pressed (true) or released (false)
@param key Actual key symbol
@param mod Modifiers
@param pressed Pressed (true) or released (false)
*/
void handleKeyEvent(StellaKey key, StellaMod mod, bool state);
void handleKeyEvent(StellaKey key, StellaMod mod, bool pressed);
/**
Handle a mouse motion event.
@ -97,9 +97,9 @@ class DialogContainer
@param stick The joystick number
@param button The joystick button
@param state The state (pressed or released)
@param pressed Pressed (true) or released (false)
*/
void handleJoyBtnEvent(int stick, int button, uInt8 state);
void handleJoyBtnEvent(int stick, int button, bool pressed);
/**
Handle a joystick axis event.