aboutsummaryrefslogtreecommitdiff
path: root/engines/pegasus/input.h
diff options
context:
space:
mode:
authorMatthew Hoops2011-12-20 18:35:33 -0500
committerMatthew Hoops2011-12-20 18:35:33 -0500
commit331da45ae3e1192e348ae817456e9f121ee74577 (patch)
tree515c36009ac0e95521099204c9caa179a670249b /engines/pegasus/input.h
parenta600dcb56a9633ebfae0d726480352b6f2e9b3ba (diff)
downloadscummvm-rg350-331da45ae3e1192e348ae817456e9f121ee74577.tar.gz
scummvm-rg350-331da45ae3e1192e348ae817456e9f121ee74577.tar.bz2
scummvm-rg350-331da45ae3e1192e348ae817456e9f121ee74577.zip
PEGASUS: Make InputDevice into a Singleton
Removes a global construction
Diffstat (limited to 'engines/pegasus/input.h')
-rwxr-xr-xengines/pegasus/input.h15
1 files changed, 9 insertions, 6 deletions
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