2012-09-08 08:45:22 +00:00
|
|
|
/* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/system.h"
|
2012-09-15 00:27:15 +00:00
|
|
|
#include "common/events.h"
|
2012-09-15 03:23:46 +00:00
|
|
|
#include "common/textconsole.h"
|
2012-09-08 08:45:22 +00:00
|
|
|
#include "hopkins/events.h"
|
|
|
|
|
|
|
|
namespace Hopkins {
|
|
|
|
|
2012-09-15 00:27:15 +00:00
|
|
|
EventsManager::EventsManager() {
|
|
|
|
souris_flag = false;
|
|
|
|
mouse_linux = false;
|
|
|
|
souris_sizex = souris_sizey = 0;
|
|
|
|
ofset_souris_x = ofset_souris_y = 0;
|
2012-09-15 03:23:46 +00:00
|
|
|
start_x = start_y = 0;
|
2012-09-15 00:27:15 +00:00
|
|
|
CASSE = false;
|
|
|
|
souris_n = 0;
|
|
|
|
souris_bb = 0;
|
|
|
|
souris_b = 0;
|
|
|
|
pointeur_souris = NULL;
|
|
|
|
lItCounter = 0;
|
|
|
|
ESC_KEY = false;
|
|
|
|
_priorFrameTime = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventsManager::INSTALL_SOURIS() {
|
2012-09-08 08:45:22 +00:00
|
|
|
// No implementation in original
|
|
|
|
}
|
|
|
|
|
2012-09-15 00:27:15 +00:00
|
|
|
void EventsManager::souris_on() {
|
2012-09-08 08:45:22 +00:00
|
|
|
souris_flag = true;
|
|
|
|
|
|
|
|
if (mouse_linux) {
|
|
|
|
souris_sizex = 52;
|
|
|
|
souris_sizey = 32;
|
|
|
|
} else {
|
|
|
|
souris_sizex = 34;
|
|
|
|
souris_sizey = 20;
|
|
|
|
}
|
|
|
|
|
|
|
|
ofset_souris_x = 0;
|
|
|
|
ofset_souris_y = 0;
|
|
|
|
|
|
|
|
if (!CASSE)
|
|
|
|
souris_xy(300, 200);
|
|
|
|
else
|
|
|
|
souris_xy(150, 100);
|
|
|
|
}
|
|
|
|
|
2012-09-15 00:27:15 +00:00
|
|
|
void EventsManager::souris_xy(int xp, int yp) {
|
2012-09-08 08:45:22 +00:00
|
|
|
g_system->warpMouse(xp, yp);
|
|
|
|
}
|
|
|
|
|
2012-09-15 00:27:15 +00:00
|
|
|
void EventsManager::souris_max() {
|
2012-09-08 08:45:22 +00:00
|
|
|
// No implementation in original
|
|
|
|
}
|
|
|
|
|
2012-09-15 03:23:46 +00:00
|
|
|
int EventsManager::XMOUSE() {
|
|
|
|
souris_x = start_x + g_system->getEventManager()->getMousePos().x;
|
|
|
|
souris_y = g_system->getEventManager()->getMousePos().y;
|
|
|
|
|
|
|
|
return souris_x + ofset_souris_x;
|
|
|
|
}
|
|
|
|
|
|
|
|
int EventsManager::YMOUSE() {
|
|
|
|
souris_x = start_x + g_system->getEventManager()->getMousePos().x;
|
|
|
|
souris_y = g_system->getEventManager()->getMousePos().y;
|
|
|
|
|
|
|
|
return souris_x + ofset_souris_x;
|
|
|
|
}
|
|
|
|
|
2012-09-15 00:27:15 +00:00
|
|
|
void EventsManager::hideCursor() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventsManager::showCursor() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventsManager::CONTROLE_MES() {
|
|
|
|
pollEvents();
|
2012-09-08 13:43:35 +00:00
|
|
|
}
|
|
|
|
|
2012-09-15 01:45:36 +00:00
|
|
|
void EventsManager::checkForNextFrameCounter() {
|
2012-09-15 00:27:15 +00:00
|
|
|
uint32 milli = g_system->getMillis();
|
|
|
|
if ((milli - _priorFrameTime) >= GAME_FRAME_TIME) {
|
|
|
|
_priorFrameTime = milli;
|
|
|
|
++lItCounter;
|
2012-09-15 01:45:36 +00:00
|
|
|
|
|
|
|
g_system->updateScreen();
|
2012-09-15 00:27:15 +00:00
|
|
|
}
|
2012-09-15 01:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventsManager::delay(int delay) {
|
|
|
|
uint32 delayEnd = g_system->getMillis() + delay;
|
2012-09-15 00:27:15 +00:00
|
|
|
|
2012-09-15 01:45:36 +00:00
|
|
|
while (!g_system->getEventManager()->shouldQuit() && g_system->getMillis() < delayEnd) {
|
|
|
|
g_system->delayMillis(10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventsManager::pollEvents() {
|
2012-09-15 11:42:20 +00:00
|
|
|
checkForNextFrameCounter();
|
|
|
|
|
2012-09-15 00:27:15 +00:00
|
|
|
Common::Event event;
|
|
|
|
while (g_system->getEventManager()->pollEvent(event)) {
|
|
|
|
// Handle keypress
|
|
|
|
switch (event.type) {
|
|
|
|
case Common::EVENT_QUIT:
|
|
|
|
case Common::EVENT_RTL:
|
|
|
|
return;
|
|
|
|
|
|
|
|
case Common::EVENT_KEYDOWN:
|
|
|
|
ESC_KEY = event.kbd.keycode == Common::KEYCODE_ESCAPE;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case Common::EVENT_LBUTTONDOWN:
|
|
|
|
case Common::EVENT_LBUTTONUP:
|
|
|
|
case Common::EVENT_RBUTTONDOWN:
|
|
|
|
case Common::EVENT_RBUTTONUP:
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-09-08 13:43:35 +00:00
|
|
|
}
|
|
|
|
|
2012-09-15 03:23:46 +00:00
|
|
|
void EventsManager::VBL() {
|
|
|
|
warning("TODO: VBL");
|
|
|
|
}
|
|
|
|
|
2012-09-08 08:45:22 +00:00
|
|
|
} // End of namespace Hopkins
|