2007-05-30 21:56:52 +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.
|
2007-03-17 00:07:34 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if !defined(DISABLE_DEFAULT_EVENTMANAGER)
|
|
|
|
|
|
|
|
#include "common/system.h"
|
2007-09-19 13:55:05 +00:00
|
|
|
#include "common/config-manager.h"
|
2007-03-17 00:07:34 +00:00
|
|
|
#include "backends/events/default/default-events.h"
|
2008-08-07 16:38:39 +00:00
|
|
|
#include "backends/keymapper/keymapper.h"
|
2008-08-08 14:23:59 +00:00
|
|
|
#include "backends/keymapper/remap-dialog.h"
|
2008-08-07 16:38:39 +00:00
|
|
|
#include "backends/vkeybd/virtual-keyboard.h"
|
2007-06-30 18:22:21 +00:00
|
|
|
|
|
|
|
#include "engines/engine.h"
|
2007-06-30 12:43:53 +00:00
|
|
|
#include "gui/message.h"
|
2007-03-17 00:07:34 +00:00
|
|
|
|
2007-09-19 13:55:05 +00:00
|
|
|
#define RECORD_SIGNATURE 0x54455354
|
|
|
|
#define RECORD_VERSION 1
|
|
|
|
|
|
|
|
void readRecord(Common::InSaveFile *inFile, uint32 &diff, Common::Event &event) {
|
|
|
|
diff = inFile->readUint32LE();
|
|
|
|
|
|
|
|
event.type = (Common::EventType)inFile->readUint32LE();
|
|
|
|
|
|
|
|
switch(event.type) {
|
|
|
|
case Common::EVENT_KEYDOWN:
|
|
|
|
case Common::EVENT_KEYUP:
|
|
|
|
event.kbd.keycode = (Common::KeyCode)inFile->readSint32LE();
|
|
|
|
event.kbd.ascii = inFile->readUint16LE();
|
|
|
|
event.kbd.flags = inFile->readByte();
|
|
|
|
break;
|
|
|
|
case Common::EVENT_MOUSEMOVE:
|
|
|
|
case Common::EVENT_LBUTTONDOWN:
|
|
|
|
case Common::EVENT_LBUTTONUP:
|
|
|
|
case Common::EVENT_RBUTTONDOWN:
|
|
|
|
case Common::EVENT_RBUTTONUP:
|
|
|
|
case Common::EVENT_WHEELUP:
|
|
|
|
case Common::EVENT_WHEELDOWN:
|
|
|
|
event.mouse.x = inFile->readSint16LE();
|
|
|
|
event.mouse.y = inFile->readSint16LE();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2008-01-27 19:47:41 +00:00
|
|
|
}
|
2007-09-19 13:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void writeRecord(Common::OutSaveFile *outFile, uint32 diff, Common::Event &event) {
|
|
|
|
outFile->writeUint32LE(diff);
|
|
|
|
|
|
|
|
outFile->writeUint32LE((uint32)event.type);
|
|
|
|
|
|
|
|
switch(event.type) {
|
|
|
|
case Common::EVENT_KEYDOWN:
|
|
|
|
case Common::EVENT_KEYUP:
|
|
|
|
outFile->writeSint32LE(event.kbd.keycode);
|
|
|
|
outFile->writeUint16LE(event.kbd.ascii);
|
|
|
|
outFile->writeByte(event.kbd.flags);
|
|
|
|
break;
|
|
|
|
case Common::EVENT_MOUSEMOVE:
|
|
|
|
case Common::EVENT_LBUTTONDOWN:
|
|
|
|
case Common::EVENT_LBUTTONUP:
|
|
|
|
case Common::EVENT_RBUTTONDOWN:
|
|
|
|
case Common::EVENT_RBUTTONUP:
|
|
|
|
case Common::EVENT_WHEELUP:
|
|
|
|
case Common::EVENT_WHEELDOWN:
|
|
|
|
outFile->writeSint16LE(event.mouse.x);
|
|
|
|
outFile->writeSint16LE(event.mouse.y);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-30 03:35:47 +00:00
|
|
|
DefaultEventManager::DefaultEventManager(EventProvider *boss) :
|
2007-03-17 00:07:34 +00:00
|
|
|
_boss(boss),
|
|
|
|
_buttonState(0),
|
|
|
|
_modifierState(0),
|
2008-07-02 00:30:49 +00:00
|
|
|
_shouldQuit(false),
|
2009-01-02 01:21:38 +00:00
|
|
|
_shouldRTL(false),
|
|
|
|
_confirmExitDialogActive(false) {
|
2007-03-17 00:07:34 +00:00
|
|
|
|
2008-01-28 00:14:17 +00:00
|
|
|
assert(_boss);
|
2007-03-17 15:44:26 +00:00
|
|
|
|
2007-09-19 13:55:05 +00:00
|
|
|
_recordFile = NULL;
|
|
|
|
_recordTimeFile = NULL;
|
|
|
|
_playbackFile = NULL;
|
|
|
|
_playbackTimeFile = NULL;
|
2009-01-30 03:35:47 +00:00
|
|
|
_timeMutex = g_system->createMutex();
|
|
|
|
_recorderMutex = g_system->createMutex();
|
2007-09-19 13:55:05 +00:00
|
|
|
|
|
|
|
_eventCount = 0;
|
|
|
|
_lastEventCount = 0;
|
|
|
|
_lastMillis = 0;
|
|
|
|
|
|
|
|
Common::String recordModeString = ConfMan.get("record_mode");
|
|
|
|
if (recordModeString.compareToIgnoreCase("record") == 0) {
|
|
|
|
_recordMode = kRecorderRecord;
|
|
|
|
} else {
|
|
|
|
if (recordModeString.compareToIgnoreCase("playback") == 0) {
|
|
|
|
_recordMode = kRecorderPlayback;
|
|
|
|
} else {
|
|
|
|
_recordMode = kPassthrough;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_recordFileName = ConfMan.get("record_file_name");
|
|
|
|
if (_recordFileName.empty()) {
|
|
|
|
_recordFileName = "record.bin";
|
|
|
|
}
|
|
|
|
_recordTempFileName = ConfMan.get("record_temp_file_name");
|
|
|
|
if (_recordTempFileName.empty()) {
|
|
|
|
_recordTempFileName = "record.tmp";
|
|
|
|
}
|
|
|
|
_recordTimeFileName = ConfMan.get("record_time_file_name");
|
|
|
|
if (_recordTimeFileName.empty()) {
|
|
|
|
_recordTimeFileName = "record.time";
|
|
|
|
}
|
|
|
|
|
2007-03-17 15:44:26 +00:00
|
|
|
// Reset key repeat
|
|
|
|
_currentKeyDown.keycode = 0;
|
2007-09-19 13:55:05 +00:00
|
|
|
|
|
|
|
// recorder stuff
|
|
|
|
if (_recordMode == kRecorderRecord) {
|
|
|
|
_recordCount = 0;
|
|
|
|
_recordTimeCount = 0;
|
2009-05-29 14:38:22 +00:00
|
|
|
_recordFile = g_system->getSavefileManager()->openForSaving(_recordTempFileName);
|
|
|
|
_recordTimeFile = g_system->getSavefileManager()->openForSaving(_recordTimeFileName);
|
2007-09-19 13:55:05 +00:00
|
|
|
_recordSubtitles = ConfMan.getBool("subtitles");
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 sign;
|
|
|
|
uint32 version;
|
|
|
|
uint32 randomSourceCount;
|
|
|
|
if (_recordMode == kRecorderPlayback) {
|
|
|
|
_playbackCount = 0;
|
|
|
|
_playbackTimeCount = 0;
|
2009-05-29 14:38:22 +00:00
|
|
|
_playbackFile = g_system->getSavefileManager()->openForLoading(_recordFileName);
|
|
|
|
_playbackTimeFile = g_system->getSavefileManager()->openForLoading(_recordTimeFileName);
|
2007-09-19 13:55:05 +00:00
|
|
|
|
|
|
|
if (!_playbackFile) {
|
|
|
|
warning("Cannot open playback file %s. Playback was switched off", _recordFileName.c_str());
|
|
|
|
_recordMode = kPassthrough;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_playbackTimeFile) {
|
|
|
|
warning("Cannot open playback time file %s. Playback was switched off", _recordTimeFileName.c_str());
|
|
|
|
_recordMode = kPassthrough;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_recordMode == kRecorderPlayback) {
|
|
|
|
sign = _playbackFile->readUint32LE();
|
|
|
|
if (sign != RECORD_SIGNATURE) {
|
|
|
|
error("Unknown record file signature");
|
|
|
|
}
|
|
|
|
version = _playbackFile->readUint32LE();
|
|
|
|
|
|
|
|
// conf vars
|
|
|
|
ConfMan.setBool("subtitles", _playbackFile->readByte() != 0);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-09-19 13:55:05 +00:00
|
|
|
_recordCount = _playbackFile->readUint32LE();
|
|
|
|
_recordTimeCount = _playbackFile->readUint32LE();
|
|
|
|
randomSourceCount = _playbackFile->readUint32LE();
|
|
|
|
for (uint i = 0; i < randomSourceCount; ++i) {
|
|
|
|
RandomSourceRecord rec;
|
|
|
|
rec.name = "";
|
|
|
|
uint32 sLen = _playbackFile->readUint32LE();
|
|
|
|
for (uint j = 0; j < sLen; ++j) {
|
|
|
|
char c = _playbackFile->readSByte();
|
|
|
|
rec.name += c;
|
|
|
|
}
|
|
|
|
rec.seed = _playbackFile->readUint32LE();
|
|
|
|
_randomSourceRecords.push_back(rec);
|
|
|
|
}
|
|
|
|
|
|
|
|
_hasPlaybackEvent = false;
|
|
|
|
}
|
2008-07-07 14:30:11 +00:00
|
|
|
|
2008-09-30 13:51:01 +00:00
|
|
|
#ifdef ENABLE_VKEYBD
|
2008-07-07 15:42:26 +00:00
|
|
|
_vk = new Common::VirtualKeyboard();
|
2008-09-30 13:51:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_KEYMAPPER
|
2008-08-06 14:21:05 +00:00
|
|
|
_keymapper = new Common::Keymapper(this);
|
2008-08-13 19:24:52 +00:00
|
|
|
_remap = false;
|
2008-09-30 13:51:01 +00:00
|
|
|
#endif
|
2007-09-19 13:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DefaultEventManager::~DefaultEventManager() {
|
2008-09-30 13:51:01 +00:00
|
|
|
#ifdef ENABLE_KEYMAPPER
|
2008-08-06 14:21:05 +00:00
|
|
|
delete _keymapper;
|
2008-09-30 13:51:01 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_VKEYBD
|
2008-07-09 13:33:36 +00:00
|
|
|
delete _vk;
|
2008-09-30 13:51:01 +00:00
|
|
|
#endif
|
2009-01-30 03:35:47 +00:00
|
|
|
g_system->lockMutex(_timeMutex);
|
|
|
|
g_system->lockMutex(_recorderMutex);
|
2007-09-19 13:55:05 +00:00
|
|
|
_recordMode = kPassthrough;
|
2009-01-30 03:35:47 +00:00
|
|
|
g_system->unlockMutex(_timeMutex);
|
|
|
|
g_system->unlockMutex(_recorderMutex);
|
2007-09-19 13:55:05 +00:00
|
|
|
|
2008-07-07 22:34:45 +00:00
|
|
|
if (!artificialEventQueue.empty())
|
|
|
|
artificialEventQueue.clear();
|
|
|
|
|
2007-09-19 13:55:05 +00:00
|
|
|
if (_playbackFile != NULL) {
|
|
|
|
delete _playbackFile;
|
|
|
|
}
|
|
|
|
if (_playbackTimeFile != NULL) {
|
|
|
|
delete _playbackTimeFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_recordFile != NULL) {
|
|
|
|
_recordFile->finalize();
|
|
|
|
delete _recordFile;
|
|
|
|
_recordTimeFile->finalize();
|
|
|
|
delete _recordTimeFile;
|
|
|
|
|
2009-05-29 14:38:22 +00:00
|
|
|
_playbackFile = g_system->getSavefileManager()->openForLoading(_recordTempFileName);
|
2007-09-19 13:55:05 +00:00
|
|
|
|
2009-05-21 22:23:04 +00:00
|
|
|
assert(_playbackFile);
|
|
|
|
|
2009-05-29 14:38:22 +00:00
|
|
|
_recordFile = g_system->getSavefileManager()->openForSaving(_recordFileName);
|
2007-09-19 13:55:05 +00:00
|
|
|
_recordFile->writeUint32LE(RECORD_SIGNATURE);
|
|
|
|
_recordFile->writeUint32LE(RECORD_VERSION);
|
|
|
|
|
|
|
|
// conf vars
|
|
|
|
_recordFile->writeByte(_recordSubtitles ? 1 : 0);
|
|
|
|
|
|
|
|
_recordFile->writeUint32LE(_recordCount);
|
|
|
|
_recordFile->writeUint32LE(_recordTimeCount);
|
|
|
|
|
|
|
|
_recordFile->writeUint32LE(_randomSourceRecords.size());
|
|
|
|
for (uint i = 0; i < _randomSourceRecords.size(); ++i) {
|
|
|
|
_recordFile->writeUint32LE(_randomSourceRecords[i].name.size());
|
|
|
|
_recordFile->writeString(_randomSourceRecords[i].name);
|
|
|
|
_recordFile->writeUint32LE(_randomSourceRecords[i].seed);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint i = 0; i < _recordCount; ++i) {
|
|
|
|
uint32 tempDiff;
|
|
|
|
Common::Event tempEvent;
|
|
|
|
readRecord(_playbackFile, tempDiff, tempEvent);
|
|
|
|
writeRecord(_recordFile, tempDiff, tempEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
_recordFile->finalize();
|
|
|
|
delete _recordFile;
|
|
|
|
delete _playbackFile;
|
|
|
|
|
|
|
|
//TODO: remove recordTempFileName'ed file
|
|
|
|
}
|
2009-01-30 03:35:47 +00:00
|
|
|
g_system->deleteMutex(_timeMutex);
|
|
|
|
g_system->deleteMutex(_recorderMutex);
|
2007-09-19 13:55:05 +00:00
|
|
|
}
|
|
|
|
|
2008-08-18 10:07:11 +00:00
|
|
|
void DefaultEventManager::init() {
|
2008-09-30 13:51:01 +00:00
|
|
|
#ifdef ENABLE_VKEYBD
|
2008-08-18 10:07:11 +00:00
|
|
|
if (ConfMan.hasKey("vkeybd_pack_name")) {
|
|
|
|
_vk->loadKeyboardPack(ConfMan.get("vkeybd_pack_name"));
|
|
|
|
} else {
|
2009-06-08 14:47:38 +00:00
|
|
|
_vk->loadKeyboardPack("vkeybd_default");
|
2008-08-18 10:07:11 +00:00
|
|
|
}
|
2008-09-30 13:51:01 +00:00
|
|
|
#endif
|
2008-08-18 10:07:11 +00:00
|
|
|
}
|
|
|
|
|
2007-09-19 13:55:05 +00:00
|
|
|
bool DefaultEventManager::playback(Common::Event &event) {
|
|
|
|
|
|
|
|
if (!_hasPlaybackEvent) {
|
|
|
|
if (_recordCount > _playbackCount) {
|
2007-09-24 17:15:21 +00:00
|
|
|
readRecord(_playbackFile, const_cast<uint32&>(_playbackDiff), _playbackEvent);
|
2007-09-19 13:55:05 +00:00
|
|
|
_playbackCount++;
|
|
|
|
_hasPlaybackEvent = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_hasPlaybackEvent) {
|
|
|
|
if (_playbackDiff <= (_eventCount - _lastEventCount)) {
|
|
|
|
switch(_playbackEvent.type) {
|
|
|
|
case Common::EVENT_MOUSEMOVE:
|
|
|
|
case Common::EVENT_LBUTTONDOWN:
|
|
|
|
case Common::EVENT_LBUTTONUP:
|
|
|
|
case Common::EVENT_RBUTTONDOWN:
|
|
|
|
case Common::EVENT_RBUTTONUP:
|
|
|
|
case Common::EVENT_WHEELUP:
|
|
|
|
case Common::EVENT_WHEELDOWN:
|
2009-01-30 03:35:47 +00:00
|
|
|
g_system->warpMouse(_playbackEvent.mouse.x, _playbackEvent.mouse.y);
|
2007-09-19 13:55:05 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2008-01-27 19:47:41 +00:00
|
|
|
}
|
2007-09-19 13:55:05 +00:00
|
|
|
event = _playbackEvent;
|
|
|
|
_hasPlaybackEvent = false;
|
|
|
|
_lastEventCount = _eventCount;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultEventManager::record(Common::Event &event) {
|
|
|
|
writeRecord(_recordFile, _eventCount - _lastEventCount, event);
|
|
|
|
|
|
|
|
_recordCount++;
|
|
|
|
_lastEventCount = _eventCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultEventManager::registerRandomSource(Common::RandomSource &rnd, const char *name) {
|
|
|
|
|
|
|
|
if (_recordMode == kRecorderRecord) {
|
|
|
|
RandomSourceRecord rec;
|
|
|
|
rec.name = name;
|
|
|
|
rec.seed = rnd.getSeed();
|
|
|
|
_randomSourceRecords.push_back(rec);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_recordMode == kRecorderPlayback) {
|
|
|
|
for (uint i = 0; i < _randomSourceRecords.size(); ++i) {
|
|
|
|
if (_randomSourceRecords[i].name == name) {
|
|
|
|
rnd.setSeed(_randomSourceRecords[i].seed);
|
|
|
|
_randomSourceRecords.remove_at(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultEventManager::processMillis(uint32 &millis) {
|
|
|
|
uint32 d;
|
|
|
|
if (_recordMode == kPassthrough) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-01-30 03:35:47 +00:00
|
|
|
g_system->lockMutex(_timeMutex);
|
2007-09-19 13:55:05 +00:00
|
|
|
if (_recordMode == kRecorderRecord) {
|
|
|
|
//Simple RLE compression
|
|
|
|
d = millis - _lastMillis;
|
|
|
|
if (d >= 0xff) {
|
|
|
|
_recordTimeFile->writeByte(0xff);
|
|
|
|
_recordTimeFile->writeUint32LE(d);
|
|
|
|
} else {
|
|
|
|
_recordTimeFile->writeByte(d);
|
|
|
|
}
|
|
|
|
_recordTimeCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_recordMode == kRecorderPlayback) {
|
|
|
|
if (_recordTimeCount > _playbackTimeCount) {
|
|
|
|
d = _playbackTimeFile->readByte();
|
|
|
|
if (d == 0xff) {
|
|
|
|
d = _playbackTimeFile->readUint32LE();
|
|
|
|
}
|
|
|
|
millis = _lastMillis + d;
|
|
|
|
_playbackTimeCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_lastMillis = millis;
|
2009-01-30 03:35:47 +00:00
|
|
|
g_system->unlockMutex(_timeMutex);
|
2007-03-17 00:07:34 +00:00
|
|
|
}
|
|
|
|
|
2007-03-17 19:02:05 +00:00
|
|
|
bool DefaultEventManager::pollEvent(Common::Event &event) {
|
2009-01-30 03:35:47 +00:00
|
|
|
uint32 time = g_system->getMillis();
|
2007-03-17 00:07:34 +00:00
|
|
|
bool result;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2008-07-07 22:34:45 +00:00
|
|
|
if (!artificialEventQueue.empty()) {
|
2008-07-09 02:27:05 +00:00
|
|
|
event = artificialEventQueue.pop();
|
2008-07-07 22:34:45 +00:00
|
|
|
result = true;
|
Merged revisions 33452-33453,33455-33459,33463-33464,33466-33471,33473-33474,33478,33490,33492,33495-33496,33509-33512,33518-33519,33522-33527,33529-33530,33537,33541,33544,33546,33550,33552-33554,33556,33558,33561-33562,33565,33568,33570,33574,33576,33578-33581,33584-33587,33590,33596,33604-33611,33614-33615,33617-33618,33620-33621,33623,33626-33627,33632-33633,33635,33637,33639-33640,33642-33645,33648,33654-33655,33664,33667-33670,33673-33674,33678,33682,33686-33691,33693,33696,33698,33700,33703,33708,33710,33712-33714,33716,33719,33721-33723,33725-33727,33729-33730,33733,33736,33742,33754,33756,33758,33761,33763,33766,33777,33781-33788,33790,33792-33793,33795,33797,33805,33807-33812,33815-33817,33819,33822,33826,33829,33837,33839,33844,33847,33858-33861,33864,33871-33873,33875,33877-33879,33886,33889-33892,33894,33896,33900,33902-33903,33919,33928,33930,33932-33936,33938-33940,33942-33943,33948,33950,33953,33967,33973,33976,33978,33980,33985,33991,33993,33999-34000,34006,34009,34011,34013,34015,34019,34021-34023,34025,34027-34028,34030,34032-34034,34036,34038-34039,34041,34046-34048,34050-34055,34057,34059-34065,34067,34072,34074,34076,34078-34081,34084,34086-34087,34089-34090,34093,34096-34102,34104,34107,34113,34116,34119,34122,34124,34126,34128,34131-34132,34135,34138,34141,34144,34146,34149,34152-34154,34156-34157,34160,34163-34164,34169,34173,34179-34194,34196-34198,34200-34201,34205-34206,34208-34217,34219-34225,34227-34228,34234-34237,34239-34249,34251-34279,34281-34284,34286-34288,34290-34320,34323-34324,34326,34328-34329,34332,34334,34336,34338-34340,34343-34353,34356-34357,34359-34371,34373,34375,34378,34381-34382,34384-34385,34389-34391,34393-34394,34396-34397,34399-34405,34407-34409,34411,34413,34415,34417-34420,34423-34426,34428-34438,34440-34454,34456-34458,34460,34462-34469,34472,34474,34479-34481,34483-34498,34501-34505,34508,34511-34518,34520-34524,34526-34563,34566-34569,34571-34590,34592,34595-34599,34602-34603,34605,34613-34615,34617,34619-34624,34627-34628,34630-34639,34642-34649 via svnmerge from
https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk
svn-id: r34654
2008-09-26 21:53:08 +00:00
|
|
|
} else {
|
2008-07-07 22:34:45 +00:00
|
|
|
result = _boss->pollEvent(event);
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2008-09-30 13:51:01 +00:00
|
|
|
#ifdef ENABLE_KEYMAPPER
|
2008-07-23 08:45:12 +00:00
|
|
|
if (result) {
|
|
|
|
// send key press events to keymapper
|
|
|
|
if (event.type == Common::EVENT_KEYDOWN) {
|
2008-08-23 17:04:40 +00:00
|
|
|
if (_keymapper->mapKeyDown(event.kbd)) {
|
2008-07-23 08:45:12 +00:00
|
|
|
result = false;
|
2008-08-23 17:04:40 +00:00
|
|
|
}
|
2008-07-23 08:45:12 +00:00
|
|
|
} else if (event.type == Common::EVENT_KEYUP) {
|
2008-08-23 17:04:40 +00:00
|
|
|
if (_keymapper->mapKeyUp(event.kbd)) {
|
2008-07-23 08:45:12 +00:00
|
|
|
result = false;
|
2008-08-23 17:04:40 +00:00
|
|
|
}
|
2008-07-23 08:45:12 +00:00
|
|
|
}
|
|
|
|
}
|
2008-09-30 13:51:01 +00:00
|
|
|
#endif
|
2008-07-23 08:45:12 +00:00
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-09-19 13:55:05 +00:00
|
|
|
if (_recordMode != kPassthrough) {
|
|
|
|
|
2009-01-30 03:35:47 +00:00
|
|
|
g_system->lockMutex(_recorderMutex);
|
2007-09-19 13:55:05 +00:00
|
|
|
_eventCount++;
|
|
|
|
|
|
|
|
if (_recordMode == kRecorderPlayback) {
|
|
|
|
if (event.type != Common::EVENT_QUIT) {
|
|
|
|
result = playback(event);
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
} else {
|
2007-09-19 13:55:05 +00:00
|
|
|
if (_recordMode == kRecorderRecord) {
|
|
|
|
if (result) {
|
|
|
|
record(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-01-30 03:35:47 +00:00
|
|
|
g_system->unlockMutex(_recorderMutex);
|
2007-09-19 13:55:05 +00:00
|
|
|
}
|
|
|
|
|
2007-03-17 00:07:34 +00:00
|
|
|
if (result) {
|
2007-03-17 15:44:26 +00:00
|
|
|
event.synthetic = false;
|
2007-03-17 00:07:34 +00:00
|
|
|
switch (event.type) {
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_KEYDOWN:
|
2007-03-17 15:44:26 +00:00
|
|
|
_modifierState = event.kbd.flags;
|
|
|
|
// init continuous event stream
|
|
|
|
// not done on PalmOS because keyboard is emulated and keyup is not generated
|
|
|
|
#if !defined(PALMOS_MODE)
|
|
|
|
_currentKeyDown.ascii = event.kbd.ascii;
|
|
|
|
_currentKeyDown.keycode = event.kbd.keycode;
|
|
|
|
_currentKeyDown.flags = event.kbd.flags;
|
|
|
|
_keyRepeatTime = time + kKeyRepeatInitialDelay;
|
|
|
|
#endif
|
2008-06-24 21:15:30 +00:00
|
|
|
// Global Main Menu
|
2009-02-07 07:05:08 +00:00
|
|
|
if (event.kbd.flags == Common::KBD_CTRL && event.kbd.keycode == Common::KEYCODE_F5) {
|
2008-07-09 02:27:05 +00:00
|
|
|
if (g_engine && !g_engine->isPaused()) {
|
|
|
|
Common::Event menuEvent;
|
|
|
|
menuEvent.type = Common::EVENT_MAINMENU;
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-09-01 17:30:03 +00:00
|
|
|
// FIXME: GSoC RTL branch passes the F6 key event to the
|
|
|
|
// engine, and also enqueues a EVENT_MAINMENU. For now,
|
|
|
|
// we just drop the key event and return an EVENT_MAINMENU
|
|
|
|
// instead. This way, we don't have to add special cases
|
|
|
|
// to engines (like it was the case for LURE in the RTL branch).
|
|
|
|
//
|
|
|
|
// However, this has other consequences, possibly negative ones.
|
|
|
|
// Like, what happens with key repeat for the trigger key?
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-09-01 17:30:03 +00:00
|
|
|
//pushEvent(menuEvent);
|
|
|
|
event = menuEvent;
|
2008-09-02 13:27:26 +00:00
|
|
|
|
|
|
|
// FIXME: Since now we do not push another MAINMENU event onto
|
|
|
|
// our event stack, the GMM would never open, so we have to do
|
|
|
|
// that here. Of course when the engine would handle MAINMENU
|
|
|
|
// as an event now and open up the GMM itself it would open the
|
|
|
|
// menu twice.
|
|
|
|
if (g_engine && !g_engine->isPaused())
|
2008-10-02 17:55:08 +00:00
|
|
|
g_engine->openMainMenuDialog();
|
2008-09-02 13:27:26 +00:00
|
|
|
|
|
|
|
if (_shouldQuit)
|
|
|
|
event.type = Common::EVENT_QUIT;
|
|
|
|
else if (_shouldRTL)
|
|
|
|
event.type = Common::EVENT_RTL;
|
2008-07-09 02:27:05 +00:00
|
|
|
}
|
2008-09-02 13:27:26 +00:00
|
|
|
}
|
2009-05-24 15:17:42 +00:00
|
|
|
#ifdef ENABLE_VKEYBD
|
2008-09-30 13:51:01 +00:00
|
|
|
else if (event.kbd.keycode == Common::KEYCODE_F7 && event.kbd.flags == 0) {
|
2008-07-07 14:30:11 +00:00
|
|
|
if (_vk->isDisplaying()) {
|
2008-08-15 01:21:29 +00:00
|
|
|
_vk->close(true);
|
2008-07-11 20:10:14 +00:00
|
|
|
} else {
|
2009-01-30 04:41:57 +00:00
|
|
|
if (g_engine)
|
|
|
|
g_engine->pauseEngine(true);
|
2008-08-18 10:07:11 +00:00
|
|
|
_vk->show();
|
2009-01-30 04:41:57 +00:00
|
|
|
if (g_engine)
|
|
|
|
g_engine->pauseEngine(false);
|
2008-08-18 10:07:11 +00:00
|
|
|
result = false;
|
2008-07-07 14:30:11 +00:00
|
|
|
}
|
2008-09-30 13:51:01 +00:00
|
|
|
}
|
|
|
|
#endif
|
2009-05-24 15:17:42 +00:00
|
|
|
#ifdef ENABLE_KEYMAPPER
|
2008-09-30 13:51:01 +00:00
|
|
|
else if (event.kbd.keycode == Common::KEYCODE_F8 && event.kbd.flags == 0) {
|
2008-08-13 19:24:52 +00:00
|
|
|
if (!_remap) {
|
|
|
|
_remap = true;
|
|
|
|
Common::RemapDialog _remapDialog;
|
2009-01-30 04:41:57 +00:00
|
|
|
if (g_engine)
|
|
|
|
g_engine->pauseEngine(true);
|
2008-08-13 19:24:52 +00:00
|
|
|
_remapDialog.runModal();
|
2009-01-30 04:41:57 +00:00
|
|
|
if (g_engine)
|
|
|
|
g_engine->pauseEngine(false);
|
2008-08-13 19:24:52 +00:00
|
|
|
_remap = false;
|
|
|
|
}
|
2008-07-07 14:30:11 +00:00
|
|
|
}
|
2008-09-30 13:51:01 +00:00
|
|
|
#endif
|
2007-03-17 15:44:26 +00:00
|
|
|
break;
|
2008-06-24 21:15:30 +00:00
|
|
|
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_KEYUP:
|
2007-03-17 00:07:34 +00:00
|
|
|
_modifierState = event.kbd.flags;
|
2007-03-17 15:44:26 +00:00
|
|
|
if (event.kbd.keycode == _currentKeyDown.keycode) {
|
|
|
|
// Only stop firing events if it's the current key
|
|
|
|
_currentKeyDown.keycode = 0;
|
|
|
|
}
|
2007-03-17 00:07:34 +00:00
|
|
|
break;
|
2007-03-17 15:44:26 +00:00
|
|
|
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_MOUSEMOVE:
|
2007-03-17 00:07:34 +00:00
|
|
|
_mousePos = event.mouse;
|
|
|
|
break;
|
|
|
|
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_LBUTTONDOWN:
|
2007-03-17 00:07:34 +00:00
|
|
|
_mousePos = event.mouse;
|
|
|
|
_buttonState |= LBUTTON;
|
|
|
|
break;
|
2008-06-24 21:15:30 +00:00
|
|
|
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_LBUTTONUP:
|
2007-03-17 00:07:34 +00:00
|
|
|
_mousePos = event.mouse;
|
|
|
|
_buttonState &= ~LBUTTON;
|
|
|
|
break;
|
|
|
|
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_RBUTTONDOWN:
|
2007-03-17 00:07:34 +00:00
|
|
|
_mousePos = event.mouse;
|
|
|
|
_buttonState |= RBUTTON;
|
|
|
|
break;
|
2008-06-24 21:15:30 +00:00
|
|
|
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_RBUTTONUP:
|
2007-03-17 00:07:34 +00:00
|
|
|
_mousePos = event.mouse;
|
|
|
|
_buttonState &= ~RBUTTON;
|
|
|
|
break;
|
|
|
|
|
2008-06-24 21:15:30 +00:00
|
|
|
case Common::EVENT_MAINMENU:
|
|
|
|
if (g_engine && !g_engine->isPaused())
|
2008-10-02 17:55:08 +00:00
|
|
|
g_engine->openMainMenuDialog();
|
2008-07-16 04:22:56 +00:00
|
|
|
|
2008-07-11 00:49:01 +00:00
|
|
|
if (_shouldQuit)
|
|
|
|
event.type = Common::EVENT_QUIT;
|
2008-07-16 04:22:56 +00:00
|
|
|
else if (_shouldRTL)
|
|
|
|
event.type = Common::EVENT_RTL;
|
2008-07-07 22:34:45 +00:00
|
|
|
break;
|
2008-07-02 00:30:49 +00:00
|
|
|
|
2008-07-07 22:34:45 +00:00
|
|
|
case Common::EVENT_RTL:
|
2008-11-11 12:28:46 +00:00
|
|
|
if (ConfMan.getBool("confirm_exit")) {
|
|
|
|
if (g_engine)
|
|
|
|
g_engine->pauseEngine(true);
|
|
|
|
GUI::MessageDialog alert("Do you really want to return to the Launcher?", "Launcher", "Cancel");
|
|
|
|
result = _shouldRTL = (alert.runModal() == GUI::kMessageOK);
|
|
|
|
if (g_engine)
|
|
|
|
g_engine->pauseEngine(false);
|
|
|
|
} else
|
|
|
|
_shouldRTL = true;
|
2008-07-07 22:34:45 +00:00
|
|
|
break;
|
2008-06-24 21:15:30 +00:00
|
|
|
|
2009-06-06 17:36:06 +00:00
|
|
|
case Common::EVENT_MUTE:
|
|
|
|
if (g_engine)
|
|
|
|
g_engine->flipMute();
|
|
|
|
break;
|
|
|
|
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_QUIT:
|
2007-06-30 12:43:53 +00:00
|
|
|
if (ConfMan.getBool("confirm_exit")) {
|
2009-01-02 01:21:38 +00:00
|
|
|
if (_confirmExitDialogActive) {
|
|
|
|
result = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
_confirmExitDialogActive = true;
|
2007-07-01 18:22:25 +00:00
|
|
|
if (g_engine)
|
|
|
|
g_engine->pauseEngine(true);
|
2008-11-11 12:28:46 +00:00
|
|
|
GUI::MessageDialog alert("Do you really want to quit?", "Quit", "Cancel");
|
2007-06-30 18:22:21 +00:00
|
|
|
result = _shouldQuit = (alert.runModal() == GUI::kMessageOK);
|
2007-07-01 18:22:25 +00:00
|
|
|
if (g_engine)
|
|
|
|
g_engine->pauseEngine(false);
|
2009-01-02 01:21:38 +00:00
|
|
|
_confirmExitDialogActive = false;
|
2007-06-30 12:43:53 +00:00
|
|
|
} else
|
|
|
|
_shouldQuit = true;
|
2008-07-02 00:30:49 +00:00
|
|
|
|
2007-03-17 00:07:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2007-03-17 15:44:26 +00:00
|
|
|
} else {
|
|
|
|
// Check if event should be sent again (keydown)
|
|
|
|
if (_currentKeyDown.keycode != 0 && _keyRepeatTime < time) {
|
|
|
|
// fire event
|
2007-03-17 19:02:05 +00:00
|
|
|
event.type = Common::EVENT_KEYDOWN;
|
2007-03-17 15:44:26 +00:00
|
|
|
event.synthetic = true;
|
|
|
|
event.kbd.ascii = _currentKeyDown.ascii;
|
2007-06-21 18:35:15 +00:00
|
|
|
event.kbd.keycode = (Common::KeyCode)_currentKeyDown.keycode;
|
2007-03-17 15:44:26 +00:00
|
|
|
event.kbd.flags = _currentKeyDown.flags;
|
|
|
|
_keyRepeatTime = time + kKeyRepeatSustainDelay;
|
|
|
|
result = true;
|
|
|
|
}
|
2007-03-17 00:07:34 +00:00
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-03-17 00:07:34 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2008-07-21 18:53:55 +00:00
|
|
|
void DefaultEventManager::pushEvent(const Common::Event &event) {
|
2008-07-13 20:41:39 +00:00
|
|
|
|
|
|
|
// If already received an EVENT_QUIT, don't add another one
|
|
|
|
if (event.type == Common::EVENT_QUIT) {
|
|
|
|
if (!_shouldQuit)
|
|
|
|
artificialEventQueue.push(event);
|
2009-01-01 15:06:43 +00:00
|
|
|
} else
|
|
|
|
artificialEventQueue.push(event);
|
2008-07-07 22:34:45 +00:00
|
|
|
}
|
|
|
|
|
2007-03-17 00:07:34 +00:00
|
|
|
#endif // !defined(DISABLE_DEFAULT_EVENTMANAGER)
|