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.
|
2005-12-03 21:29:13 +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
|
2005-12-04 08:49:08 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-12-03 21:29:13 +00:00
|
|
|
*
|
2006-02-11 12:47:47 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2005-12-03 21:29:13 +00:00
|
|
|
*/
|
|
|
|
|
2007-09-28 20:54:11 +00:00
|
|
|
#include <eikenv.h> // for CEikonEnv::Static() @ Symbian::FatalError()
|
|
|
|
#include <sdlapp.h> // for CSDLApp::GetExecutablePathCStr() @ Symbian::GetExecutablePath()
|
2008-09-07 13:40:30 +00:00
|
|
|
#include <bautils.h>
|
2008-04-02 21:19:17 +00:00
|
|
|
|
|
|
|
#include "backends/fs/symbian/symbian-fs-factory.h"
|
2006-08-04 17:47:57 +00:00
|
|
|
#include "backends/platform/symbian/src/SymbianOS.h"
|
|
|
|
#include "backends/platform/symbian/src/SymbianActions.h"
|
2006-02-12 00:27:19 +00:00
|
|
|
#include "common/config-manager.h"
|
2007-03-17 19:02:05 +00:00
|
|
|
#include "common/events.h"
|
2008-08-03 17:05:01 +00:00
|
|
|
#include "common/file.h"
|
2005-12-03 21:29:13 +00:00
|
|
|
#include "gui/Actions.h"
|
|
|
|
#include "gui/Key.h"
|
|
|
|
#include "gui/message.h"
|
2008-07-18 19:02:40 +00:00
|
|
|
#include "sound/mixer_intern.h"
|
2007-09-28 20:54:11 +00:00
|
|
|
#include "..\..\sdl\main.cpp"
|
2005-12-03 21:29:13 +00:00
|
|
|
|
2008-01-22 14:16:02 +00:00
|
|
|
#ifdef SAMPLES_PER_SEC_8000 // the GreanSymbianMMP format cannot handle values for defines :(
|
|
|
|
#define SAMPLES_PER_SEC 8000
|
|
|
|
#else
|
|
|
|
#define SAMPLES_PER_SEC 16000
|
|
|
|
#endif
|
|
|
|
|
2008-08-03 17:05:01 +00:00
|
|
|
|
|
|
|
#define DEFAULT_CONFIG_FILE "scummvm.ini"
|
2008-09-07 13:40:30 +00:00
|
|
|
#define DEFAULT_SAVE_PATH "Savegames"
|
2008-07-18 20:40:48 +00:00
|
|
|
|
|
|
|
#define FILE void
|
2008-01-22 14:16:02 +00:00
|
|
|
|
2006-02-12 00:27:19 +00:00
|
|
|
////////// extern "C" ///////////////////////////////////////////////////
|
|
|
|
namespace Symbian {
|
|
|
|
|
2008-07-18 20:40:48 +00:00
|
|
|
|
|
|
|
|
2005-12-03 21:29:13 +00:00
|
|
|
// Show a simple Symbian Info win with Msg & exit
|
2006-02-12 00:27:19 +00:00
|
|
|
void FatalError(const char *msg) {
|
2008-01-27 19:47:41 +00:00
|
|
|
TPtrC8 msgPtr((const TUint8 *)msg);
|
2005-12-03 21:29:13 +00:00
|
|
|
TBuf<512> msg16Bit;
|
|
|
|
msg16Bit.Copy(msgPtr);
|
2007-03-11 11:23:40 +00:00
|
|
|
#ifdef S60
|
|
|
|
#else
|
2005-12-03 21:29:13 +00:00
|
|
|
CEikonEnv::Static()->InfoWinL(_L("ScummVM Fatal Error"), msg16Bit);
|
2007-03-11 11:23:40 +00:00
|
|
|
#endif
|
2005-12-03 21:29:13 +00:00
|
|
|
if (g_system)
|
|
|
|
g_system->quit();
|
|
|
|
}
|
|
|
|
|
2006-02-12 00:27:19 +00:00
|
|
|
// make this easily available everywhere
|
2008-01-22 14:16:02 +00:00
|
|
|
char* GetExecutablePath() {
|
2008-01-27 19:47:41 +00:00
|
|
|
return CSDLApp::GetExecutablePathCStr();
|
2006-02-12 00:27:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Symbian {
|
|
|
|
|
|
|
|
////////// OSystem_SDL_Symbian //////////////////////////////////////////
|
|
|
|
|
|
|
|
static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
|
|
|
|
{"1x", "Fullscreen", GFX_NORMAL},
|
|
|
|
{0, 0, 0}
|
|
|
|
};
|
|
|
|
|
2005-12-03 21:29:13 +00:00
|
|
|
bool OSystem_SDL_Symbian::hasFeature(Feature f) {
|
|
|
|
switch(f) {
|
|
|
|
case kFeatureFullscreenMode:
|
|
|
|
case kFeatureAspectRatioCorrection:
|
|
|
|
case kFeatureAutoComputeDirtyRects:
|
|
|
|
case kFeatureCursorHasPalette:
|
|
|
|
#ifdef USE_VIBRA_SE_PXXX
|
|
|
|
case kFeatureVibration:
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-14 19:25:33 +00:00
|
|
|
void OSystem_SDL_Symbian::setFeatureState(Feature f, bool enable) {
|
2008-01-27 19:47:41 +00:00
|
|
|
switch(f) {
|
|
|
|
case kFeatureVirtualKeyboard:
|
|
|
|
if (enable) {
|
2007-03-14 19:25:33 +00:00
|
|
|
}
|
|
|
|
else {
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-03-14 19:25:33 +00:00
|
|
|
}
|
2007-06-08 18:09:24 +00:00
|
|
|
break;
|
|
|
|
case kFeatureDisableKeyFiltering:
|
|
|
|
GUI::Actions::Instance()->beginMapping(enable);
|
2008-01-13 22:12:35 +00:00
|
|
|
break;
|
2007-03-14 19:25:33 +00:00
|
|
|
default:
|
|
|
|
OSystem_SDL::setFeatureState(f, enable);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-03 17:05:01 +00:00
|
|
|
static Common::String getDefaultConfigFileName() {
|
|
|
|
char configFile[MAXPATHLEN];
|
|
|
|
strcpy(configFile, Symbian::GetExecutablePath());
|
|
|
|
strcat(configFile, DEFAULT_CONFIG_FILE);
|
|
|
|
return configFile;
|
|
|
|
}
|
|
|
|
|
2008-09-05 19:03:30 +00:00
|
|
|
Common::SeekableReadStream *OSystem_SDL_Symbian::openConfigFileForReading() {
|
|
|
|
Common::FilesystemNode file(getDefaultConfigFileName());
|
|
|
|
return file.openForReading();
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::WriteStream *OSystem_SDL_Symbian::openConfigFileForWriting() {
|
|
|
|
Common::FilesystemNode file(getDefaultConfigFileName());
|
|
|
|
return file.openForWriting();
|
|
|
|
}
|
|
|
|
|
2005-12-03 21:29:13 +00:00
|
|
|
OSystem_SDL_Symbian::zoneDesc OSystem_SDL_Symbian::_zones[TOTAL_ZONES] = {
|
|
|
|
{ 0, 0, 320, 145 },
|
|
|
|
{ 0, 145, 150, 55 },
|
|
|
|
{ 150, 145, 170, 55 }
|
|
|
|
};
|
2006-04-21 21:15:05 +00:00
|
|
|
OSystem_SDL_Symbian::OSystem_SDL_Symbian() :_channels(0),_stereo_mix_buffer(0) {
|
2008-08-17 21:16:07 +00:00
|
|
|
_RFs = &CEikonEnv::Static()->FsSession();
|
2008-09-05 18:49:13 +00:00
|
|
|
_fsFactory = new SymbianFilesystemFactory();
|
2006-04-21 21:15:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_SDL_Symbian::initBackend() {
|
2008-09-07 13:40:30 +00:00
|
|
|
// First set the extrapath (for installed dat files etc)
|
2007-06-11 19:30:24 +00:00
|
|
|
ConfMan.set("extrapath", Symbian::GetExecutablePath());
|
2008-09-07 13:40:30 +00:00
|
|
|
|
|
|
|
// Calculate the default savepath
|
|
|
|
Common::String savePath;
|
|
|
|
savePath = Symbian::GetExecutablePath();
|
|
|
|
savePath += DEFAULT_SAVE_PATH "\\";
|
|
|
|
ConfMan.registerDefault("savepath", savePath);
|
|
|
|
|
|
|
|
// If savepath has not already been set then set it
|
|
|
|
if (!ConfMan.hasKey("savepath")) {
|
|
|
|
ConfMan.set("savepath", savePath);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ensure that the current set path (might have been altered by the user) exists
|
|
|
|
Common::String currentPath = ConfMan.get("savepath");
|
|
|
|
TFileName fname;
|
|
|
|
TPtrC8 ptr((const unsigned char*)currentPath.c_str(),currentPath.size());
|
|
|
|
fname.Copy(ptr);
|
|
|
|
BaflUtils::EnsurePathExistsL(static_cast<OSystem_SDL_Symbian*>(g_system)->FsSession(), fname);
|
|
|
|
|
2006-04-21 21:15:05 +00:00
|
|
|
ConfMan.setBool("FM_high_quality", false);
|
2006-06-04 11:39:46 +00:00
|
|
|
#if !defined(S60) || defined(S60V3) // S60 has low quality as default
|
2006-04-21 21:15:05 +00:00
|
|
|
ConfMan.setBool("FM_medium_quality", true);
|
2005-12-03 21:29:13 +00:00
|
|
|
#else
|
2006-04-21 21:15:05 +00:00
|
|
|
ConfMan.setBool("FM_medium_quality", false);
|
2005-12-03 21:29:13 +00:00
|
|
|
#endif
|
2006-04-21 21:15:05 +00:00
|
|
|
ConfMan.setInt("joystick_num", 0); // Symbian OS should have joystick_num set to 0 in the ini file , but uiq devices might refuse opening the joystick
|
2005-12-03 21:29:13 +00:00
|
|
|
ConfMan.flushToDisk();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-05-31 21:13:37 +00:00
|
|
|
GUI::Actions::init();
|
2006-04-21 21:15:05 +00:00
|
|
|
|
|
|
|
OSystem_SDL::initBackend();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2005-12-03 21:29:13 +00:00
|
|
|
// Initialize global key mapping for Smartphones
|
|
|
|
GUI::Actions* actions = GUI::Actions::Instance();
|
2006-05-31 21:13:37 +00:00
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
actions->initInstanceMain(this);
|
2005-12-03 21:29:13 +00:00
|
|
|
actions->loadMapping();
|
|
|
|
initZones();
|
|
|
|
}
|
|
|
|
|
|
|
|
OSystem_SDL_Symbian::~OSystem_SDL_Symbian() {
|
2008-05-07 15:09:10 +00:00
|
|
|
delete[] _stereo_mix_buffer;
|
2005-12-03 21:29:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int OSystem_SDL_Symbian::getDefaultGraphicsMode() const {
|
|
|
|
return GFX_NORMAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
const OSystem::GraphicsMode *OSystem_SDL_Symbian::getSupportedGraphicsModes() const {
|
|
|
|
return s_supportedGraphicsModes;
|
|
|
|
}
|
|
|
|
|
|
|
|
// make sure we always go to normal, even if the string might be set wrong!
|
|
|
|
bool OSystem_SDL_Symbian::setGraphicsMode(const char * /*name*/) {
|
|
|
|
// let parent OSystem_SDL handle it
|
|
|
|
return OSystem_SDL::setGraphicsMode(getDefaultGraphicsMode());
|
|
|
|
}
|
|
|
|
|
2007-06-10 19:43:48 +00:00
|
|
|
void OSystem_SDL_Symbian::quitWithErrorMsg(const char * /*aMsg*/) {
|
2005-12-03 21:29:13 +00:00
|
|
|
|
|
|
|
CEikonEnv::Static()->AlertWin(_L("quitWithErrorMsg()")) ;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2005-12-03 21:29:13 +00:00
|
|
|
if (g_system)
|
|
|
|
g_system->quit();
|
|
|
|
}
|
|
|
|
|
2006-12-28 09:12:58 +00:00
|
|
|
// Overloaded from SDL_Commmon
|
|
|
|
void OSystem_SDL_Symbian::quit() {
|
|
|
|
delete GUI_Actions::Instance();
|
|
|
|
OSystem_SDL::quit();
|
|
|
|
}
|
|
|
|
|
2008-06-28 15:28:29 +00:00
|
|
|
void OSystem_SDL_Symbian::setupMixer() {
|
2005-12-03 21:29:13 +00:00
|
|
|
|
|
|
|
SDL_AudioSpec desired;
|
|
|
|
SDL_AudioSpec obtained;
|
|
|
|
|
|
|
|
memset(&desired, 0, sizeof(desired));
|
|
|
|
|
|
|
|
_samplesPerSec = 0;
|
|
|
|
|
|
|
|
if (ConfMan.hasKey("output_rate"))
|
|
|
|
_samplesPerSec = ConfMan.getInt("output_rate");
|
|
|
|
|
|
|
|
if (_samplesPerSec <= 0)
|
|
|
|
_samplesPerSec = SAMPLES_PER_SEC;
|
|
|
|
|
|
|
|
// Originally, we always used 2048 samples. This loop will produce the
|
|
|
|
// same result at 22050 Hz, and should hopefully produce something
|
|
|
|
// sensible for other frequencies. Note that it must be a power of two.
|
|
|
|
|
|
|
|
uint32 samples = 0x8000;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
if ((1000 * samples) / _samplesPerSec < 100)
|
|
|
|
break;
|
|
|
|
samples >>= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
desired.freq = _samplesPerSec;
|
|
|
|
desired.format = AUDIO_S16SYS;
|
|
|
|
desired.channels = 2;
|
|
|
|
desired.samples = (uint16)samples;
|
|
|
|
desired.callback = symbianMixCallback;
|
|
|
|
desired.userdata = this;
|
2008-06-28 15:28:29 +00:00
|
|
|
|
|
|
|
// Create the mixer instance
|
|
|
|
assert(!_mixer);
|
|
|
|
_mixer = new Audio::MixerImpl(this);
|
|
|
|
assert(_mixer);
|
|
|
|
|
2005-12-03 21:29:13 +00:00
|
|
|
if (SDL_OpenAudio(&desired, &obtained) != 0) {
|
|
|
|
warning("Could not open audio device: %s", SDL_GetError());
|
2008-06-28 15:28:29 +00:00
|
|
|
_samplesPerSec = 0;
|
|
|
|
_mixer->setReady(false);
|
|
|
|
} else {
|
|
|
|
// Note: This should be the obtained output rate, but it seems that at
|
|
|
|
// least on some platforms SDL will lie and claim it did get the rate
|
|
|
|
// even if it didn't. Probably only happens for "weird" rates, though.
|
|
|
|
_samplesPerSec = obtained.freq;
|
|
|
|
_channels = obtained.channels;
|
|
|
|
|
|
|
|
// Need to create mixbuffer for stereo mix to downmix
|
|
|
|
if (_channels != 2) {
|
|
|
|
_stereo_mix_buffer = new byte [obtained.size*2];//*2 for stereo values
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tell the mixer that we are ready and start the sound processing
|
|
|
|
_mixer->setOutputRate(_samplesPerSec);
|
|
|
|
_mixer->setReady(true);
|
|
|
|
SDL_PauseAudio(0);
|
2005-12-03 21:29:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The mixer callback function, passed on to OSystem::setSoundCallback().
|
|
|
|
* This simply calls the mix() method.
|
|
|
|
*/
|
2008-06-28 15:28:29 +00:00
|
|
|
void OSystem_SDL_Symbian::symbianMixCallback(void *sys, byte *samples, int len) {
|
|
|
|
OSystem_SDL_Symbian *this_ = (OSystem_SDL_Symbian *)sys;
|
|
|
|
assert(this_);
|
2005-12-03 21:29:13 +00:00
|
|
|
|
2008-06-28 15:28:29 +00:00
|
|
|
if (!this_->_mixer)
|
|
|
|
return;
|
2005-12-03 21:29:13 +00:00
|
|
|
|
2008-07-18 19:02:40 +00:00
|
|
|
#if defined (S60) && !defined(S60V3)
|
2005-12-03 21:29:13 +00:00
|
|
|
// If not stereo then we need to downmix
|
2008-07-18 19:02:40 +00:00
|
|
|
if (this_->_mixer->_channels != 2) {
|
2008-06-28 15:28:29 +00:00
|
|
|
this_->_mixer->mixCallback(_stereo_mix_buffer, len * 2);
|
|
|
|
|
2005-12-03 21:29:13 +00:00
|
|
|
int16 *bitmixDst = (int16 *)samples;
|
|
|
|
int16 *bitmixSrc = (int16 *)_stereo_mix_buffer;
|
|
|
|
|
|
|
|
for (int loop = len / 2; loop >= 0; loop --) {
|
|
|
|
*bitmixDst = (*bitmixSrc + *(bitmixSrc + 1)) >> 1;
|
|
|
|
bitmixDst++;
|
|
|
|
bitmixSrc += 2;
|
|
|
|
}
|
|
|
|
} else
|
2008-06-28 15:28:29 +00:00
|
|
|
#else
|
|
|
|
this_->_mixer->mixCallback(samples, len);
|
|
|
|
#endif
|
2005-12-03 21:29:13 +00:00
|
|
|
}
|
|
|
|
|
2008-06-28 15:28:29 +00:00
|
|
|
|
2005-12-03 21:29:13 +00:00
|
|
|
/**
|
|
|
|
* This is an implementation by the remapKey function
|
|
|
|
* @param SDL_Event to remap
|
|
|
|
* @param ScumVM event to modify if special result is requested
|
2007-03-17 19:02:05 +00:00
|
|
|
* @return true if Common::Event has a valid return status
|
2005-12-03 21:29:13 +00:00
|
|
|
*/
|
2007-03-17 19:02:05 +00:00
|
|
|
bool OSystem_SDL_Symbian::remapKey(SDL_Event &ev, Common::Event &event) {
|
2005-12-03 21:29:13 +00:00
|
|
|
if (GUI::Actions::Instance()->mappingActive() || ev.key.keysym.sym <= SDLK_UNKNOWN)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (TInt loop = 0; loop < GUI::ACTION_LAST; loop++) {
|
2008-01-27 19:47:41 +00:00
|
|
|
if (GUI::Actions::Instance()->getMapping(loop) == ev.key.keysym.sym &&
|
2005-12-03 21:29:13 +00:00
|
|
|
GUI::Actions::Instance()->isEnabled(loop)) {
|
|
|
|
// Create proper event instead
|
|
|
|
switch(loop) {
|
2008-01-27 19:47:41 +00:00
|
|
|
case GUI::ACTION_UP:
|
2005-12-03 21:29:13 +00:00
|
|
|
if (ev.type == SDL_KEYDOWN) {
|
|
|
|
_km.y_vel = -1;
|
|
|
|
_km.y_down_count = 1;
|
|
|
|
} else {
|
|
|
|
_km.y_vel = 0;
|
|
|
|
_km.y_down_count = 0;
|
|
|
|
}
|
2007-03-17 19:02:05 +00:00
|
|
|
event.type = Common::EVENT_MOUSEMOVE;
|
2005-12-03 21:29:13 +00:00
|
|
|
fillMouseEvent(event, _km.x, _km.y);
|
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
return true;
|
2005-12-03 21:29:13 +00:00
|
|
|
|
|
|
|
case GUI::ACTION_DOWN:
|
2007-03-11 14:28:03 +00:00
|
|
|
if (ev.type == SDL_KEYDOWN) {
|
2005-12-03 21:29:13 +00:00
|
|
|
_km.y_vel = 1;
|
|
|
|
_km.y_down_count = 1;
|
|
|
|
} else {
|
|
|
|
_km.y_vel = 0;
|
|
|
|
_km.y_down_count = 0;
|
|
|
|
}
|
2007-03-17 19:02:05 +00:00
|
|
|
event.type = Common::EVENT_MOUSEMOVE;
|
2005-12-03 21:29:13 +00:00
|
|
|
fillMouseEvent(event, _km.x, _km.y);
|
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
return true;
|
2005-12-03 21:29:13 +00:00
|
|
|
|
|
|
|
case GUI::ACTION_LEFT:
|
2007-03-11 14:28:03 +00:00
|
|
|
if (ev.type == SDL_KEYDOWN) {
|
2005-12-03 21:29:13 +00:00
|
|
|
_km.x_vel = -1;
|
|
|
|
_km.x_down_count = 1;
|
|
|
|
} else {
|
|
|
|
_km.x_vel = 0;
|
|
|
|
_km.x_down_count = 0;
|
|
|
|
}
|
2007-03-17 19:02:05 +00:00
|
|
|
event.type = Common::EVENT_MOUSEMOVE;
|
2005-12-03 21:29:13 +00:00
|
|
|
fillMouseEvent(event, _km.x, _km.y);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case GUI::ACTION_RIGHT:
|
2007-03-11 14:28:03 +00:00
|
|
|
if (ev.type == SDL_KEYDOWN) {
|
2005-12-03 21:29:13 +00:00
|
|
|
_km.x_vel = 1;
|
|
|
|
_km.x_down_count = 1;
|
|
|
|
} else {
|
|
|
|
_km.x_vel = 0;
|
|
|
|
_km.x_down_count = 0;
|
|
|
|
}
|
2007-03-17 19:02:05 +00:00
|
|
|
event.type = Common::EVENT_MOUSEMOVE;
|
2005-12-03 21:29:13 +00:00
|
|
|
fillMouseEvent(event, _km.x, _km.y);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case GUI::ACTION_LEFTCLICK:
|
2007-03-17 19:02:05 +00:00
|
|
|
event.type = (ev.type == SDL_KEYDOWN ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP);
|
2005-12-03 21:29:13 +00:00
|
|
|
fillMouseEvent(event, _km.x, _km.y);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case GUI::ACTION_RIGHTCLICK:
|
2007-03-17 19:02:05 +00:00
|
|
|
event.type = (ev.type == SDL_KEYDOWN ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP);
|
2005-12-03 21:29:13 +00:00
|
|
|
fillMouseEvent(event, _km.x, _km.y);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case GUI::ACTION_ZONE:
|
2007-03-11 14:28:03 +00:00
|
|
|
if (ev.type == SDL_KEYDOWN) {
|
2008-01-27 19:47:41 +00:00
|
|
|
int i;
|
|
|
|
|
2005-12-03 21:29:13 +00:00
|
|
|
for (i=0; i < TOTAL_ZONES; i++)
|
|
|
|
if (_km.x >= _zones[i].x && _km.y >= _zones[i].y &&
|
|
|
|
_km.x <= _zones[i].x + _zones[i].width && _km.y <= _zones[i].y + _zones[i].height
|
|
|
|
) {
|
|
|
|
_mouseXZone[i] = _km.x;
|
|
|
|
_mouseYZone[i] = _km.y;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
_currentZone++;
|
|
|
|
if (_currentZone >= TOTAL_ZONES)
|
|
|
|
_currentZone = 0;
|
2007-03-17 19:02:05 +00:00
|
|
|
event.type = Common::EVENT_MOUSEMOVE;
|
2005-12-03 21:29:13 +00:00
|
|
|
fillMouseEvent(event, _mouseXZone[_currentZone], _mouseYZone[_currentZone]);
|
2008-01-27 19:47:41 +00:00
|
|
|
SDL_WarpMouse(event.mouse.x, event.mouse.y);
|
2005-12-03 21:29:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2007-06-08 18:09:24 +00:00
|
|
|
case GUI::ACTION_MULTI: {
|
|
|
|
GUI::Key &key = GUI::Actions::Instance()->getKeyAction(loop);
|
|
|
|
// if key code is pause, then change event to interactive or just fall through
|
2007-09-18 20:16:33 +00:00
|
|
|
if (key.keycode() == SDLK_PAUSE) {
|
2007-06-08 18:09:24 +00:00
|
|
|
event.type = Common::EVENT_PREDICTIVE_DIALOG;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2005-12-03 21:29:13 +00:00
|
|
|
case GUI::ACTION_SAVE:
|
|
|
|
case GUI::ACTION_SKIP:
|
|
|
|
case GUI::ACTION_SKIP_TEXT:
|
|
|
|
case GUI::ACTION_PAUSE:
|
2007-03-14 19:25:33 +00:00
|
|
|
case GUI::ACTION_SWAPCHAR:
|
|
|
|
case GUI::ACTION_FASTMODE:
|
2007-06-08 18:09:24 +00:00
|
|
|
case GUI::ACTION_DEBUGGER: {
|
2005-12-03 21:29:13 +00:00
|
|
|
GUI::Key &key = GUI::Actions::Instance()->getKeyAction(loop);
|
2007-11-24 12:57:08 +00:00
|
|
|
ev.key.keysym.sym = (SDLKey) key.keycode();
|
|
|
|
ev.key.keysym.scancode = 0;
|
2007-03-14 19:25:33 +00:00
|
|
|
ev.key.keysym.mod = (SDLMod) key.flags();
|
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
// Translate from SDL keymod event to Scummvm Key Mod Common::Event.
|
2007-03-14 19:25:33 +00:00
|
|
|
// This codes is also present in GP32 backend and in SDL backend as a static function
|
2008-01-27 19:47:41 +00:00
|
|
|
// Perhaps it should be shared.
|
|
|
|
if (key.flags() != 0) {
|
2007-03-14 19:25:33 +00:00
|
|
|
event.kbd.flags = 0;
|
|
|
|
|
|
|
|
if (ev.key.keysym.mod & KMOD_SHIFT)
|
2007-03-17 19:02:05 +00:00
|
|
|
event.kbd.flags |= Common::KBD_SHIFT;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-03-14 19:25:33 +00:00
|
|
|
if (ev.key.keysym.mod & KMOD_ALT)
|
2007-03-17 19:02:05 +00:00
|
|
|
event.kbd.flags |= Common::KBD_ALT;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-03-14 19:25:33 +00:00
|
|
|
if (ev.key.keysym.mod & KMOD_CTRL)
|
2007-03-17 19:02:05 +00:00
|
|
|
event.kbd.flags |= Common::KBD_CTRL;
|
2007-03-14 19:25:33 +00:00
|
|
|
}
|
2005-12-03 21:29:13 +00:00
|
|
|
|
|
|
|
return false;
|
2008-01-27 19:47:41 +00:00
|
|
|
}
|
2005-12-03 21:29:13 +00:00
|
|
|
|
|
|
|
case GUI::ACTION_QUIT:
|
|
|
|
{
|
|
|
|
GUI::MessageDialog alert("Do you want to quit ?", "Yes", "No");
|
|
|
|
if (alert.runModal() == GUI::kMessageOK)
|
|
|
|
quit();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_SDL_Symbian::setWindowCaption(const char *caption) {
|
|
|
|
OSystem_SDL::setWindowCaption(caption);
|
|
|
|
check_mappings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_SDL_Symbian::check_mappings() {
|
2006-04-15 17:39:14 +00:00
|
|
|
if (ConfMan.get("gameid").empty() || GUI::Actions::Instance()->initialized())
|
2005-12-03 21:29:13 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
GUI::Actions::Instance()->initInstanceGame();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_SDL_Symbian::initZones() {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
_currentZone = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < TOTAL_ZONES; i++) {
|
|
|
|
_mouseXZone[i] = (_zones[i].x + (_zones[i].width / 2));
|
|
|
|
_mouseYZone[i] = (_zones[i].y + (_zones[i].height / 2));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-17 21:16:07 +00:00
|
|
|
RFs& OSystem_SDL_Symbian::FsSession() {
|
|
|
|
return *_RFs;
|
|
|
|
}
|
|
|
|
|
2008-09-06 10:30:05 +00:00
|
|
|
// Symbian bsearch implementation is flawed
|
|
|
|
void* scumm_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) {
|
|
|
|
// Perform binary search
|
|
|
|
size_t lo = 0;
|
|
|
|
size_t hi = nmemb;
|
|
|
|
while (lo < hi) {
|
|
|
|
size_t mid = (lo + hi) / 2;
|
|
|
|
const void *p = ((const char *)base) + mid * size;
|
|
|
|
int tmp = (*compar)(key, p);
|
|
|
|
if (tmp < 0)
|
|
|
|
hi = mid;
|
|
|
|
else if (tmp > 0)
|
|
|
|
lo = mid + 1;
|
|
|
|
else
|
|
|
|
return (void *)p;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-09-07 13:40:30 +00:00
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
// Include the snprintf and vsnprintf implementations as 'C' code
|
|
|
|
#include "vsnprintf.h"
|
2008-09-05 11:31:51 +00:00
|
|
|
}
|
|
|
|
|
2005-12-03 21:29:13 +00:00
|
|
|
/** Vibration support */
|
|
|
|
#ifdef USE_VIBRA_SE_PXXX
|
|
|
|
void OSystem_SDL_Symbian::initializeVibration() {
|
2008-09-07 13:40:30 +00:00
|
|
|
#ifdef UIQ3
|
|
|
|
#else
|
|
|
|
#endif
|
2005-12-03 21:29:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_SDL_Symbian::vibrationOn(int vibraLength) {
|
2008-09-07 13:40:30 +00:00
|
|
|
#ifdef UIQ3
|
|
|
|
// initialize?
|
2005-12-03 21:29:13 +00:00
|
|
|
if (!_vibrationApi) _vibrationApi = SonyEricsson::CVibration::NewL();
|
|
|
|
// do it!
|
|
|
|
_vibrationApi->VibrationOn(1, 1, vibraLength);
|
2008-09-07 13:40:30 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
#endif
|
2005-12-03 21:29:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_SDL_Symbian::vibrationOff() {
|
2008-09-07 13:40:30 +00:00
|
|
|
#ifdef UIQ3
|
|
|
|
#else
|
2005-12-03 21:29:13 +00:00
|
|
|
_vibrationApi->VibrationOff();
|
2008-09-07 13:40:30 +00:00
|
|
|
#endif
|
2005-12-03 21:29:13 +00:00
|
|
|
}
|
2007-03-11 14:28:03 +00:00
|
|
|
|
2005-12-03 21:29:13 +00:00
|
|
|
#endif // USE_SE_PXX_VIBRA
|
|
|
|
|