diff options
| -rwxr-xr-x | engines/pegasus/ai/ai_area.cpp | 4 | ||||
| -rwxr-xr-x | engines/pegasus/input.cpp | 18 | ||||
| -rwxr-xr-x | engines/pegasus/input.h | 15 | ||||
| -rwxr-xr-x | engines/pegasus/neighborhood/caldoria/caldoria.cpp | 2 | ||||
| -rw-r--r-- | engines/pegasus/neighborhood/neighborhood.cpp | 6 | ||||
| -rwxr-xr-x | engines/pegasus/neighborhood/tsa/fulltsa.cpp | 6 | ||||
| -rw-r--r-- | engines/pegasus/pegasus.cpp | 8 | 
7 files changed, 31 insertions, 28 deletions
diff --git a/engines/pegasus/ai/ai_area.cpp b/engines/pegasus/ai/ai_area.cpp index b0836ab638..9eacb038bd 100755 --- a/engines/pegasus/ai/ai_area.cpp +++ b/engines/pegasus/ai/ai_area.cpp @@ -265,7 +265,7 @@ bool AIArea::playAIMovie(const LowerAreaSignature area, const Common::String &mo  	lockAIOut(); -	InputHandler::getCurrentInputDevice()->waitInput(interruptFilter); +	InputDevice.waitInput(interruptFilter);  	if (_AIMovie.isMovieValid())  		_AIMovie.releaseMovie(); @@ -295,7 +295,7 @@ bool AIArea::playAIMovie(const LowerAreaSignature area, const Common::String &mo  	while (_AIMovie.isRunning()) {  		Input input; -		InputHandler::getCurrentInputDevice()->getInput(input, interruptFilter); +		InputDevice.getInput(input, interruptFilter);  		if (input.anyInput() || vm->shouldQuit()) {  			result = false; diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp index d0b8b69b5b..ef9d9a6b8e 100755 --- a/engines/pegasus/input.cpp +++ b/engines/pegasus/input.cpp @@ -30,16 +30,17 @@  #include "pegasus/input.h"  #include "pegasus/pegasus.h" +namespace Common { +DECLARE_SINGLETON(Pegasus::InputDeviceManager); +} +  namespace Pegasus { -InputDevice::InputDevice() { +InputDeviceManager::InputDeviceManager() {  	_lastRawBits = kAllUpBits;  } -InputDevice::~InputDevice() { -} - -void InputDevice::getInput(Input &input, const InputBits filter) { +void InputDeviceManager::getInput(Input &input, const InputBits filter) {  	// TODO: Save/Load keys  	InputBits currentBits = 0; @@ -140,7 +141,7 @@ void InputDevice::getInput(Input &input, const InputBits filter) {  }  // Wait until the input device stops returning input allowed by filter... -void InputDevice::waitInput(const InputBits filter) { +void InputDeviceManager::waitInput(const InputBits filter) {  	if (filter != 0) {  		for (;;) {  			Input input; @@ -160,7 +161,6 @@ int operator!=(const Input &arg1, const Input &arg2) {  }  InputHandler *InputHandler::_inputHandler = 0; -InputDevice InputHandler::_inputDevice;  bool InputHandler::_invalHotspots = false;  InputBits InputHandler::_lastFilter = kFilterNoInput; @@ -198,7 +198,7 @@ void InputHandler::getInput(Input &input, Hotspot *&cursorSpot) {  	else  		_lastFilter = kFilterAllInput; -	_inputDevice.getInput(input, _lastFilter); +	InputDevice.getInput(input, _lastFilter);  	if (_inputHandler && _inputHandler->wantsCursor() && (_lastFilter & _inputHandler->getClickFilter()) != 0) {  		if (cursor->isVisible()) { @@ -220,7 +220,7 @@ void InputHandler::getInput(Input &input, Hotspot *&cursorSpot) {  }  void InputHandler::readInputDevice(Input &input) { -	_inputDevice.getInput(input, kFilterAllInput); +	InputDevice.getInput(input, kFilterAllInput);  }  InputHandler::InputHandler(InputHandler *nextHandler) { diff --git a/engines/pegasus/input.h b/engines/pegasus/input.h index 57d5f93df1..0ee01f1949 100755 --- a/engines/pegasus/input.h +++ b/engines/pegasus/input.h @@ -27,6 +27,7 @@  #define PEGASUS_INPUT_H  #include "common/rect.h" +#include "common/singleton.h"  #include "pegasus/constants.h"  #include "pegasus/types.h" @@ -36,16 +37,18 @@ namespace Pegasus {  class Hotspot;  class Input; -class InputDevice { +class InputDeviceManager : public Common::Singleton<InputDeviceManager> {  public: -	InputDevice(); -	~InputDevice(); +	InputDeviceManager(); +	~InputDeviceManager() {}  	void getInput(Input &, const InputBits);  	void waitInput(const InputBits);  protected: +	friend class Common::Singleton<SingletonBaseType>; +  	InputBits _lastRawBits;  }; @@ -292,7 +295,7 @@ static const InputBits kOpticalInterruption = kFilterAllInputNoAuto;  class Input {  friend int operator==(const Input &, const Input &);  friend int operator!=(const Input &, const Input &); -friend class InputDevice; +friend class InputDeviceManager;  public:  	Input() { clearInput(); } @@ -385,7 +388,6 @@ class InputHandler {  public:  	static InputHandler *setInputHandler(InputHandler*);  	static InputHandler *getCurrentHandler() { return _inputHandler; } -	static InputDevice *getCurrentInputDevice() { return &_inputDevice; }  	static void pollForInput();  	static void getInput(Input&, Hotspot*&);  	static void readInputDevice(Input&); @@ -419,7 +421,6 @@ public:  protected:  	static InputHandler *_inputHandler; -	static InputDevice _inputDevice; // TODO: Remove global constructor  	static bool _invalHotspots;  	static InputBits _lastFilter; @@ -487,4 +488,6 @@ public:  } // End of namespace Pegasus +#define InputDevice (::Pegasus::InputDeviceManager::instance()) +  #endif diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp index a4beecde9b..484242371a 100755 --- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp +++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp @@ -222,7 +222,7 @@ void Caldoria::start() {  				}  			} -			InputHandler::getCurrentInputDevice()->getInput(input, kPullbackInterruptFilter); +			InputDevice.getInput(input, kPullbackInterruptFilter);  			if (input.anyInput()) { // TODO: Save/Quit requests  				skipped = true;  				break; diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp index b516989e4d..224d954eca 100644 --- a/engines/pegasus/neighborhood/neighborhood.cpp +++ b/engines/pegasus/neighborhood/neighborhood.cpp @@ -882,7 +882,7 @@ void Neighborhood::startExtraSequence(const ExtraID extraID, const NotificationF  }  bool Neighborhood::startExtraSequenceSync(const ExtraID extraID, const InputBits interruptionFilter) { -	InputHandler::getCurrentInputDevice()->waitInput(interruptionFilter); +	InputDevice.waitInput(interruptionFilter);  	return prepareExtraSync(extraID) && waitMovieFinish(&_navMovie, interruptionFilter);  } @@ -1315,7 +1315,7 @@ bool Neighborhood::waitMovieFinish(Movie *movie, const InputBits interruptionFil  	bool openAllowed = _vm->swapLoadAllowed(false);  	while (movie->isRunning()) { -		InputHandler::getCurrentInputDevice()->getInput(input, interruptionFilter); +		InputDevice.getInput(input, interruptionFilter);  		if (input.anyInput() || _vm->shouldQuit()) {  			result = false; @@ -1590,7 +1590,7 @@ void Neighborhood::playCroppedMovieOnce(const Common::String &movieName, CoordTy  	Input input;  	while (_croppedMovie.isRunning() && !_vm->shouldQuit()) {  		_vm->processShell(); -		InputHandler::getCurrentInputDevice()->getInput(input, interruptionFilter); +		InputDevice.getInput(input, interruptionFilter);  		if (input.anyInput() || _vm->shouldQuit()) // TODO: Save/Load request  			break;  		_vm->_system->delayMillis(10); diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.cpp b/engines/pegasus/neighborhood/tsa/fulltsa.cpp index c54e252a64..7f5c3925d1 100755 --- a/engines/pegasus/neighborhood/tsa/fulltsa.cpp +++ b/engines/pegasus/neighborhood/tsa/fulltsa.cpp @@ -1619,7 +1619,7 @@ void FullTSA::showMainJumpMenu() {  }  void FullTSA::playTBPMonitor() { -	InputHandler::getCurrentInputDevice()->waitInput(kFilterAllButtons); +	InputDevice.waitInput(kFilterAllButtons);  	if ((GameState.getT0BMonitorMode() & kPlayingTBPMask) == 0) {  		ExtraID extra; @@ -1770,7 +1770,7 @@ void FullTSA::initializeComparisonMonitor(const int newMode, const ExtraID compa  }  void FullTSA::playLeftComparison() { -	InputHandler::getCurrentInputDevice()->waitInput(kFilterAllButtons); +	InputDevice.waitInput(kFilterAllButtons);  	if ((GameState.getT0BMonitorMode() & kPlayingLeftComparisonMask) == 0) {  		ExtraID extra; @@ -1820,7 +1820,7 @@ void FullTSA::playLeftComparison() {  }  void FullTSA::playRightComparison() {	 -	InputHandler::getCurrentInputDevice()->waitInput(kFilterAllButtons); +	InputDevice.waitInput(kFilterAllButtons);  	if ((GameState.getT0BMonitorMode() & kPlayingRightComparisonMask) == 0) {  		ExtraID extra; diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp index 2f1da77a24..2e352bdc6b 100644 --- a/engines/pegasus/pegasus.cpp +++ b/engines/pegasus/pegasus.cpp @@ -281,7 +281,7 @@ void PegasusEngine::runIntro() {  			}  			Input input; -			InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput); +			InputDevice.getInput(input, kFilterAllInput);  			if (input.anyInput())  				skipped = true; @@ -892,7 +892,7 @@ void PegasusEngine::doInterfaceOverview() {  	highlight.setHighlightCornerDiameter(8);  	Input input; -	InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput); +	InputDevice.getInput(input, kFilterAllInput);  	Common::Point cursorLoc;  	input.getInputLocation(cursorLoc); @@ -934,7 +934,7 @@ void PegasusEngine::doInterfaceOverview() {  	_gfx->doFadeInSync();  	for (;;) { -		InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput); +		InputDevice.getInput(input, kFilterAllInput);  		if (input.anyInput() || shouldQuit()) // TODO: Check for save/load requests too  			break; @@ -1150,7 +1150,7 @@ bool PegasusEngine::playMovieScaled(Video::SeekableVideoDecoder *video, uint16 x  		}  		Input input; -		InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput); +		InputDevice.getInput(input, kFilterAllInput);  		if (input.anyInput())  			skipped = true;  | 
