aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/tony/gfxengine.cpp2
-rw-r--r--engines/tony/input.cpp254
-rw-r--r--engines/tony/input.h37
-rw-r--r--engines/tony/mpal/mpal.cpp1
-rw-r--r--engines/tony/tony.cpp4
5 files changed, 55 insertions, 243 deletions
diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp
index 1858221350..acf6339e73 100644
--- a/engines/tony/gfxengine.cpp
+++ b/engines/tony/gfxengine.cpp
@@ -660,11 +660,9 @@ void RMGfxEngine::Close(void) {
}
void RMGfxEngine::SwitchFullscreen(bool bFull) {
- m_input.SwitchFullscreen(bFull);
}
void RMGfxEngine::GDIControl(bool bCon) {
- m_input.GDIControl(bCon);
}
void RMGfxEngine::EnableInput(void) {
diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp
index 09b15fa127..b6793695f3 100644
--- a/engines/tony/input.cpp
+++ b/engines/tony/input.cpp
@@ -51,238 +51,68 @@ namespace Tony {
#define DIRELEASE(x) if (x) { (x)->Release(); (x)=NULL; }
-void RMInput::DIInit(/*HINSTANCE hInst*/) {
-#ifdef REFACTOR_ME
- HRESULT err;
-
- // Crea l'oggetto madre
- err = DirectInputCreate(hInst, DIRECTINPUT_VERSION, &m_DI, NULL);
- if (err!=DI_OK) {
- MessageBox(theGame.m_wnd,"Error initializing DirectInput!","RMInput::DIInit()",MB_OK);
- assert(0);
- }
-
- // Crea il device del mouse
- // ************************
- err=m_DI->CreateDevice(GUID_SysMouse,&m_DIDMouse,NULL);
- if (err!=DI_OK) {
- MessageBox(theGame.m_wnd,"Error creating mouse device!","RMInput::DIInit()",MB_OK);
- assert(0);
- }
-
- // Setta il data format
- err=m_DIDMouse->SetDataFormat(&c_dfDIMouse);
- if (err!=DI_OK) {
- MessageBox(theGame.m_wnd,"Error setting mouse data format!","RMInput::DIInit()",MB_OK);
- assert(0);
- }
-
- // Setta il cooperative level
- err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE);
- if (err!=DI_OK) {
- MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK);
- assert(0);
- }
-
- // Crea il device della tastiera
- // *****************************
- err=m_DI->CreateDevice(GUID_SysKeyboard,&m_DIDKeyboard,NULL);
- if (err!=DI_OK) {
- MessageBox(theGame.m_wnd,"Error creating keyboard device!","RMInput::DIInit()",MB_OK);
- assert(0);
- }
-
- // Setta il data format
- err=m_DIDKeyboard->SetDataFormat(&c_dfDIKeyboard);
- if (err!=DI_OK) {
- MessageBox(theGame.m_wnd,"Error setting keyboard data format!","RMInput::DIInit()",MB_OK);
- assert(0);
- }
-
- // Setta il cooperative level
- err=m_DIDKeyboard->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE);
- if (err!=DI_OK) {
- MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK);
- assert(0);
- }
-#endif
-}
-
-void RMInput::SwitchFullscreen(bool bFull) {
-#ifdef REFACTOR_ME
- HRESULT err;
-
- // Il camping del mouse e' attivo solo in fullscreen
- m_bClampMouse=bFull;
-
- // Prima di tutto leviamo l'acquiring ai device, altrimenti non possiamo cambiare il
- // cooperative level
- Unacquire();
-
- if (bFull) {
- // Setta il cooperative level
- err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE);
- if (err!=DI_OK) {
- MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK);
- assert(0);
- }
- } else {
- // Setta il cooperative level
- err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE);
- if (err!=DI_OK) {
- MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK);
- assert(0);
- }
- }
-#endif
-}
-
-void RMInput::DIClose(void) {
-#ifdef REFACTOR_ME
- DIRELEASE(m_DIDMouse);
- DIRELEASE(m_DI);
-#endif
-}
-
-
-bool RMInput::Acquire(void) {
-#ifdef REFACTOR_ME
- HRESULT err;
-
- if (m_DIDMouse == NULL)
- return true;
-
- // Inizializza la posizione del mouse
- POINT pt;
- RECT rc;
- GetWindowRect(theGame.m_wnd,&rc);
- GetCursorPos(&pt);
- m_mX=pt.x-rc.left-GetSystemMetrics(SM_CXDLGFRAME);
- m_mY=pt.y-rc.top-(GetSystemMetrics(SM_CYDLGFRAME)+GetSystemMetrics(SM_CYCAPTION));
-
- err=m_DIDMouse->Acquire();
- if (err!=DI_OK)
- return false;
-
- err=m_DIDKeyboard->Acquire();
- if (err!=DI_OK)
- return false;
-#endif
- return true;
-}
+RMInput::RMInput() {
+ _clampMouse = false;
+ _mousePos.Set(0, 0);
+ _leftButton = _rightButton = false;;
-void RMInput::Unacquire(void) {
-#ifdef REFACTOR_ME
- if (m_DIDMouse!=NULL)
- m_DIDMouse->Unacquire();
-
- if (m_DIDKeyboard!=NULL)
- m_DIDKeyboard->Unacquire();
-#endif
+ _leftClickMouse = _leftReleaseMouse = false;
+ _rightClickMouse = _rightReleaseMouse = false;
}
+RMInput::~RMInput() {
-void RMInput::GDIControl(bool bCon) {
-#ifdef REFACTOR_ME
- if (bCon) {
- Unacquire();
- ShowCursor(true);
- } else {
- ShowCursor(false);
- Acquire();
- }
-#endif
}
void RMInput::Poll(void) {
-#ifdef REFACTOR_ME
- HRESULT err;
- bool mLastLeft, mLastRight;
-
- mLastLeft=MouseLeft();
- mLastRight=MouseRight();
- m_bLeftClickMouse=m_bLeftReleaseMouse=m_bRightClickMouse=m_bRightReleaseMouse=false;
-
- // Legge lo stato del mouse
- while (1) {
- ZeroMemory(&m_mState,sizeof(m_mState));
- err=m_DIDMouse->GetDeviceState(sizeof(m_mState),&m_mState);
- if (err==DI_OK)
+ _leftClickMouse = _leftReleaseMouse = _rightClickMouse = _rightReleaseMouse = false;
+
+ // Get pending events
+ while (g_system->getEventManager()->pollEvent(_event)) {
+ switch (_event.type) {
+ case Common::EVENT_MOUSEMOVE:
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_LBUTTONUP:
+ case Common::EVENT_RBUTTONDOWN:
+ case Common::EVENT_RBUTTONUP:
+ _mousePos.Set(_event.mouse.x, _event.mouse.y);
+
+ if (_event.type == Common::EVENT_LBUTTONDOWN) {
+ _leftButton = true;
+ _leftClickMouse = true;
+ } else if (_event.type == Common::EVENT_LBUTTONUP) {
+ _leftButton = false;
+ _leftReleaseMouse = true;
+ } else if (_event.type == Common::EVENT_RBUTTONDOWN) {
+ _rightButton = true;
+ _rightClickMouse = true;
+ } else if (_event.type == Common::EVENT_RBUTTONDOWN) {
+ _rightButton = false;
+ _rightReleaseMouse = true;
+ } else
+ continue;
+
+ // Since a mouse button has changed, don't do any further event processing this frame
+ return;
+
+ default:
break;
- else if (err==DIERR_INPUTLOST || err==DIERR_NOTACQUIRED) {
- ZeroMemory(&m_mState,sizeof(m_mState));
- // Se l'acquire non funziona (ad esempio, quando siamo in background, allora lasciamo perdere
- if (!Acquire())
- return;
}
- else
- break;
- }
-
- // Aggiorna le coordinate del mouse
- m_mX+=m_mState.lX;
- m_mY+=m_mState.lY;
-
- // Clamp dei valori sui bordi della finestra
- if (m_bClampMouse) {
- if (m_mX<0) m_mX=0;
- if (m_mY<0) m_mY=0;
- if (m_mX>=640) m_mX=639;
- if (m_mY>=480) m_mY=479;
- }
-
- // Controlla se e' cambiato lo stato dei bottoni
- if (mLastLeft && !MouseLeft())
- m_bLeftReleaseMouse=true;
-
- if (!mLastLeft && MouseLeft())
- m_bLeftClickMouse=true;
-
- if (mLastRight && !MouseRight())
- m_bRightReleaseMouse=true;
-
- if (!mLastRight && MouseRight())
- m_bRightClickMouse=true;
-#endif
+ }
}
-
-RMInput::RMInput() {
- m_bClampMouse = false;
-}
-
-RMInput::~RMInput() {
-
-}
-
-void RMInput::Init(/*HINSTANCE hInst*/) {
-#ifdef REFACTOR_ME
- DIInit(hInst);
-#ifdef STARTFULLSCREEN
- SwitchFullscreen(true);
-#endif
- Acquire();
-#endif
+void RMInput::Init() {
}
void RMInput::Close(void) {
- Unacquire();
- DIClose();
}
-
bool RMInput::MouseLeft() {
- return false;
-#ifdef REFACTOR_ME
- return (m_mState.rgbButtons[0] & 0x80);
-#endif
+ return _leftButton;
}
bool RMInput::MouseRight() {
- return false;
-#ifdef REFACTOR_ME
- return (m_mState.rgbButtons[1] & 0x80);
-#endif
+ return _rightButton;
}
} // End of namespace Tony
diff --git a/engines/tony/input.h b/engines/tony/input.h
index bff6dcd396..dce35141c5 100644
--- a/engines/tony/input.h
+++ b/engines/tony/input.h
@@ -48,25 +48,23 @@
#ifndef TONY_INPUT_H
#define TONY_INPUT_H
+#include "common/events.h"
#include "tony/utils.h"
namespace Tony {
class RMInput {
private:
-// LPDIRECTINPUT m_DI;
-// LPDIRECTINPUTDEVICE m_DIDKeyboard, m_DIDMouse;
+ Common::Event _event;
+ RMPoint _mousePos;
// DIMOUSESTATE m_mState;
- int m_mX, m_mY;
- bool m_bClampMouse;
+ bool _clampMouse;
+ bool _leftButton, _rightButton;
- bool m_bLeftClickMouse, m_bLeftReleaseMouse, m_bRightClickMouse, m_bRightReleaseMouse;
+ bool _leftClickMouse, _leftReleaseMouse, _rightClickMouse, _rightReleaseMouse;
private:
- // Inizializza DirectInput
- void DIInit(/*uint32 hInst*/);
-
// Deinizializza DirectInput
void DIClose(void);
@@ -83,29 +81,20 @@ public:
// Polling (must be performed once per frame)
void Poll(void);
- // Aquire the DirectInput device
- bool Acquire(void);
-
- // Deacquires the device
- void Unacquire(void);
-
// Reading of the mouse
- RMPoint MousePos() { return RMPoint(m_mX, m_mY); }
+ RMPoint MousePos() { return _mousePos; }
// Current status of the mouse buttons
bool MouseLeft();
bool MouseRight();
// Events of mouse clicks
- bool MouseLeftClicked() { return m_bLeftClickMouse; }
- bool MouseRightClicked() { return m_bRightClickMouse; }
- bool MouseBothClicked() { return m_bLeftClickMouse&&m_bRightClickMouse; }
- bool MouseLeftReleased() { return m_bLeftReleaseMouse; }
- bool MouseRightReleased() { return m_bRightReleaseMouse; }
- bool MouseBothReleased() { return m_bLeftReleaseMouse&&m_bRightReleaseMouse; }
-
- // Warns when changing from full screen to windowed
- void SwitchFullscreen(bool bFull);
+ bool MouseLeftClicked() { return _leftClickMouse; }
+ bool MouseRightClicked() { return _rightClickMouse; }
+ bool MouseBothClicked() { return _leftClickMouse && _rightClickMouse; }
+ bool MouseLeftReleased() { return _leftReleaseMouse; }
+ bool MouseRightReleased() { return _rightReleaseMouse; }
+ bool MouseBothReleased() { return _leftReleaseMouse && _rightReleaseMouse; }
// Warns when we are in the GDI loop
void GDIControl(bool bCon);
diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp
index 851de7cb0c..9000693292 100644
--- a/engines/tony/mpal/mpal.cpp
+++ b/engines/tony/mpal/mpal.cpp
@@ -2202,7 +2202,6 @@ void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) {
bool mpalStartIdlePoll(int nLoc) {
uint32 i;
- uint32 dwId;
for (i = 0; i < MAXPOLLINGLOCATIONS; i++)
if (nPollingLocations[i] == (uint32)nLoc)
diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp
index ab6592342d..01d0cf9add 100644
--- a/engines/tony/tony.cpp
+++ b/engines/tony/tony.cpp
@@ -390,10 +390,6 @@ void TonyEngine::Play(void) {
g_system->delayMillis(50);
- Common::Event evt;
- while (g_system->getEventManager()->pollEvent(evt))
- ;
-
// Call any scheduled processes
_scheduler.schedule();