diff options
Diffstat (limited to 'backends')
23 files changed, 262 insertions, 272 deletions
diff --git a/backends/events/openpandora/op-events.cpp b/backends/events/openpandora/op-events.cpp index c1d6362fcb..fc63cdf74f 100644 --- a/backends/events/openpandora/op-events.cpp +++ b/backends/events/openpandora/op-events.cpp @@ -44,7 +44,8 @@ enum { /* Touchscreen TapMode */ TAPMODE_LEFT = 0, TAPMODE_RIGHT = 1, - TAPMODE_HOVER = 2 + TAPMODE_HOVER = 2, + TAPMODE_HOVER_DPAD = 3 }; OPEventSource::OPEventSource() @@ -63,6 +64,8 @@ bool OPEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_RBUTTONDOWN; else if (OP::tapmodeLevel == TAPMODE_HOVER) /* TAPMODE_HOVER = Hover (No Click) Tap Mode */ event.type = Common::EVENT_MOUSEMOVE; + else if (OP::tapmodeLevel == TAPMODE_HOVER_DPAD) /* TAPMODE_HOVER_DPAD = Hover (DPad Clicks) Tap Mode */ + event.type = Common::EVENT_MOUSEMOVE; else event.type = Common::EVENT_LBUTTONDOWN; /* For normal mice etc. */ } else if (ev.button.button == SDL_BUTTON_RIGHT) @@ -95,6 +98,8 @@ bool OPEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_RBUTTONUP; else if (OP::tapmodeLevel == TAPMODE_HOVER) /* TAPMODE_HOVER = Hover (No Click) Tap Mode */ event.type = Common::EVENT_MOUSEMOVE; + else if (OP::tapmodeLevel == TAPMODE_HOVER_DPAD) /* TAPMODE_HOVER_DPAD = Hover (DPad Clicks) Tap Mode */ + event.type = Common::EVENT_MOUSEMOVE; else event.type = Common::EVENT_LBUTTONUP; /* For normal mice etc. */ } else if (ev.button.button == SDL_BUTTON_RIGHT) @@ -117,6 +122,30 @@ bool OPEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) { bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) { + if (OP::tapmodeLevel == TAPMODE_HOVER_DPAD) { + switch (ev.key.keysym.sym) { + case SDLK_LEFT: + event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP; + processMouseEvent(event, _km.x, _km.y); + return true; + break; + case SDLK_RIGHT: + event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP; + processMouseEvent(event, _km.x, _km.y); + return true; + break; +#if defined(SDL_BUTTON_MIDDLE) + case SDLK_UP: + event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_MBUTTONDOWN : Common::EVENT_MBUTTONUP; + processMouseEvent(event, _km.x, _km.y); + return true; + break; +#endif + default: + break; + } + } + if (ev.type == SDL_KEYDOWN) { switch (ev.key.keysym.sym) { case SDLK_HOME: @@ -141,6 +170,8 @@ bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) { g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Right Click")); } else if (OP::tapmodeLevel == TAPMODE_HOVER) { g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Hover (No Click)")); + } else if (OP::tapmodeLevel == TAPMODE_HOVER_DPAD) { + g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Hover (DPad Clicks)")); } break; case SDLK_RSHIFT: diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index f94171646a..0ca5bbb059 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -191,6 +191,8 @@ void SdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) { #endif if (mod & KMOD_CTRL) event.kbd.flags |= Common::KBD_CTRL; + if (mod & KMOD_META) + event.kbd.flags |= Common::KBD_META; // Sticky flags if (mod & KMOD_NUM) diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h index 2ba88c702b..ca4835126f 100644 --- a/backends/events/sdl/sdl-events.h +++ b/backends/events/sdl/sdl-events.h @@ -116,7 +116,7 @@ protected: //@} /** - * Assigns the mouse coords to the mouse event. Furthermore notify the + * Assigns the mouse coords to the mouse event. Furthermore notify the * graphics manager about the position change. */ virtual void processMouseEvent(Common::Event &event, int x, int y); diff --git a/backends/events/webossdl/webossdl-events.h b/backends/events/webossdl/webossdl-events.h index 99ed3105f8..1ba5c6fcbf 100644 --- a/backends/events/webossdl/webossdl-events.h +++ b/backends/events/webossdl/webossdl-events.h @@ -73,10 +73,10 @@ protected: // The current mouse position on the screen. int _curX, _curY; - + // The current screen dimensions int _screenX, _screenY; - + // The drag distance for linear gestures int _swipeDistX, _swipeDistY; @@ -107,7 +107,7 @@ protected: virtual bool handleMouseButtonUp(SDL_Event &ev, Common::Event &event); virtual bool handleMouseMotion(SDL_Event &ev, Common::Event &event); virtual bool pollEvent(Common::Event &event); - + // Utility functions void calculateDimensions(); }; diff --git a/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp b/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp index f515343d3c..bd87c9fafd 100644 --- a/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp +++ b/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp @@ -479,7 +479,7 @@ void DINGUXSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) case OSystem::kFeatureCursorPalette: _cursorPaletteDisabled = !enable; blitCursor(); - break; + break; default: break; } diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index 67041ae17b..fed02ef22e 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -665,7 +665,7 @@ void OpenGLSdlGraphicsManager::notifyResize(const uint width, const uint height) void OpenGLSdlGraphicsManager::transformMouseCoordinates(Common::Point &point) { adjustMousePosition(point.x, point.y); } - + void OpenGLSdlGraphicsManager::notifyMousePos(Common::Point mouse) { setMousePosition(mouse.x, mouse.y); } diff --git a/backends/midi/coreaudio.cpp b/backends/midi/coreaudio.cpp index 43c801287d..94262d0d92 100644 --- a/backends/midi/coreaudio.cpp +++ b/backends/midi/coreaudio.cpp @@ -172,10 +172,15 @@ int MidiDriver_CORE::open() { // Load custom soundfont, if specified if (ConfMan.hasKey("soundfont")) { - FSRef fsref; - FSSpec fsSpec; const char *soundfont = ConfMan.get("soundfont").c_str(); + // TODO: We should really check whether the file contains an + // actual soundfont... + +#if USE_DEPRECATED_COREAUDIO_API + // Before 10.5, we need to use kMusicDeviceProperty_SoundBankFSSpec + FSRef fsref; + FSSpec fsSpec; err = FSPathMakeRef ((const byte *)soundfont, &fsref, NULL); if (err == noErr) { @@ -183,8 +188,6 @@ int MidiDriver_CORE::open() { } if (err == noErr) { - // TODO: We should really check here whether the file contains an - // actual soundfont... err = AudioUnitSetProperty ( _synth, kMusicDeviceProperty_SoundBankFSSpec, kAudioUnitScope_Global, @@ -192,9 +195,27 @@ int MidiDriver_CORE::open() { &fsSpec, sizeof(fsSpec) ); } +#else + // kMusicDeviceProperty_SoundBankFSSpec is present on 10.6+, but broken + // kMusicDeviceProperty_SoundBankURL was added in 10.5 as a replacement + CFURLRef url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8 *)soundfont, strlen(soundfont), false); + + if (url) { + err = AudioUnitSetProperty ( + _synth, + kMusicDeviceProperty_SoundBankURL, kAudioUnitScope_Global, + 0, + &url, sizeof(url) + ); + + CFRelease(url); + } else { + warning("Failed to allocate CFURLRef from '%s'", soundfont); + } +#endif if (err != noErr) - warning("Failed loading custom sound font '%s' (error %ld)\n", soundfont, (long)err); + error("Failed loading custom sound font '%s' (error %ld)", soundfont, (long)err); } #ifdef COREAUDIO_DISABLE_REVERB diff --git a/backends/midi/sndio.cpp b/backends/midi/sndio.cpp index 21c9ea4fec..a065a658e1 100644 --- a/backends/midi/sndio.cpp +++ b/backends/midi/sndio.cpp @@ -81,7 +81,7 @@ void MidiDriver_Sndio::send(uint32 b) { if (!hdl) return; - buf[0] = b & 0xff; + buf[0] = b & 0xff; buf[1] = (b >> 8) & 0xff; buf[2] = (b >> 16) & 0xff; buf[3] = (b >> 24) & 0xff; @@ -101,7 +101,7 @@ void MidiDriver_Sndio::send(uint32 b) { void MidiDriver_Sndio::sysEx(const byte *msg, uint16 length) { if (!hdl) return; - + unsigned char buf[266]; assert(length + 2 <= ARRAYSIZE(buf)); diff --git a/backends/mixer/sdl13/sdl13-mixer.cpp b/backends/mixer/sdl13/sdl13-mixer.cpp index 84777c8bab..24d3434fde 100644 --- a/backends/mixer/sdl13/sdl13-mixer.cpp +++ b/backends/mixer/sdl13/sdl13-mixer.cpp @@ -69,13 +69,13 @@ void Sdl13MixerManager::init() { warning("Could not open audio device: %s", SDL_GetError()); _mixer = new Audio::MixerImpl(g_system, desired.freq); - assert(_mixer); + assert(_mixer); _mixer->setReady(false); } else { debug(1, "Output sample rate: %d Hz", _obtained.freq); _mixer = new Audio::MixerImpl(g_system, _obtained.freq); - assert(_mixer); + assert(_mixer); _mixer->setReady(true); startAudio(); diff --git a/backends/platform/bada/application.cpp b/backends/platform/bada/application.cpp index ba8e544983..e761649245 100644 --- a/backends/platform/bada/application.cpp +++ b/backends/platform/bada/application.cpp @@ -103,7 +103,7 @@ void BadaScummVM::pauseGame(bool pause) { if (pause && g_engine && !g_engine->isPaused()) { _appForm->pushKey(Common::KEYCODE_SPACE); } - + if (g_system) { ((BadaSystem *)g_system)->setMute(pause); } diff --git a/backends/platform/bada/sscanf.cpp b/backends/platform/bada/sscanf.cpp index b5e5b88cb5..aa846698f6 100644 --- a/backends/platform/bada/sscanf.cpp +++ b/backends/platform/bada/sscanf.cpp @@ -56,7 +56,7 @@ bool scanInt(const char **in, va_list *ap, int max) { bool err = false; if (end == *in || (max > 0 && (end - *in) > max)) { - err = true; + err = true; } else { *arg = (int)n; *in = end; diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 7877bc6430..54e5d633d2 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -476,7 +476,7 @@ const char *iPhone_getDocumentsDir() { else if (_videoContext.screenWidth == 640 && _videoContext.screenHeight == 400) adjustedHeight = 480; } - + float overlayPortraitRatio; if (_orientation == UIDeviceOrientationLandscapeLeft || _orientation == UIDeviceOrientationLandscapeRight) { diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm index aa1856490f..ebe435cb25 100644 --- a/backends/platform/iphone/osys_video.mm +++ b/backends/platform/iphone/osys_video.mm @@ -353,7 +353,7 @@ void OSystem_IPHONE::copyRectToOverlay(const void *buf, int pitch, int x, int y, } byte *dst = (byte *)_videoContext->overlayTexture.getBasePtr(x, y); - do { + do { memcpy(dst, src, w * sizeof(uint16)); src += pitch; dst += _videoContext->overlayTexture.pitch; @@ -435,7 +435,7 @@ void OSystem_IPHONE::setCursorPalette(const byte *colors, uint start, uint num) for (uint i = start; i < start + num; ++i, colors += 3) _mouseCursorPalette[i] = Graphics::RGBToColor<Graphics::ColorMasks<5551> >(colors[0], colors[1], colors[2]); - + // FIXME: This is just stupid, our client code seems to assume that this // automatically enables the cursor palette. _mouseCursorPaletteEnabled = true; diff --git a/backends/platform/maemo/debian/rules b/backends/platform/maemo/debian/rules index 43a34399a3..c713403876 100755 --- a/backends/platform/maemo/debian/rules +++ b/backends/platform/maemo/debian/rules @@ -47,7 +47,7 @@ install: build install -m0644 gui/themes/scummclassic.zip gui/themes/scummmodern.zip debian/scummvm/opt/scummvm/share install -m0644 backends/vkeybd/packs/vkeybd_default.zip debian/scummvm/opt/scummvm/share # for optified version we can also add engine datafiles - install -m0644 dists/engine-data/drascula.dat dists/engine-data/hugo.dat dists/engine-data/kyra.dat dists/engine-data/lure.dat dists/engine-data/queen.tbl dists/engine-data/sky.cpt dists/engine-data/teenagent.dat dists/engine-data/toon.dat debian/scummvm/opt/scummvm/share + install -m0644 dists/engine-data/drascula.dat dists/engine-data/hugo.dat dists/engine-data/kyra.dat dists/engine-data/lure.dat dists/engine-data/queen.tbl dists/engine-data/sky.cpt dists/engine-data/teenagent.dat dists/engine-data/tony.dat dists/engine-data/toon.dat debian/scummvm/opt/scummvm/share install -m0644 -d debian/scummvm/usr/share/doc/scummvm install -m0644 AUTHORS COPYING COPYING.BSD COPYING.FREEFONT COPYING.LGPL COPYRIGHT NEWS README debian/scummvm/usr/share/doc/scummvm diff --git a/backends/platform/openpandora/op-options.cpp b/backends/platform/openpandora/op-options.cpp index 58f0fb7188..005a76b76c 100644 --- a/backends/platform/openpandora/op-options.cpp +++ b/backends/platform/openpandora/op-options.cpp @@ -33,7 +33,8 @@ enum { /* Touchscreen TapMode */ TAPMODE_LEFT = 0, TAPMODE_RIGHT = 1, - TAPMODE_HOVER = 2 + TAPMODE_HOVER = 2, + TAPMODE_HOVER_DPAD = 3 }; int tapmodeLevel = TAPMODE_LEFT; @@ -44,6 +45,8 @@ void ToggleTapMode() { } else if (tapmodeLevel == TAPMODE_RIGHT) { tapmodeLevel = TAPMODE_HOVER; } else if (tapmodeLevel == TAPMODE_HOVER) { + tapmodeLevel = TAPMODE_HOVER_DPAD; + } else if (tapmodeLevel == TAPMODE_HOVER_DPAD) { tapmodeLevel = TAPMODE_LEFT; } else { tapmodeLevel = TAPMODE_LEFT; diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index 639bd980f6..fb76c111f2 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -156,7 +156,7 @@ Common::String OSystem_MacOSX::getSystemLanguage() const { } CFRelease(preferredLocalizations); } - + } // Falback to POSIX implementation return OSystem_POSIX::getSystemLanguage(); diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h index 4837e643b3..d9cb28b973 100644 --- a/backends/platform/sdl/macosx/macosx.h +++ b/backends/platform/sdl/macosx/macosx.h @@ -32,7 +32,7 @@ public: virtual bool hasFeature(Feature f); virtual bool displayLogFile(); - + virtual Common::String getSystemLanguage() const; virtual void initBackend(); diff --git a/backends/platform/sdl/main.cpp b/backends/platform/sdl/main.cpp deleted file mode 100644 index 040028079d..0000000000 --- a/backends/platform/sdl/main.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* 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/scummsys.h" - -// Several SDL based ports use a custom main, and hence do not want to compile -// of this file. The following "#if" ensures that. -#if !defined(POSIX) && \ - !defined(WIN32) && \ - !defined(MAEMO) && \ - !defined(__SYMBIAN32__) && \ - !defined(_WIN32_WCE) && \ - !defined(__amigaos4__) && \ - !defined(DINGUX) && \ - !defined(CAANOO) && \ - !defined(LINUXMOTO) && \ - !defined(SAMSUNGTV) && \ - !defined(PLAYSTATION3) && \ - !defined(OPENPANDORA) - -#include "backends/platform/sdl/sdl.h" -#include "backends/plugins/sdl/sdl-provider.h" -#include "base/main.h" - -int main(int argc, char *argv[]) { - - // Create our OSystem instance - g_system = new OSystem_SDL(); - assert(g_system); - - // Pre initialize the backend - ((OSystem_SDL *)g_system)->init(); - -#ifdef DYNAMIC_MODULES - PluginManager::instance().addPluginProvider(new SDLPluginProvider()); -#endif - - // Invoke the actual ScummVM main entry point: - int res = scummvm_main(argc, argv); - - // Free OSystem - delete (OSystem_SDL *)g_system; - - return res; -} - -#endif diff --git a/backends/platform/sdl/module.mk b/backends/platform/sdl/module.mk index 98a8265301..a17a326889 100644 --- a/backends/platform/sdl/module.mk +++ b/backends/platform/sdl/module.mk @@ -1,7 +1,6 @@ MODULE := backends/platform/sdl MODULE_OBJS := \ - main.o \ sdl.o ifdef POSIX diff --git a/backends/taskbar/win32/mingw-compat.h b/backends/taskbar/win32/mingw-compat.h index 55105407c6..f6151936f1 100644 --- a/backends/taskbar/win32/mingw-compat.h +++ b/backends/taskbar/win32/mingw-compat.h @@ -70,7 +70,7 @@ DECLARE_INTERFACE_(IPropertyStore, IUnknown) { STDMETHOD (GetValue) (REFPROPERTYKEY key, PROPVARIANT *pv) PURE; STDMETHOD (SetValue) (REFPROPERTYKEY key, REFPROPVARIANT propvar) PURE; STDMETHOD (Commit) (void) PURE; - + private: ~IPropertyStore(); }; @@ -137,7 +137,7 @@ DECLARE_INTERFACE_(ITaskbarList3, IUnknown) { STDMETHOD (SetOverlayIcon) (THIS_ HWND hwnd, HICON hIcon, LPCWSTR pszDescription) PURE; STDMETHOD (SetThumbnailTooltip) (THIS_ HWND hwnd, LPCWSTR pszTip) PURE; STDMETHOD (SetThumbnailClip) (THIS_ HWND hwnd, RECT *prcClip) PURE; - + private: ~ITaskbarList3(); }; diff --git a/backends/timer/bada/timer.cpp b/backends/timer/bada/timer.cpp index f030e0695f..e41ecd4864 100644 --- a/backends/timer/bada/timer.cpp +++ b/backends/timer/bada/timer.cpp @@ -1,115 +1,115 @@ -/* 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.
- *
- */
-
-#if defined(BADA)
-
-#include "backends/timer/bada/timer.h"
-
-//
-// TimerSlot
-//
-TimerSlot::TimerSlot(Common::TimerManager::TimerProc callback,
- uint32 interval, void *refCon) :
- _timer(0),
- _callback(callback),
- _interval(interval),
- _refCon(refCon) {
-}
-
-TimerSlot::~TimerSlot() {
-}
-
-bool TimerSlot::OnStart() {
- _timer = new Osp::Base::Runtime::Timer();
- if (!_timer || IsFailed(_timer->Construct(*this))) {
- AppLog("Failed to create timer");
- return false;
- }
-
- if (IsFailed(_timer->Start(_interval))) {
- AppLog("failed to start timer");
- return false;
- }
-
- AppLog("started timer %d", _interval);
- return true;
-}
-
-void TimerSlot::OnStop() {
- AppLog("timer stopped");
- if (_timer) {
- _timer->Cancel();
- delete _timer;
- _timer = NULL;
- }
-}
-
-void TimerSlot::OnTimerExpired(Timer &timer) {
- _callback(_refCon);
- timer.Start(_interval);
-}
-
-//
-// BadaTimerManager
-//
-BadaTimerManager::BadaTimerManager() {
-}
-
-BadaTimerManager::~BadaTimerManager() {
- for (Common::List<TimerSlot>::iterator slot = _timers.begin();
- slot != _timers.end(); ) {
- slot->Stop();
- slot = _timers.erase(slot);
- }
-}
-
-bool BadaTimerManager::installTimerProc(TimerProc proc, int32 interval, void *refCon,
- const Common::String &id) {
- TimerSlot *slot = new TimerSlot(proc, interval / 1000, refCon);
-
- if (IsFailed(slot->Construct(THREAD_TYPE_EVENT_DRIVEN))) {
- AppLog("Failed to create timer thread");
- delete slot;
- return false;
- }
-
- if (IsFailed(slot->Start())) {
- delete slot;
- AppLog("Failed to start timer thread");
- return false;
- }
-
- _timers.push_back(*slot);
- return true;
-}
-
-void BadaTimerManager::removeTimerProc(TimerProc proc) {
- for (Common::List<TimerSlot>::iterator slot = _timers.begin();
- slot != _timers.end(); ++slot) {
- if (slot->_callback == proc) {
- slot->Stop();
- slot = _timers.erase(slot);
- }
- }
-}
-
-#endif
+/* 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. + * + */ + +#if defined(BADA) + +#include "backends/timer/bada/timer.h" + +// +// TimerSlot +// +TimerSlot::TimerSlot(Common::TimerManager::TimerProc callback, + uint32 interval, void *refCon) : + _timer(0), + _callback(callback), + _interval(interval), + _refCon(refCon) { +} + +TimerSlot::~TimerSlot() { +} + +bool TimerSlot::OnStart() { + _timer = new Osp::Base::Runtime::Timer(); + if (!_timer || IsFailed(_timer->Construct(*this))) { + AppLog("Failed to create timer"); + return false; + } + + if (IsFailed(_timer->Start(_interval))) { + AppLog("failed to start timer"); + return false; + } + + AppLog("started timer %d", _interval); + return true; +} + +void TimerSlot::OnStop() { + AppLog("timer stopped"); + if (_timer) { + _timer->Cancel(); + delete _timer; + _timer = NULL; + } +} + +void TimerSlot::OnTimerExpired(Timer &timer) { + _callback(_refCon); + timer.Start(_interval); +} + +// +// BadaTimerManager +// +BadaTimerManager::BadaTimerManager() { +} + +BadaTimerManager::~BadaTimerManager() { + for (Common::List<TimerSlot>::iterator slot = _timers.begin(); + slot != _timers.end(); ) { + slot->Stop(); + slot = _timers.erase(slot); + } +} + +bool BadaTimerManager::installTimerProc(TimerProc proc, int32 interval, void *refCon, + const Common::String &id) { + TimerSlot *slot = new TimerSlot(proc, interval / 1000, refCon); + + if (IsFailed(slot->Construct(THREAD_TYPE_EVENT_DRIVEN))) { + AppLog("Failed to create timer thread"); + delete slot; + return false; + } + + if (IsFailed(slot->Start())) { + delete slot; + AppLog("Failed to start timer thread"); + return false; + } + + _timers.push_back(*slot); + return true; +} + +void BadaTimerManager::removeTimerProc(TimerProc proc) { + for (Common::List<TimerSlot>::iterator slot = _timers.begin(); + slot != _timers.end(); ++slot) { + if (slot->_callback == proc) { + slot->Stop(); + slot = _timers.erase(slot); + } + } +} + +#endif diff --git a/backends/timer/bada/timer.h b/backends/timer/bada/timer.h index 04ca771c26..826064d7ff 100644 --- a/backends/timer/bada/timer.h +++ b/backends/timer/bada/timer.h @@ -1,62 +1,62 @@ -/* 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.
- *
- */
-
-#ifndef BADA_TIMER_H
-#define BADA_TIMER_H
-
-#include <FBase.h>
-
-#include "common/timer.h"
-#include "common/list.h"
-
-using namespace Osp::Base::Runtime;
-
-struct TimerSlot: public ITimerEventListener, public Thread {
- TimerSlot(Common::TimerManager::TimerProc callback,
- uint32 interval,
- void *refCon);
- ~TimerSlot();
-
- bool OnStart(void);
- void OnStop(void);
- void OnTimerExpired(Timer &timer);
-
- Timer *_timer;
- Common::TimerManager::TimerProc _callback;
- uint32 _interval; // in microseconds
- void *_refCon;
-};
-
-class BadaTimerManager : public Common::TimerManager {
-public:
- BadaTimerManager();
- ~BadaTimerManager();
-
- bool installTimerProc(TimerProc proc, int32 interval, void *refCon,
- const Common::String &id);
- void removeTimerProc(TimerProc proc);
-
-private:
- Common::List<TimerSlot> _timers;
-};
-
-#endif
+/* 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. + * + */ + +#ifndef BADA_TIMER_H +#define BADA_TIMER_H + +#include <FBase.h> + +#include "common/timer.h" +#include "common/list.h" + +using namespace Osp::Base::Runtime; + +struct TimerSlot: public ITimerEventListener, public Thread { + TimerSlot(Common::TimerManager::TimerProc callback, + uint32 interval, + void *refCon); + ~TimerSlot(); + + bool OnStart(void); + void OnStop(void); + void OnTimerExpired(Timer &timer); + + Timer *_timer; + Common::TimerManager::TimerProc _callback; + uint32 _interval; // in microseconds + void *_refCon; +}; + +class BadaTimerManager : public Common::TimerManager { +public: + BadaTimerManager(); + ~BadaTimerManager(); + + bool installTimerProc(TimerProc proc, int32 interval, void *refCon, + const Common::String &id); + void removeTimerProc(TimerProc proc); + +private: + Common::List<TimerSlot> _timers; +}; + +#endif diff --git a/backends/timer/default/default-timer.cpp b/backends/timer/default/default-timer.cpp index 9cd803f148..9f56d58b12 100644 --- a/backends/timer/default/default-timer.cpp +++ b/backends/timer/default/default-timer.cpp @@ -156,7 +156,7 @@ void DefaultTimerManager::removeTimerProc(TimerProc callback) { } // We need to remove all names referencing the timer proc here. - // + // // Else we run into troubles, when the client code removes and readds timer // callbacks. // |