Minor refactoring with Controller::isAnalog() usage.

This commit is contained in:
Stephen Anthony 2018-03-18 16:13:28 -02:30
parent 3ce71302b7
commit 0cde1ec4b9
4 changed files with 7 additions and 21 deletions

View File

@ -94,6 +94,9 @@ class Console : public Serializable
*/
Controller& leftController() const { return *myLeftControl; }
Controller& rightController() const { return *myRightControl; }
Controller& controller(Controller::Jack jack) const {
return jack == Controller::Left ? leftController() : rightController();
}
/**
Get the TIA for this console

View File

@ -1695,15 +1695,6 @@ void EventHandler::takeSnapshot(uInt32 number)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool EventHandler::controllerIsAnalog(Controller::Jack jack) const
{
const Controller& controller = jack == Controller::Left ?
myOSystem.console().leftController() : myOSystem.console().rightController();
return controller.isAnalog();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setMouseControllerMode(const string& enable)
{
@ -1716,8 +1707,8 @@ void EventHandler::setMouseControllerMode(const string& enable)
usemouse = false;
else // 'analog'
{
usemouse = controllerIsAnalog(Controller::Left) ||
controllerIsAnalog(Controller::Right);
usemouse = myOSystem.console().controller(Controller::Left).isAnalog() ||
myOSystem.console().controller(Controller::Right).isAnalog();
}
const string& control = usemouse ?

View File

@ -269,14 +269,6 @@ class EventHandler
*/
void allowAllDirections(bool allow) { myAllowAllDirectionsFlag = allow; }
/**
Determines whether the given controller must use the mouse (aka,
whether the controller generates analog output).
@param jack The controller to query
*/
bool controllerIsAnalog(Controller::Jack jack) const;
/**
Detects and changes the eventhandler state.

View File

@ -662,8 +662,8 @@ void FrameBuffer::setCursorState()
bool emulation =
myOSystem.eventHandler().state() == EventHandlerState::EMULATION;
bool analog = myOSystem.hasConsole() ?
(myOSystem.eventHandler().controllerIsAnalog(Controller::Left) ||
myOSystem.eventHandler().controllerIsAnalog(Controller::Right)) : false;
(myOSystem.console().controller(Controller::Left).isAnalog() ||
myOSystem.console().controller(Controller::Right).isAnalog()) : false;
bool alwaysUseMouse = BSPF::equalsIgnoreCase("always", myOSystem.settings().getString("usemouse"));
grabMouse(emulation && (analog || alwaysUseMouse) && myGrabMouse);