From b0eef829728183b7ea170b30a33eca091bcc4574 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 30 Apr 2012 09:27:12 +1000 Subject: TONY: Added include files for graphics engine and all dependent classes --- engines/tony/input.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 engines/tony/input.cpp (limited to 'engines/tony/input.cpp') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp new file mode 100644 index 0000000000..367317bd88 --- /dev/null +++ b/engines/tony/input.cpp @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Input.CPP............ * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#include "tony/gfxEngine.h" + +namespace Tony { + + + +} // End of namespace Tony -- cgit v1.2.3 From fde1f13676273405cd2d686f1e0ae53834c049ff Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 3 May 2012 13:32:09 +1000 Subject: TONY: Implemented stubs for Input.cpp methods --- engines/tony/input.cpp | 253 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 253 insertions(+) (limited to 'engines/tony/input.cpp') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 367317bd88..72c7bf06f7 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -49,6 +49,259 @@ 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; +} + +void RMInput::Unacquire(void) { +#ifdef REFACTOR_ME + if (m_DIDMouse!=NULL) + m_DIDMouse->Unacquire(); + + if (m_DIDKeyboard!=NULL) + m_DIDKeyboard->Unacquire(); +#endif +} + + +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) + 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::Close(void) { + Unacquire(); + DIClose(); +} + + +bool RMInput::MouseLeft() { + return false; +#ifdef REFACTOR_ME + return (m_mState.rgbButtons[0] & 0x80); +#endif +} + +bool RMInput::MouseRight() { + return false; +#ifdef REFACTOR_ME + return (m_mState.rgbButtons[1] & 0x80); +#endif +} } // End of namespace Tony -- cgit v1.2.3 From 6d0f1fca46c8bd9b5b4e7ccaf6631850c29d1447 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 3 May 2012 23:08:19 +1000 Subject: TONY: Formatting fixes --- engines/tony/input.cpp | 50 ++++++++++++++++---------------------------------- 1 file changed, 16 insertions(+), 34 deletions(-) (limited to 'engines/tony/input.cpp') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 72c7bf06f7..25f271d7eb 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -57,8 +57,7 @@ void RMInput::DIInit(/*HINSTANCE hInst*/) { // Crea l'oggetto madre err = DirectInputCreate(hInst, DIRECTINPUT_VERSION, &m_DI, NULL); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error initializing DirectInput!","RMInput::DIInit()",MB_OK); assert(0); } @@ -66,24 +65,21 @@ void RMInput::DIInit(/*HINSTANCE hInst*/) { // Crea il device del mouse // ************************ err=m_DI->CreateDevice(GUID_SysMouse,&m_DIDMouse,NULL); - if (err!=DI_OK) - { + 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) - { + 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) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); assert(0); } @@ -91,24 +87,21 @@ void RMInput::DIInit(/*HINSTANCE hInst*/) { // Crea il device della tastiera // ***************************** err=m_DI->CreateDevice(GUID_SysKeyboard,&m_DIDKeyboard,NULL); - if (err!=DI_OK) - { + 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) - { + 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) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); assert(0); } @@ -126,22 +119,17 @@ void RMInput::SwitchFullscreen(bool bFull) { // cooperative level Unacquire(); - if (bFull) - { + if (bFull) { // Setta il cooperative level err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); assert(0); } - } - else - { + } else { // Setta il cooperative level err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); assert(0); } @@ -197,13 +185,10 @@ void RMInput::Unacquire(void) { void RMInput::GDIControl(bool bCon) { #ifdef REFACTOR_ME - if (bCon) - { + if (bCon) { Unacquire(); ShowCursor(true); - } - else - { + } else { ShowCursor(false); Acquire(); } @@ -220,14 +205,12 @@ void RMInput::Poll(void) { m_bLeftClickMouse=m_bLeftReleaseMouse=m_bRightClickMouse=m_bRightReleaseMouse=false; // Legge lo stato del mouse - while (1) - { + while (1) { ZeroMemory(&m_mState,sizeof(m_mState)); err=m_DIDMouse->GetDeviceState(sizeof(m_mState),&m_mState); if (err==DI_OK) break; - else if (err==DIERR_INPUTLOST || err==DIERR_NOTACQUIRED) - { + 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()) @@ -242,8 +225,7 @@ void RMInput::Poll(void) { m_mY+=m_mState.lY; // Clamp dei valori sui bordi della finestra - if (m_bClampMouse) - { + if (m_bClampMouse) { if (m_mX<0) m_mX=0; if (m_mY<0) m_mY=0; if (m_mX>=640) m_mX=639; -- cgit v1.2.3 From 23cd3b7730c292539649578d1aea373812e6b4ce Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 22:28:51 +1000 Subject: TONY: Fixed many warnings identified by gcc --- engines/tony/input.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'engines/tony/input.cpp') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 25f271d7eb..09b15fa127 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -45,7 +45,7 @@ * * **************************************************************************/ -#include "tony/gfxEngine.h" +#include "tony/gfxengine.h" namespace Tony { @@ -137,8 +137,7 @@ void RMInput::SwitchFullscreen(bool bFull) { #endif } -void RMInput::DIClose(void) -{ +void RMInput::DIClose(void) { #ifdef REFACTOR_ME DIRELEASE(m_DIDMouse); DIRELEASE(m_DI); -- cgit v1.2.3 From 8bfc60f5c9bdba4b1f37fcf42df4b0aa360c325f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 6 May 2012 16:39:42 +1000 Subject: TONY: Refactored RMInput class to use ScummVM event loop --- engines/tony/input.cpp | 254 ++++++++----------------------------------------- 1 file changed, 42 insertions(+), 212 deletions(-) (limited to 'engines/tony/input.cpp') 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 -- cgit v1.2.3 From 166980fa4f7aa29ef604307662ed04d21b26a211 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 May 2012 00:08:09 +1000 Subject: TONY: Fix for properly signaling right button release. --- engines/tony/input.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/tony/input.cpp') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index b6793695f3..3574980176 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -86,7 +86,7 @@ void RMInput::Poll(void) { } else if (_event.type == Common::EVENT_RBUTTONDOWN) { _rightButton = true; _rightClickMouse = true; - } else if (_event.type == Common::EVENT_RBUTTONDOWN) { + } else if (_event.type == Common::EVENT_RBUTTONUP) { _rightButton = false; _rightReleaseMouse = true; } else -- cgit v1.2.3 From 109e5f8226c1db18926e307d4ecb9c3c83fdd7bc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 May 2012 20:49:36 +1000 Subject: TONY: Conversion of more methods to coroutines --- engines/tony/input.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'engines/tony/input.cpp') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 3574980176..bd90ec641d 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -52,12 +52,16 @@ namespace Tony { #define DIRELEASE(x) if (x) { (x)->Release(); (x)=NULL; } RMInput::RMInput() { + // Setup mouse fields _clampMouse = false; _mousePos.Set(0, 0); _leftButton = _rightButton = false;; _leftClickMouse = _leftReleaseMouse = false; _rightClickMouse = _rightReleaseMouse = false; + + // Setup keyboard fields + Common::fill(&_keyDown[0], &_keyDown[350], 0); } RMInput::~RMInput() { @@ -95,6 +99,14 @@ void RMInput::Poll(void) { // Since a mouse button has changed, don't do any further event processing this frame return; + case Common::EVENT_KEYDOWN: + _keyDown[(int)_event.kbd.keycode] = true; + return; + + case Common::EVENT_KEYUP: + _keyDown[(int)_event.kbd.keycode] = false; + return; + default: break; } -- cgit v1.2.3 From 073e46503cd09130c3d7e2372ae50e47402569d2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 May 2012 21:54:37 +1000 Subject: TONY: Properly implement game saving and loading. Saving isn't enabled in the demo, so for testing purposes I'm currently dissbling the ADGF_DEMO flag in the detection tables so saving is enabled. --- engines/tony/input.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines/tony/input.cpp') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index bd90ec641d..fcd56b5989 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -127,4 +127,14 @@ bool RMInput::MouseRight() { return _rightButton; } +/** + * Return true if a key has been pressed */ +bool RMInput::GetAsyncKeyState(Common::KeyCode kc) { + // The act of testing for a particular key automatically clears the state, to prevent + // the same key being registered in multiple different frames + bool result = _keyDown[(int)kc]; + _keyDown[(int)kc] = false; + return result; +} + } // End of namespace Tony -- cgit v1.2.3 From b01482bddb6d8f0b0be4dd46ee7c9e4141908673 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 23:05:41 +1000 Subject: TONY: Further globals added to Globals class --- engines/tony/input.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'engines/tony/input.cpp') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index fcd56b5989..f29d4ddc8e 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -49,8 +49,6 @@ namespace Tony { -#define DIRELEASE(x) if (x) { (x)->Release(); (x)=NULL; } - RMInput::RMInput() { // Setup mouse fields _clampMouse = false; @@ -128,7 +126,8 @@ bool RMInput::MouseRight() { } /** - * Return true if a key has been pressed */ + * Return true if a key has been pressed + */ bool RMInput::GetAsyncKeyState(Common::KeyCode kc) { // The act of testing for a particular key automatically clears the state, to prevent // the same key being registered in multiple different frames -- cgit v1.2.3 From 099fe1e9e62ada666a312e08d7dca5cd2083de0b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 14 May 2012 07:43:50 +0200 Subject: TONY: Remove original header --- engines/tony/input.cpp | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) (limited to 'engines/tony/input.cpp') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index f29d4ddc8e..97425e49c9 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Input.CPP............ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "tony/gfxengine.h" -- cgit v1.2.3 From 88762667b52e4b904c56ecc94bf304c1a91e9feb Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 14 May 2012 21:29:27 +0200 Subject: TONY: Fix some formatting --- engines/tony/input.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/tony/input.cpp') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 97425e49c9..7663774ee4 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -32,7 +32,7 @@ namespace Tony { RMInput::RMInput() { // Setup mouse fields - _clampMouse = false; + _clampMouse = false; _mousePos.Set(0, 0); _leftButton = _rightButton = false;; @@ -89,7 +89,7 @@ void RMInput::Poll(void) { default: break; } - } + } } void RMInput::Init() { @@ -107,12 +107,12 @@ bool RMInput::MouseRight() { } /** - * Return true if a key has been pressed + * Return true if a key has been pressed */ -bool RMInput::GetAsyncKeyState(Common::KeyCode kc) { +bool RMInput::GetAsyncKeyState(Common::KeyCode kc) { // The act of testing for a particular key automatically clears the state, to prevent // the same key being registered in multiple different frames - bool result = _keyDown[(int)kc]; + bool result = _keyDown[(int)kc]; _keyDown[(int)kc] = false; return result; } -- cgit v1.2.3 From 6856fa2447195e8a65f6d5c7efa73543668d85b0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 22 May 2012 00:29:27 +1000 Subject: TONY: Implemented ScummVM debugger, with an initial 'scene' command --- engines/tony/input.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'engines/tony/input.cpp') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 7663774ee4..c1104204b5 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -27,6 +27,7 @@ */ #include "tony/gfxengine.h" +#include "tony/tony.h" namespace Tony { @@ -79,7 +80,15 @@ void RMInput::Poll(void) { return; case Common::EVENT_KEYDOWN: - _keyDown[(int)_event.kbd.keycode] = true; + // Check for debugger + if ((_event.kbd.keycode == Common::KEYCODE_d) && (_event.kbd.flags & Common::KBD_CTRL)) { + // Attach to the debugger + _vm->_debugger->attach(); + _vm->_debugger->onFrame(); + } else { + // Flag the given key as being down + _keyDown[(int)_event.kbd.keycode] = true; + } return; case Common::EVENT_KEYUP: -- cgit v1.2.3 From ea8c4960c7139440df9416366a78094f4753aa12 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jun 2012 17:15:24 +1000 Subject: TONY: Fix Valgrind warnings of checks on uninitialised variables --- engines/tony/input.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'engines/tony/input.cpp') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index c1104204b5..fc98544e14 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -35,11 +35,12 @@ RMInput::RMInput() { // Setup mouse fields _clampMouse = false; _mousePos.Set(0, 0); - _leftButton = _rightButton = false;; - + _leftButton = _rightButton = false; _leftClickMouse = _leftReleaseMouse = false; _rightClickMouse = _rightReleaseMouse = false; + Common::fill((byte *)&_event, (byte *)&_event + sizeof(Common::Event), 0); + // Setup keyboard fields Common::fill(&_keyDown[0], &_keyDown[350], 0); } -- cgit v1.2.3 From 014330a538244b0e33bcf230cc5e84c28977f096 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 5 Jun 2012 00:02:15 +0200 Subject: TONY: Rename variables and functions in input.h --- engines/tony/input.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/tony/input.cpp') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index fc98544e14..4990b379b9 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -49,7 +49,7 @@ RMInput::~RMInput() { } -void RMInput::Poll(void) { +void RMInput::poll(void) { _leftClickMouse = _leftReleaseMouse = _rightClickMouse = _rightReleaseMouse = false; // Get pending events @@ -102,24 +102,24 @@ void RMInput::Poll(void) { } } -void RMInput::Init() { +void RMInput::init() { } -void RMInput::Close(void) { +void RMInput::close(void) { } -bool RMInput::MouseLeft() { +bool RMInput::mouseLeft() { return _leftButton; } -bool RMInput::MouseRight() { +bool RMInput::mouseRight() { return _rightButton; } /** * Return true if a key has been pressed */ -bool RMInput::GetAsyncKeyState(Common::KeyCode kc) { +bool RMInput::getAsyncKeyState(Common::KeyCode kc) { // The act of testing for a particular key automatically clears the state, to prevent // the same key being registered in multiple different frames bool result = _keyDown[(int)kc]; -- cgit v1.2.3 From f12ab3e521b01ed2b40e7d517753dd14bc6e6f0f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 7 Jun 2012 08:42:35 +0200 Subject: TONY: Rename variables and functions in utils.h --- engines/tony/input.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/tony/input.cpp') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 4990b379b9..36cad4c6a1 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -34,7 +34,7 @@ namespace Tony { RMInput::RMInput() { // Setup mouse fields _clampMouse = false; - _mousePos.Set(0, 0); + _mousePos.set(0, 0); _leftButton = _rightButton = false; _leftClickMouse = _leftReleaseMouse = false; _rightClickMouse = _rightReleaseMouse = false; @@ -60,7 +60,7 @@ void RMInput::poll(void) { case Common::EVENT_LBUTTONUP: case Common::EVENT_RBUTTONDOWN: case Common::EVENT_RBUTTONUP: - _mousePos.Set(_event.mouse.x, _event.mouse.y); + _mousePos.set(_event.mouse.x, _event.mouse.y); if (_event.type == Common::EVENT_LBUTTONDOWN) { _leftButton = true; -- cgit v1.2.3 From e8a6f61f8815fcf36e7a43383695c74b8925993f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 Jun 2012 08:24:33 +0200 Subject: TONY: Remove useless void in function declaration --- engines/tony/input.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'engines/tony/input.cpp') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 36cad4c6a1..2a8cdc10c3 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -46,10 +46,9 @@ RMInput::RMInput() { } RMInput::~RMInput() { - } -void RMInput::poll(void) { +void RMInput::poll() { _leftClickMouse = _leftReleaseMouse = _rightClickMouse = _rightReleaseMouse = false; // Get pending events @@ -105,7 +104,7 @@ void RMInput::poll(void) { void RMInput::init() { } -void RMInput::close(void) { +void RMInput::close() { } bool RMInput::mouseLeft() { -- cgit v1.2.3 From b8d5e17fefd2a36e253a150fee324c912ca35384 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 Jun 2012 21:14:56 +1000 Subject: TONY: Added an extra check for shouldQuit into the main event loop --- engines/tony/input.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/tony/input.cpp') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 2a8cdc10c3..7d663c1465 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -52,7 +52,7 @@ void RMInput::poll() { _leftClickMouse = _leftReleaseMouse = _rightClickMouse = _rightReleaseMouse = false; // Get pending events - while (g_system->getEventManager()->pollEvent(_event)) { + while (g_system->getEventManager()->pollEvent(_event) && !_vm->shouldQuit()) { switch (_event.type) { case Common::EVENT_MOUSEMOVE: case Common::EVENT_LBUTTONDOWN: -- cgit v1.2.3 From c3407390013b1e1826bdb31979a50f5e8a957f04 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 22 Aug 2012 14:00:46 +0200 Subject: TONY: Replace _vm with g_vm. --- engines/tony/input.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/tony/input.cpp') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 7d663c1465..1e79032af2 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -52,7 +52,7 @@ void RMInput::poll() { _leftClickMouse = _leftReleaseMouse = _rightClickMouse = _rightReleaseMouse = false; // Get pending events - while (g_system->getEventManager()->pollEvent(_event) && !_vm->shouldQuit()) { + while (g_system->getEventManager()->pollEvent(_event) && !g_vm->shouldQuit()) { switch (_event.type) { case Common::EVENT_MOUSEMOVE: case Common::EVENT_LBUTTONDOWN: @@ -83,8 +83,8 @@ void RMInput::poll() { // Check for debugger if ((_event.kbd.keycode == Common::KEYCODE_d) && (_event.kbd.flags & Common::KBD_CTRL)) { // Attach to the debugger - _vm->_debugger->attach(); - _vm->_debugger->onFrame(); + g_vm->_debugger->attach(); + g_vm->_debugger->onFrame(); } else { // Flag the given key as being down _keyDown[(int)_event.kbd.keycode] = true; -- cgit v1.2.3 From 7b4dd0a682bf79cc86024d77d16411a6e2681f47 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Mon, 27 Aug 2012 12:39:58 +0200 Subject: TONY: Remove various bits of unused code. --- engines/tony/input.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'engines/tony/input.cpp') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 1e79032af2..88bc3f4092 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -101,12 +101,6 @@ void RMInput::poll() { } } -void RMInput::init() { -} - -void RMInput::close() { -} - bool RMInput::mouseLeft() { return _leftButton; } -- cgit v1.2.3 From 3ab8ebc4f72e54a5ffcabaa22d3cf8e250062457 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 1 Sep 2012 02:27:31 +0200 Subject: TONY: Move some more code from .h to .cpp files --- engines/tony/input.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'engines/tony/input.cpp') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 88bc3f4092..b96ccaf842 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -120,4 +120,38 @@ bool RMInput::getAsyncKeyState(Common::KeyCode kc) { return result; } +/** + * Reading of the mouse + */ +RMPoint RMInput::mousePos() { + return _mousePos; +} + +/** + * Events of mouse clicks + */ +bool RMInput::mouseLeftClicked() { + return _leftClickMouse; +} + +bool RMInput::mouseRightClicked() { + return _rightClickMouse; +} + +bool RMInput::mouseBothClicked() { + return _leftClickMouse && _rightClickMouse; +} + +bool RMInput::mouseLeftReleased() { + return _leftReleaseMouse; +} + +bool RMInput::mouseRightReleased() { + return _rightReleaseMouse; +} + +bool RMInput::mouseBothReleased() { + return _leftReleaseMouse && _rightReleaseMouse; +} + } // End of namespace Tony -- cgit v1.2.3