Minor refactoring of Controller class:

- a controller can now answer whether it is intrinsically an analog controller
This commit is contained in:
Stephen Anthony 2018-03-17 20:03:05 -02:30
parent 7eab28b2ef
commit 9a4b14392b
6 changed files with 27 additions and 12 deletions

View File

@ -171,6 +171,12 @@ class Controller : public Serializable
*/
virtual void update() = 0;
/**
Answers whether the controller is intrinsically an analog controller.
Specific controllers should override and implement this method.
*/
virtual bool isAnalog() const { return false; }
/**
Notification method invoked by the system after its reset method has
been called. It may be necessary to override this method for

View File

@ -47,6 +47,11 @@ class Driving : public Controller
*/
void update() override;
/**
Answers whether the controller is intrinsically an analog controller.
*/
bool isAnalog() const override { return true; }
/**
Determines how this controller will treat values received from the
X/Y axis and left/right buttons of the mouse. Since not all controllers

View File

@ -1701,18 +1701,7 @@ bool EventHandler::controllerIsAnalog(Controller::Jack jack) const
const Controller& controller = jack == Controller::Left ?
myOSystem.console().leftController() : myOSystem.console().rightController();
switch(controller.type())
{
case Controller::Paddles:
case Controller::Driving:
case Controller::AmigaMouse:
case Controller::AtariMouse:
case Controller::TrakBall:
case Controller::MindLink:
return true;
default:
return false;
}
return controller.isAnalog();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -72,6 +72,11 @@ class MindLink : public Controller
*/
void update() override;
/**
Answers whether the controller is intrinsically an analog controller.
*/
bool isAnalog() const override { return true; }
/**
Determines how this controller will treat values received from the
X/Y axis and left/right buttons of the mouse. Since not all controllers

View File

@ -54,6 +54,11 @@ class Paddles : public Controller
*/
void update() override;
/**
Answers whether the controller is intrinsically an analog controller.
*/
bool isAnalog() const override { return true; }
/**
Determines how this controller will treat values received from the
X/Y axis and left/right buttons of the mouse. Since not all controllers

View File

@ -57,6 +57,11 @@ class PointingDevice : public Controller
*/
void update() override;
/**
Answers whether the controller is intrinsically an analog controller.
*/
bool isAnalog() const override { return true; }
/**
Determines how this controller will treat values received from the
X/Y axis and left/right buttons of the mouse. Since not all controllers