diff options
author | Willem Jan Palenstijn | 2013-04-18 23:35:23 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:40:58 +0200 |
commit | 9c2341678ef4984bf92b3878295250faf980b066 (patch) | |
tree | 2fb4805e05e16b9924e80c9947e6bad723b28c4b /backends | |
parent | 8172d679df5148a4a32f46074b20cb6caf91844f (diff) | |
parent | a5f4ff36ffc386d48f2da49387a9655ce9295a4d (diff) | |
download | scummvm-rg350-9c2341678ef4984bf92b3878295250faf980b066.tar.gz scummvm-rg350-9c2341678ef4984bf92b3878295250faf980b066.tar.bz2 scummvm-rg350-9c2341678ef4984bf92b3878295250faf980b066.zip |
Merge branch 'master'
Diffstat (limited to 'backends')
212 files changed, 3779 insertions, 4599 deletions
diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp index 78072b0021..99d12c73dc 100644 --- a/backends/events/default/default-events.cpp +++ b/backends/events/default/default-events.cpp @@ -60,6 +60,8 @@ DefaultEventManager::DefaultEventManager(Common::EventSource *boss) : // EventDispatcher will automatically free the keymapper _dispatcher.registerMapper(_keymapper); _remap = false; +#else + _dispatcher.registerMapper(new Common::DefaultEventMapper()); #endif } @@ -100,67 +102,7 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { _currentKeyDown.flags = event.kbd.flags; _keyRepeatTime = time + kKeyRepeatInitialDelay; - // Global Main Menu - if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_F5) { - if (g_engine && !g_engine->isPaused()) { - Common::Event menuEvent; - menuEvent.type = Common::EVENT_MAINMENU; - - // 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? - - //pushEvent(menuEvent); - event = menuEvent; - - // 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()) - g_engine->openMainMenuDialog(); - - if (_shouldQuit) - event.type = Common::EVENT_QUIT; - else if (_shouldRTL) - event.type = Common::EVENT_RTL; - } - } -#ifdef ENABLE_VKEYBD - else if (event.kbd.keycode == Common::KEYCODE_F7 && event.kbd.hasFlags(0)) { - if (_vk->isDisplaying()) { - _vk->close(true); - } else { - if (g_engine) - g_engine->pauseEngine(true); - _vk->show(); - if (g_engine) - g_engine->pauseEngine(false); - result = false; - } - } -#endif -#ifdef ENABLE_KEYMAPPER - else if (event.kbd.keycode == Common::KEYCODE_F8 && event.kbd.hasFlags(0)) { - if (!_remap) { - _remap = true; - Common::RemapDialog _remapDialog; - if (g_engine) - g_engine->pauseEngine(true); - _remapDialog.runModal(); - if (g_engine) - g_engine->pauseEngine(false); - _remap = false; - } - } -#endif - else if (event.kbd.keycode == Common::KEYCODE_BACKSPACE) { + if (event.kbd.keycode == Common::KEYCODE_BACKSPACE) { // WORKAROUND: Some engines incorrectly attempt to use the // ascii value instead of the keycode to detect the backspace // key (a non-portable behavior). This fails at least on @@ -214,7 +156,34 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { else if (_shouldRTL) event.type = Common::EVENT_RTL; break; - +#ifdef ENABLE_VKEYBD + case Common::EVENT_VIRTUAL_KEYBOARD: + if (_vk->isDisplaying()) { + _vk->close(true); + } else { + if (g_engine) + g_engine->pauseEngine(true); + _vk->show(); + if (g_engine) + g_engine->pauseEngine(false); + result = false; + } + break; +#endif +#ifdef ENABLE_KEYMAPPER + case Common::EVENT_KEYMAPPER_REMAP: + if (!_remap) { + _remap = true; + Common::RemapDialog _remapDialog; + if (g_engine) + g_engine->pauseEngine(true); + _remapDialog.runModal(); + if (g_engine) + g_engine->pauseEngine(false); + _remap = false; + } + break; +#endif case Common::EVENT_RTL: if (ConfMan.getBool("confirm_exit")) { if (g_engine) diff --git a/backends/events/default/default-events.h b/backends/events/default/default-events.h index 3a8025f5e8..4d89b78861 100644 --- a/backends/events/default/default-events.h +++ b/backends/events/default/default-events.h @@ -92,6 +92,8 @@ public: #endif #ifdef ENABLE_KEYMAPPER + // IMPORTANT NOTE: This is part of the WIP Keymapper. If you plan to use + // this, please talk to tsoliman and/or LordHoto. virtual Common::Keymapper *getKeymapper() { return _keymapper; } #endif }; diff --git a/backends/events/maemosdl/maemosdl-events.cpp b/backends/events/maemosdl/maemosdl-events.cpp index 32d5cfb5ac..dcdf0384e3 100644 --- a/backends/events/maemosdl/maemosdl-events.cpp +++ b/backends/events/maemosdl/maemosdl-events.cpp @@ -33,10 +33,25 @@ MaemoSdlEventSource::MaemoSdlEventSource() : SdlEventSource(), _clickEnabled(tru } +struct KeymapEntry { + SDLKey sym; + Common::KeyCode keycode; + uint16 ascii; +}; + +static const KeymapEntry keymapEntries[] = { + {SDLK_F4, Common::KEYCODE_F11, 0}, + {SDLK_F5, Common::KEYCODE_F12, 0}, + {SDLK_F6, Common::KEYCODE_F13, 0}, + {SDLK_F7, Common::KEYCODE_F14, 0}, + {SDLK_F8, Common::KEYCODE_F15, 0}, + {SDLK_LAST, Common::KEYCODE_INVALID, 0} +}; + bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { Model model = Model(((OSystem_SDL_Maemo *)g_system)->getModel()); - debug(10, "Model: %s %u %s %s", model.hwId, model.modelType, model.hwAlias, model.hwKeyboard ? "true" : "false"); + debug(10, "Model: %s %u %s %s", model.hwId, model.modelType, model.hwAlias, model.hasHwKeyboard ? "true" : "false"); // List of special N810 keys: // SDLK_F4 -> menu @@ -45,14 +60,32 @@ bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { // SDLK_F7 -> zoom + // SDLK_F8 -> zoom - +#ifdef ENABLE_KEYMAPPER + if (ev.type == SDL_KEYDOWN || ev.type == SDL_KEYUP) { + const KeymapEntry *entry; + for (entry = keymapEntries; entry->sym != SDLK_LAST; ++entry) { + if (ev.key.keysym.sym == entry->sym) { + SDLModToOSystemKeyFlags(SDL_GetModState(), event); + event.type = ev.type == SDL_KEYDOWN ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP; + event.kbd.keycode = entry->keycode; + event.kbd.ascii = entry->ascii; + return true; + } + } + } +#else switch (ev.type) { case SDL_KEYDOWN:{ - if (ev.key.keysym.sym == SDLK_F4) { + if (ev.key.keysym.sym == SDLK_F4 + || (model.modelType == kModelTypeN900 + && ev.key.keysym.sym == SDLK_m + && (ev.key.keysym.mod & KMOD_CTRL) + && (ev.key.keysym.mod & KMOD_SHIFT))) { event.type = Common::EVENT_MAINMENU; debug(9, "remapping to main menu"); return true; } else if (ev.key.keysym.sym == SDLK_F6) { - if (!model.hwKeyboard) { + if (!model.hasHwKeyboard) { event.type = Common::EVENT_KEYDOWN; event.kbd.keycode = Common::KEYCODE_F7; event.kbd.ascii = Common::ASCII_F7; @@ -83,11 +116,15 @@ bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { break; } case SDL_KEYUP: { - if (ev.key.keysym.sym == SDLK_F4) { + if (ev.key.keysym.sym == SDLK_F4 + || (model.modelType == kModelTypeN900 + && ev.key.keysym.sym == SDLK_m + && (ev.key.keysym.mod & KMOD_CTRL) + && (ev.key.keysym.mod & KMOD_SHIFT))) { event.type = Common::EVENT_MAINMENU; return true; } else if (ev.key.keysym.sym == SDLK_F6) { - if (!model.hwKeyboard) { + if (!model.hasHwKeyboard) { event.type = Common::EVENT_KEYUP; event.kbd.keycode = Common::KEYCODE_F7; event.kbd.ascii = Common::ASCII_F7; @@ -116,9 +153,7 @@ bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { debug(9, "remapping to F7 up (virtual keyboard)"); return true; } else { - _clickEnabled = !_clickEnabled; - ((SurfaceSdlGraphicsManager*) _graphicsManager)->displayMessageOnOSD( - _clickEnabled ? _("Clicking Enabled") : _("Clicking Disabled")); + toggleClickMode(); debug(9, "remapping to click toggle"); return true; } @@ -126,6 +161,7 @@ bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { break; } } +#endif // Invoke parent implementation of this method return SdlEventSource::remapKey(ev, event); } @@ -150,6 +186,32 @@ bool MaemoSdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &even return SdlEventSource::handleMouseButtonUp(ev, event); } +bool MaemoSdlEventSource::toggleClickMode() { + _clickEnabled = !_clickEnabled; + ((SurfaceSdlGraphicsManager *) _graphicsManager)->displayMessageOnOSD( + _clickEnabled ? _("Clicking Enabled") : _("Clicking Disabled")); + + return _clickEnabled; +} + +MaemoSdlEventObserver::MaemoSdlEventObserver(MaemoSdlEventSource *eventSource) { + assert(eventSource); + _eventSource = eventSource; +} + +bool MaemoSdlEventObserver::notifyEvent(const Common::Event &event) { +#ifdef ENABLE_KEYMAPPER + if (event.type != Common::EVENT_CUSTOM_BACKEND_ACTION) + return false; + if (event.customType == kEventClickMode) { + assert(_eventSource); + _eventSource->toggleClickMode(); + return true; + } +#endif + return false; +} + } // namespace Maemo #endif // if defined(MAEMO) diff --git a/backends/events/maemosdl/maemosdl-events.h b/backends/events/maemosdl/maemosdl-events.h index 5c06c4bc22..f3f05feeca 100644 --- a/backends/events/maemosdl/maemosdl-events.h +++ b/backends/events/maemosdl/maemosdl-events.h @@ -37,6 +37,8 @@ namespace Maemo { class MaemoSdlEventSource : public SdlEventSource { public: MaemoSdlEventSource(); + + bool toggleClickMode(); protected: virtual bool remapKey(SDL_Event &ev, Common::Event &event); virtual bool handleMouseButtonDown(SDL_Event &ev, Common::Event &event); @@ -45,6 +47,15 @@ protected: bool _clickEnabled; }; +class MaemoSdlEventObserver : public Common::EventObserver { +public: + MaemoSdlEventObserver(MaemoSdlEventSource *eventSource); + + virtual bool notifyEvent(const Common::Event &event); +private: + MaemoSdlEventSource *_eventSource; +}; + } // namespace Maemo #endif // include guard diff --git a/backends/events/webossdl/webossdl-events.cpp b/backends/events/webossdl/webossdl-events.cpp index d01e51fafe..286289f7a6 100644 --- a/backends/events/webossdl/webossdl-events.cpp +++ b/backends/events/webossdl/webossdl-events.cpp @@ -151,8 +151,8 @@ bool WebOSSdlEventSource::handleMouseButtonDown(SDL_Event &ev, event.type = Common::EVENT_LBUTTONDOWN; processMouseEvent(event, _curX, _curY); } - // If we're not in touchpad mode, move the cursor to the tap - if (!_touchpadMode) { + // If we're not in trackpad mode, move the cursor to the tap + if (!_trackpadMode) { _curX = MIN(_screenX, MAX(0, 0 + ev.motion.x)); _curY = MIN(_screenY, MAX(0, 0 + ev.motion.y)); // If we're already clicking, hold it until after the move. @@ -254,7 +254,7 @@ bool WebOSSdlEventSource::handleMouseMotion(SDL_Event &ev, // If only one finger is on the screen and moving, that's // the mouse pointer. if (!_fingerDown[1] && !_fingerDown[2]) { - if (_touchpadMode) { + if (_trackpadMode) { _curX = MIN(_screenX, MAX(0, _curX + ev.motion.xrel)); _curY = MIN(_screenY, MAX(0, _curY + ev.motion.yrel)); } else { @@ -301,16 +301,16 @@ bool WebOSSdlEventSource::handleMouseMotion(SDL_Event &ev, _queuedEscapeUpTime = g_system->getMillis() + QUEUED_KEY_DELAY; } else if (_dragDiffX[0] > 0 && _dragDiffX[1] > 0) { - // A swipe right toggles touchpad mode - _touchpadMode = !_touchpadMode; - g_system->showMouse(_touchpadMode); - // I18N: Touchpad mode toggle status. - Common::String dialogMsg(_("Touchpad mode is now")); + // A swipe right toggles trackpad mode + _trackpadMode = !_trackpadMode; + g_system->showMouse(_trackpadMode); + // I18N: Trackpad mode toggle status. + Common::String dialogMsg(_("Trackpad mode is now")); dialogMsg += " "; - // I18N: Touchpad mode on or off. - dialogMsg += (_touchpadMode ? _("ON") : _("OFF")); + // I18N: Trackpad mode on or off. + dialogMsg += (_trackpadMode ? _("ON") : _("OFF")); dialogMsg += ".\n"; - // I18N: Instructions to toggle Touchpad mode. + // I18N: Instructions to toggle Trackpad mode. dialogMsg += _("Swipe two fingers to the right to toggle."); GUI::TimedMessageDialog dialog(dialogMsg, 1500); @@ -376,12 +376,12 @@ bool WebOSSdlEventSource::pollEvent(Common::Event &event) { if (_firstPoll) { // Set the initial dimensions calculateDimensions(); - - // Having a mouse pointer on screen when not in Touchpad mode is poor + + // Having a mouse pointer on screen when not in Trackpad mode is poor // interface design, because the user won't know whether to tap buttons // or drag the pointer to them. On the first poll, set the appropriate // pointer visibility. - g_system->showMouse(_touchpadMode); + g_system->showMouse(_trackpadMode); _firstPoll = false; } diff --git a/backends/events/webossdl/webossdl-events.h b/backends/events/webossdl/webossdl-events.h index a36ee535a3..99ed3105f8 100644 --- a/backends/events/webossdl/webossdl-events.h +++ b/backends/events/webossdl/webossdl-events.h @@ -45,7 +45,7 @@ public: _dragStartTime(0), _dragging(false), _curX(0), _curY(0), _screenX(0), _screenY(0), - _touchpadMode(false), _autoDragMode(true), + _trackpadMode(false), _autoDragMode(true), _doClick(true), _queuedDragTime(0), _queuedEscapeUpTime(0), _queuedSpaceUpTime(0), _queuedRUpTime(0), @@ -80,8 +80,8 @@ protected: // The drag distance for linear gestures int _swipeDistX, _swipeDistY; - // Indicates if we're in touchpad mode or tap-to-move mode. - bool _touchpadMode; + // Indicates if we're in trackpad mode or tap-to-move mode. + bool _trackpadMode; // Indicates if we're in automatic drag mode. bool _autoDragMode; diff --git a/backends/fs/amigaos4/amigaos4-fs.h b/backends/fs/amigaos4/amigaos4-fs.h index 4e231330f0..c5ca61476f 100644 --- a/backends/fs/amigaos4/amigaos4-fs.h +++ b/backends/fs/amigaos4/amigaos4-fs.h @@ -91,10 +91,10 @@ public: virtual ~AmigaOSFilesystemNode(); virtual bool exists() const; - virtual Common::String getDisplayName() const { return _sDisplayName; }; - virtual Common::String getName() const { return _sDisplayName; }; - virtual Common::String getPath() const { return _sPath; }; - virtual bool isDirectory() const { return _bIsDirectory; }; + virtual Common::String getDisplayName() const { return _sDisplayName; } + virtual Common::String getName() const { return _sDisplayName; } + virtual Common::String getPath() const { return _sPath; } + virtual bool isDirectory() const { return _bIsDirectory; } virtual bool isReadable() const; virtual bool isWritable() const; diff --git a/backends/fs/ps2/ps2-fs.h b/backends/fs/ps2/ps2-fs.h index 9323715c7f..df78f9f68a 100644 --- a/backends/fs/ps2/ps2-fs.h +++ b/backends/fs/ps2/ps2-fs.h @@ -96,7 +96,7 @@ public: virtual Common::SeekableReadStream *createReadStream(); virtual Common::WriteStream *createWriteStream(); - int getDev() { return 0; }; + int getDev() { return 0; } }; #endif diff --git a/backends/fs/psp/psp-fs-factory.h b/backends/fs/psp/psp-fs-factory.h index aeaa9d6a87..d57c8fb655 100644 --- a/backends/fs/psp/psp-fs-factory.h +++ b/backends/fs/psp/psp-fs-factory.h @@ -37,7 +37,7 @@ public: virtual AbstractFSNode *makeFileNodePath(const Common::String &path) const; protected: - PSPFilesystemFactory() {}; + PSPFilesystemFactory() {} private: friend class Common::Singleton<SingletonBaseType>; diff --git a/backends/fs/symbian/symbian-fs.cpp b/backends/fs/symbian/symbian-fs.cpp index 9f70e7a7c9..fc78f7580b 100644 --- a/backends/fs/symbian/symbian-fs.cpp +++ b/backends/fs/symbian/symbian-fs.cpp @@ -70,7 +70,7 @@ SymbianFilesystemNode::SymbianFilesystemNode(const Common::String &path) { TPtrC8 ptr((const unsigned char*)_path.c_str(),_path.size()); fname.Copy(ptr); - if (static_cast<OSystem_SDL_Symbian*>(g_system)->FsSession().Entry(fname, fileAttribs) == KErrNone) { + if (static_cast<OSystem_SDL_Symbian *>(g_system)->FsSession().Entry(fname, fileAttribs) == KErrNone) { _isValid = true; _isDirectory = fileAttribs.IsDir(); } else { @@ -87,7 +87,7 @@ bool SymbianFilesystemNode::exists() const { TFileName fname; TPtrC8 ptr((const unsigned char*) _path.c_str(), _path.size()); fname.Copy(ptr); - bool fileExists = BaflUtils::FileExists(static_cast<OSystem_SDL_Symbian*> (g_system)->FsSession(), fname); + bool fileExists = BaflUtils::FileExists(static_cast<OSystem_SDL_Symbian *> (g_system)->FsSession(), fname); if (!fileExists) { TParsePtrC parser(fname); if (parser.PathPresent() && parser.Path().Compare(_L("\\")) == KErrNone && !parser.NameOrExtPresent()) { @@ -125,7 +125,7 @@ bool SymbianFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b if (_isPseudoRoot) { // Drives enumeration - RFs& fs = static_cast<OSystem_SDL_Symbian*>(g_system)->FsSession(); + RFs& fs = static_cast<OSystem_SDL_Symbian *>(g_system)->FsSession(); TInt driveNumber; TChar driveLetter; TUint driveLetterValue; @@ -153,7 +153,7 @@ bool SymbianFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b sprintf(path,"%c:\\", driveNumber+'A'); SymbianFilesystemNode entry(false); - entry._displayName = (char*) driveString8.PtrZ(); // drive_name + entry._displayName = (char *) driveString8.PtrZ(); // drive_name entry._isDirectory = true; entry._isValid = true; entry._isPseudoRoot = false; @@ -170,7 +170,7 @@ bool SymbianFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b if (_path.lastChar() != '\\') fname.Append('\\'); - if (static_cast<OSystem_SDL_Symbian*>(g_system)->FsSession().GetDir(fname, KEntryAttNormal|KEntryAttDir, 0, dirPtr) == KErrNone) { + if (static_cast<OSystem_SDL_Symbian *>(g_system)->FsSession().GetDir(fname, KEntryAttNormal|KEntryAttDir, 0, dirPtr) == KErrNone) { CleanupStack::PushL(dirPtr); TInt cnt = dirPtr->Count(); for (TInt loop = 0; loop < cnt; loop++) { diff --git a/backends/fs/symbian/symbianstream.cpp b/backends/fs/symbian/symbianstream.cpp index 39249578f7..fa7842d3b1 100644 --- a/backends/fs/symbian/symbianstream.cpp +++ b/backends/fs/symbian/symbianstream.cpp @@ -70,22 +70,22 @@ TSymbianFileEntry* CreateSymbianFileEntry(const char* name, const char* mode) { switch (mode[0]) { case 'a': - if (fileEntry->_fileHandle.Open(static_cast<OSystem_SDL_Symbian*>(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) { - if (fileEntry->_fileHandle.Create(static_cast<OSystem_SDL_Symbian*>(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) { + if (fileEntry->_fileHandle.Open(static_cast<OSystem_SDL_Symbian *>(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) { + if (fileEntry->_fileHandle.Create(static_cast<OSystem_SDL_Symbian *>(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) { delete fileEntry; fileEntry = NULL; } } break; case 'r': - if (fileEntry->_fileHandle.Open(static_cast<OSystem_SDL_Symbian*>(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) { + if (fileEntry->_fileHandle.Open(static_cast<OSystem_SDL_Symbian *>(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) { delete fileEntry; fileEntry = NULL; } break; case 'w': - if (fileEntry->_fileHandle.Replace(static_cast<OSystem_SDL_Symbian*>(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) { + if (fileEntry->_fileHandle.Replace(static_cast<OSystem_SDL_Symbian *>(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) { delete fileEntry; fileEntry = NULL; } @@ -96,7 +96,7 @@ TSymbianFileEntry* CreateSymbianFileEntry(const char* name, const char* mode) { } size_t ReadData(const void* ptr, size_t size, size_t numItems, TSymbianFileEntry* handle) { - TSymbianFileEntry* entry = ((TSymbianFileEntry*)(handle)); + TSymbianFileEntry* entry = ((TSymbianFileEntry *)(handle)); TUint32 totsize = size*numItems; TPtr8 pointer ( (unsigned char*) ptr, totsize); @@ -169,29 +169,29 @@ SymbianStdioStream::SymbianStdioStream(void *handle) : _handle(handle) { } SymbianStdioStream::~SymbianStdioStream() { - ((TSymbianFileEntry*)(_handle))->_fileHandle.Close(); + ((TSymbianFileEntry *)(_handle))->_fileHandle.Close(); - delete (TSymbianFileEntry*)(_handle); + delete (TSymbianFileEntry *)(_handle); } bool SymbianStdioStream::err() const { - return ((TSymbianFileEntry*)(_handle))->_lastError != 0; + return ((TSymbianFileEntry *)(_handle))->_lastError != 0; } void SymbianStdioStream::clearErr() { - ((TSymbianFileEntry*)(_handle))->_lastError = 0; - ((TSymbianFileEntry*)(_handle))->_eofReached = 0; + ((TSymbianFileEntry *)(_handle))->_lastError = 0; + ((TSymbianFileEntry *)(_handle))->_eofReached = 0; } bool SymbianStdioStream::eos() const { - TSymbianFileEntry* entry = ((TSymbianFileEntry*)(_handle)); + TSymbianFileEntry* entry = ((TSymbianFileEntry *)(_handle)); return entry->_eofReached != 0; } int32 SymbianStdioStream::pos() const { TInt pos = 0; - TSymbianFileEntry* entry = ((TSymbianFileEntry*)(_handle)); + TSymbianFileEntry* entry = ((TSymbianFileEntry *)(_handle)); entry->_lastError = entry->_fileHandle.Seek(ESeekCurrent, pos); if (entry->_lastError == KErrNone && entry->_inputPos != KErrNotFound) { @@ -204,7 +204,7 @@ int32 SymbianStdioStream::pos() const { int32 SymbianStdioStream::size() const { TInt length = 0; - ((TSymbianFileEntry*)(_handle))->_fileHandle.Size(length); + ((TSymbianFileEntry *)(_handle))->_fileHandle.Size(length); return length; } @@ -214,7 +214,7 @@ bool SymbianStdioStream::seek(int32 offs, int whence) { TSeek seekMode = ESeekStart; TInt pos = offs; - TSymbianFileEntry* entry = ((TSymbianFileEntry*)(_handle)); + TSymbianFileEntry* entry = ((TSymbianFileEntry *)(_handle)); switch (whence) { case SEEK_SET: @@ -246,11 +246,11 @@ uint32 SymbianStdioStream::read(void *ptr, uint32 len) { uint32 SymbianStdioStream::write(const void *ptr, uint32 len) { TPtrC8 pointer( (unsigned char*) ptr, len); - ((TSymbianFileEntry*)(_handle))->_inputPos = KErrNotFound; - ((TSymbianFileEntry*)(_handle))->_lastError = ((TSymbianFileEntry*)(_handle))->_fileHandle.Write(pointer); - ((TSymbianFileEntry*)(_handle))->_eofReached = EFalse; + ((TSymbianFileEntry *)(_handle))->_inputPos = KErrNotFound; + ((TSymbianFileEntry *)(_handle))->_lastError = ((TSymbianFileEntry *)(_handle))->_fileHandle.Write(pointer); + ((TSymbianFileEntry *)(_handle))->_eofReached = EFalse; - if (((TSymbianFileEntry*)(_handle))->_lastError == KErrNone) { + if (((TSymbianFileEntry *)(_handle))->_lastError == KErrNone) { return len; } @@ -258,7 +258,7 @@ uint32 SymbianStdioStream::write(const void *ptr, uint32 len) { } bool SymbianStdioStream::flush() { - ((TSymbianFileEntry*)(_handle))->_fileHandle.Flush(); + ((TSymbianFileEntry *)(_handle))->_fileHandle.Flush(); return true; } diff --git a/backends/fs/windows/windows-fs.cpp b/backends/fs/windows/windows-fs.cpp index c32ad2da94..030f394f81 100644 --- a/backends/fs/windows/windows-fs.cpp +++ b/backends/fs/windows/windows-fs.cpp @@ -87,7 +87,7 @@ void WindowsFilesystemNode::addFile(AbstractFSList &list, ListMode mode, const c char* WindowsFilesystemNode::toAscii(TCHAR *str) { #ifndef UNICODE - return (char*)str; + return (char *)str; #else static char asciiString[MAX_PATH]; WideCharToMultiByte(CP_ACP, 0, str, _tcslen(str) + 1, asciiString, sizeof(asciiString), NULL, NULL); diff --git a/backends/graphics/maemosdl/maemosdl-graphics.cpp b/backends/graphics/maemosdl/maemosdl-graphics.cpp new file mode 100644 index 0000000000..527ef82b9d --- /dev/null +++ b/backends/graphics/maemosdl/maemosdl-graphics.cpp @@ -0,0 +1,60 @@ +/* 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(MAEMO) + +#include "SDL_syswm.h" + +#include "common/scummsys.h" + +#include "backends/platform/maemo/maemo.h" +#include "backends/events/maemosdl/maemosdl-events.h" +#include "backends/graphics/maemosdl/maemosdl-graphics.h" + +MaemoSdlGraphicsManager::MaemoSdlGraphicsManager(SdlEventSource *sdlEventSource) + : SurfaceSdlGraphicsManager(sdlEventSource) { +} + +bool MaemoSdlGraphicsManager::loadGFXMode() { + bool success = SurfaceSdlGraphicsManager::loadGFXMode(); + + // fix the problematic zoom key capture in Maemo5/N900 + SDL_SysWMinfo info; + SDL_VERSION(&info.version); + if (SDL_GetWMInfo(&info)) { + Display *dpy = info.info.x11.display; + Window win; + unsigned long val = 1; + Atom atom_zoom = XInternAtom(dpy, "_HILDON_ZOOM_KEY_ATOM", 0); + info.info.x11.lock_func(); + win = info.info.x11.fswindow; + if (win) + XChangeProperty(dpy, win, atom_zoom, XA_INTEGER, 32, PropModeReplace, (unsigned char *) &val, 1); // grab zoom keys + win = info.info.x11.wmwindow; + if (win) + XChangeProperty(dpy, win, atom_zoom, XA_INTEGER, 32, PropModeReplace, (unsigned char *) &val, 1); // grab zoom keys + info.info.x11.unlock_func(); + } + + return success; +} + +#endif diff --git a/backends/platform/iphone/blit.cpp b/backends/graphics/maemosdl/maemosdl-graphics.h index 58de22bf75..81064d2d5f 100644 --- a/backends/platform/iphone/blit.cpp +++ b/backends/graphics/maemosdl/maemosdl-graphics.h @@ -20,29 +20,21 @@ * */ -#include "common/scummsys.h" -#include "blit_arm.h" - -void blitLandscapeScreenRect16bpp(uint16 *dst, uint16 *src, int width, int height, int screenWidth, int screenHeight) -{ - for (int x = width; x > 0; x--) { - for (int y = height; y > 0; y--) { - *(dst++) = *src; - src += screenWidth; - } - dst -= screenHeight + height; - src += 1 - height * screenWidth; - } -} - -void blitLandscapeScreenRect8bpp(uint16 *dst, byte *src, int width, int height, uint16 *palette, int screenWidth, int screenHeight) -{ - for (int x = width; x > 0; x--) { - for (int y = height; y > 0; y--) { - *(dst++) = palette[*src]; - src += screenWidth; - } - dst -= screenHeight + height; - src += 1 - height * screenWidth; - } -} +#if defined(MAEMO) + +#ifndef BACKENDS_GRAPHICS_MAEMOSDL_GRAPHICS_H +#define BACKENDS_GRAPHICS_MAEMOSDL_GRAPHICS_H + +#include "backends/graphics/surfacesdl/surfacesdl-graphics.h" + +class MaemoSdlGraphicsManager : public SurfaceSdlGraphicsManager { +public: + MaemoSdlGraphicsManager(SdlEventSource *sdlEventSource); + +protected: + virtual bool loadGFXMode(); +}; + +#endif + +#endif diff --git a/backends/graphics/null/null-graphics.h b/backends/graphics/null/null-graphics.h index 28b24f6aca..2e6b24d147 100644 --- a/backends/graphics/null/null-graphics.h +++ b/backends/graphics/null/null-graphics.h @@ -27,7 +27,7 @@ static const OSystem::GraphicsMode s_noGraphicsModes[] = { {0, 0, 0} }; -class NullGraphicsManager : GraphicsManager { +class NullGraphicsManager : public GraphicsManager { public: virtual ~NullGraphicsManager() {} @@ -38,6 +38,7 @@ public: const OSystem::GraphicsMode *getSupportedGraphicsModes() const { return s_noGraphicsModes; } int getDefaultGraphicsMode() const { return 0; } bool setGraphicsMode(int mode) { return true; } + void resetGraphicsScale(){} int getGraphicsMode() const { return 0; } inline Graphics::PixelFormat getScreenFormat() const { return Graphics::PixelFormat::createFormatCLUT8(); diff --git a/backends/graphics/opengl/glerrorcheck.cpp b/backends/graphics/opengl/glerrorcheck.cpp index 682207c7ef..439593577d 100644 --- a/backends/graphics/opengl/glerrorcheck.cpp +++ b/backends/graphics/opengl/glerrorcheck.cpp @@ -26,6 +26,7 @@ #include "backends/graphics/opengl/glerrorcheck.h" #include "common/textconsole.h" +#include "common/str.h" #ifdef WIN32 #if defined(ARRAYSIZE) && !defined(_WINDOWS_) @@ -44,7 +45,7 @@ #include <GL/gl.h> #endif -static const char *getGlErrStr(GLenum error) { +static Common::String getGlErrStr(GLenum error) { switch (error) { case GL_NO_ERROR: return "GL_NO_ERROR"; case GL_INVALID_ENUM: return "GL_INVALID_ENUM"; @@ -54,16 +55,13 @@ static const char *getGlErrStr(GLenum error) { case GL_OUT_OF_MEMORY: return "GL_OUT_OF_MEMORY"; } - // FIXME: Convert to use Common::String::format() - static char buf[40]; - snprintf(buf, sizeof(buf), "(Unknown GL error code 0x%x)", error); - return buf; + return Common::String::format("(Unknown GL error code 0x%x)", error); } void checkGlError(const char *file, int line) { GLenum error = glGetError(); if (error != GL_NO_ERROR) - warning("%s:%d: GL error: %s", file, line, getGlErrStr(error)); + warning("%s:%d: GL error: %s", file, line, getGlErrStr(error).c_str()); } #endif diff --git a/backends/graphics/opengl/gltexture.cpp b/backends/graphics/opengl/gltexture.cpp index b7f5c90105..ce69dc4aab 100644 --- a/backends/graphics/opengl/gltexture.cpp +++ b/backends/graphics/opengl/gltexture.cpp @@ -11,7 +11,7 @@ * 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 + * 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 @@ -60,8 +60,7 @@ void GLTexture::initGLExtensions() { return; // Get a string with all extensions - const char* ext_string = - reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)); + const char *ext_string = (const char *)glGetString(GL_EXTENSIONS); CHECK_GL_ERROR(); Common::StringTokenizer tokenizer(ext_string, " "); // Iterate all string tokens @@ -132,7 +131,7 @@ void GLTexture::allocBuffer(GLuint w, GLuint h) { // Allocate room for the texture glTexImage2D(GL_TEXTURE_2D, 0, _internalFormat, - _textureWidth, _textureHeight, 0, _glFormat, _glType, NULL); CHECK_GL_ERROR(); + _textureWidth, _textureHeight, 0, _glFormat, _glType, NULL); CHECK_GL_ERROR(); _refresh = false; } @@ -146,15 +145,15 @@ void GLTexture::updateBuffer(const void *buf, int pitch, GLuint x, GLuint y, GLu glBindTexture(GL_TEXTURE_2D, _textureName); CHECK_GL_ERROR(); // Check if the buffer has its data contiguously - if (static_cast<int>(w) * _bytesPerPixel == pitch) { + if ((int)w * _bytesPerPixel == pitch) { glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, - _glFormat, _glType, buf); CHECK_GL_ERROR(); + _glFormat, _glType, buf); CHECK_GL_ERROR(); } else { // Update the texture row by row - const byte *src = static_cast<const byte *>(buf); + const byte *src = (const byte *)buf; do { glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, - w, 1, _glFormat, _glType, src); CHECK_GL_ERROR(); + w, 1, _glFormat, _glType, src); CHECK_GL_ERROR(); ++y; src += pitch; } while (--h); diff --git a/backends/graphics/opengl/gltexture.h b/backends/graphics/opengl/gltexture.h index 71f1eeb78f..8ff9838ff7 100644 --- a/backends/graphics/opengl/gltexture.h +++ b/backends/graphics/opengl/gltexture.h @@ -68,29 +68,29 @@ public: static void initGLExtensions(); GLTexture(byte bpp, GLenum internalFormat, GLenum format, GLenum type); - virtual ~GLTexture(); + ~GLTexture(); /** * Refresh the texture after a context change. The * process will be completed on next allocBuffer call. */ - virtual void refresh(); + void refresh(); /** * Allocates memory needed for the given size. */ - virtual void allocBuffer(GLuint width, GLuint height); + void allocBuffer(GLuint width, GLuint height); /** * Updates the texture pixels. */ - virtual void updateBuffer(const void *buf, int pitch, GLuint x, GLuint y, + void updateBuffer(const void *buf, int pitch, GLuint x, GLuint y, GLuint w, GLuint h); /** * Draws the texture to the screen buffer. */ - virtual void drawTexture(GLshort x, GLshort y, GLshort w, GLshort h); + void drawTexture(GLshort x, GLshort y, GLshort w, GLshort h); /** * Get the texture width. @@ -103,12 +103,17 @@ public: GLuint getHeight() const { return _realHeight; } /** + * Get the bytes per pixel. + */ + uint getBytesPerPixel() const { return _bytesPerPixel; } + + /** * Set the texture filter. * @filter the filter type, GL_NEAREST or GL_LINEAR */ void setFilter(GLint filter) { _filter = filter; } -protected: +private: const byte _bytesPerPixel; const GLenum _internalFormat; const GLenum _glFormat; diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index 8e01e76f16..45804b5d6e 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -81,8 +81,8 @@ OpenGLGraphicsManager::~OpenGLGraphicsManager() { bool OpenGLGraphicsManager::hasFeature(OSystem::Feature f) { return - (f == OSystem::kFeatureAspectRatioCorrection) || - (f == OSystem::kFeatureCursorPalette); + (f == OSystem::kFeatureAspectRatioCorrection) || + (f == OSystem::kFeatureCursorPalette); } void OpenGLGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { @@ -269,9 +269,9 @@ OSystem::TransactionError OpenGLGraphicsManager::endGFXTransaction() { } if (_videoMode.fullscreen == _oldVideoMode.fullscreen && - _videoMode.mode == _oldVideoMode.mode && - _videoMode.screenWidth == _oldVideoMode.screenWidth && - _videoMode.screenHeight == _oldVideoMode.screenHeight) { + _videoMode.mode == _oldVideoMode.mode && + _videoMode.screenWidth == _oldVideoMode.screenWidth && + _videoMode.screenHeight == _oldVideoMode.screenHeight) { _oldVideoMode.setup = false; } @@ -420,7 +420,7 @@ void OpenGLGraphicsManager::setShakePos(int shakeOffset) { _shakePos = shakeOffset; } -void OpenGLGraphicsManager::setFocusRectangle(const Common::Rect& rect) { +void OpenGLGraphicsManager::setFocusRectangle(const Common::Rect &rect) { } void OpenGLGraphicsManager::clearFocusRectangle() { @@ -487,7 +487,8 @@ void OpenGLGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pitch } if (y < 0) { - h += y; buf -= y * pitch; + h += y; + buf -= y * pitch; y = 0; } @@ -500,26 +501,13 @@ void OpenGLGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pitch if (w <= 0 || h <= 0) return; - if (_overlayFormat.aBits() == 1) { - // Copy buffer with the alpha bit on for all pixels for correct - // overlay drawing. - const uint16 *src = (const uint16 *)buf; - uint16 *dst = (uint16 *)_overlayData.pixels + y * _overlayData.w + x; - for (int i = 0; i < h; i++) { - for (int e = 0; e < w; e++) - dst[e] = src[e] | 0x1; - src += pitch; - dst += _overlayData.w; - } - } else { - // Copy buffer data to internal overlay surface - const byte *src = (const byte *)buf; - byte *dst = (byte *)_overlayData.pixels + y * _overlayData.pitch; - for (int i = 0; i < h; i++) { - memcpy(dst + x * _overlayData.format.bytesPerPixel, src, w * _overlayData.format.bytesPerPixel); - src += pitch * sizeof(buf[0]); - dst += _overlayData.pitch; - } + // Copy buffer data to internal overlay surface + const byte *src = (const byte *)buf; + byte *dst = (byte *)_overlayData.pixels + y * _overlayData.pitch; + for (int i = 0; i < h; i++) { + memcpy(dst + x * _overlayData.format.bytesPerPixel, src, w * _overlayData.format.bytesPerPixel); + src += pitch * sizeof(buf[0]); + dst += _overlayData.pitch; } // Extend dirty area if not full screen redraw is flagged @@ -594,10 +582,8 @@ void OpenGLGraphicsManager::warpMouse(int x, int y) { scaledY += _displayY; } + setMousePosition(scaledX, scaledY); setInternalMousePosition(scaledX, scaledY); - - _cursorState.x = scaledX; - _cursorState.y = scaledY; } void OpenGLGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { @@ -613,7 +599,7 @@ void OpenGLGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int // Allocate space for cursor data if (_cursorData.w != w || _cursorData.h != h || - _cursorData.format.bytesPerPixel != _cursorFormat.bytesPerPixel) + _cursorData.format.bytesPerPixel != _cursorFormat.bytesPerPixel) _cursorData.create(w, h, _cursorFormat); // Save cursor data @@ -717,7 +703,7 @@ void OpenGLGraphicsManager::refreshGameScreen() { } else { // Update the texture _gameTexture->updateBuffer((byte *)_screenData.pixels + y * _screenData.pitch + - x * _screenData.format.bytesPerPixel, _screenData.pitch, x, y, w, h); + x * _screenData.format.bytesPerPixel, _screenData.pitch, x, y, w, h); } _screenNeedsRedraw = false; @@ -759,7 +745,7 @@ void OpenGLGraphicsManager::refreshOverlay() { } else { // Update the texture _overlayTexture->updateBuffer((byte *)_overlayData.pixels + y * _overlayData.pitch + - x * _overlayData.format.bytesPerPixel, _overlayData.pitch, x, y, w, h); + x * _overlayData.format.bytesPerPixel, _overlayData.pitch, x, y, w, h); } _overlayNeedsRedraw = false; @@ -838,38 +824,50 @@ void OpenGLGraphicsManager::refreshCursor() { } void OpenGLGraphicsManager::refreshCursorScale() { - // Get the window minimum scale factor. The cursor will mantain its original aspect - // ratio, and we do not want it to get too big if only one dimension is resized - uint screenScaleFactor = MIN(_videoMode.hardwareWidth * 10000 / _videoMode.screenWidth, - _videoMode.hardwareHeight * 10000 / _videoMode.screenHeight); - - // Do not scale cursor if original size is used - if (_videoMode.mode == OpenGL::GFX_ORIGINAL) - screenScaleFactor = _videoMode.scaleFactor * 10000; - - if ((uint)_cursorTargetScale * 10000 >= screenScaleFactor && (uint)_videoMode.scaleFactor * 10000 >= screenScaleFactor) { - // If the cursor target scale and the video mode scale factor are bigger than - // the current window scale, do not scale the cursor for the overlay - _cursorState.rW = _cursorState.w; - _cursorState.rH = _cursorState.h; - _cursorState.rHotX = _cursorState.hotX; - _cursorState.rHotY = _cursorState.hotY; - } else { - // Otherwise, scale the cursor for the overlay - int targetScaleFactor = MIN(_cursorTargetScale, _videoMode.scaleFactor); - // We limit the maximum scale to 3 here to avoid too big cursors, for large overlay resolutions - int actualFactor = MIN<uint>(3, screenScaleFactor - (targetScaleFactor - 1)) * 10000; - _cursorState.rW = (int16)(_cursorState.w * actualFactor / 10000); - _cursorState.rH = (int16)(_cursorState.h * actualFactor / 10000); - _cursorState.rHotX = (int16)(_cursorState.hotX * actualFactor / 10000); - _cursorState.rHotY = (int16)(_cursorState.hotY * actualFactor / 10000); - } - - // Always scale the cursor for the game - _cursorState.vW = (int16)(_cursorState.w * screenScaleFactor / 10000); - _cursorState.vH = (int16)(_cursorState.h * screenScaleFactor / 10000); - _cursorState.vHotX = (int16)(_cursorState.hotX * screenScaleFactor / 10000); - _cursorState.vHotY = (int16)(_cursorState.hotY * screenScaleFactor / 10000); + // Calculate the scale factors of the screen. We limit ourselves to 3 at + // most here to avoid really big (and ugly) cursors for big resolutions. + // It might be noteworthy that 3 is the (current) target scale for the + // modern theme and thus assures the cursor is *never* scaled. + // We also totally ignore the aspect of the overlay cursor, since aspect + // ratio correction only applies to the game screen. + uint screenScaleFactorX = MIN(30000, _videoMode.hardwareWidth * 10000 / _videoMode.screenWidth); + uint screenScaleFactorY = MIN(30000, _videoMode.hardwareHeight * 10000 / _videoMode.screenHeight); + + // Apply the target scale factor to the cursor. + // It might be noteworthy we only apply any scaling to the cursor in case + // the current scale factor is bigger than the target scale to match + // SurfaceSdlGraphicsManager's behavior. Otherwise we would downscale the + // GUI cursor of the modern theme for example. + if (screenScaleFactorX > uint(_cursorTargetScale * 10000)) + screenScaleFactorX /= _cursorTargetScale; + else + screenScaleFactorX = 10000; + if (screenScaleFactorY > uint(_cursorTargetScale * 10000)) + screenScaleFactorY /= _cursorTargetScale; + else + screenScaleFactorY = 10000; + + // Apply them (without any possible) aspect ratio correction to the + // overlay. + _cursorState.rW = (int16)(_cursorState.w * screenScaleFactorX / 10000); + _cursorState.rH = (int16)(_cursorState.h * screenScaleFactorY / 10000); + _cursorState.rHotX = (int16)(_cursorState.hotX * screenScaleFactorX / 10000); + _cursorState.rHotY = (int16)(_cursorState.hotY * screenScaleFactorY / 10000); + + // Make sure we properly scale the cursor according to the desired aspect. + // It might be noteworthy that, unlike with the overlay, we do not limit + // the scale factor here to avoid odd looks if the game uses items as + // mouse cursor, which would otherwise suddenly be smaller. + int width, height; + calculateDisplaySize(width, height); + screenScaleFactorX = (width * 10000 / _videoMode.screenWidth) / _cursorTargetScale; + screenScaleFactorY = (height * 10000 / _videoMode.screenHeight) / _cursorTargetScale; + + // Always scale the cursor for the game. + _cursorState.vW = (int16)(_cursorState.w * screenScaleFactorX / 10000); + _cursorState.vH = (int16)(_cursorState.h * screenScaleFactorY / 10000); + _cursorState.vHotX = (int16)(_cursorState.hotX * screenScaleFactorX / 10000); + _cursorState.vHotY = (int16)(_cursorState.hotY * screenScaleFactorY / 10000); } void OpenGLGraphicsManager::calculateDisplaySize(int &width, int &height) { @@ -1031,10 +1029,10 @@ void OpenGLGraphicsManager::internUpdateScreen() { // Draw the cursor if (_overlayVisible) _cursorTexture->drawTexture(_cursorState.x - _cursorState.rHotX, - _cursorState.y - _cursorState.rHotY, _cursorState.rW, _cursorState.rH); + _cursorState.y - _cursorState.rHotY, _cursorState.rW, _cursorState.rH); else _cursorTexture->drawTexture(_cursorState.x - _cursorState.vHotX, - _cursorState.y - _cursorState.vHotY, _cursorState.vW, _cursorState.vH); + _cursorState.y - _cursorState.vHotY, _cursorState.vW, _cursorState.vH); glPopMatrix(); } @@ -1115,8 +1113,6 @@ void OpenGLGraphicsManager::loadTextures() { } #endif - uint gameScreenBPP = 0; - if (!_gameTexture) { byte bpp; GLenum intformat; @@ -1127,7 +1123,6 @@ void OpenGLGraphicsManager::loadTextures() { #else getGLPixelFormat(Graphics::PixelFormat::createFormatCLUT8(), bpp, intformat, format, type); #endif - gameScreenBPP = bpp; _gameTexture = new GLTexture(bpp, intformat, format, type); } else _gameTexture->refresh(); @@ -1161,23 +1156,23 @@ void OpenGLGraphicsManager::loadTextures() { if ( #ifdef USE_RGB_COLOR - _transactionDetails.formatChanged || + _transactionDetails.formatChanged || #endif - _oldVideoMode.screenWidth != _videoMode.screenWidth || - _oldVideoMode.screenHeight != _videoMode.screenHeight) + _oldVideoMode.screenWidth != _videoMode.screenWidth || + _oldVideoMode.screenHeight != _videoMode.screenHeight) _screenData.create(_videoMode.screenWidth, _videoMode.screenHeight, #ifdef USE_RGB_COLOR - _screenFormat + _screenFormat #else - Graphics::PixelFormat::createFormatCLUT8() + Graphics::PixelFormat::createFormatCLUT8() #endif - ); + ); if (_oldVideoMode.overlayWidth != _videoMode.overlayWidth || - _oldVideoMode.overlayHeight != _videoMode.overlayHeight) + _oldVideoMode.overlayHeight != _videoMode.overlayHeight) _overlayData.create(_videoMode.overlayWidth, _videoMode.overlayHeight, - _overlayFormat); + _overlayFormat); _screenNeedsRedraw = true; _overlayNeedsRedraw = true; @@ -1186,10 +1181,11 @@ void OpenGLGraphicsManager::loadTextures() { // We need to setup a proper unpack alignment value here, else we will // get problems with the texture updates, in case the surface data is // not properly aligned. - // For now we use the gcd of the game screen format and 2, since 2 is - // the BPP value for the overlay and the OSD. - if (gameScreenBPP) - glPixelStorei(GL_UNPACK_ALIGNMENT, Common::gcd<uint>(gameScreenBPP, 2)); + // It is noteworthy this assumes the OSD uses the same BPP as the overlay + // and that the cursor works with any alignment setting. + int newAlignment = Common::gcd(_gameTexture->getBytesPerPixel(), _overlayTexture->getBytesPerPixel()); + assert(newAlignment == 1 || newAlignment == 2 || newAlignment == 4); + glPixelStorei(GL_UNPACK_ALIGNMENT, newAlignment); // We use a "pack" alignment (when reading from textures) to 4 here, // since the only place where we really use it is the BMP screenshot @@ -1253,8 +1249,8 @@ uint OpenGLGraphicsManager::getAspectRatio() const { // ratio correction is enabled, but it's better than the previous 4/3 mode // mess at least... if (_videoMode.aspectRatioCorrection - && ((_videoMode.screenWidth == 320 && _videoMode.screenHeight == 200) - || (_videoMode.screenWidth == 640 && _videoMode.screenHeight == 400))) + && ((_videoMode.screenWidth == 320 && _videoMode.screenHeight == 200) + || (_videoMode.screenWidth == 640 && _videoMode.screenHeight == 400))) return 13333; else if (_videoMode.mode == OpenGL::GFX_NORMAL) return _videoMode.hardwareWidth * 10000 / _videoMode.hardwareHeight; @@ -1266,15 +1262,13 @@ void OpenGLGraphicsManager::adjustMousePosition(int16 &x, int16 &y) { if (_overlayVisible) return; - if (!_overlayVisible) { - x -= _displayX; - y -= _displayY; + x -= _displayX; + y -= _displayY; - if (_displayWidth != _videoMode.screenWidth) - x = x * _videoMode.screenWidth / _displayWidth; - if (_displayHeight != _videoMode.screenHeight) - y = y * _videoMode.screenHeight / _displayHeight; - } + if (_displayWidth != _videoMode.screenWidth) + x = x * _videoMode.screenWidth / _displayWidth; + if (_displayHeight != _videoMode.screenHeight) + y = y * _videoMode.screenHeight / _displayHeight; } bool OpenGLGraphicsManager::saveScreenshot(const char *filename) { @@ -1349,7 +1343,7 @@ const char *OpenGLGraphicsManager::getCurrentModeName() { #ifdef USE_OSD const Graphics::Font *OpenGLGraphicsManager::getFontOSD() { - return FontMan.getFontByUsage(Graphics::FontManager::kLocalizedFont); + return FontMan.getFontByUsage(Graphics::FontManager::kLocalizedFont); } void OpenGLGraphicsManager::updateOSD() { diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index 6ded680eae..ad8765bab1 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -217,6 +217,7 @@ protected: uint getAspectRatio() const; + void setFormatIsBGR(bool isBGR) { _formatBGR = isBGR; } bool _formatBGR; // @@ -285,6 +286,14 @@ protected: int _cursorTargetScale; bool _cursorNeedsRedraw; + /** + * Set up the mouse position for graphics output. + * + * @param x X coordinate in native coordinates. + * @param y Y coordinate in native coordinates. + */ + void setMousePosition(int x, int y) { _cursorState.x = x; _cursorState.y = y; } + virtual void refreshCursor(); virtual void refreshCursorScale(); @@ -312,20 +321,20 @@ protected: #ifdef USE_OSD /** - * The OSD contents. + * Returns the font used for on screen display */ - Common::Array<Common::String> _osdLines; - - /** - * Returns the font used for on screen display - */ - virtual const Graphics::Font *getFontOSD(); + virtual const Graphics::Font *getFontOSD(); /** * Update the OSD texture / surface. */ void updateOSD(); + /** + * The OSD contents. + */ + Common::Array<Common::String> _osdLines; + GLTexture *_osdTexture; Graphics::Surface _osdSurface; uint8 _osdAlpha; diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index cfc78cfcac..b37d631c6d 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -318,12 +318,12 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() { // only used to ensure that the original pixel size aspect for these // modes is used. // (Non-square pixels on old monitors vs square pixel on new ones). - if (_videoMode.aspectRatioCorrection - && ((_videoMode.screenWidth == 320 && _videoMode.screenHeight == 200) - || (_videoMode.screenWidth == 640 && _videoMode.screenHeight == 400))) - _videoMode.overlayHeight = _videoMode.hardwareHeight = 240 * scaleFactor; - else - _videoMode.overlayHeight = _videoMode.hardwareHeight = _videoMode.screenHeight * scaleFactor; + if (_videoMode.aspectRatioCorrection) { + if (_videoMode.screenWidth == 320 && _videoMode.screenHeight == 200) + _videoMode.overlayHeight = _videoMode.hardwareHeight = 240 * scaleFactor; + else if (_videoMode.screenWidth == 640 && _videoMode.screenHeight == 400) + _videoMode.overlayHeight = _videoMode.hardwareHeight = 480 * scaleFactor; + } } _screenResized = false; @@ -376,7 +376,7 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() { } // Check if the screen is BGR format - _formatBGR = _hwscreen->format->Rshift != 0; + setFormatIsBGR(_hwscreen->format->Rshift != 0); if (isFullscreen) { _lastFullscreenModeWidth = _videoMode.hardwareWidth; @@ -460,10 +460,6 @@ void OpenGLSdlGraphicsManager::toggleFullScreen(int loop) { _activeFullscreenMode = -2; setFullscreenMode(!isFullscreen); } - - // HACK: We need to force a refresh here, since we change the - // fullscreen mode. - _transactionDetails.needRefresh = true; endGFXTransaction(); // Ignore resize events for the next 10 frames @@ -486,7 +482,7 @@ void OpenGLSdlGraphicsManager::toggleFullScreen(int loop) { } bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { - switch ((int)event.type) { + switch (event.type) { case Common::EVENT_KEYDOWN: if (event.kbd.hasFlags(Common::KBD_ALT)) { // Alt-Return and Alt-Enter toggle full screen mode @@ -671,8 +667,7 @@ void OpenGLSdlGraphicsManager::transformMouseCoordinates(Common::Point &point) { } void OpenGLSdlGraphicsManager::notifyMousePos(Common::Point mouse) { - _cursorState.x = mouse.x; - _cursorState.y = mouse.y; + setMousePosition(mouse.x, mouse.y); } #endif diff --git a/backends/keymapper/action.cpp b/backends/keymapper/action.cpp index 6ee506e7c3..33f5c423b0 100644 --- a/backends/keymapper/action.cpp +++ b/backends/keymapper/action.cpp @@ -28,10 +28,8 @@ namespace Common { -Action::Action(Keymap *boss, const char *i, String des, ActionType typ, - KeyType prefKey, int pri, int flg) - : _boss(boss), description(des), type(typ), preferredKey(prefKey), - priority(pri), flags(flg), _hwKey(0) { +Action::Action(Keymap *boss, const char *i, String des) + : _boss(boss), description(des), _hwInput(0) { assert(i); assert(_boss); @@ -40,18 +38,18 @@ Action::Action(Keymap *boss, const char *i, String des, ActionType typ, _boss->addAction(this); } -void Action::mapKey(const HardwareKey *key) { - if (_hwKey) +void Action::mapInput(const HardwareInput *input) { + if (_hwInput) _boss->unregisterMapping(this); - _hwKey = key; + _hwInput = input; - if (_hwKey) - _boss->registerMapping(this, _hwKey); + if (_hwInput) + _boss->registerMapping(this, _hwInput); } -const HardwareKey *Action::getMappedKey() const { - return _hwKey; +const HardwareInput *Action::getMappedInput() const { + return _hwInput; } } // End of namespace Common diff --git a/backends/keymapper/action.h b/backends/keymapper/action.h index b15b3aaaad..5e69ed3918 100644 --- a/backends/keymapper/action.h +++ b/backends/keymapper/action.h @@ -27,7 +27,6 @@ #ifdef ENABLE_KEYMAPPER -#include "backends/keymapper/types.h" #include "common/events.h" #include "common/func.h" #include "common/list.h" @@ -35,11 +34,17 @@ namespace Common { -struct HardwareKey; +struct HardwareInput; class Keymap; #define ACTION_ID_SIZE (4) +struct KeyActionEntry { + const KeyState ks; + const char *id; + const char *description; +}; + struct Action { /** unique id used for saving/loading to config */ char id[ACTION_ID_SIZE]; @@ -48,27 +53,26 @@ struct Action { /** Events to be sent when mapped key is pressed */ List<Event> events; - ActionType type; - KeyType preferredKey; - int priority; - int group; - int flags; private: - /** Hardware key that is mapped to this Action */ - const HardwareKey *_hwKey; + /** Hardware input that is mapped to this Action */ + const HardwareInput *_hwInput; Keymap *_boss; public: - Action(Keymap *boss, const char *id, String des = "", - ActionType typ = kGenericActionType, - KeyType prefKey = kGenericKeyType, - int pri = 0, int flg = 0 ); + Action(Keymap *boss, const char *id, String des = ""); void addEvent(const Event &evt) { events.push_back(evt); } + void addEvent(const EventType evtType) { + Event evt; + + evt.type = evtType; + events.push_back(evt); + } + void addKeyEvent(const KeyState &ks) { Event evt; @@ -78,42 +82,24 @@ public: } void addLeftClickEvent() { - Event evt; - - evt.type = EVENT_LBUTTONDOWN; - addEvent(evt); + addEvent(EVENT_LBUTTONDOWN); } void addMiddleClickEvent() { - Event evt; - - evt.type = EVENT_MBUTTONDOWN; - addEvent(evt); + addEvent(EVENT_MBUTTONDOWN); } void addRightClickEvent() { - Event evt; - - evt.type = EVENT_RBUTTONDOWN; - addEvent(evt); + addEvent(EVENT_RBUTTONDOWN); } Keymap *getParent() { return _boss; } - void mapKey(const HardwareKey *key); - const HardwareKey *getMappedKey() const; - -}; + void mapInput(const HardwareInput *input); + const HardwareInput *getMappedInput() const; -struct ActionPriorityComp : public BinaryFunction<Action, Action, bool> { - bool operator()(const Action *x, const Action *y) const { - return x->priority > y->priority; - } - bool operator()(const Action &x, const Action &y) const { - return x.priority > y.priority; - } }; } // End of namespace Common diff --git a/backends/keymapper/hardware-input.cpp b/backends/keymapper/hardware-input.cpp new file mode 100644 index 0000000000..a09f0b54fc --- /dev/null +++ b/backends/keymapper/hardware-input.cpp @@ -0,0 +1,273 @@ +/* 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 "backends/keymapper/hardware-input.h" + +#ifdef ENABLE_KEYMAPPER + +#include "backends/keymapper/keymapper.h" + +namespace Common { + +static const KeyTableEntry defaultKeys[] = { + {"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", false}, + {"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", false}, + {"CLEAR", KEYCODE_CLEAR, 0, "Clear", false}, + {"RETURN", KEYCODE_RETURN, ASCII_RETURN, "Return", false}, + {"PAUSE", KEYCODE_PAUSE, 0, "Pause", false}, + {"ESCAPE", KEYCODE_ESCAPE, ASCII_ESCAPE, "Esc", false}, + {"SPACE", KEYCODE_SPACE, ASCII_SPACE, "Space", false}, + {"EXCLAIM", KEYCODE_EXCLAIM, '!', "!", false}, + {"QUOTEDBL", KEYCODE_QUOTEDBL, '"', "\"", false}, + {"HASH", KEYCODE_HASH, '#', "#", false}, + {"DOLLAR", KEYCODE_DOLLAR, '$', "$", false}, + {"AMPERSAND", KEYCODE_AMPERSAND, '&', "&", false}, + {"QUOTE", KEYCODE_QUOTE, '\'', "'", false}, + {"LEFTPAREN", KEYCODE_LEFTPAREN, '(', "(", false}, + {"RIGHTPAREN", KEYCODE_RIGHTPAREN, ')', ")", false}, + {"ASTERISK", KEYCODE_ASTERISK, '*', "*", false}, + {"PLUS", KEYCODE_PLUS, '+', "+", false}, + {"COMMA", KEYCODE_COMMA, ',', ",", false}, + {"MINUS", KEYCODE_MINUS, '-', "-", false}, + {"PERIOD", KEYCODE_PERIOD, '.', ".", false}, + {"SLASH", KEYCODE_SLASH, '/', "/", false}, + {"0", KEYCODE_0, '0', "0", false}, + {"1", KEYCODE_1, '1', "1", false}, + {"2", KEYCODE_2, '2', "2", false}, + {"3", KEYCODE_3, '3', "3", false}, + {"4", KEYCODE_4, '4', "4", false}, + {"5", KEYCODE_5, '5', "5", false}, + {"6", KEYCODE_6, '6', "6", false}, + {"7", KEYCODE_7, '7', "7", false}, + {"8", KEYCODE_8, '8', "8", false}, + {"9", KEYCODE_9, '9', "9", false}, + {"COLON", KEYCODE_COLON, ':', ":", false}, + {"SEMICOLON", KEYCODE_SEMICOLON, ';', ";", false}, + {"LESS", KEYCODE_LESS, '<', "<", false}, + {"EQUALS", KEYCODE_EQUALS, '=', "=", false}, + {"GREATER", KEYCODE_GREATER, '>', ">", false}, + {"QUESTION", KEYCODE_QUESTION, '?', "?", false}, + {"AT", KEYCODE_AT, '@', "@", false}, + + {"LEFTBRACKET", KEYCODE_LEFTBRACKET, '[', "[", false}, + {"BACKSLASH", KEYCODE_BACKSLASH, '\\', "\\", false}, + {"RIGHTBRACKET", KEYCODE_RIGHTBRACKET, ']', "]", false}, + {"CARET", KEYCODE_CARET, '^', "^", false}, + {"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", false}, + {"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", false}, + {"a", KEYCODE_a, 'a', "a", true}, + {"b", KEYCODE_b, 'b', "b", true}, + {"c", KEYCODE_c, 'c', "c", true}, + {"d", KEYCODE_d, 'd', "d", true}, + {"e", KEYCODE_e, 'e', "e", true}, + {"f", KEYCODE_f, 'f', "f", true}, + {"g", KEYCODE_g, 'g', "g", true}, + {"h", KEYCODE_h, 'h', "h", true}, + {"i", KEYCODE_i, 'i', "i", true}, + {"j", KEYCODE_j, 'j', "j", true}, + {"k", KEYCODE_k, 'k', "k", true}, + {"l", KEYCODE_l, 'l', "l", true}, + {"m", KEYCODE_m, 'm', "m", true}, + {"n", KEYCODE_n, 'n', "n", true}, + {"o", KEYCODE_o, 'o', "o", true}, + {"p", KEYCODE_p, 'p', "p", true}, + {"q", KEYCODE_q, 'q', "q", true}, + {"r", KEYCODE_r, 'r', "r", true}, + {"s", KEYCODE_s, 's', "s", true}, + {"t", KEYCODE_t, 't', "t", true}, + {"u", KEYCODE_u, 'u', "u", true}, + {"v", KEYCODE_v, 'v', "v", true}, + {"w", KEYCODE_w, 'w', "w", true}, + {"x", KEYCODE_x, 'x', "x", true}, + {"y", KEYCODE_y, 'y', "y", true}, + {"z", KEYCODE_z, 'z', "z", true}, + {"DELETE", KEYCODE_DELETE, 0, "Del", false}, + + // Numeric keypad + {"KP0", KEYCODE_KP0, 0, "KP0", false}, + {"KP1", KEYCODE_KP1, 0, "KP1", false}, + {"KP2", KEYCODE_KP2, 0, "KP2", false}, + {"KP3", KEYCODE_KP3, 0, "KP3", false}, + {"KP4", KEYCODE_KP4, 0, "KP4", false}, + {"KP5", KEYCODE_KP5, 0, "KP5", false}, + {"KP6", KEYCODE_KP6, 0, "KP6", false}, + {"KP7", KEYCODE_KP7, 0, "KP7", false}, + {"KP8", KEYCODE_KP8, 0, "KP8", false}, + {"KP9", KEYCODE_KP9, 0, "KP9", false}, + {"KP_PERIOD", KEYCODE_KP_PERIOD, 0, "KP.", false}, + {"KP_DIVIDE", KEYCODE_KP_DIVIDE, 0, "KP/", false}, + {"KP_MULTIPLY", KEYCODE_KP_MULTIPLY, 0, "KP*", false}, + {"KP_MINUS", KEYCODE_KP_MINUS, 0, "KP-", false}, + {"KP_PLUS", KEYCODE_KP_PLUS, 0, "KP+", false}, + {"KP_ENTER", KEYCODE_KP_ENTER, 0, "KP Enter", false}, + {"KP_EQUALS", KEYCODE_KP_EQUALS, 0, "KP=", false}, + + // Arrows + Home/End pad + {"UP", KEYCODE_UP, 0, "Up", false}, + {"DOWN", KEYCODE_DOWN, 0, "Down", false}, + {"RIGHT", KEYCODE_RIGHT, 0, "Right", false}, + {"LEFT", KEYCODE_LEFT, 0, "Left", false}, + {"INSERT", KEYCODE_INSERT, 0, "Insert", false}, + {"HOME", KEYCODE_HOME, 0, "Home", false}, + {"END", KEYCODE_END, 0, "End", false}, + {"PAGEUP", KEYCODE_PAGEUP, 0, "PgUp", false}, + {"PAGEDOWN", KEYCODE_PAGEDOWN, 0, "PgDn", false}, + + // Function keys + {"F1", KEYCODE_F1, ASCII_F1, "F1", false}, + {"F2", KEYCODE_F2, ASCII_F2, "F2", false}, + {"F3", KEYCODE_F3, ASCII_F3, "F3", false}, + {"F4", KEYCODE_F4, ASCII_F4, "F4", false}, + {"F5", KEYCODE_F5, ASCII_F5, "F5", false}, + {"F6", KEYCODE_F6, ASCII_F6, "F6", false}, + {"F7", KEYCODE_F7, ASCII_F7, "F7", false}, + {"F8", KEYCODE_F8, ASCII_F8, "F8", false}, + {"F9", KEYCODE_F9, ASCII_F9, "F9", false}, + {"F10", KEYCODE_F10, ASCII_F10, "F10", false}, + {"F11", KEYCODE_F11, ASCII_F11, "F11", false}, + {"F12", KEYCODE_F12, ASCII_F12, "F12", false}, + {"F13", KEYCODE_F13, 0, "F13", false}, + {"F14", KEYCODE_F14, 0, "F14", false}, + {"F15", KEYCODE_F15, 0, "F15", false}, + + // Miscellaneous function keys + {"HELP", KEYCODE_HELP, 0, "Help", false}, + {"PRINT", KEYCODE_PRINT, 0, "Print", false}, + {"SYSREQ", KEYCODE_SYSREQ, 0, "SysRq", false}, + {"BREAK", KEYCODE_BREAK, 0, "Break", false}, + {"MENU", KEYCODE_MENU, 0, "Menu", false}, + // Power Macintosh power key + {"POWER", KEYCODE_POWER, 0, "Power", false}, + // Some european keyboards + {"EURO", KEYCODE_EURO, 0, "Euro", false}, + // Atari keyboard has Undo + {"UNDO", KEYCODE_UNDO, 0, "Undo", false}, + {0, KEYCODE_INVALID, 0, 0, false} +}; + +static const ModifierTableEntry defaultModifiers[] = { + { 0, "", "", false }, + { KBD_CTRL, "C+", "Ctrl+", false }, + { KBD_ALT, "A+", "Alt+", false }, + { KBD_SHIFT, "", "", true }, + { KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+", false }, + { KBD_SHIFT | KBD_CTRL, "S+C+", "Shift+Ctrl+", true }, + { KBD_SHIFT | KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+", true }, + { 0, 0, 0, false } +}; + +HardwareInputSet::HardwareInputSet(bool useDefault, const KeyTableEntry *keys, const ModifierTableEntry *modifiers) { + if (useDefault) + addHardwareInputs(defaultKeys, defaultModifiers); + if (keys) + addHardwareInputs(keys, modifiers ? modifiers : defaultModifiers); +} + +HardwareInputSet::~HardwareInputSet() { + List<const HardwareInput *>::const_iterator it; + + for (it = _inputs.begin(); it != _inputs.end(); ++it) + delete *it; +} + +void HardwareInputSet::addHardwareInput(const HardwareInput *input) { + assert(input); + + debug(8, "Adding hardware input [%s][%s]", input->id.c_str(), input->description.c_str()); + + removeHardwareInput(input); + + _inputs.push_back(input); +} + +const HardwareInput *HardwareInputSet::findHardwareInput(String id) const { + List<const HardwareInput *>::const_iterator it; + + for (it = _inputs.begin(); it != _inputs.end(); ++it) { + if ((*it)->id == id) + return (*it); + } + return 0; +} + +const HardwareInput *HardwareInputSet::findHardwareInput(const KeyState& keystate) const { + List<const HardwareInput *>::const_iterator it; + + for (it = _inputs.begin(); it != _inputs.end(); ++it) { + if ((*it)->key == keystate) + return (*it); + } + return 0; +} + +void HardwareInputSet::addHardwareInputs(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]) { + const KeyTableEntry *key; + const ModifierTableEntry *mod; + char fullKeyId[50]; + char fullKeyDesc[100]; + uint16 ascii; + + for (mod = modifiers; mod->id; mod++) { + for (key = keys; key->hwId; key++) { + ascii = key->ascii; + + if (mod->shiftable && key->shiftable) { + snprintf(fullKeyId, 50, "%s%c", mod->id, toupper(key->hwId[0])); + snprintf(fullKeyDesc, 100, "%s%c", mod->desc, toupper(key->desc[0])); + ascii = toupper(key->ascii); + } else if (mod->shiftable) { + snprintf(fullKeyId, 50, "S+%s%s", mod->id, key->hwId); + snprintf(fullKeyDesc, 100, "Shift+%s%s", mod->desc, key->desc); + } else { + snprintf(fullKeyId, 50, "%s%s", mod->id, key->hwId); + snprintf(fullKeyDesc, 100, "%s%s", mod->desc, key->desc); + } + + addHardwareInput(new HardwareInput(fullKeyId, KeyState(key->keycode, ascii, mod->flag), fullKeyDesc)); + } + } +} + +void HardwareInputSet::addHardwareInputs(const KeyTableEntry keys[]) { + addHardwareInputs(keys, defaultModifiers); +} + +void HardwareInputSet::removeHardwareInput(const HardwareInput *input) { + if (!input) + return; + + List<const HardwareInput *>::iterator it; + + for (it = _inputs.begin(); it != _inputs.end(); ++it) { + const HardwareInput *entry = (*it); + if (entry->id == input->id || entry->key == input->key) { + debug(7, "Removing hardware input [%s] (%s) because it matches [%s] (%s)", entry->id.c_str(), entry->description.c_str(), input->id.c_str(), input->description.c_str()); + delete entry; + _inputs.erase(it); + } + } +} + +} //namespace Common + +#endif // #ifdef ENABLE_KEYMAPPER + diff --git a/backends/keymapper/hardware-input.h b/backends/keymapper/hardware-input.h new file mode 100644 index 0000000000..9396765bbe --- /dev/null +++ b/backends/keymapper/hardware-input.h @@ -0,0 +1,131 @@ +/* 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 COMMON_HARDWARE_KEY_H +#define COMMON_HARDWARE_KEY_H + +#include "common/scummsys.h" + +#ifdef ENABLE_KEYMAPPER + +#include "common/keyboard.h" +#include "common/list.h" +#include "common/str.h" +#include "common/textconsole.h" + +namespace Common { + +/** +* Describes an available hardware input +*/ +struct HardwareInput { + /** unique id used for saving/loading to config */ + String id; + + /** Human readable description */ + String description; + + /** + * The KeyState that is generated by the back-end + * when this hardware key is pressed. + */ + KeyState key; + + HardwareInput(String i, KeyState ky = KeyState(), String desc = "") + : id(i), key(ky), description(desc) { } +}; + +/** + * Entry in a static table of available non-modifier keys + */ +struct KeyTableEntry { + const char *hwId; + KeyCode keycode; + uint16 ascii; + const char *desc; + bool shiftable; +}; + +/** + * Entry in a static table of available key modifiers + */ +struct ModifierTableEntry { + byte flag; + const char *id; + const char *desc; + bool shiftable; +}; + +/** + * Simple class to encapsulate a device's set of HardwareInputs. + * Each device should instantiate this and call addHardwareInput a number of times + * in its constructor to define the device's available keys. + */ +class HardwareInputSet { +public: + + /** + * Add hardware input keys to the set out of key and modifier tables. + * @param useDefault auto-add the built-in default inputs + * @param keys table of available keys + * @param modifiers table of available modifiers + */ + HardwareInputSet(bool useDefault = false, const KeyTableEntry keys[] = 0, const ModifierTableEntry modifiers[] = 0); + + virtual ~HardwareInputSet(); + + void addHardwareInput(const HardwareInput *input); + + const HardwareInput *findHardwareInput(String id) const; + + const HardwareInput *findHardwareInput(const KeyState& keystate) const; + + const List<const HardwareInput *> &getHardwareInputs() const { return _inputs; } + + uint size() const { return _inputs.size(); } + + /** + * Add hardware inputs to the set out of key and modifier tables. + * @param keys table of available keys + * @param modifiers table of available modifiers + */ + void addHardwareInputs(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]); + + /** + * Add hardware inputs to the set out of a key table. + * The default modifiers are applied to the key entries + * @param keys table of available keys + */ + void addHardwareInputs(const KeyTableEntry keys[]); + + void removeHardwareInput(const HardwareInput *input); + +private: + + List<const HardwareInput *> _inputs; +}; + +} // End of namespace Common + +#endif // #ifdef ENABLE_KEYMAPPER + +#endif // #ifndef COMMON_HARDWARE_KEY_H diff --git a/backends/keymapper/hardware-key.h b/backends/keymapper/hardware-key.h deleted file mode 100644 index 32df042525..0000000000 --- a/backends/keymapper/hardware-key.h +++ /dev/null @@ -1,136 +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. -* -*/ - -#ifndef COMMON_HARDWARE_KEY_H -#define COMMON_HARDWARE_KEY_H - -#include "common/scummsys.h" - -#ifdef ENABLE_KEYMAPPER - -#include "backends/keymapper/types.h" -#include "common/textconsole.h" - -namespace Common { - - -#define HWKEY_ID_SIZE (30) - -/** -* Describes an available hardware key -*/ -struct HardwareKey { - /** unique id used for saving/loading to config */ - char hwKeyId[HWKEY_ID_SIZE]; - - /** Human readable description */ - String description; - - /** - * The KeyState that is generated by the back-end - * when this hardware key is pressed. - */ - KeyState key; - - KeyType type; - ActionType preferredAction; - - HardwareKey(const char *i, KeyState ky = KeyState(), String desc = "", - KeyType typ = kGenericKeyType, ActionType prefAct = kGenericActionType) - : key(ky), description(desc), type(typ), preferredAction(prefAct) { - assert(i); - Common::strlcpy(hwKeyId, i, HWKEY_ID_SIZE); - } -}; - - -/** - * Simple class to encapsulate a device's set of HardwareKeys. - * Each device should instantiate this and call addHardwareKey a number of times - * in its constructor to define the device's available keys. - */ -class HardwareKeySet { -public: - - virtual ~HardwareKeySet() { - List<const HardwareKey*>::const_iterator it; - - for (it = _keys.begin(); it != _keys.end(); it++) - delete *it; - } - - void addHardwareKey(HardwareKey *key) { - checkForKey(key); - _keys.push_back(key); - } - - const HardwareKey *findHardwareKey(const char *id) const { - List<const HardwareKey*>::const_iterator it; - - for (it = _keys.begin(); it != _keys.end(); it++) { - if (strncmp((*it)->hwKeyId, id, HWKEY_ID_SIZE) == 0) - return (*it); - } - return 0; - } - - const HardwareKey *findHardwareKey(const KeyState& keystate) const { - List<const HardwareKey*>::const_iterator it; - - for (it = _keys.begin(); it != _keys.end(); it++) { - if ((*it)->key == keystate) - return (*it); - } - return 0; - } - - const List<const HardwareKey*> &getHardwareKeys() const { - return _keys; - } - - uint size() const { - return _keys.size(); - } - - -private: - - void checkForKey(HardwareKey *key) { - List<const HardwareKey*>::iterator it; - - for (it = _keys.begin(); it != _keys.end(); it++) { - if (strncmp((*it)->hwKeyId, key->hwKeyId, HWKEY_ID_SIZE) == 0) - error("Error adding HardwareKey '%s' - id of %s already in use!", key->description.c_str(), key->hwKeyId); - else if ((*it)->key == key->key) - error("Error adding HardwareKey '%s' - key already in use!", key->description.c_str()); - } - } - - List<const HardwareKey*> _keys; -}; - - -} // End of namespace Common - -#endif // #ifdef ENABLE_KEYMAPPER - -#endif // #ifndef COMMON_HARDWARE_KEY_H diff --git a/backends/keymapper/keymap.cpp b/backends/keymapper/keymap.cpp index 1518cba693..8ea975c927 100644 --- a/backends/keymapper/keymap.cpp +++ b/backends/keymapper/keymap.cpp @@ -24,26 +24,29 @@ #ifdef ENABLE_KEYMAPPER -#include "backends/keymapper/hardware-key.h" +#include "common/system.h" + +#include "backends/keymapper/hardware-input.h" +#include "backends/keymapper/keymapper-defaults.h" #define KEYMAP_KEY_PREFIX "keymap_" namespace Common { Keymap::Keymap(const Keymap& km) : _actions(km._actions), _keymap(), _configDomain(0) { - List<Action*>::iterator it; + List<Action *>::iterator it; for (it = _actions.begin(); it != _actions.end(); ++it) { - const HardwareKey *hwKey = (*it)->getMappedKey(); + const HardwareInput *hwInput = (*it)->getMappedInput(); - if (hwKey) { - _keymap[hwKey->key] = *it; + if (hwInput) { + _keymap[hwInput->key] = *it; } } } Keymap::~Keymap() { - List<Action*>::iterator it; + List<Action *>::iterator it; for (it = _actions.begin(); it != _actions.end(); ++it) delete *it; @@ -56,24 +59,24 @@ void Keymap::addAction(Action *action) { _actions.push_back(action); } -void Keymap::registerMapping(Action *action, const HardwareKey *hwKey) { - HashMap<KeyState, Action*>::iterator it; +void Keymap::registerMapping(Action *action, const HardwareInput *hwInput) { + HashMap<KeyState, Action *>::iterator it; - it = _keymap.find(hwKey->key); + it = _keymap.find(hwInput->key); // if key is already mapped to a different action then un-map it if (it != _keymap.end() && action != it->_value) { - it->_value->mapKey(0); + it->_value->mapInput(0); } - _keymap[hwKey->key] = action; + _keymap[hwInput->key] = action; } void Keymap::unregisterMapping(Action *action) { - const HardwareKey *hwKey = action->getMappedKey(); + const HardwareInput *hwInput = action->getMappedInput(); - if (hwKey) { - _keymap.erase(hwKey->key); + if (hwInput) { + _keymap.erase(hwInput->key); } } @@ -82,7 +85,7 @@ Action *Keymap::getAction(const char *id) { } Action *Keymap::findAction(const char *id) { - List<Action*>::iterator it; + List<Action *>::iterator it; for (it = _actions.begin(); it != _actions.end(); ++it) { if (strncmp((*it)->id, id, ACTION_ID_SIZE) == 0) @@ -92,7 +95,7 @@ Action *Keymap::findAction(const char *id) { } const Action *Keymap::findAction(const char *id) const { - List<Action*>::const_iterator it; + List<Action *>::const_iterator it; for (it = _actions.begin(); it != _actions.end(); ++it) { if (strncmp((*it)->id, id, ACTION_ID_SIZE) == 0) @@ -103,7 +106,7 @@ const Action *Keymap::findAction(const char *id) const { } Action *Keymap::getMappedAction(const KeyState& ks) const { - HashMap<KeyState, Action*>::iterator it; + HashMap<KeyState, Action *>::iterator it; it = _keymap.find(ks); @@ -117,40 +120,55 @@ void Keymap::setConfigDomain(ConfigManager::Domain *dom) { _configDomain = dom; } -void Keymap::loadMappings(const HardwareKeySet *hwKeys) { +void Keymap::loadMappings(const HardwareInputSet *hwKeys) { if (!_configDomain) return; - ConfigManager::Domain::iterator it; - String prefix = KEYMAP_KEY_PREFIX + _name + "_"; + if (_actions.empty()) + return; - for (it = _configDomain->begin(); it != _configDomain->end(); ++it) { - const String& key = it->_key; + Common::KeymapperDefaultBindings *defaults = g_system->getKeymapperDefaultBindings(); - if (!key.hasPrefix(prefix.c_str())) - continue; + HashMap<String, const HardwareInput *> mappedInputs; + List<Action*>::iterator it; + String prefix = KEYMAP_KEY_PREFIX + _name + "_"; - // parse Action ID - const char *actionId = key.c_str() + prefix.size(); - Action *ua = getAction(actionId); + for (it = _actions.begin(); it != _actions.end(); ++it) { + Action* ua = *it; + String actionId(ua->id); + String confKey = prefix + actionId; + + String hwInputId = _configDomain->getVal(confKey); + + bool defaulted = false; + // fall back to the platform-specific defaults + if (hwInputId.empty() && defaults) { + hwInputId = defaults->getDefaultBinding(_name, actionId); + if (!hwInputId.empty()) + defaulted = true; + } + // there's no mapping + if (hwInputId.empty()) + continue; - if (!ua) { - warning("'%s' keymap does not contain Action with ID %s", - _name.c_str(), actionId); - _configDomain->erase(key); + const HardwareInput *hwInput = hwKeys->findHardwareInput(hwInputId.c_str()); + if (!hwInput) { + warning("HardwareInput with ID '%s' not known", hwInputId.c_str()); continue; } - const HardwareKey *hwKey = hwKeys->findHardwareKey(it->_value.c_str()); - - if (!hwKey) { - warning("HardwareKey with ID %s not known", it->_value.c_str()); - _configDomain->erase(key); - continue; + if (defaulted) { + if (mappedInputs.contains(hwInputId)) { + debug(1, "Action [%s] not falling back to hardcoded default value [%s] because the hardware input is in use", confKey.c_str(), hwInputId.c_str()); + continue; + } + warning("Action [%s] fell back to hardcoded default value [%s]", confKey.c_str(), hwInputId.c_str()); } - ua->mapKey(hwKey); + mappedInputs.setVal(hwInputId, hwInput); + // map the key + ua->mapInput(hwInput); } } @@ -158,7 +176,7 @@ void Keymap::saveMappings() { if (!_configDomain) return; - List<Action*>::const_iterator it; + List<Action *>::const_iterator it; String prefix = KEYMAP_KEY_PREFIX + _name + "_"; for (it = _actions.begin(); it != _actions.end(); ++it) { @@ -167,170 +185,29 @@ void Keymap::saveMappings() { actIdLen = (actIdLen > ACTION_ID_SIZE) ? ACTION_ID_SIZE : actIdLen; String actId((*it)->id, (*it)->id + actIdLen); - char hwId[HWKEY_ID_SIZE+1]; - - memset(hwId, 0, HWKEY_ID_SIZE+1); + String hwId = ""; - if ((*it)->getMappedKey()) { - memcpy(hwId, (*it)->getMappedKey()->hwKeyId, HWKEY_ID_SIZE); + if ((*it)->getMappedInput()) { + hwId = (*it)->getMappedInput()->id; } _configDomain->setVal(prefix + actId, hwId); } } -bool Keymap::isComplete(const HardwareKeySet *hwKeys) { - List<Action*>::iterator it; +bool Keymap::isComplete(const HardwareInputSet *hwInputs) { + List<Action *>::iterator it; bool allMapped = true; uint numberMapped = 0; for (it = _actions.begin(); it != _actions.end(); ++it) { - if ((*it)->getMappedKey()) { - numberMapped++; + if ((*it)->getMappedInput()) { + ++numberMapped; } else { allMapped = false; } } - return allMapped || (numberMapped == hwKeys->size()); -} - -// TODO: -// - current weakness: -// - if an action finds a key with required type but a parent action with -// higher priority is using it, that key is never used -void Keymap::automaticMapping(HardwareKeySet *hwKeys) { - // Create copies of action and key lists. - List<Action*> actions(_actions); - List<const HardwareKey*> keys(hwKeys->getHardwareKeys()); - - List<Action*>::iterator actIt; - List<const HardwareKey*>::iterator keyIt, selectedKey; - - // Remove actions and keys from local lists that have already been mapped. - actIt = actions.begin(); - - while (actIt != actions.end()) { - Action *act = *actIt; - const HardwareKey *key = act->getMappedKey(); - - if (key) { - keys.remove(key); - actIt = actions.erase(actIt); - } else { - ++actIt; - } - } - - // Sort remaining actions by priority. - ActionPriorityComp priorityComp; - sort(actions.begin(), actions.end(), priorityComp); - - // First mapping pass: - // - Match if a key's preferred action type is the same as the action's - // type, or vice versa. - // - Priority is given to: - // - keys that match action types over key types. - // - keys that have not been used by parent maps. - // - If a key has been used by a parent map the new action must have a - // higher priority than the parent action. - // - As soon as the number of skipped actions equals the number of keys - // remaining we stop matching. This means that the second pass will assign keys - // to these higher priority skipped actions. - uint skipped = 0; - actIt = actions.begin(); - - while (actIt != actions.end() && skipped < keys.size()) { - selectedKey = keys.end(); - int matchRank = 0; - Action *act = *actIt; - - for (keyIt = keys.begin(); keyIt != keys.end(); ++keyIt) { - if ((*keyIt)->preferredAction == act->type && act->type != kGenericActionType) { - Action *parentAct = getParentMappedAction((*keyIt)->key); - - if (!parentAct) { - selectedKey = keyIt; - break; - } else if (parentAct->priority <= act->priority && matchRank < 3) { - selectedKey = keyIt; - matchRank = 3; - } - } else if ((*keyIt)->type == act->preferredKey && act->preferredKey != kGenericKeyType && matchRank < 2) { - Action *parentAct = getParentMappedAction((*keyIt)->key); - - if (!parentAct) { - selectedKey = keyIt; - matchRank = 2; - } else if (parentAct->priority <= act->priority && matchRank < 1) { - selectedKey = keyIt; - matchRank = 1; - } - } - } - if (selectedKey != keys.end()) { - // Map action and delete action & key from local lists. - act->mapKey(*selectedKey); - keys.erase(selectedKey); - actIt = actions.erase(actIt); - } else { - // Skip action (will be mapped in next pass). - ++actIt; - ++skipped; - } - } - - // Second mapping pass: - // - Maps any remaining actions to keys - // - priority given to: - // - keys that have no parent action - // - keys whose parent action has lower priority than the new action - // - keys whose parent action has the lowest priority - // - is guaranteed to match a key if they are not all used up - for (actIt = actions.begin(); actIt != actions.end(); ++actIt) { - selectedKey = keys.end(); - - int matchRank = 0; - int lowestPriority = 0; - Action *act = *actIt; - - for (keyIt = keys.begin(); keyIt != keys.end(); ++keyIt) { - Action *parentAct = getParentMappedAction((*keyIt)->key); - - if (!parentAct) { - selectedKey = keyIt; - break; - } else if (matchRank < 2) { - if (parentAct->priority <= act->priority) { - matchRank = 2; - selectedKey = keyIt; - } else if (parentAct->priority < lowestPriority || matchRank == 0) { - matchRank = 1; - lowestPriority = parentAct->priority; - selectedKey = keyIt; - } - } - } - - if (selectedKey != keys.end()) { - act->mapKey(*selectedKey); - keys.erase(selectedKey); - } else {// no match = no keys left - break; - } - } -} - -Action *Keymap::getParentMappedAction(KeyState key) { - if (_parent) { - Action *act = _parent->getMappedAction(key); - - if (act) - return act; - else - return _parent->getParentMappedAction(key); - } else { - return 0; - } + return allMapped || (numberMapped == hwInputs->size()); } } // End of namespace Common diff --git a/backends/keymapper/keymap.h b/backends/keymapper/keymap.h index 73f2293653..4c3e89700f 100644 --- a/backends/keymapper/keymap.h +++ b/backends/keymapper/keymap.h @@ -36,8 +36,8 @@ namespace Common { -struct HardwareKey; -class HardwareKeySet; +struct HardwareInput; +class HardwareInputSet; /** * Hash function for KeyState @@ -52,7 +52,7 @@ template<> struct Hash<KeyState> class Keymap { public: - Keymap(const String& name, Keymap *parent = 0) : _name(name), _parent(parent) {} + Keymap(const String& name) : _name(name) {} Keymap(const Keymap& km); ~Keymap(); @@ -67,7 +67,7 @@ public: /** * Get the list of all the Actions contained in this Keymap */ - List<Action*>& getActions() { return _actions; } + List<Action *>& getActions() { return _actions; } /** * Find the Action that a key is mapped to @@ -80,9 +80,9 @@ public: /** * Load this keymap's mappings from the config manager. - * @param hwKeys the set to retrieve hardware key pointers from + * @param hwInputs the set to retrieve hardware input pointers from */ - void loadMappings(const HardwareKeySet *hwKeys); + void loadMappings(const HardwareInputSet *hwInputs); /** * Save this keymap's mappings to the config manager @@ -91,17 +91,13 @@ public: */ void saveMappings(); - - void automaticMapping(HardwareKeySet *hwKeys); - /** * Returns true if all UserAction's in Keymap are mapped, or, - * all HardwareKey's from the given set have been used up. + * all HardwareInputs from the given set have been used up. */ - bool isComplete(const HardwareKeySet *hwKeys); + bool isComplete(const HardwareInputSet *hwInputs); const String& getName() { return _name; } - Keymap *getParent() { return _parent; } private: friend struct Action; @@ -114,15 +110,15 @@ private: void addAction(Action *action); /** - * Registers a HardwareKey to the given Action + * Registers a HardwareInput to the given Action * @param action Action in this Keymap - * @param key pointer to HardwareKey to map + * @param key pointer to HardwareInput to map * @see Action::mapKey */ - void registerMapping(Action *action, const HardwareKey *key); + void registerMapping(Action *action, const HardwareInput *input); /** - * Unregisters a HardwareKey from the given Action (if one is mapped) + * Unregisters a HardwareInput from the given Action (if one is mapped) * @param action Action in this Keymap * @see Action::mapKey */ @@ -131,14 +127,9 @@ private: Action *findAction(const char *id); const Action *findAction(const char *id) const; - void internalMapKey(Action *action, HardwareKey *hwKey); - - Action *getParentMappedAction(KeyState key); - String _name; - Keymap *_parent; - List<Action*> _actions; - HashMap<KeyState, Action*> _keymap; + List<Action *> _actions; + HashMap<KeyState, Action *> _keymap; ConfigManager::Domain *_configDomain; }; diff --git a/backends/keymapper/keymapper-defaults.h b/backends/keymapper/keymapper-defaults.h new file mode 100644 index 0000000000..bd4afd4e3a --- /dev/null +++ b/backends/keymapper/keymapper-defaults.h @@ -0,0 +1,56 @@ +/* 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. +* +*/ + +#ifdef ENABLE_KEYMAPPER + +#ifndef KEYMAPPER_DEFAULTS_H +#define KEYMAPPER_DEFAULTS_H + +#include "common/scummsys.h" +#include "common/hashmap.h" +#include "common/str.h" +#include "common/hash-str.h" + +namespace Common { + +class KeymapperDefaultBindings : HashMap<String, String> { +public: + /** + * This sets a default hwInput for a given Keymap Action + * @param keymapId String representing Keymap id (Keymap.name) + * @param actionId String representing Action id (Action.id) + * @param hwInputId String representing the HardwareInput id (HardwareInput.id) + */ + void setDefaultBinding(String keymapId, String actionId, String hwInputId) { setVal(keymapId + "_" + actionId, hwInputId); } + /** + * This retrieves the assigned default hwKey for a given Keymap Action + * @param keymapId String representing Keymap id (Keymap.name) + * @param actionId String representing Action id (Action.id) + * @return String representing the HardwareInput id (HardwareInput.id) + */ + String getDefaultBinding(String keymapId, String actionId) { return getVal(keymapId + "_" + actionId); } +}; + +} //namespace Common + +#endif // #ifndef KEYMAPPER_DEFAULTS_H +#endif // #ifdef ENABLE_KEYMAPPER diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index f5f29a2940..bda4cd47da 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -54,26 +54,26 @@ Keymap *Keymapper::Domain::getKeymap(const String& name) { } Keymapper::Keymapper(EventManager *evtMgr) - : _eventMan(evtMgr), _enabled(true), _hardwareKeys(0) { + : _eventMan(evtMgr), _enabled(true), _hardwareInputs(0) { ConfigManager::Domain *confDom = ConfMan.getDomain(ConfigManager::kKeymapperDomain); _globalDomain.setConfigDomain(confDom); } Keymapper::~Keymapper() { - delete _hardwareKeys; + delete _hardwareInputs; } -void Keymapper::registerHardwareKeySet(HardwareKeySet *keys) { - if (_hardwareKeys) - error("Hardware key set already registered"); +void Keymapper::registerHardwareInputSet(HardwareInputSet *inputs) { + if (_hardwareInputs) + error("Hardware input set already registered"); - if (!keys) { - warning("No hardware keys are supplied"); - return; + if (!inputs) { + warning("No hardware input were defined, using defaults"); + inputs = new HardwareInputSet(true); } - _hardwareKeys = keys; + _hardwareInputs = inputs; } void Keymapper::addGlobalKeymap(Keymap *keymap) { @@ -95,16 +95,15 @@ void Keymapper::addGameKeymap(Keymap *keymap) { } void Keymapper::initKeymap(Domain &domain, Keymap *map) { - if (!_hardwareKeys) { - warning("No hardware keys were registered yet (%s)", map->getName().c_str()); + if (!_hardwareInputs) { + warning("No hardware inputs were registered yet (%s)", map->getName().c_str()); return; } map->setConfigDomain(domain.getConfigDomain()); - map->loadMappings(_hardwareKeys); + map->loadMappings(_hardwareInputs); - if (map->isComplete(_hardwareKeys) == false) { - map->automaticMapping(_hardwareKeys); + if (map->isComplete(_hardwareInputs) == false) { map->saveMappings(); ConfMan.flushToDisk(); } @@ -120,7 +119,7 @@ void Keymapper::cleanupGameKeymaps() { // the game specific (=deleted) ones. Stack<MapRecord> newStack; - for (int i = 0; i < _activeMaps.size(); i++) { + for (Stack<MapRecord>::size_type i = 0; i < _activeMaps.size(); i++) { if (_activeMaps[i].global) newStack.push(_activeMaps[i]); } @@ -128,63 +127,87 @@ void Keymapper::cleanupGameKeymaps() { _activeMaps = newStack; } -Keymap *Keymapper::getKeymap(const String& name, bool &global) { +Keymap *Keymapper::getKeymap(const String& name, bool *globalReturn) { Keymap *keymap = _gameDomain.getKeymap(name); - global = false; + bool global = false; if (!keymap) { keymap = _globalDomain.getKeymap(name); global = true; } + if (globalReturn) + *globalReturn = global; + return keymap; } -bool Keymapper::pushKeymap(const String& name, bool inherit) { +bool Keymapper::pushKeymap(const String& name, bool transparent) { bool global; - Keymap *newMap = getKeymap(name, global); + + assert(!name.empty()); + Keymap *newMap = getKeymap(name, &global); if (!newMap) { warning("Keymap '%s' not registered", name.c_str()); return false; } - pushKeymap(newMap, inherit, global); + pushKeymap(newMap, transparent, global); return true; } -void Keymapper::pushKeymap(Keymap *newMap, bool inherit, bool global) { - MapRecord mr = {newMap, inherit, global}; +void Keymapper::pushKeymap(Keymap *newMap, bool transparent, bool global) { + MapRecord mr = {newMap, transparent, global}; _activeMaps.push(mr); } -void Keymapper::popKeymap() { - if (!_activeMaps.empty()) - _activeMaps.pop(); +void Keymapper::popKeymap(const char *name) { + if (!_activeMaps.empty()) { + if (name) { + String topKeymapName = _activeMaps.top().keymap->getName(); + if (topKeymapName.equals(name)) + _activeMaps.pop(); + else + warning("An attempt to pop wrong keymap was blocked (expected %s but was %s)", name, topKeymapName.c_str()); + } else { + _activeMaps.pop(); + } + } + } -bool Keymapper::notifyEvent(const Common::Event &ev) { +List<Event> Keymapper::mapEvent(const Event &ev, EventSource *source) { + if (source && !source->allowMapping()) { + return DefaultEventMapper::mapEvent(ev, source); + } + + List<Event> mappedEvents; + if (ev.type == Common::EVENT_KEYDOWN) - return mapKeyDown(ev.kbd); + mappedEvents = mapKeyDown(ev.kbd); else if (ev.type == Common::EVENT_KEYUP) - return mapKeyUp(ev.kbd); + mappedEvents = mapKeyUp(ev.kbd); + + if (!mappedEvents.empty()) + return mappedEvents; else - return false; + return DefaultEventMapper::mapEvent(ev, source); } -bool Keymapper::mapKeyDown(const KeyState& key) { +List<Event> Keymapper::mapKeyDown(const KeyState& key) { return mapKey(key, true); } -bool Keymapper::mapKeyUp(const KeyState& key) { +List<Event> Keymapper::mapKeyUp(const KeyState& key) { return mapKey(key, false); } -bool Keymapper::mapKey(const KeyState& key, bool keyDown) { +List<Event> Keymapper::mapKey(const KeyState& key, bool keyDown) { if (!_enabled || _activeMaps.empty()) - return false; + return List<Event>(); Action *action = 0; @@ -192,17 +215,17 @@ bool Keymapper::mapKey(const KeyState& key, bool keyDown) { // Search for key in active keymap stack for (int i = _activeMaps.size() - 1; i >= 0; --i) { MapRecord mr = _activeMaps[i]; - + debug(5, "Keymapper::mapKey keymap: %s", mr.keymap->getName().c_str()); action = mr.keymap->getMappedAction(key); - if (action || mr.inherit == false) + if (action || !mr.transparent) break; } if (action) _keysDown[key] = action; } else { - HashMap<KeyState, Action*>::iterator it = _keysDown.find(key); + HashMap<KeyState, Action *>::iterator it = _keysDown.find(key); if (it != _keysDown.end()) { action = it->_value; @@ -211,11 +234,9 @@ bool Keymapper::mapKey(const KeyState& key, bool keyDown) { } if (!action) - return false; - - executeAction(action, keyDown); + return List<Event>(); - return true; + return executeAction(action, keyDown); } Action *Keymapper::getAction(const KeyState& key) { @@ -224,7 +245,8 @@ Action *Keymapper::getAction(const KeyState& key) { return action; } -void Keymapper::executeAction(const Action *action, bool keyDown) { +List<Event> Keymapper::executeAction(const Action *action, bool keyDown) { + List<Event> mappedEvents; List<Event>::const_iterator it; for (it = action->events.begin(); it != action->events.end(); ++it) { @@ -255,18 +277,22 @@ void Keymapper::executeAction(const Action *action, bool keyDown) { case EVENT_MBUTTONUP: if (keyDown) evt.type = EVENT_MBUTTONDOWN; break; + case EVENT_MAINMENU: + if (!keyDown) evt.type = EVENT_MAINMENU; + break; default: // don't deliver other events on key up if (!keyDown) continue; } evt.mouse = _eventMan->getMousePos(); - addEvent(evt); + mappedEvents.push_back(evt); } + return mappedEvents; } -const HardwareKey *Keymapper::findHardwareKey(const KeyState& key) { - return (_hardwareKeys) ? _hardwareKeys->findHardwareKey(key) : 0; +const HardwareInput *Keymapper::findHardwareInput(const KeyState& key) { + return (_hardwareInputs) ? _hardwareInputs->findHardwareInput(key) : 0; } } // End of namespace Common diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h index fcb444aa64..daa746f379 100644 --- a/backends/keymapper/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -31,17 +31,20 @@ #include "common/list.h" #include "common/hashmap.h" #include "common/stack.h" -#include "backends/keymapper/hardware-key.h" +#include "backends/keymapper/hardware-input.h" #include "backends/keymapper/keymap.h" namespace Common { -class Keymapper : public Common::EventMapper, private Common::ArtificialEventSource { +const char *const kGuiKeymapName = "gui"; +const char *const kGlobalKeymapName = "global"; + +class Keymapper : public Common::DefaultEventMapper { public: struct MapRecord { Keymap* keymap; - bool inherit; + bool transparent; bool global; }; @@ -74,18 +77,21 @@ public: Keymapper(EventManager *eventMan); ~Keymapper(); + // EventMapper interface + virtual List<Event> mapEvent(const Event &ev, EventSource *source); + /** - * Registers a HardwareKeySet with the Keymapper + * Registers a HardwareInputSet with the Keymapper * @note should only be called once (during backend initialisation) */ - void registerHardwareKeySet(HardwareKeySet *keys); + void registerHardwareInputSet(HardwareInputSet *inputs); /** - * Get a list of all registered HardwareKeys + * Get a list of all registered HardwareInputs */ - const List<const HardwareKey*> &getHardwareKeys() const { - assert(_hardwareKeys); - return _hardwareKeys->getHardwareKeys(); + const List<const HardwareInput *> &getHardwareInputs() const { + assert(_hardwareInputs); + return _hardwareInputs->getHardwareInputs(); } /** @@ -114,26 +120,25 @@ public: * @param name name of the keymap to return * @param global set to true if returned keymap is global, false if game */ - Keymap *getKeymap(const String& name, bool &global); + Keymap *getKeymap(const String& name, bool *global = 0); /** * Push a new keymap to the top of the active stack, activating * it for use. - * @param name name of the keymap to push - * @param inherit if true keymapper will iterate down the - * stack if it cannot find a key in the new map - * @return true if succesful + * @param name name of the keymap to push + * @param transparent if true keymapper will iterate down the + * stack if it cannot find a key in the new map + * @return true if succesful */ - bool pushKeymap(const String& name, bool inherit = false); + bool pushKeymap(const String& name, bool transparent = false); /** * Pop the top keymap off the active stack. + * @param name (optional) name of keymap expected to be popped + * if provided, will not pop unless name is the same + * as the top keymap */ - void popKeymap(); - - // Implementation of the EventMapper interface - bool notifyEvent(const Common::Event &ev); - bool pollEvent(Common::Event &ev) { return Common::ArtificialEventSource::pollEvent(ev); } + void popKeymap(const char *name = 0); /** * @brief Map a key press event. @@ -141,21 +146,21 @@ public: * the Action's events are pushed into the EventManager's event queue. * @param key key that was pressed * @param keyDown true for key down, false for key up - * @return true if key was mapped + * @return mapped events */ - bool mapKey(const KeyState& key, bool keyDown); + List<Event> mapKey(const KeyState& key, bool keyDown); /** * @brief Map a key down event. * @see mapKey */ - bool mapKeyDown(const KeyState& key); + List<Event> mapKeyDown(const KeyState& key); /** * @brief Map a key up event. * @see mapKey */ - bool mapKeyUp(const KeyState& key); + List<Event> mapKeyUp(const KeyState& key); /** * Enable/disable the keymapper @@ -163,9 +168,9 @@ public: void setEnabled(bool enabled) { _enabled = enabled; } /** - * Return a HardwareKey pointer for the given key state + * Return a HardwareInput pointer for the given key state */ - const HardwareKey *findHardwareKey(const KeyState& key); + const HardwareInput *findHardwareInput(const KeyState& key); Domain& getGlobalDomain() { return _globalDomain; } Domain& getGameDomain() { return _gameDomain; } @@ -178,19 +183,19 @@ private: Domain _globalDomain; Domain _gameDomain; - HardwareKeySet *_hardwareKeys; + HardwareInputSet *_hardwareInputs; - void pushKeymap(Keymap *newMap, bool inherit, bool global); + void pushKeymap(Keymap *newMap, bool transparent, bool global); Action *getAction(const KeyState& key); - void executeAction(const Action *act, bool keyDown); + List<Event> executeAction(const Action *act, bool keyDown); EventManager *_eventMan; bool _enabled; Stack<MapRecord> _activeMaps; - HashMap<KeyState, Action*> _keysDown; + HashMap<KeyState, Action *> _keysDown; }; diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index 7f2df2f0fe..dab295219a 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -28,18 +28,18 @@ #include "gui/widgets/popup.h" #include "gui/widgets/scrollbar.h" #include "gui/ThemeEval.h" - #include "common/translation.h" namespace Common { enum { kRemapCmd = 'REMP', + kClearCmd = 'CLER', kCloseCmd = 'CLOS' }; RemapDialog::RemapDialog() - : Dialog("KeyMapper"), _keymapTable(0), _activeRemapAction(0), _topAction(0), _remapTimeout(0) { + : Dialog("KeyMapper"), _keymapTable(0), _activeRemapAction(0), _topAction(0), _remapTimeout(0), _topKeymapIsGui(false) { _keymapper = g_system->getEventManager()->getKeymapper(); assert(_keymapper); @@ -57,12 +57,13 @@ RemapDialog::~RemapDialog() { } void RemapDialog::open() { - bool divider = false; const Stack<Keymapper::MapRecord> &activeKeymaps = _keymapper->getActiveStack(); - if (!(activeKeymaps.size() > 0)) { - _kmPopUp->appendEntry(activeKeymaps.top().keymap->getName() + _(" (Active)")); - divider = true; + if (activeKeymaps.size() > 0) { + if (activeKeymaps.top().keymap->getName() == Common::kGuiKeymapName) + _topKeymapIsGui = true; + // Add the entry for the "effective" special view. See RemapDialog::loadKeymap() + _kmPopUp->appendEntry(activeKeymaps.top().keymap->getName() + _(" (Effective)")); } Keymapper::Domain *_globalKeymaps = &_keymapper->getGlobalDomain(); @@ -84,27 +85,45 @@ void RemapDialog::open() { keymapCount += _gameKeymaps->size(); } - debug(3, "keymaps: %d", keymapCount); + if (activeKeymaps.size() > 1) { + keymapCount += activeKeymaps.size() - 1; + } + + debug(3, "RemapDialog::open keymaps: %d", keymapCount); - _keymapTable = (Keymap **)malloc(sizeof(Keymap*) * keymapCount); + _keymapTable = (Keymap **)malloc(sizeof(Keymap *) * keymapCount); Keymapper::Domain::iterator it; uint32 idx = 0; + if (activeKeymaps.size() > 1) { + int topIndex = activeKeymaps.size() - 1; + bool active = activeKeymaps[topIndex].transparent; + for (int i = topIndex - 1; i >= 0; --i) { + Keymapper::MapRecord mr = activeKeymaps[i]; + // Add an entry for each keymap in the stack after the top keymap. Mark it Active if it is + // reachable or Blocked if an opaque keymap is on top of it thus blocking access to it. + _kmPopUp->appendEntry(mr.keymap->getName() + (active ? _(" (Active)") : _(" (Blocked)")), idx); + _keymapTable[idx++] = mr.keymap; + active &= mr.transparent; + } + } + + _kmPopUp->appendEntry(""); + + // Now add entries for all known keymaps. Note that there will be duplicates with the stack entries. + if (_globalKeymaps) { - if (divider) - _kmPopUp->appendEntry(""); for (it = _globalKeymaps->begin(); it != _globalKeymaps->end(); ++it) { + // "global" means its keybindings apply to all games; saved in a global conf domain _kmPopUp->appendEntry(it->_value->getName() + _(" (Global)"), idx); _keymapTable[idx++] = it->_value; } - divider = true; } if (_gameKeymaps) { - if (divider) - _kmPopUp->appendEntry(""); for (it = _gameKeymaps->begin(); it != _gameKeymaps->end(); ++it) { + // "game" means its keybindings are saved per-target _kmPopUp->appendEntry(it->_value->getName() + _(" (Game)"), idx); _keymapTable[idx++] = it->_value; } @@ -138,16 +157,19 @@ void RemapDialog::reflowLayout() { int16 areaX, areaY; uint16 areaW, areaH; + g_gui.xmlEval()->getWidgetData((const String&)String("KeyMapper.KeymapArea"), areaX, areaY, areaW, areaH); + int spacing = g_gui.xmlEval()->getVar("Globals.KeyMapper.Spacing"); - int labelWidth = g_gui.xmlEval()->getVar("Globals.KeyMapper.LabelWidth"); - int buttonWidth = g_gui.xmlEval()->getVar("Globals.KeyMapper.ButtonWidth"); - int colWidth = labelWidth + buttonWidth + spacing; + int keyButtonWidth = g_gui.xmlEval()->getVar("Globals.KeyMapper.ButtonWidth"); + int clearButtonWidth = g_gui.xmlEval()->getVar("Globals.Line.Height"); + int clearButtonHeight = g_gui.xmlEval()->getVar("Globals.Line.Height"); - g_gui.xmlEval()->getWidgetData((const String&)String("KeyMapper.KeymapArea"), areaX, areaY, areaW, areaH); + int colWidth = areaW - scrollbarWidth; + int labelWidth = colWidth - (keyButtonWidth + spacing + clearButtonWidth + spacing); - _colCount = (areaW - scrollbarWidth) / colWidth; _rowCount = (areaH + spacing) / (buttonHeight + spacing); - if (_colCount <= 0 || _rowCount <= 0) + debug(7, "rowCount = %d" , _rowCount); + if (colWidth <= 0 || _rowCount <= 0) error("Remap dialog too small to display any keymaps"); _scrollBar->resize(areaX + areaW - scrollbarWidth, areaY, scrollbarWidth, areaH); @@ -156,8 +178,9 @@ void RemapDialog::reflowLayout() { _scrollBar->recalc(); uint textYOff = (buttonHeight - kLineHeight) / 2; + uint clearButtonYOff = (buttonHeight - clearButtonHeight) / 2; uint oldSize = _keymapWidgets.size(); - uint newSize = _rowCount * _colCount; + uint newSize = _rowCount; _keymapWidgets.reserve(newSize); @@ -166,19 +189,22 @@ void RemapDialog::reflowLayout() { if (i >= _keymapWidgets.size()) { widg.actionText = - new GUI::StaticTextWidget(this, 0, 0, 0, 0, "", Graphics::kTextAlignRight); + new GUI::StaticTextWidget(this, 0, 0, 0, 0, "", Graphics::kTextAlignLeft); widg.keyButton = new GUI::ButtonWidget(this, 0, 0, 0, 0, "", 0, kRemapCmd + i); + widg.clearButton = addClearButton(this, "", kClearCmd + i, 0, 0, clearButtonWidth, clearButtonHeight); _keymapWidgets.push_back(widg); } else { widg = _keymapWidgets[i]; } - uint x = areaX + (i % _colCount) * colWidth; - uint y = areaY + (i / _colCount) * (buttonHeight + spacing); + uint x = areaX; + uint y = areaY + (i) * (buttonHeight + spacing); + + widg.keyButton->resize(x, y, keyButtonWidth, buttonHeight); + widg.clearButton->resize(x + keyButtonWidth + spacing, y + clearButtonYOff, clearButtonWidth, clearButtonHeight); + widg.actionText->resize(x + keyButtonWidth + spacing + clearButtonWidth + spacing, y + textYOff, labelWidth, kLineHeight); - widg.actionText->resize(x, y + textYOff, labelWidth, kLineHeight); - widg.keyButton->resize(x + labelWidth, y, buttonWidth, buttonHeight); } while (oldSize > newSize) { ActionWidgets widg = _keymapWidgets.remove_at(--oldSize); @@ -188,14 +214,19 @@ void RemapDialog::reflowLayout() { removeWidget(widg.keyButton); delete widg.keyButton; + + removeWidget(widg.clearButton); + delete widg.clearButton; } } void RemapDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { - debug(0, "Command!"); + debug(3, "RemapDialog::handleCommand %u %u", cmd, data); if (cmd >= kRemapCmd && cmd < kRemapCmd + _keymapWidgets.size()) { startRemapping(cmd - kRemapCmd); + } else if (cmd >= kClearCmd && cmd < kClearCmd + _keymapWidgets.size()) { + clearMapping(cmd - kClearCmd); } else if (cmd == GUI::kPopUpItemSelectedCmd) { loadKeymap(); } else if (cmd == GUI::kSetPositionCmd) { @@ -207,6 +238,23 @@ void RemapDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 d } } +void RemapDialog::clearMapping(uint i) { + if (_topAction + i >= _currentActions.size()) + return; + + debug(3, "clear the mapping %u", i); + _activeRemapAction = _currentActions[_topAction + i].action; + _activeRemapAction->mapInput(0); + _activeRemapAction->getParent()->saveMappings(); + _changes = true; + + // force refresh + _topAction = -1; + refreshKeymap(); + + _activeRemapAction = 0; +} + void RemapDialog::startRemapping(uint i) { if (_topAction + i >= _currentActions.size()) return; @@ -238,12 +286,12 @@ void RemapDialog::handleKeyDown(Common::KeyState state) { void RemapDialog::handleKeyUp(Common::KeyState state) { if (_activeRemapAction) { - const HardwareKey *hwkey = _keymapper->findHardwareKey(state); + const HardwareInput *hwInput = _keymapper->findHardwareInput(state); - debug(0, "Key: %d, %d (%c), %x", state.keycode, state.ascii, (state.ascii ? state.ascii : ' '), state.flags); + debug(4, "RemapDialog::handleKeyUp Key: %d, %d (%c), %x", state.keycode, state.ascii, (state.ascii ? state.ascii : ' '), state.flags); - if (hwkey) { - _activeRemapAction->mapKey(hwkey); + if (hwInput) { + _activeRemapAction->mapInput(hwInput); _activeRemapAction->getParent()->saveMappings(); _changes = true; stopRemapping(); @@ -270,52 +318,67 @@ void RemapDialog::loadKeymap() { _currentActions.clear(); const Stack<Keymapper::MapRecord> &activeKeymaps = _keymapper->getActiveStack(); + debug(3, "RemapDialog::loadKeymap active keymaps: %u", activeKeymaps.size()); + if (!activeKeymaps.empty() && _kmPopUp->getSelected() == 0) { - // load active keymaps + // This is the "effective" view which shows all effective actions: + // - all of the topmost keymap action + // - all mapped actions that are reachable - List<const HardwareKey*> freeKeys(_keymapper->getHardwareKeys()); + List<const HardwareInput *> freeInputs(_keymapper->getHardwareInputs()); - // add most active keymap's keys - Keymapper::MapRecord top = activeKeymaps.top(); - List<Action*>::iterator actIt; + int topIndex = activeKeymaps.size() - 1; + // This is a WORKAROUND for changing the popup list selected item and changing it back + // to the top entry. Upon changing it back, the top keymap is always "gui". + if (!_topKeymapIsGui && activeKeymaps[topIndex].keymap->getName() == kGuiKeymapName) + --topIndex; + + // add most active keymap's keys + Keymapper::MapRecord top = activeKeymaps[topIndex]; + List<Action *>::iterator actIt; + debug(3, "RemapDialog::loadKeymap top keymap: %s", top.keymap->getName().c_str()); for (actIt = top.keymap->getActions().begin(); actIt != top.keymap->getActions().end(); ++actIt) { Action *act = *actIt; ActionInfo info = {act, false, act->description}; _currentActions.push_back(info); - if (act->getMappedKey()) - freeKeys.remove(act->getMappedKey()); + if (act->getMappedInput()) + freeInputs.remove(act->getMappedInput()); } // loop through remaining finding mappings for unmapped keys - if (top.inherit) { - for (int i = activeKeymaps.size() - 2; i >= 0; --i) { + if (top.transparent && topIndex >= 0) { + for (int i = topIndex - 1; i >= 0; --i) { Keymapper::MapRecord mr = activeKeymaps[i]; - List<const HardwareKey*>::iterator keyIt = freeKeys.begin(); + debug(3, "RemapDialog::loadKeymap keymap: %s", mr.keymap->getName().c_str()); + List<const HardwareInput *>::iterator inputIt = freeInputs.begin(); + while (inputIt != freeInputs.end()) { - while (keyIt != freeKeys.end()) { - Action *act = mr.keymap->getMappedAction((*keyIt)->key); + Action *act = mr.keymap->getMappedAction((*inputIt)->key); if (act) { ActionInfo info = {act, true, act->description + " (" + mr.keymap->getName() + ")"}; _currentActions.push_back(info); - freeKeys.erase(keyIt++); + freeInputs.erase(inputIt); } else { - ++keyIt; + ++inputIt; } } - if (mr.inherit == false || freeKeys.empty()) + if (mr.transparent == false || freeInputs.empty()) break; } } } else if (_kmPopUp->getSelected() != -1) { + // This is the regular view of a keymap that isn't the topmost one. + // It shows all of that keymap's actions + Keymap *km = _keymapTable[_kmPopUp->getSelectedTag()]; - List<Action*>::iterator it; + List<Action *>::iterator it; for (it = km->getActions().begin(); it != km->getActions().end(); ++it) { ActionInfo info = {*it, false, (*it)->description}; @@ -326,7 +389,7 @@ void RemapDialog::loadKeymap() { // refresh scroll bar _scrollBar->_currentPos = 0; - _scrollBar->_numEntries = (_currentActions.size() + _colCount - 1) / _colCount; + _scrollBar->_numEntries = _currentActions.size(); _scrollBar->recalc(); // force refresh @@ -335,7 +398,7 @@ void RemapDialog::loadKeymap() { } void RemapDialog::refreshKeymap() { - int newTopAction = _scrollBar->_currentPos * _colCount; + int newTopAction = _scrollBar->_currentPos; if (newTopAction == _topAction) return; @@ -351,25 +414,28 @@ void RemapDialog::refreshKeymap() { ActionWidgets& widg = _keymapWidgets[widgetI]; if (actionI < _currentActions.size()) { + debug(8, "RemapDialog::refreshKeymap actionI=%u", actionI); ActionInfo& info = _currentActions[actionI]; - widg.actionText->setLabel(info.description + ": "); + widg.actionText->setLabel(info.description); widg.actionText->setEnabled(!info.inherited); - const HardwareKey *mappedKey = info.action->getMappedKey(); + const HardwareInput *mappedInput = info.action->getMappedInput(); - if (mappedKey) - widg.keyButton->setLabel(mappedKey->description); + if (mappedInput) + widg.keyButton->setLabel(mappedInput->description); else widg.keyButton->setLabel("-"); widg.actionText->setVisible(true); widg.keyButton->setVisible(true); + widg.clearButton->setVisible(true); actionI++; } else { widg.actionText->setVisible(false); widg.keyButton->setVisible(false); + widg.clearButton->setVisible(false); } //widg.actionText->draw(); //widg.keyButton->draw(); diff --git a/backends/keymapper/remap-dialog.h b/backends/keymapper/remap-dialog.h index f587ae515d..143deca4cf 100644 --- a/backends/keymapper/remap-dialog.h +++ b/backends/keymapper/remap-dialog.h @@ -55,6 +55,7 @@ protected: struct ActionWidgets { GUI::StaticTextWidget *actionText; GUI::ButtonWidget *keyButton; + GUI::ButtonWidget *clearButton; }; struct ActionInfo { Action *action; @@ -64,6 +65,7 @@ protected: void loadKeymap(); void refreshKeymap(); + void clearMapping(uint i); void startRemapping(uint i); void stopRemapping(); @@ -80,7 +82,7 @@ protected: //GUI::ContainerWidget *_container; GUI::ScrollBarWidget *_scrollBar; - uint _colCount, _rowCount; + uint _rowCount; Array<ActionWidgets> _keymapWidgets; Action *_activeRemapAction; @@ -89,6 +91,8 @@ protected: bool _changes; + bool _topKeymapIsGui; + }; } // End of namespace Common diff --git a/backends/keymapper/types.h b/backends/keymapper/types.h deleted file mode 100644 index ed2e498bd0..0000000000 --- a/backends/keymapper/types.h +++ /dev/null @@ -1,74 +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. -* -*/ - -#ifndef KEYMAPPER_TYPES_H -#define KEYMAPPER_TYPES_H - -#include "common/scummsys.h" - -#ifdef ENABLE_KEYMAPPER - -namespace Common { - -enum KeyType { - kGenericKeyType, - kDirUpKeyType, - kDirDownKeyType, - kDirLeftKeyType, - kDirRightKeyType, - kActionKeyType, - kTriggerLeftKeyType, - kTriggerRightKeyType, - kStartKeyType, - kSelectKeyType, - /* ... */ - - kKeyTypeMax -}; - -enum ActionType { - kGenericActionType, - - // common actions - kDirUpActionType, - kDirDownActionType, - kDirLeftActionType, - kDirRightActionType, - kLeftClickActionType, - kRightClickActionType, - kSaveActionType, - kMenuActionType, - kQuitActionType, - kVirtualKeyboardActionType, - kKeyRemapActionType, - kVolumeUpActionType, - kVolumeDownActionType, - - - kActionTypeMax -}; - -} // End of namespace Common - -#endif // #ifdef ENABLE_KEYMAPPER - -#endif // #ifndef KEYMAPPER_TYPES_H diff --git a/backends/midi/coreaudio.cpp b/backends/midi/coreaudio.cpp index 305b462836..43c801287d 100644 --- a/backends/midi/coreaudio.cpp +++ b/backends/midi/coreaudio.cpp @@ -26,15 +26,38 @@ #ifdef MACOSX -// HACK to disable deprecated warnings under Mac OS X 10.5. -// Apple depracted the AUGraphNewNode & AUGraphGetNodeInfo APIs -// in favor of the new AUGraphAddNode & AUGraphNodeInfo APIs. -// While it would be trivial to switch to those, this would break -// binary compatibility with all pre-10.5 systems, so we don't want -// to do that just now. Maybe when 10.6 comes... :) #include <AvailabilityMacros.h> -#undef DEPRECATED_ATTRIBUTE -#define DEPRECATED_ATTRIBUTE + +// With the release of Mac OS X 10.5 in October 2007, Apple deprecated the +// AUGraphNewNode & AUGraphGetNodeInfo APIs in favor of the new AUGraphAddNode & +// AUGraphNodeInfo APIs. While it is easy to switch to those, it breaks +// compatibility with all pre-10.5 systems. +// +// Since 10.5 was the last system to support PowerPC, we use the old, deprecated +// APIs on PowerPC based systems by default. On all other systems (such as Mac +// OS X running on Intel hardware, or iOS running on ARM), we use the new API by +// default. +// +// This leaves Mac OS X 10.4 running on x86 processors as the only system +// combination that this code will not support by default. It seems quite +// reasonable to assume that anybody with an Intel system has since then moved +// on to a newer Mac OS X release. But if for some reason you absolutely need to +// build an x86 version of this code using the old, deprecated API, you can +// simply do so by manually enable the USE_DEPRECATED_COREAUDIO_API switch (e.g. +// by adding setting it suitably in CPPFLAGS). +#if !defined(USE_DEPRECATED_COREAUDIO_API) + #if TARGET_CPU_PPC || TARGET_CPU_PPC64 || !defined(MAC_OS_X_VERSION_10_6) + #define USE_DEPRECATED_COREAUDIO_API 1 + #else + #define USE_DEPRECATED_COREAUDIO_API 0 + #endif +#endif + +#if USE_DEPRECATED_COREAUDIO_API + // Try to silence warnings about use of deprecated APIs + #undef DEPRECATED_ATTRIBUTE + #define DEPRECATED_ATTRIBUTE +#endif #include "common/config-manager.h" @@ -105,7 +128,11 @@ int MidiDriver_CORE::open() { RequireNoErr(NewAUGraph(&_auGraph)); AUNode outputNode, synthNode; +#if USE_DEPRECATED_COREAUDIO_API ComponentDescription desc; +#else + AudioComponentDescription desc; +#endif // The default output device desc.componentType = kAudioUnitType_Output; @@ -113,13 +140,21 @@ int MidiDriver_CORE::open() { desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentFlags = 0; desc.componentFlagsMask = 0; +#if USE_DEPRECATED_COREAUDIO_API RequireNoErr(AUGraphNewNode(_auGraph, &desc, 0, NULL, &outputNode)); +#else + RequireNoErr(AUGraphAddNode(_auGraph, &desc, &outputNode)); +#endif // The built-in default (softsynth) music device desc.componentType = kAudioUnitType_MusicDevice; desc.componentSubType = kAudioUnitSubType_DLSSynth; desc.componentManufacturer = kAudioUnitManufacturer_Apple; +#if USE_DEPRECATED_COREAUDIO_API RequireNoErr(AUGraphNewNode(_auGraph, &desc, 0, NULL, &synthNode)); +#else + RequireNoErr(AUGraphAddNode(_auGraph, &desc, &synthNode)); +#endif // Connect the softsynth to the default output RequireNoErr(AUGraphConnectNodeInput(_auGraph, synthNode, 0, outputNode, 0)); @@ -129,8 +164,11 @@ int MidiDriver_CORE::open() { RequireNoErr(AUGraphInitialize(_auGraph)); // Get the music device from the graph. +#if USE_DEPRECATED_COREAUDIO_API RequireNoErr(AUGraphGetNodeInfo(_auGraph, synthNode, NULL, NULL, NULL, &_synth)); - +#else + RequireNoErr(AUGraphNodeInfo(_auGraph, synthNode, NULL, &_synth)); +#endif // Load custom soundfont, if specified if (ConfMan.hasKey("soundfont")) { diff --git a/backends/midi/timidity.cpp b/backends/midi/timidity.cpp index 87cd08659c..172d31e799 100644 --- a/backends/midi/timidity.cpp +++ b/backends/midi/timidity.cpp @@ -197,6 +197,8 @@ int MidiDriver_TIMIDITY::open() { /* should read something like "200 63017 is ready acceptable", * where 63017 is port for data connection */ + // FIXME: The following looks like a cheap endian test. If this is true, then + // it should be replaced by suitable #ifdef SCUMM_LITTLE_ENDIAN. i = 1; if (*(char *)&i == 1) res = timidity_ctl_command("OPEN lsb"); diff --git a/backends/midi/windows.cpp b/backends/midi/windows.cpp index 828411cd22..f4c5431d6e 100644 --- a/backends/midi/windows.cpp +++ b/backends/midi/windows.cpp @@ -177,13 +177,49 @@ MusicDevices WindowsMusicPlugin::getDevices() const { int numDevs = midiOutGetNumDevs(); MIDIOUTCAPS tmp; + Common::StringArray deviceNames; for (int i = 0; i < numDevs; i++) { if (midiOutGetDevCaps(i, &tmp, sizeof(MIDIOUTCAPS)) != MMSYSERR_NOERROR) break; + deviceNames.push_back(tmp.szPname); + } + + // Check for non-unique device names. This may happen if someone has devices with identical + // names (e. g. more than one USB device of the exact same hardware type). It seems that this + // does happen in reality sometimes. We generate index numbers for these devices. + // This is not an ideal solution, since this index could change whenever another USB + // device gets plugged in or removed, switched off or just plugged into a different port. + // Unfortunately midiOutGetDevCaps() does not generate any other unique information + // that could be used. Our index numbers which match the device order should at least be + // a little more stable than just using the midiOutGetDevCaps() device ID, since a missing + // device (e.g. switched off) should actually not be harmful to our indices (as it would be + // when using the device IDs). The cases where users have devices with identical names should + // be rare enough anyway. + Common::Array<int> nonUniqueIndex; + for (int i = 0; i < numDevs; i++) { + int match = -1; + for (int ii = 0; ii < i; ii++) { + if (deviceNames[i] == deviceNames[ii]) { + if (nonUniqueIndex[ii] == -1) + nonUniqueIndex[ii] = 0; + if (++match == 0) + ++match; + } + } + nonUniqueIndex.push_back(match); + } + + // We now add the index number to the non-unique device names to make them unique. + for (int i = 0; i < numDevs; i++) { + if (nonUniqueIndex[i] != -1) + deviceNames[i] = Common::String::format("%s - #%.02d", deviceNames[i].c_str(), nonUniqueIndex[i]); + } + + for (Common::StringArray::iterator i = deviceNames.begin(); i != deviceNames.end(); ++i) // There is no way to detect the "MusicType" so I just set it to MT_GM // The user will have to manually select his MT32 type device and his GM type device. - devices.push_back(MusicDevice(this, tmp.szPname, MT_GM)); - } + devices.push_back(MusicDevice(this, *i, MT_GM)); + return devices; } diff --git a/backends/modular-backend.h b/backends/modular-backend.h index b864da0df5..072ee805b6 100644 --- a/backends/modular-backend.h +++ b/backends/modular-backend.h @@ -105,13 +105,6 @@ public: //@} - /** @name Events and Time */ - //@{ - - virtual Common::HardwareKeySet *getHardwareKeySet() { return 0; } - - //@} - /** @name Mutex handling */ //@{ diff --git a/backends/module.mk b/backends/module.mk index 89cde44536..95725d9d87 100644 --- a/backends/module.mk +++ b/backends/module.mk @@ -33,6 +33,7 @@ endif ifdef ENABLE_KEYMAPPER MODULE_OBJS += \ keymapper/action.o \ + keymapper/hardware-input.o \ keymapper/keymap.o \ keymapper/keymapper.o \ keymapper/remap-dialog.o @@ -98,6 +99,7 @@ MODULE_OBJS += \ fs/windows/windows-fs-factory.o \ midi/windows.o \ plugins/win32/win32-provider.o \ + saves/windows/windows-saves.o \ taskbar/win32/win32-taskbar.o endif @@ -149,7 +151,8 @@ endif ifeq ($(BACKEND),maemo) MODULE_OBJS += \ - events/maemosdl/maemosdl-events.o + events/maemosdl/maemosdl-events.o \ + graphics/maemosdl/maemosdl-graphics.o endif ifeq ($(BACKEND),n64) diff --git a/backends/mutex/null/null-mutex.h b/backends/mutex/null/null-mutex.h index fdb32b241c..7ae10cedb8 100644 --- a/backends/mutex/null/null-mutex.h +++ b/backends/mutex/null/null-mutex.h @@ -28,7 +28,7 @@ /** * Null mutex manager */ -class NullMutexManager : MutexManager { +class NullMutexManager : public MutexManager { public: virtual OSystem::MutexRef createMutex() { return OSystem::MutexRef(); } virtual void lockMutex(OSystem::MutexRef mutex) {} diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index aba31320ea..902599d50f 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -134,6 +134,7 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) : _enable_zoning(false), _mixer(0), _shake_offset(0), + _queuedEventTime(0), _event_queue_lock(createMutex()), _touch_pt_down(), _touch_pt_scroll(), diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h index f39a8f1144..47a6515a2a 100644 --- a/backends/platform/android/android.h +++ b/backends/platform/android/android.h @@ -220,6 +220,8 @@ public: private: Common::Queue<Common::Event> _event_queue; + Common::Event _queuedEvent; + uint32 _queuedEventTime; MutexRef _event_queue_lock; Common::Point _touch_pt_down, _touch_pt_scroll, _touch_pt_dt; diff --git a/backends/platform/android/android.mk b/backends/platform/android/android.mk index 63d194fdc1..2e8fd62152 100644 --- a/backends/platform/android/android.mk +++ b/backends/platform/android/android.mk @@ -63,7 +63,7 @@ PATH_BUILD_CLASSES_PLUGIN_TOP = $(PATH_BUILD)/classes.plugin PATH_STAGE_PREFIX = build.stage PATH_STAGE_MAIN = $(PATH_STAGE_PREFIX).main -PATH_REL = org/inodes/gus/scummvm +PATH_REL = org/scummvm/scummvm PATH_SRC_TOP = $(srcdir)/backends/platform/android PATH_SRC = $(PATH_SRC_TOP)/$(PATH_REL) @@ -172,13 +172,13 @@ androidrelease: $(addprefix release/, $(APK_MAIN) $(APK_PLUGINS)) androidtestmain: $(APK_MAIN) $(ADB) install -r $(APK_MAIN) - $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.inodes.gus.scummvm/.Unpacker + $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.scummvm.scummvm/.Unpacker androidtest: $(APK_MAIN) $(APK_PLUGINS) @set -e; for apk in $^; do \ $(ADB) install -r $$apk; \ done - $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.inodes.gus.scummvm/.Unpacker + $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.scummvm.scummvm/.Unpacker # used by buildbot! androiddistdebug: all diff --git a/backends/platform/android/asset-archive.cpp b/backends/platform/android/asset-archive.cpp index fe52a3d8d4..14840de996 100644 --- a/backends/platform/android/asset-archive.cpp +++ b/backends/platform/android/asset-archive.cpp @@ -103,7 +103,7 @@ JavaInputStream::JavaInputStream(JNIEnv *env, jobject is) : MID_mark = env->GetMethodID(cls, "mark", "(I)V"); assert(MID_mark); MID_available = env->GetMethodID(cls, "available", "()I"); - assert(MID_mark); + assert(MID_available); MID_close = env->GetMethodID(cls, "close", "()V"); assert(MID_close); MID_read = env->GetMethodID(cls, "read", "([BII)I"); @@ -389,7 +389,7 @@ AndroidAssetArchive::~AndroidAssetArchive() { env->DeleteGlobalRef(_am); } -bool AndroidAssetArchive::hasFile(const Common::String &name) { +bool AndroidAssetArchive::hasFile(const Common::String &name) const { JNIEnv *env = JNI::getEnv(); jstring path = env->NewStringUTF(name.c_str()); jobject result = env->CallObjectMethod(_am, MID_open, path, ACCESS_UNKNOWN); @@ -409,7 +409,7 @@ bool AndroidAssetArchive::hasFile(const Common::String &name) { return true; } -int AndroidAssetArchive::listMembers(Common::ArchiveMemberList &member_list) { +int AndroidAssetArchive::listMembers(Common::ArchiveMemberList &member_list) const { JNIEnv *env = JNI::getEnv(); Common::List<Common::String> dirlist; dirlist.push_back(""); @@ -466,7 +466,7 @@ int AndroidAssetArchive::listMembers(Common::ArchiveMemberList &member_list) { return count; } -Common::ArchiveMemberPtr AndroidAssetArchive::getMember(const Common::String &name) { +const Common::ArchiveMemberPtr AndroidAssetArchive::getMember(const Common::String &name) const { return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); } diff --git a/backends/platform/android/asset-archive.h b/backends/platform/android/asset-archive.h index 9216412e0a..c5e43555e0 100644 --- a/backends/platform/android/asset-archive.h +++ b/backends/platform/android/asset-archive.h @@ -37,9 +37,9 @@ public: AndroidAssetArchive(jobject am); virtual ~AndroidAssetArchive(); - virtual bool hasFile(const Common::String &name); - virtual int listMembers(Common::ArchiveMemberList &list); - virtual Common::ArchiveMemberPtr getMember(const Common::String &name); + virtual bool hasFile(const Common::String &name) const; + virtual int listMembers(Common::ArchiveMemberList &list) const; + virtual const Common::ArchiveMemberPtr getMember(const Common::String &name) const; virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; private: diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp index 2a16e69411..21d2344fa7 100644 --- a/backends/platform/android/events.cpp +++ b/backends/platform/android/events.cpp @@ -211,36 +211,35 @@ static const Common::KeyCode jkeymap[] = { }; // floating point. use sparingly -template <class T> +template<class T> static inline T scalef(T in, float numerator, float denominator) { return static_cast<float>(in) * numerator / denominator; } +static const int kQueuedInputEventDelay = 50; + void OSystem_Android::setupKeymapper() { #ifdef ENABLE_KEYMAPPER using namespace Common; Keymapper *mapper = getEventManager()->getKeymapper(); - HardwareKeySet *keySet = new HardwareKeySet(); + HardwareInputSet *inputSet = new HardwareInputSet(); - keySet->addHardwareKey( - new HardwareKey("n", KeyState(KEYCODE_n), "n (vk)", - kTriggerLeftKeyType, - kVirtualKeyboardActionType)); + keySet->addHardwareInput( + new HardwareInput("n", KeyState(KEYCODE_n), "n (vk)")); - mapper->registerHardwareKeySet(keySet); + mapper->registerHardwareInputSet(inputSet); - Keymap *globalMap = new Keymap("global"); + Keymap *globalMap = new Keymap(kGlobalKeymapName); Action *act; - act = new Action(globalMap, "VIRT", "Display keyboard", - kVirtualKeyboardActionType); + act = new Action(globalMap, "VIRT", "Display keyboard"); act->addKeyEvent(KeyState(KEYCODE_F7, ASCII_F7, 0)); mapper->addGlobalKeymap(globalMap); - mapper->pushKeymap("global"); + mapper->pushKeymap(kGlobalKeymapName); #endif } @@ -601,13 +600,18 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, lockMutex(_event_queue_lock); + if (_queuedEventTime) + _event_queue.push(_queuedEvent); + if (!_touchpad_mode) _event_queue.push(e); e.type = down; _event_queue.push(e); + e.type = up; - _event_queue.push(e); + _queuedEvent = e; + _queuedEventTime = getMillis() + kQueuedInputEventDelay; unlockMutex(_event_queue_lock); } @@ -702,9 +706,14 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, lockMutex(_event_queue_lock); + if (_queuedEventTime) + _event_queue.push(_queuedEvent); + _event_queue.push(e); + e.type = up; - _event_queue.push(e); + _queuedEvent = e; + _queuedEventTime = getMillis() + kQueuedInputEventDelay; unlockMutex(_event_queue_lock); return; @@ -800,6 +809,13 @@ bool OSystem_Android::pollEvent(Common::Event &event) { lockMutex(_event_queue_lock); + if (_queuedEventTime && (getMillis() > _queuedEventTime)) { + event = _queuedEvent; + _queuedEventTime = 0; + unlockMutex(_event_queue_lock); + return true; + } + if (_event_queue.empty()) { unlockMutex(_event_queue_lock); return false; diff --git a/backends/platform/android/jni.cpp b/backends/platform/android/jni.cpp index b44a585528..a7ebb87651 100644 --- a/backends/platform/android/jni.cpp +++ b/backends/platform/android/jni.cpp @@ -125,7 +125,7 @@ jint JNI::onLoad(JavaVM *vm) { if (_vm->GetEnv((void **)&env, JNI_VERSION_1_2)) return JNI_ERR; - jclass cls = env->FindClass("org/inodes/gus/scummvm/ScummVM"); + jclass cls = env->FindClass("org/scummvm/scummvm/ScummVM"); if (cls == 0) return JNI_ERR; diff --git a/backends/platform/android/org/inodes/gus/scummvm/EditableSurfaceView.java b/backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java index 3aef14b851..b593fc6abf 100644 --- a/backends/platform/android/org/inodes/gus/scummvm/EditableSurfaceView.java +++ b/backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java @@ -1,4 +1,4 @@ -package org.inodes.gus.scummvm; +package org.scummvm.scummvm; import android.content.Context; import android.text.InputType; diff --git a/backends/platform/android/org/inodes/gus/scummvm/PluginProvider.java b/backends/platform/android/org/scummvm/scummvm/PluginProvider.java index d90b7b2c68..e27e8d41a8 100644 --- a/backends/platform/android/org/inodes/gus/scummvm/PluginProvider.java +++ b/backends/platform/android/org/scummvm/scummvm/PluginProvider.java @@ -1,10 +1,11 @@ -package org.inodes.gus.scummvm; +package org.scummvm.scummvm; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; +import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.net.Uri; import android.os.Bundle; @@ -16,7 +17,7 @@ public class PluginProvider extends BroadcastReceiver { private final static String LOG_TAG = "ScummVM"; public final static String META_UNPACK_LIB = - "org.inodes.gus.scummvm.meta.UNPACK_LIB"; + "org.scummvm.scummvm.meta.UNPACK_LIB"; public void onReceive(Context context, Intent intent) { if (!intent.getAction().equals(ScummVMApplication.ACTION_PLUGIN_QUERY)) @@ -25,15 +26,24 @@ public class PluginProvider extends BroadcastReceiver { Bundle extras = getResultExtras(true); final ActivityInfo info; + final PackageInfo pinfo; try { info = context.getPackageManager() .getReceiverInfo(new ComponentName(context, this.getClass()), PackageManager.GET_META_DATA); + pinfo = context.getPackageManager() + .getPackageInfo(context.getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { Log.e(LOG_TAG, "Error finding my own info?", e); return; } + String host_version = extras.getString(ScummVMApplication.EXTRA_VERSION); + if (!pinfo.versionName.equals(host_version)) { + Log.e(LOG_TAG, "Plugin version " + pinfo.versionName + " is not equal to ScummVM version " + host_version); + return; + } + String mylib = info.metaData.getString(META_UNPACK_LIB); if (mylib != null) { ArrayList<String> all_libs = diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java b/backends/platform/android/org/scummvm/scummvm/ScummVM.java index 246a02c9be..3a25b54eeb 100644 --- a/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java +++ b/backends/platform/android/org/scummvm/scummvm/ScummVM.java @@ -1,4 +1,4 @@ -package org.inodes.gus.scummvm; +package org.scummvm.scummvm; import android.util.Log; import android.content.res.AssetManager; diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java index ce4e016322..fbd6513761 100644 --- a/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java +++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java @@ -1,4 +1,4 @@ -package org.inodes.gus.scummvm; +package org.scummvm.scummvm; import android.app.Activity; import android.app.AlertDialog; @@ -14,6 +14,8 @@ import android.view.MotionEvent; import android.view.inputmethod.InputMethodManager; import android.widget.Toast; +import java.io.File; + public class ScummVMActivity extends Activity { private class MyScummVM extends ScummVM { @@ -128,6 +130,16 @@ public class ScummVMActivity extends Activity { getFilesDir().mkdirs(); + // Store savegames on external storage if we can, which means they're + // world-readable and don't get deleted on uninstall. + String savePath = Environment.getExternalStorageDirectory() + "/ScummVM/Saves/"; + File saveDir = new File(savePath); + saveDir.mkdirs(); + if (!saveDir.isDirectory()) { + // If it doesn't work, resort to the internal app path. + savePath = getDir("saves", MODE_WORLD_READABLE).getPath(); + } + // Start ScummVM _scummvm = new MyScummVM(main_surface.getHolder()); @@ -136,7 +148,7 @@ public class ScummVMActivity extends Activity { "--config=" + getFileStreamPath("scummvmrc").getPath(), "--path=" + Environment.getExternalStorageDirectory().getPath(), "--gui-theme=scummmodern", - "--savepath=" + getDir("saves", 0).getPath() + "--savepath=" + savePath }); _events = new ScummVMEvents(this, _scummvm); diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVMApplication.java b/backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java index 8ab7d1a084..0adc166222 100644 --- a/backends/platform/android/org/inodes/gus/scummvm/ScummVMApplication.java +++ b/backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java @@ -1,12 +1,13 @@ -package org.inodes.gus.scummvm; +package org.scummvm.scummvm; import android.app.Application; import java.io.File; public class ScummVMApplication extends Application { - public final static String ACTION_PLUGIN_QUERY = "org.inodes.gus.scummvm.action.PLUGIN_QUERY"; - public final static String EXTRA_UNPACK_LIBS = "org.inodes.gus.scummvm.extra.UNPACK_LIBS"; + public final static String ACTION_PLUGIN_QUERY = "org.scummvm.scummvm.action.PLUGIN_QUERY"; + public final static String EXTRA_UNPACK_LIBS = "org.scummvm.scummvm.extra.UNPACK_LIBS"; + public final static String EXTRA_VERSION = "org.scummvm.scummvm.extra.VERSION"; private static File _cache_dir; diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java index 175ff0b677..86227b9352 100644 --- a/backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java +++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java @@ -1,4 +1,4 @@ -package org.inodes.gus.scummvm; +package org.scummvm.scummvm; import android.os.Handler; import android.os.Message; diff --git a/backends/platform/android/org/inodes/gus/scummvm/Unpacker.java b/backends/platform/android/org/scummvm/scummvm/Unpacker.java index 6cc7f8eadb..da76ceb5e5 100644 --- a/backends/platform/android/org/inodes/gus/scummvm/Unpacker.java +++ b/backends/platform/android/org/scummvm/scummvm/Unpacker.java @@ -1,4 +1,4 @@ -package org.inodes.gus.scummvm; +package org.scummvm.scummvm; import android.app.Activity; import android.app.AlertDialog; @@ -10,6 +10,7 @@ import android.content.ContextWrapper; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.ActivityInfo; +import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.net.Uri; @@ -38,7 +39,7 @@ public class Unpacker extends Activity { // TODO don't hardcode this private final static boolean PLUGINS_ENABLED = false; private final static String META_NEXT_ACTIVITY = - "org.inodes.gus.unpacker.nextActivity"; + "org.scummvm.unpacker.nextActivity"; private ProgressBar mProgress; private File mUnpackDest; // location to unpack into private AsyncTask<String, Integer, Void> mUnpacker; @@ -275,6 +276,15 @@ public class Unpacker extends Activity { extras.putStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS, unpack_libs); + final PackageInfo info; + try { + info = getPackageManager().getPackageInfo(getPackageName(), 0); + } catch (PackageManager.NameNotFoundException e) { + Log.e(LOG_TAG, "Error finding my own info?", e); + return; + } + extras.putString(ScummVMApplication.EXTRA_VERSION, info.versionName); + Intent intent = new Intent(ScummVMApplication.ACTION_PLUGIN_QUERY); // Android 3.1 defaults to FLAG_EXCLUDE_STOPPED_PACKAGES, and since // none of our plugins will ever be running, that is not helpful diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp index 53b4d1cc59..95c96e0d25 100644 --- a/backends/platform/android/texture.cpp +++ b/backends/platform/android/texture.cpp @@ -61,7 +61,7 @@ static inline GLfixed xdiv(int numerator, int denominator) { return (numerator << 16) / denominator; } -template <class T> +template<class T> static T nextHigher2(T k) { if (k == 0) return 1; @@ -287,7 +287,7 @@ void GLESTexture::fillBuffer(uint32 color) { ((color & 0xff) == ((color >> 8) & 0xff))) memset(_pixels, color & 0xff, _surface.pitch * _surface.h); else - Common::set_to(_pixels, _pixels + _surface.pitch * _surface.h, + Common::fill(_pixels, _pixels + _surface.pitch * _surface.h, (uint16)color); setDirty(); diff --git a/backends/platform/bada/application.cpp b/backends/platform/bada/application.cpp index bf585d2782..ba8e544983 100644 --- a/backends/platform/bada/application.cpp +++ b/backends/platform/bada/application.cpp @@ -68,7 +68,7 @@ void BadaScummVM::OnUserEventReceivedN(RequestId requestId, // assertion failure termination String *message = NULL; if (args) { - message = (String*)args->GetAt(0); + message = (String *)args->GetAt(0); } if (!message) { message = new String("Unknown error"); diff --git a/backends/platform/bada/audio.cpp b/backends/platform/bada/audio.cpp index b868e91357..65a5a80fa5 100644 --- a/backends/platform/bada/audio.cpp +++ b/backends/platform/bada/audio.cpp @@ -238,7 +238,7 @@ void AudioThread::OnAudioOutBufferEndReached(Osp::Media::AudioOut &src) { void AudioThread::OnTimerExpired(Timer &timer) { if (_ready < NUM_AUDIO_BUFFERS) { uint len = _audioBuffer[_head].GetCapacity(); - int samples = _mixer->mixCallback((byte*)_audioBuffer[_head].GetPointer(), len); + int samples = _mixer->mixCallback((byte *)_audioBuffer[_head].GetPointer(), len); if (samples) { _head = (_head + 1) % NUM_AUDIO_BUFFERS; _ready++; diff --git a/backends/platform/bada/fs.cpp b/backends/platform/bada/fs.cpp index 0ae0cde43d..37ca496d18 100644 --- a/backends/platform/bada/fs.cpp +++ b/backends/platform/bada/fs.cpp @@ -170,17 +170,17 @@ uint32 BadaFileStream::read(void *ptr, uint32 len) { uint32 available = bufferLength - bufferIndex; if (len <= available) { // use allocation - memcpy((byte*)ptr, &buffer[bufferIndex], len); + memcpy((byte *)ptr, &buffer[bufferIndex], len); bufferIndex += len; result = len; } else { // use remaining allocation - memcpy((byte*)ptr, &buffer[bufferIndex], available); + memcpy((byte *)ptr, &buffer[bufferIndex], available); uint32 remaining = len - available; result = available; if (remaining) { - result += file->Read(((byte*)ptr) + available, remaining); + result += file->Read(((byte *)ptr) + available, remaining); } bufferIndex = bufferLength = 0; } @@ -192,11 +192,11 @@ uint32 BadaFileStream::read(void *ptr, uint32 len) { if (bufferLength < len) { len = bufferLength; } - memcpy((byte*)ptr, buffer, len); + memcpy((byte *)ptr, buffer, len); result = bufferIndex = len; } } else { - result = file->Read((byte*)ptr, len); + result = file->Read((byte *)ptr, len); bufferIndex = bufferLength = 0; } } else { diff --git a/backends/platform/bada/missing.cpp b/backends/platform/bada/missing.cpp index a5433ec61a..10d45ca4b5 100644 --- a/backends/platform/bada/missing.cpp +++ b/backends/platform/bada/missing.cpp @@ -96,7 +96,7 @@ int sprintf(char *str, const char *format, ...) { char *strdup(const char *strSource) { char *buffer; int len = strlen(strSource) + 1; - buffer = (char*)malloc(len); + buffer = (char *)malloc(len); if (buffer) { memcpy(buffer, strSource, len); } diff --git a/backends/platform/bada/portdefs.h b/backends/platform/bada/portdefs.h index e85d578678..813c5acde3 100644 --- a/backends/platform/bada/portdefs.h +++ b/backends/platform/bada/portdefs.h @@ -30,6 +30,7 @@ #include <stdio.h> #include <unistd.h> #include <math.h> +#include <new> #define M_PI 3.14159265358979323846 @@ -64,9 +65,9 @@ void stderr_vfprintf(void*, const char *format, va_list ap); #undef fputs #undef fflush -#define stderr (void*)0 -#define stdout (void*)1 -#define stdin (void*)2 +#define stderr (void *)0 +#define stdout (void *)1 +#define stdin (void *)2 #define fputs(str, file) #define fflush(file) #define sscanf simple_sscanf diff --git a/backends/platform/dc/audio.cpp b/backends/platform/dc/audio.cpp index 35cb51f349..4f01531486 100644 --- a/backends/platform/dc/audio.cpp +++ b/backends/platform/dc/audio.cpp @@ -59,7 +59,7 @@ void OSystem_Dreamcast::checkSound() if (n<100) return; - _mixer->mixCallback((byte*)temp_sound_buffer, + _mixer->mixCallback((byte *)temp_sound_buffer, 2*SAMPLES_TO_BYTES(n)); if (fillpos+n > curr_ring_buffer_samples) { diff --git a/backends/platform/dc/dc-fs.cpp b/backends/platform/dc/dc-fs.cpp index f30c9c56d1..36f5a1465c 100644 --- a/backends/platform/dc/dc-fs.cpp +++ b/backends/platform/dc/dc-fs.cpp @@ -39,7 +39,7 @@ protected: Common::String _path; public: - RoninCDFileNode(const Common::String &path) : _path(path) {}; + RoninCDFileNode(const Common::String &path) : _path(path) {} virtual bool exists() const { return true; } virtual Common::String getName() const { return lastPathComponent(_path, '/'); } @@ -61,7 +61,7 @@ public: /* A directory */ class RoninCDDirectoryNode : public RoninCDFileNode { public: - RoninCDDirectoryNode(const Common::String &path) : RoninCDFileNode(path) {}; + RoninCDDirectoryNode(const Common::String &path) : RoninCDFileNode(path) {} virtual bool isDirectory() const { return true; } virtual AbstractFSNode *getChild(const Common::String &n) const; @@ -72,7 +72,7 @@ public: /* A file/directory which does not exist */ class RoninCDNonexistingNode : public RoninCDFileNode { public: - RoninCDNonexistingNode(const Common::String &path) : RoninCDFileNode(path) {}; + RoninCDNonexistingNode(const Common::String &path) : RoninCDFileNode(path) {} virtual bool exists() const { return false; } virtual bool isReadable() const { return false; } diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h index 2e32ff3eb4..8ca48bf19e 100644 --- a/backends/platform/dc/dc.h +++ b/backends/platform/dc/dc.h @@ -29,6 +29,8 @@ #include "backends/audiocd/default/default-audiocd.h" #include "backends/fs/fs-factory.h" #include "audio/mixer_intern.h" +#include "common/language.h" +#include "common/platform.h" #ifdef DYNAMIC_MODULES #include "backends/plugins/dynamic-plugin.h" #endif diff --git a/backends/platform/dc/dcloader.cpp b/backends/platform/dc/dcloader.cpp index 675f7ad8c7..56193c282a 100644 --- a/backends/platform/dc/dcloader.cpp +++ b/backends/platform/dc/dcloader.cpp @@ -385,8 +385,8 @@ void *DLObject::symbol(const char *name) for (int c = symbol_cnt; c--; s++) if ((s->st_info>>4 == 1 || s->st_info>>4 == 2) && strtab[s->st_name] == '_' && !strcmp(name, strtab+s->st_name+1)) { - DBG(("=> %p\n", (void*)s->st_value)); - return (void*)s->st_value; + DBG(("=> %p\n", (void *)s->st_value)); + return (void *)s->st_value; } seterror("Symbol \"%s\" not found.", name); diff --git a/backends/platform/dc/display.cpp b/backends/platform/dc/display.cpp index 76658c6590..e886b55869 100644 --- a/backends/platform/dc/display.cpp +++ b/backends/platform/dc/display.cpp @@ -334,8 +334,8 @@ void OSystem_Dreamcast::updateScreenTextures(void) unsigned short *dst = (unsigned short *)screen_tx[_screen_buffer]; unsigned char *src = screen; - // while ((*((volatile unsigned int *)(void*)0xa05f810c) & 0x3ff) != 200); - // *((volatile unsigned int *)(void*)0xa05f8040) = 0xff0000; + // while ((*((volatile unsigned int *)(void *)0xa05f810c) & 0x3ff) != 200); + // *((volatile unsigned int *)(void *)0xa05f8040) = 0xff0000; if (_screenFormat == 0) for ( int y = 0; y<_screen_h; y++ ) @@ -379,7 +379,7 @@ void OSystem_Dreamcast::updateScreenPolygons(void) struct polygon_list mypoly; struct packed_colour_vertex_list myvertex; - // *((volatile unsigned int *)(void*)0xa05f8040) = 0x00ff00; + // *((volatile unsigned int *)(void *)0xa05f8040) = 0x00ff00; mypoly.cmd = TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_OPAQUE|TA_CMD_POLYGON_SUBLIST| @@ -395,7 +395,7 @@ void OSystem_Dreamcast::updateScreenPolygons(void) mypoly.red = mypoly.green = mypoly.blue = mypoly.alpha = 0; ta_begin_frame(); - // *((volatile unsigned int *)(void*)0xa05f8040) = 0x0000ff; + // *((volatile unsigned int *)(void *)0xa05f8040) = 0x0000ff; ta_commit_list(&mypoly); myvertex.cmd = TA_CMD_VERTEX; @@ -493,12 +493,12 @@ void OSystem_Dreamcast::updateScreenPolygons(void) _softkbd.draw(330.0*sin(0.013*_softkbd_motion) - 320.0, 200.0, 120-_softkbd_motion); - // *((volatile unsigned int *)(void*)0xa05f8040) = 0xffff00; + // *((volatile unsigned int *)(void *)0xa05f8040) = 0xffff00; drawMouse(_ms_cur_x, _ms_cur_y, _ms_cur_w, _ms_cur_h, _ms_buf, _ms_visible); - // *((volatile unsigned int *)(void*)0xa05f8040) = 0xff00ff; + // *((volatile unsigned int *)(void *)0xa05f8040) = 0xff00ff; ta_commit_frame(); - // *((volatile unsigned int *)(void*)0xa05f8040) = 0x0; + // *((volatile unsigned int *)(void *)0xa05f8040) = 0x0; _last_screen_refresh = Timer(); } diff --git a/backends/platform/dc/portdefs.h b/backends/platform/dc/portdefs.h index ca2b5208a3..1f5c8f566a 100644 --- a/backends/platform/dc/portdefs.h +++ b/backends/platform/dc/portdefs.h @@ -29,6 +29,7 @@ #include <assert.h> #include <ctype.h> #include <math.h> +#include <new> #ifndef RONIN_TIMER_ACCESS #define Timer ronin_Timer #endif diff --git a/backends/platform/ds/arm7/source/main.cpp b/backends/platform/ds/arm7/source/main.cpp index 2e9cacc669..6e714b22fa 100644 --- a/backends/platform/ds/arm7/source/main.cpp +++ b/backends/platform/ds/arm7/source/main.cpp @@ -46,10 +46,10 @@ #include "cartreset_nolibfat.h" -#define TOUCH_CAL_X1 (*(vs16*)0x027FFCD8) -#define TOUCH_CAL_Y1 (*(vs16*)0x027FFCDA) -#define TOUCH_CAL_X2 (*(vs16*)0x027FFCDE) -#define TOUCH_CAL_Y2 (*(vs16*)0x027FFCE0) +#define TOUCH_CAL_X1 (*(vs16 *)0x027FFCD8) +#define TOUCH_CAL_Y1 (*(vs16 *)0x027FFCDA) +#define TOUCH_CAL_X2 (*(vs16 *)0x027FFCDE) +#define TOUCH_CAL_Y2 (*(vs16 *)0x027FFCE0) #define SCREEN_WIDTH 256 #define SCREEN_HEIGHT 192 s32 TOUCH_WIDTH = TOUCH_CAL_X2 - TOUCH_CAL_X1; @@ -71,10 +71,10 @@ int temp; int adpcmBufferNum = 0; // those are pixel positions of the two points you click when calibrating -#define TOUCH_CNTRL_X1 (*(vu8*)0x027FFCDC) -#define TOUCH_CNTRL_Y1 (*(vu8*)0x027FFCDD) -#define TOUCH_CNTRL_X2 (*(vu8*)0x027FFCE2) -#define TOUCH_CNTRL_Y2 (*(vu8*)0x027FFCE3) +#define TOUCH_CNTRL_X1 (*(vu8 *)0x027FFCDC) +#define TOUCH_CNTRL_Y1 (*(vu8 *)0x027FFCDD) +#define TOUCH_CNTRL_X2 (*(vu8 *)0x027FFCE2) +#define TOUCH_CNTRL_Y2 (*(vu8 *)0x027FFCE3) ////////////////////////////////////////////////////////////////////// @@ -330,7 +330,7 @@ void performSleep() { // int saveInts = REG_IE; // REG_IE = (1 << 22) | IRQ_VBLANK; // Lid open -// *((u32*) (0x0380FFF8)) = *((u32*) (0x0380FFF8)) | (REG_IE & REG_IF); +// *((u32 *) (0x0380FFF8)) = *((u32 *) (0x0380FFF8)) | (REG_IE & REG_IF); // VBLANK_INTR_WAIT_FLAGS = IRQ_VBLANK; diff --git a/backends/platform/ds/arm9/source/blitters.cpp b/backends/platform/ds/arm9/source/blitters.cpp index 0076b302fd..1e8d56615d 100644 --- a/backends/platform/ds/arm9/source/blitters.cpp +++ b/backends/platform/ds/arm9/source/blitters.cpp @@ -222,8 +222,8 @@ static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3 u32 d10 = 0x80008000 | (rd1 << 26) | (gd1 << 21) | (bd1 << 16) | (rd0 << 10) | (gd0 << 5) | bd0; u32 d32 = 0x80008000 | (rd3 << 26) | (gd3 << 21) | (bd3 << 16) | (rd2 << 10) | (gd2 << 5) | bd2; - ((u32*)dest)[0] = d10; - ((u32*)dest)[1] = d32; + ((u32 *)dest)[0] = d10; + ((u32 *)dest)[1] = d32; } #else static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3, u16 s4, @@ -290,7 +290,7 @@ static inline void RescaleBlock_5x8888_To_4x1555( u32 s0, u32 s1, u32 s2, u32 s3 gd0 = DIV_BY_5[gd0]; gd1 = DIV_BY_5[gd1]; bd0 = DIV_BY_5[bd0]; bd1 = DIV_BY_5[bd1]; u32 d10 = 0x80008000 | (rd1 << 26) | (gd1 << 21) | (bd1 << 16) | (rd0 << 10) | (gd0 << 5) | bd0; - ((u32*)dest)[0] = d10; + ((u32 *)dest)[0] = d10; u32 d2 = 2*s2 + 2*s3 + s3; u32 d3 = s3 + 4*s4; @@ -307,7 +307,7 @@ static inline void RescaleBlock_5x8888_To_4x1555( u32 s0, u32 s1, u32 s2, u32 s3 bd2 = DIV_BY_5[bd2]; bd3 = DIV_BY_5[bd3]; u32 d32 = 0x80008000 | (rd3 << 26) | (gd3 << 21) | (bd3 << 16) | (rd2 << 10) | (gd2 << 5) | bd2; - ((u32*)dest)[1] = d32; + ((u32 *)dest)[1] = d32; } // Can't work in place @@ -377,7 +377,7 @@ void Rescale_320x256xPAL8_To_256x256x1555(u16 *dest, const u8 *src, int destStri void Rescale_320x256xPAL8_To_256x256x1555(u16 *dest, const u8 *src, int destStride, int srcStride, const u16 *palette) { u16 fastRam[256]; for (size_t i = 0; i < 128; ++i) - ((u32*)fastRam)[i] = ((const u32*)palette)[i]; + ((u32 *)fastRam)[i] = ((const u32*)palette)[i]; for (size_t i = 0; i < 200; ++i) { Rescale_320xPAL8Scanline_To_256x1555Scanline(dest + i*destStride, src + i *srcStride, fastRam); diff --git a/backends/platform/ds/arm9/source/dsmain.cpp b/backends/platform/ds/arm9/source/dsmain.cpp index dfd906d816..cedbdcb167 100644 --- a/backends/platform/ds/arm9/source/dsmain.cpp +++ b/backends/platform/ds/arm9/source/dsmain.cpp @@ -926,7 +926,7 @@ void displayMode16Bit() { SUB_BG0_Y0 = 0; consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 4, 0, false, true); -// consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(4), (u16*)CHAR_BASE_BLOCK_SUB(0), 16); +// consoleInitDefault((u16 *)SCREEN_BASE_BLOCK_SUB(4), (u16 *)CHAR_BASE_BLOCK_SUB(0), 16); for (int r = 0; r < 32 * 32; r++) { ((u16 *) SCREEN_BASE_BLOCK_SUB(4))[r] = buffer[r]; @@ -2414,7 +2414,7 @@ void initHardware() { BG_PALETTE[255] = RGB15(31,31,31);//by default font will be rendered with color 255 //consoleInit() is a lot more flexible but this gets you up and running quick -// consoleInitDefault((u16*)SCREEN_BASE_BLOCK(0), (u16*)CHAR_BASE_BLOCK(1), 16); +// consoleInitDefault((u16 *)SCREEN_BASE_BLOCK(0), (u16 *)CHAR_BASE_BLOCK(1), 16); //consolePrintSet(0, 6); //irqs are nice @@ -2886,7 +2886,7 @@ void dsExceptionHandler() { setExceptionHandler(NULL); u32 currentMode = getCPSR() & 0x1f; - u32 thumbState = ((*(u32*)0x027FFD90) & 0x20); + u32 thumbState = ((*(u32 *)0x027FFD90) & 0x20); u32 codeAddress, exceptionAddress = 0; diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp index fdd310ec17..73340ed18a 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.cpp +++ b/backends/platform/ds/arm9/source/osystem_ds.cpp @@ -267,23 +267,6 @@ void OSystem_DS::setCursorPalette(const byte *colors, uint start, uint num) { refreshCursor(); } -bool OSystem_DS::grabRawScreen(Graphics::Surface *surf) { - surf->create(DS::getGameWidth(), DS::getGameHeight(), Graphics::PixelFormat::createFormatCLUT8()); - - // Ensure we copy using 16 bit quantities due to limitation of VRAM addressing - - - const u16 *image = (const u16 *) DS::get8BitBackBuffer(); - for (int y = 0; y < DS::getGameHeight(); y++) { - DC_FlushRange(image + (y << 8), DS::getGameWidth()); - for (int x = 0; x < DS::getGameWidth() >> 1; x++) { - *(((u16 *) (surf->pixels)) + y * (DS::getGameWidth() >> 1) + x) = image[(y << 8) + x]; - } - } - - return true; -} - void OSystem_DS::grabPalette(unsigned char *colors, uint start, uint num) { // consolePrintf("Grabpalette"); diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h index b1222a152d..6aa3731916 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.h +++ b/backends/platform/ds/arm9/source/osystem_ds.h @@ -141,8 +141,6 @@ public: void addEvent(const Common::Event& e); bool isEventQueueEmpty() const { return queuePos == 0; } - virtual bool grabRawScreen(Graphics::Surface *surf); - virtual void setFocusRectangle(const Common::Rect& rect); virtual void clearFocusRectangle(); diff --git a/backends/platform/ds/arm9/source/portdefs.h b/backends/platform/ds/arm9/source/portdefs.h index f512ce3ea2..e40849a513 100644 --- a/backends/platform/ds/arm9/source/portdefs.h +++ b/backends/platform/ds/arm9/source/portdefs.h @@ -37,6 +37,7 @@ #include <stdarg.h> #include <ctype.h> #include <math.h> +#include <new> #define double float diff --git a/backends/platform/ds/arm9/source/scummhelp.h b/backends/platform/ds/arm9/source/scummhelp.h index 79103b35ed..2735727560 100644 --- a/backends/platform/ds/arm9/source/scummhelp.h +++ b/backends/platform/ds/arm9/source/scummhelp.h @@ -24,7 +24,7 @@ #define _SCUMMHELP_H_ #include "common/str.h" -#include "common/util.h" +#include "common/platform.h" namespace DS { diff --git a/backends/platform/gph/caanoo-bundle.mk b/backends/platform/gph/caanoo-bundle.mk index 8aabca9028..2cf8e62b37 100755 --- a/backends/platform/gph/caanoo-bundle.mk +++ b/backends/platform/gph/caanoo-bundle.mk @@ -14,11 +14,11 @@ caanoo-bundle: $(EXECUTABLE) echo "Please put your save games in this dir" >> "$(bundle_name)/scummvm/saves/PUT_SAVES_IN_THIS_DIR" - $(CP) $(srcdir)/backends/platform/gph/devices/caanoo/scummvm.gpe $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.png $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvmb.png $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/README-GPH $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.ini $(bundle_name)/ + $(CP) $(srcdir)/dists/gph/caanoo/scummvm.gpe $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvmb.png $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvm.ini $(bundle_name)/ $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/ $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/scummvm/ @@ -45,11 +45,11 @@ caanoo-bundle-debug: $(EXECUTABLE) echo "Please put your save games in this dir" >> "$(bundle_name)/scummvm/saves/PUT_SAVES_IN_THIS_DIR" - $(CP) $(srcdir)/backends/platform/gph/devices/caanoo/scummvm-gdb.gpe $(bundle_name)/scummvm/scummvm.gpe - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.png $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvmb.png $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/README-GPH $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.ini $(bundle_name)/ + $(CP) $(srcdir)/dists/gph/caanoo/scummvm-gdb.gpe $(bundle_name)/scummvm/scummvm.gpe + $(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvmb.png $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvm.ini $(bundle_name)/ $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/ $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/scummvm/ diff --git a/backends/platform/gph/devices/caanoo/scummvm-gdb.gpe b/backends/platform/gph/devices/caanoo/scummvm-gdb.gpe deleted file mode 100644 index 63ce193ca8..0000000000 --- a/backends/platform/gph/devices/caanoo/scummvm-gdb.gpe +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -# Export the location of any libs ScummVM depends on -# (to avoid installing to the NAND and overwriting the broken ones there). -export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH - -# Run ScummVM via GDB (so make sure you have a terminal open or serial). -# Oh, and GDB installed of course ;) -gdb --args ./scummvm.gph --fullscreen --gfx-mode=1x --config=$(pwd)/.scummvmrc - -# Sync the SD card to check that everything is written. -sync - -# Return to the GPH menu screen -cd /usr/gp2x -exec /usr/gp2x/gp2xmenu diff --git a/backends/platform/gph/devices/caanoo/scummvm.gpe b/backends/platform/gph/devices/caanoo/scummvm.gpe deleted file mode 100644 index 37d0f65d18..0000000000 --- a/backends/platform/gph/devices/caanoo/scummvm.gpe +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# Export the location of any libs ScummVM depends on -# (to avoid installing to the NAND and overwriting the broken ones there). -export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH - -# Run ScummVM, important this bit. -./scummvm.gph --fullscreen --gfx-mode=1x --config=$(pwd)/.scummvmrc - -# Sync the SD card to check that everything is written. -sync - -# Return to the GPH menu screen -cd /usr/gp2x -exec /usr/gp2x/gp2xmenu diff --git a/backends/platform/gph/devices/common/README-GPH b/backends/platform/gph/devices/common/README-GPH deleted file mode 100644 index ea196f6649..0000000000 --- a/backends/platform/gph/devices/common/README-GPH +++ /dev/null @@ -1,60 +0,0 @@ -ScummVM - GPH DEVICE SPECIFIC README ------------------------------------------------------------------------- - -Contents: - - * About the backend/port <#About_the_backendport> - * Supported audio options <#Supported_audio_options> - * Credits <#Credits> - ------------------------------------------------------------------------- - -Please refer to the: - -GPH ScummVM Forum: <http://forums.scummvm.org/viewforum.php?f=14> - -WiKi: (Select your device) - -<http://wiki.scummvm.org/index.php/GP2X> -<http://wiki.scummvm.org/index.php/GP2XWiz> -<http://wiki.scummvm.org/index.php/Caanoo> - -for the most current information on the port and any updates to this -documentation. - -The wiki includes detailed instructions on how to use the port and -control information. - ------------------------------------------------------------------------- -About the backend/port - -This is the readme for the official GPH ScummVM backend (also known as -the GP2X port/GP2XWiz port or Caanoo port). - -This is an SVN test release of ScummVM for GPH devices, it would be -appreciated if this SVN test distribution was not mirrored and that -people be directed to http://scummvm.distant-earth.com/ instead for -updated SVN builds. - -Fully supported official releases of the GPH ScummVM backend are made in -line with main official releases and are avalalble from the ScummVM -downloads page <http://www.scummvm.org/downloads.php> for the GP2X, -GP2XWiz and Caanoo. - ------------------------------------------------------------------------- -Supported audio options - -Raw audio. -MP3 audio. -OGG Vorbis audio. - -FLAC audio is currently unsupported. - -For best results use uncompressed audio in games. - ------------------------------------------------------------------------- -Credits - -Core ScummVM code (c) The ScummVM Team -Portions of the GPH backend (c) John Willis -Detailed (c) information can be found within the source code diff --git a/backends/platform/gph/devices/common/scummvm.ini b/backends/platform/gph/devices/common/scummvm.ini deleted file mode 100644 index c9cce92379..0000000000 --- a/backends/platform/gph/devices/common/scummvm.ini +++ /dev/null @@ -1,5 +0,0 @@ -[info] -name="ScummVM" -path="/scummvm/scummvm.gpe" -icon="/scummvm/scummvm.png" -title="/scummvm/scummvmb.png" diff --git a/backends/platform/gph/devices/common/scummvm.png b/backends/platform/gph/devices/common/scummvm.png Binary files differdeleted file mode 100644 index 128e59efc4..0000000000 --- a/backends/platform/gph/devices/common/scummvm.png +++ /dev/null diff --git a/backends/platform/gph/devices/common/scummvmb.png b/backends/platform/gph/devices/common/scummvmb.png Binary files differdeleted file mode 100644 index 24a27bc0e1..0000000000 --- a/backends/platform/gph/devices/common/scummvmb.png +++ /dev/null diff --git a/backends/platform/gph/devices/gp2x/mmuhack/Makefile b/backends/platform/gph/devices/gp2x/mmuhack/Makefile deleted file mode 100644 index a35d5c2a98..0000000000 --- a/backends/platform/gph/devices/gp2x/mmuhack/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -TARGET = mmuhack -INCLUDE = -I/opt/gcc-3.4.4-glibc-2.3.6/arm-open2x-linux/sys-include -CFLAGS = -O2 -DMODULE -D__KERNEL__ ${INCLUDE} -CC = arm-open2x-linux-gcc - -all: ${TARGET}.o - -${TARGET}.o: ${TARGET}.c - -clean: - rm -rf ${TARGET}.o diff --git a/backends/platform/gph/devices/gp2x/mmuhack/README b/backends/platform/gph/devices/gp2x/mmuhack/README deleted file mode 100644 index 6db7d81845..0000000000 --- a/backends/platform/gph/devices/gp2x/mmuhack/README +++ /dev/null @@ -1,116 +0,0 @@ -PLEASE NOTE: - -The binary object 'mmuhack.o' is stored in the source tree as it is very awkward to -build it manually each time and would require the use of 2 toolchains to do so. - -Notes on how to rebuild from the included source can be found below. - -About ------ - -This is a module for GP2X 2.4 based Linux kernel, created for developers to use in their -programs. - -Normally the upper 32MB is uncached. This means that reads/writes on the memory -are always done via the physical memory modules rather than the much faster -memory built into the processor (called 'cache'). Access to the upper 32MB can -be sped up by Squidge's MMU hack. The easiest way to use the MMU hack is to add -and load the MMU hack kernel module into your program. - -Note: Building this module requries a GP2X 'kernel' toolchain (i.e. GCC 2.95.* -for the GP2X stock, 3.* for Open2X). - -You can't build this module with the GCC 4 based application toolchains. - -Operation ---------- - -When loaded into kernel, this module creates /dev/mmuhack device. Whenever -a program opens that device using open() call, the module traverses all -memory, which was allocated in 0x02000000-0x03ffffff range by the program via -using mmap() system call. While doing that, it marks all encountered memory -as bufferable and cacheable. - -The most common use of this is to remove the framebuffer access bottleneck. -Note that, however, by making the framebuffer cacheable you can cause display -artifacts. This can happen because parts of your framebuffer may stay in CPU -cache and not to be written back to the physical memory. The display -controller only fetches data from the physical memory, so you get incomplete -image (the memory will most likely contain data from previous frame, so these -artifacts are better visible during fade effects). The easy way to fix this -is by using a special ARM Linux system call, which flushes the cache (forces -the CPU to write data in cache to the physical memory (see section "Flushing -the cache")). - -Using this module affects the whole upper memory area. But in some situations -this may be not desirable, for example when using ARM940 core in your program -(ether using 940 libraries like ogg940 and gpu940, or using your custom code, -which needs uncacheable memory for communication and such). If you need part -of your upper memory to be cached, and other part not, you should mmap() that -memory (which you want to be uncached) _after_ doing open("/dev/mmuhack"). -Another way is to modify mmuhack.c to suit your needs and rebuild the module. - - -Usage ------ - -The very first thing to do is to load the kernel module (mmuhack.o) into the -running kernel. But before that you should try to unload mmuhack module, -because other program might have left a different version loaded with -different memory configuration, which may not suit your program. - -system("/sbin/rmmod mmuhack"); -system("/sbin/insmod mmuhack.o"); - -Now you can assume the module is loaded into kernel and open /dev/mmuhack -device. You don't need to worry about previous calls failing, because in that -case open() will simply fail and nothing bad will happen. - -IMPORTANT: you _must_ do the open() call _after_ you initialize your graphics -library or allocate your memory, because it can only work with memory which is -already allocated, it won't affect memory you or your lib allocates after the -open() call. - -int mmufd = open("/dev/mmuhack", O_RDWR); -if(mmufd < 0) -{ - printf("MMU hack failed"); -} -else -{ - printf("MMU hack loaded"); - close(mmufd); -} - -If the above call succeeded, you are all done. -I recommend to unload the module when your program exits, because the other -program may want to load a different mmuhack.o and may fail, because you left -your mmuhack.o loaded (it does not get unloaded automatically on exit). - -system("/sbin/rmmod mmuhack"); - - -Flushing the cache ------------------- - -If using mmuhack.o causes your program to display artifacts (see "Operation" -section for explanation), you will need to flush the CPU cache. This should -be done after finishing every frame and just before flipping your display -buffer/surface. You will need to add flush_uppermem_cache.s file to your -Makefile/project and add a call to flush_uppermem_cache() just before final -framebuffer flip or blit. - -flush_uppermem_cache() has 3 parameters. First param is the start address, -second param is the end address, third one should always be 0. The addresses -should be virtual ones (most often pointers to the start/end of your -framebuffer). Example: - -flush_uppermem_cache(screen_surface->pixels, screen_surface->pixels + 320*240, 0); - - -Credits -------- - -Original idea/implementation: Squidge (this whole thing is also known as squidgehack) -Kernel module: NK -Documentation: notaz diff --git a/backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.h b/backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.h deleted file mode 100644 index d01548e474..0000000000 --- a/backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifdef __cplusplus -extern "C" -{ -#endif - -void flush_uppermem_cache(void *start_address, void *end_address, int flags); - -#ifdef __cplusplus -} -#endif diff --git a/backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.s b/backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.s deleted file mode 100644 index 265908e1fd..0000000000 --- a/backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.s +++ /dev/null @@ -1,5 +0,0 @@ -.global flush_uppermem_cache @ void *start_address, void *end_address, int flags - -flush_uppermem_cache: - swi #0x9f0002 - bx lr diff --git a/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.c b/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.c deleted file mode 100644 index 2e38bdb284..0000000000 --- a/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.c +++ /dev/null @@ -1,126 +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 <linux/config.h> -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/init.h> -#include <linux/miscdevice.h> -#include <asm/memory.h> - -#define MMUHACK_MINOR 225 -#define DEVICE_NAME "mmuhack" - -#if __GNUC__ == 3 -#include <linux/version.h> -static const char __module_kernel_version_gcc3[] __attribute__((__used__)) __attribute__((section(".modinfo"))) = -"kernel_version=" UTS_RELEASE; -#endif - -static ssize_t mmuhack_open(struct inode *inode, struct file *filp) -{ - unsigned int *pgtable; - unsigned int *cpt; - int i, j; - int ttb; - int ret = -EFAULT; - - // get the pointer to the translation table base... - asm volatile( - "stmdb sp!, {r0}\n\t" - "mrc p15, 0, r0, c2, c0, 0\n\t" - "mov %0, r0\n\t" - "ldmia sp!, {r0}\n\t": "=r"(ttb) - ); - - pgtable = __va(ttb); - - for (i = 0; i < 4096; i ++) if ( (pgtable[i] & 3) == 1 ) { - cpt = __va(pgtable[i] & 0xfffffc00); - - for (j = 0; j < 256; j ++) {/* - if ( (cpt[j] & 0xfe00000f) == 0x02000002 ) { - // set C and B bits in upper 32MB memory area... - printk("Set C&B bits %08x\n",cpt[j]); - cpt[j] |= 0xFFC; - ret = 0; - } - */ - if (((cpt[j] & 0xff000000) == 0x02000000) && ((cpt[j] & 12)==0) ) - { - //printk("Set C&B bits %08x\n",cpt[j]); - cpt[j] |= 0xFFC; - } - //if ((a>=0x31 && a<=0x36) && ((cpt[i] & 12)==0)) - if (((cpt[j] & 0xff000000) == 0x03000000) && ((cpt[j] & 12)==0)) - { - //printk("Set C&B bits %08x\n",cpt[j]); - //printf("SDL c and b bits not set, overwriting\n"); - cpt[j] |= 0xFFC; - } - } - } - - // drain the write buffer and flush the tlb caches... - asm volatile( - "stmdb sp!, {r0}\n\t" - "mov r0, #0\n\t" - "mcr 15, 0, r0, cr7, cr10, 4\n\t" - "mcr 15, 0, r0, cr8, cr7, 0\n\t" - "ldmia sp!, {r0}\n\t" - ); - - if (ret == 0) - printk("MMU hack applied.\n"); - - return 0; -} - -static struct file_operations mmuhack_fops = { - owner: THIS_MODULE, - open: mmuhack_open, -}; - - -static struct miscdevice mmuhack = { - MMUHACK_MINOR, DEVICE_NAME, &mmuhack_fops -}; - -static int __init mmuhack_init(void) -{ - misc_register(&mmuhack); -/* - printk("MMSP2 MMU Hack module.\n"); -*/ - return 0; -} - -static void __exit mmuhack_exit(void) -{ - misc_deregister(&mmuhack); -/* - printk(KERN_ALERT "MMU Hack module removed.\n"); -*/ -} - -module_init(mmuhack_init); -module_exit(mmuhack_exit); diff --git a/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.o b/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.o Binary files differdeleted file mode 100644 index 475f4a54ae..0000000000 --- a/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.o +++ /dev/null diff --git a/backends/platform/gph/devices/gp2x/scummvm.gpe b/backends/platform/gph/devices/gp2x/scummvm.gpe deleted file mode 100644 index 51a49f7560..0000000000 --- a/backends/platform/gph/devices/gp2x/scummvm.gpe +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -# Remount SD with forced Sync, does this really work? -mount -o sync,remount /dev/mmcsd/disc0/part1 /mnt/sd/ - -# Export the location of any libs ScummVM depends on -# (to avoid installing to the NAND and overwriting the broken ones there). -export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH - -# Run ScummVM, important this bit. -./scummvm.gph --fullscreen --gfx-mode=1x --config=$(pwd)/.scummvmrc - -# Sync the SD card to check that everything is written. -sync - -# Return to the GPH menu screen -cd /usr/gp2x -exec /usr/gp2x/gp2xmenu diff --git a/backends/platform/gph/devices/gp2xwiz/scummvm-gdb.gpe b/backends/platform/gph/devices/gp2xwiz/scummvm-gdb.gpe deleted file mode 100644 index 63ce193ca8..0000000000 --- a/backends/platform/gph/devices/gp2xwiz/scummvm-gdb.gpe +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -# Export the location of any libs ScummVM depends on -# (to avoid installing to the NAND and overwriting the broken ones there). -export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH - -# Run ScummVM via GDB (so make sure you have a terminal open or serial). -# Oh, and GDB installed of course ;) -gdb --args ./scummvm.gph --fullscreen --gfx-mode=1x --config=$(pwd)/.scummvmrc - -# Sync the SD card to check that everything is written. -sync - -# Return to the GPH menu screen -cd /usr/gp2x -exec /usr/gp2x/gp2xmenu diff --git a/backends/platform/gph/devices/gp2xwiz/scummvm.gpe b/backends/platform/gph/devices/gp2xwiz/scummvm.gpe deleted file mode 100644 index 59ff562aeb..0000000000 --- a/backends/platform/gph/devices/gp2xwiz/scummvm.gpe +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# Export the location of any libs ScummVM depends on -# (to avoid installing to the NAND and overwriting the broken ones there). -export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH - -# Run ScummVM, important this bit. -./scummvm.gph --fullscreen --gfx-mode=1x --config=$(pwd)/.scummvmrc - -# Sync the SD card to check that everything is written. -sync - -# Return to the GPH menu screen -cd /usr/gp2x -exec /usr/gp2x/gp2xmenu diff --git a/backends/platform/gph/gp2x-bundle.mk b/backends/platform/gph/gp2x-bundle.mk index 810ff8b8f0..9fcb379e04 100644 --- a/backends/platform/gph/gp2x-bundle.mk +++ b/backends/platform/gph/gp2x-bundle.mk @@ -12,15 +12,15 @@ gp2x-bundle: $(EXECUTABLE) echo "Please put your save games in this dir" >> "$(bundle_name)/saves/PUT_SAVES_IN_THIS_DIR" - $(CP) $(srcdir)/backends/platform/gph/devices/gp2x/scummvm.gpe $(bundle_name)/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.png $(bundle_name)/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/README-GPH $(bundle_name)/ - $(CP) $(srcdir)/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.o $(bundle_name)/ + $(CP) $(srcdir)/dists/gph/gp2x/scummvm.gpe $(bundle_name) + $(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name) + $(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name) + $(CP) $(srcdir)/dists/gph/gp2x/mmuhack/mmuhack.o $(bundle_name) - $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/ - $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/ + $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name) + $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name) $(INSTALL) -c -m 644 $(DIST_FILES_ENGINEDATA) $(bundle_name)/engine-data - $(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_default.zip $(bundle_name)/ + $(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_default.zip $(bundle_name) $(STRIP) $(EXECUTABLE) -o $(bundle_name)/$(EXECUTABLE) @@ -39,18 +39,19 @@ gp2x-bundle-debug: $(EXECUTABLE) $(MKDIR) "$(bundle_name)" $(MKDIR) "$(bundle_name)/saves" $(MKDIR) "$(bundle_name)/engine-data" + $(MKDIR) "$(bundle_name)/lib" echo "Please put your save games in this dir" >> "$(bundle_name)/saves/PUT_SAVES_IN_THIS_DIR" - $(CP) $(srcdir)/backends/platform/gph/devices/gp2x/scummvm.gpe $(bundle_name)/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.png $(bundle_name)/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/README-GPH $(bundle_name)/ - $(CP) $(srcdir)/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.o $(bundle_name)/ + $(CP) $(srcdir)/dists/gph/gp2x/scummvm.gpe $(bundle_name) + $(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name) + $(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name) + $(CP) $(srcdir)/dists/gph/gp2x/mmuhack/mmuhack.o $(bundle_name) - $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/ - $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/ + $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name) + $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name) $(INSTALL) -c -m 644 $(DIST_FILES_ENGINEDATA) $(bundle_name)/engine-data - $(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_default.zip $(bundle_name)/ + $(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_default.zip $(bundle_name) $(INSTALL) -c -m 777 $(srcdir)/$(EXECUTABLE) $(bundle_name)/$(EXECUTABLE) diff --git a/backends/platform/gph/gp2xwiz-bundle.mk b/backends/platform/gph/gp2xwiz-bundle.mk index 65e2952fde..4f49850813 100755 --- a/backends/platform/gph/gp2xwiz-bundle.mk +++ b/backends/platform/gph/gp2xwiz-bundle.mk @@ -13,11 +13,11 @@ gp2xwiz-bundle: $(EXECUTABLE) echo "Please put your save games in this dir" >> "$(bundle_name)/scummvm/saves/PUT_SAVES_IN_THIS_DIR" - $(CP) $(srcdir)/backends/platform/gph/devices/gp2xwiz/scummvm.gpe $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.png $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvmb.png $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/README-GPH $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.ini $(bundle_name)/ + $(CP) $(srcdir)/dists/gph/gp2xwiz/scummvm.gpe $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvmb.png $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvm.ini $(bundle_name)/ $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/ $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/scummvm/ @@ -47,11 +47,11 @@ gp2xwiz-bundle-debug: $(EXECUTABLE) echo "Please put your save games in this dir" >> "$(bundle_name)/scummvm/saves/PUT_SAVES_IN_THIS_DIR" - $(CP) $(srcdir)/backends/platform/gph/devices/gp2xwiz/scummvm-gdb.gpe $(bundle_name)/scummvm/scummvm.gpe - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.png $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvmb.png $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/README-GPH $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.ini $(bundle_name)/ + $(CP) $(srcdir)/dists/gph/gp2xwiz/scummvm-gdb.gpe $(bundle_name)/scummvm/scummvm.gpe + $(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvmb.png $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvm.ini $(bundle_name)/ $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/ $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/scummvm/ diff --git a/backends/platform/iphone/blit_arm.s b/backends/platform/iphone/blit_arm.s deleted file mode 100644 index 04f9a87614..0000000000 --- a/backends/platform/iphone/blit_arm.s +++ /dev/null @@ -1,137 +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. -@ -@ @author Robin Watts (robin@wss.co.uk) - - .text - - .global _blitLandscapeScreenRect16bpp - .global _blitLandscapeScreenRect8bpp - - -_blitLandscapeScreenRect16bpp: - @ r0 = dst - @ r1 = src - @ r2 = w - @ r3 = h - @ <> = _screenWidth - @ <> = _screenHeight - mov r12,r13 - stmfd r13!,{r4-r11,r14} - ldmfd r12,{r12,r14} @ r12 = _screenWidth - @ r14 = _screenHeight - add r14,r14,r3 @ r14 = _screenHeight + h - mvn r11,#0 - mla r11,r3,r12,r11 @ r11= _screenWidth*h-1 - add r12,r12,r12 -xloop: - subs r4,r3,#5 @ r4 = y = h - ble thin -yloop: - ldrh r5, [r1],r12 @ r5 = *src src += _screenWidth - ldrh r6, [r1],r12 @ r6 = *src src += _screenWidth - ldrh r7, [r1],r12 @ r7 = *src src += _screenWidth - ldrh r8, [r1],r12 @ r8 = *src src += _screenWidth - ldrh r9, [r1],r12 @ r9 = *src src += _screenWidth - ldrh r10,[r1],r12 @ r10= *src src += _screenWidth - subs r4,r4,#6 - strh r5, [r0],#2 @ *dst++ = r5 - strh r6, [r0],#2 @ *dst++ = r6 - strh r7, [r0],#2 @ *dst++ = r7 - strh r8, [r0],#2 @ *dst++ = r8 - strh r9, [r0],#2 @ *dst++ = r9 - strh r10,[r0],#2 @ *dst++ = r10 - bgt yloop -thin: - adds r4,r4,#5 - beq lineend -thin_loop: - ldrh r5,[r1],r12 @ r5 = *src src += _screenWidth - subs r4,r4,#1 - strh r5,[r0],#2 @ *dst++ = r5 - bgt thin_loop -lineend: - sub r0,r0,r14,LSL #1 @ dst -= _screenHeight + h - sub r1,r1,r11,LSL #1 @ src += 1-_screenWidth*h - subs r2,r2,#1 - bgt xloop - - ldmfd r13!,{r4-r11,PC} - -_blitLandscapeScreenRect8bpp: - @ r0 = dst - @ r1 = src - @ r2 = w - @ r3 = h - @ <> = _palette - @ <> = _screenWidth - @ <> = _screenHeight - mov r12,r13 - stmfd r13!,{r4-r11,r14} - ldmfd r12,{r11,r12,r14} @ r11 = _palette - @ r12 = _screenWidth - @ r14 = _screenHeight - add r14,r14,r3 @ r14 = _screenHeight + h - mvn r6,#0 - mla r6,r3,r12,r6 @ r6 = _screenWidth*h-1 -xloop8: - mov r4,r3 @ r4 = y = h - subs r4,r3,#4 @ r4 = y = h - ble thin8 -yloop8: - ldrb r5, [r1],r12 @ r5 = *src src += _screenWidth - ldrb r7, [r1],r12 @ r7 = *src src += _screenWidth - ldrb r8, [r1],r12 @ r8 = *src src += _screenWidth - ldrb r9, [r1],r12 @ r9 = *src src += _screenWidth - ldrb r10,[r1],r12 @ r10= *src src += _screenWidth - add r5, r5, r5 - add r7, r7, r7 - add r8, r8, r8 - add r9, r9, r9 - add r10,r10,r10 - ldrh r5, [r11,r5] - ldrh r7, [r11,r7] - ldrh r8, [r11,r8] - ldrh r9, [r11,r9] - ldrh r10,[r11,r10] - subs r4,r4,#5 - strh r5, [r0],#2 @ *dst++ = r5 - strh r7, [r0],#2 @ *dst++ = r7 - strh r8, [r0],#2 @ *dst++ = r8 - strh r9, [r0],#2 @ *dst++ = r9 - strh r10,[r0],#2 @ *dst++ = r10 - bgt yloop8 -thin8: - adds r4,r4,#4 - beq lineend8 -thin_loop8: - ldrb r5,[r1],r12 @ r5 = *src src += _screenWidth - add r5,r5,r5 - ldrh r5,[r11,r5] - subs r4,r4,#1 - strh r5,[r0],#2 @ *dst++ = r5 - bgt thin_loop8 -lineend8: - sub r0,r0,r14,LSL #1 @ dst -= _screenHeight + h - sub r1,r1,r6 @ src += 1-_screenWidth*h - subs r2,r2,#1 - bgt xloop8 - - ldmfd r13!,{r4-r11,PC} diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 0cbcb77bcb..19e4f2ce9b 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -20,6 +20,10 @@ * */ +#ifndef BACKENDS_PLATFORM_IPHONE_IPHONE_COMMON_H +#define BACKENDS_PLATFORM_IPHONE_IPHONE_COMMON_H + +#include "graphics/surface.h" enum InputEvent { kInputMouseDown, @@ -41,43 +45,53 @@ enum ScreenOrientation { kScreenOrientationFlippedLandscape }; -typedef enum -{ +enum UIViewSwipeDirection { kUIViewSwipeUp = 1, kUIViewSwipeDown = 2, kUIViewSwipeLeft = 4, kUIViewSwipeRight = 8 -} UIViewSwipeDirection; +}; -#ifdef IPHONE_OFFICIAL -void iphone_main(int argc, char **argv); -#endif +enum GraphicsModes { + kGraphicsModeLinear = 0, + kGraphicsModeNone = 1 +}; -// We need this to be able to call functions from/in Objective-C. -#ifdef __cplusplus -extern "C" { -#endif +struct VideoContext { + VideoContext() : asprectRatioCorrection(), screenWidth(), screenHeight(), overlayVisible(false), + overlayWidth(), overlayHeight(), mouseX(), mouseY(), + mouseHotspotX(), mouseHotspotY(), mouseWidth(), mouseHeight(), + mouseIsVisible(), graphicsMode(kGraphicsModeLinear), shakeOffsetY() { + } -// On the C++ side -#ifndef IPHONE_OFFICIAL -void iphone_main(int argc, char *argv[]); -#endif + // Game screen state + bool asprectRatioCorrection; + uint screenWidth, screenHeight; + Graphics::Surface screenTexture; + + // Overlay state + bool overlayVisible; + uint overlayWidth, overlayHeight; + Graphics::Surface overlayTexture; + + // Mouse cursor state + uint mouseX, mouseY; + int mouseHotspotX, mouseHotspotY; + uint mouseWidth, mouseHeight; + bool mouseIsVisible; + Graphics::Surface mouseTexture; + + // Misc state + GraphicsModes graphicsMode; + int shakeOffsetY; +}; // On the ObjC side -void iPhone_updateScreen(int mouseX, int mouseY); -void iPhone_updateScreenRect(unsigned short* screen, int x1, int y1, int x2, int y2); -void iPhone_updateOverlayRect(unsigned short* screen, int x1, int y1, int x2, int y2); -void iPhone_initSurface(int width, int height); -bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY); -const char* iPhone_getDocumentsDir(); +void iPhone_updateScreen(); +bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY); +const char *iPhone_getDocumentsDir(); bool iPhone_isHighResDevice(); -int iPhone_getScreenHeight(); -int iPhone_getScreenWidth(); -void iPhone_enableOverlay(int state); -void iPhone_setMouseCursor(short* buffer, int width, int height); uint getSizeNextPOT(uint size); -#ifdef __cplusplus -} #endif diff --git a/backends/platform/iphone/iphone_keyboard.h b/backends/platform/iphone/iphone_keyboard.h index eecad09398..2d1238c92f 100644 --- a/backends/platform/iphone/iphone_keyboard.h +++ b/backends/platform/iphone/iphone_keyboard.h @@ -20,17 +20,22 @@ * */ -#import <UIKit/UIKit.h> -#import <UIKit/UITextView.h> +#ifndef BACKENDS_PLATFORM_IPHONE_IPHONE_KEYBOARD_H +#define BACKENDS_PLATFORM_IPHONE_IPHONE_KEYBOARD_H + +#include <UIKit/UIKit.h> +#include <UIKit/UITextView.h> @interface SoftKeyboard : UIView { id inputDelegate; - UITextView* inputView; + UITextView *inputView; } - (id)initWithFrame:(CGRect)frame; -- (UITextView*)inputView; +- (UITextView *)inputView; - (void)setInputDelegate:(id)delegate; - (void)handleKeyPress:(unichar)c; @end + +#endif diff --git a/backends/platform/iphone/iphone_keyboard.m b/backends/platform/iphone/iphone_keyboard.mm index 1624d02977..b00930ab31 100644 --- a/backends/platform/iphone/iphone_keyboard.m +++ b/backends/platform/iphone/iphone_keyboard.mm @@ -20,7 +20,7 @@ * */ -#import "iphone_keyboard.h" +#include "iphone_keyboard.h" @interface UITextInputTraits - (void)setAutocorrectionType:(int)type; @@ -29,17 +29,17 @@ @end @interface TextInputHandler : UITextView { - SoftKeyboard* softKeyboard; + SoftKeyboard *softKeyboard; } -- (id)initWithKeyboard:(SoftKeyboard*)keyboard; +- (id)initWithKeyboard:(SoftKeyboard *)keyboard; @end @implementation TextInputHandler -- (id)initWithKeyboard:(SoftKeyboard*)keyboard; { +- (id)initWithKeyboard:(SoftKeyboard *)keyboard; { self = [super initWithFrame:CGRectMake(0.0f, 0.0f, 0.0f, 0.0f)]; softKeyboard = keyboard; @@ -80,7 +80,7 @@ return self; } -- (UITextView*)inputView { +- (UITextView *)inputView { return inputView; } diff --git a/backends/platform/iphone/iphone_main.m b/backends/platform/iphone/iphone_main.mm index c2ec328bf5..e76ffe866e 100644 --- a/backends/platform/iphone/iphone_main.m +++ b/backends/platform/iphone/iphone_main.mm @@ -20,38 +20,41 @@ * */ -#import <UIKit/UIKit.h> -#import <Foundation/NSThread.h> +// Disable symbol overrides so that we can use system headers. +#define FORBIDDEN_SYMBOL_ALLOW_ALL + +#include <UIKit/UIKit.h> +#include <Foundation/NSThread.h> #include "iphone_video.h" void iphone_main(int argc, char *argv[]); @interface iPhoneMain : UIApplication { - UIWindow* _window; - iPhoneView* _view; + UIWindow *_window; + iPhoneView *_view; } -- (void) mainLoop: (id)param; -- (iPhoneView*) getView; -- (UIWindow*) getWindow; +- (void)mainLoop:(id)param; +- (iPhoneView *)getView; +- (UIWindow *)getWindow; - (void)didRotate:(NSNotification *)notification; @end -static int gArgc; -static char** gArgv; +static int g_argc; +static char **g_argv; -int main(int argc, char** argv) { - gArgc = argc; - gArgv = argv; +int main(int argc, char **argv) { + g_argc = argc; + g_argv = argv; - NSAutoreleasePool *autoreleasePool = [ - [ NSAutoreleasePool alloc ] init - ]; + NSAutoreleasePool *autoreleasePool = [ + [NSAutoreleasePool alloc] init + ]; - int returnCode = UIApplicationMain(argc, argv, @"iPhoneMain", @"iPhoneMain"); - [ autoreleasePool release ]; - return returnCode; + int returnCode = UIApplicationMain(argc, argv, @"iPhoneMain", @"iPhoneMain"); + [autoreleasePool release]; + return returnCode; } @implementation iPhoneMain @@ -63,14 +66,14 @@ int main(int argc, char** argv) { return self; } -- (void) mainLoop: (id)param { +- (void)mainLoop:(id)param { [[NSAutoreleasePool alloc] init]; - iphone_main(gArgc, gArgv); + iphone_main(g_argc, g_argv); exit(0); } -- (iPhoneView*) getView { +- (iPhoneView *)getView { return _view; } @@ -78,38 +81,36 @@ int main(int argc, char** argv) { CGRect rect = [[UIScreen mainScreen] bounds]; // hide the status bar - [application setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO]; - [application setStatusBarHidden:YES animated:YES]; + [application setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO]; + [application setStatusBarHidden:YES animated:YES]; _window = [[UIWindow alloc] initWithFrame:rect]; [_window retain]; - _view = [[iPhoneView alloc] initWithFrame: rect]; + _view = [[iPhoneView alloc] initWithFrame:rect]; _view.multipleTouchEnabled = YES; - [_window setContentView: _view]; + [_window setContentView:_view]; [_window addSubview:_view]; [_window makeKeyAndVisible]; [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(didRotate:) - name:@"UIDeviceOrientationDidChangeNotification" object:nil]; + selector:@selector(didRotate:) + name:@"UIDeviceOrientationDidChangeNotification" + object:nil]; [NSThread detachNewThreadSelector:@selector(mainLoop:) toTarget:self withObject:nil]; } -- (void)applicationDidResume -{ +- (void)applicationDidResume { } -- (void)applicationWillSuspend -{ +- (void)applicationWillSuspend { } -- (void)applicationWillTerminate -{ +- (void)applicationWillTerminate { } - (void)applicationSuspend:(struct __GSEvent *)event { @@ -122,14 +123,14 @@ int main(int argc, char** argv) { // Workaround, need to "hide" and unhide the statusbar to properly remove it, // since the Springboard has put it back without apparently flagging our application. - [self setStatusBarHidden:YES animated:YES]; - [self setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO]; - [self setStatusBarHidden:YES animated:YES]; + [self setStatusBarHidden:YES animated:YES]; + [self setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO]; + [self setStatusBarHidden:YES animated:YES]; } - (void)didRotate:(NSNotification *)notification { - int screenOrientation = [[UIDevice currentDevice] orientation]; - [_view deviceOrientationChanged: screenOrientation]; + UIDeviceOrientation screenOrientation = [[UIDevice currentDevice] orientation]; + [_view deviceOrientationChanged:screenOrientation]; } - (UIWindow*) getWindow { diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 223f025978..1405fe35f1 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -20,48 +20,69 @@ * */ -#ifndef _IPHONE_VIDEO__H -#define _IPHONE_VIDEO__H +#ifndef BACKENDS_PLATFORM_IPHONE_IPHONE_VIDEO_H +#define BACKENDS_PLATFORM_IPHONE_IPHONE_VIDEO_H -#import <UIKit/UIKit.h> -#import <Foundation/Foundation.h> -#import <QuartzCore/QuartzCore.h> +#include <UIKit/UIKit.h> +#include <Foundation/Foundation.h> +#include <QuartzCore/QuartzCore.h> -#import <OpenGLES/EAGL.h> -#import <OpenGLES/ES1/gl.h> -#import <OpenGLES/ES1/glext.h> +#include <OpenGLES/EAGL.h> +#include <OpenGLES/ES1/gl.h> +#include <OpenGLES/ES1/glext.h> -#import "iphone_keyboard.h" +#include "iphone_keyboard.h" +#include "iphone_common.h" -@interface iPhoneView : UIView -{ - void* _screenSurface; - NSMutableArray* _events; - SoftKeyboard* _keyboardView; - CALayer* _screenLayer; +@interface iPhoneView : UIView { + VideoContext _videoContext; - int _widthOffset; - int _heightOffset; + NSMutableArray *_events; + SoftKeyboard *_keyboardView; - EAGLContext* _context; + EAGLContext *_context; GLuint _viewRenderbuffer; GLuint _viewFramebuffer; - GLint _backingWidth; - GLint _backingHeight; - GLint _visibleWidth; - GLint _visibleHeight; GLuint _screenTexture; GLuint _overlayTexture; GLuint _mouseCursorTexture; + + UIDeviceOrientation _orientation; + + GLint _renderBufferWidth; + GLint _renderBufferHeight; + + GLfloat _gameScreenVertCoords[4 * 2]; + GLfloat _gameScreenTexCoords[4 * 2]; + CGRect _gameScreenRect; + + GLfloat _overlayVertCoords[4 * 2]; + GLfloat _overlayTexCoords[4 * 2]; + CGRect _overlayRect; + + GLfloat _mouseVertCoords[4 * 2]; + GLfloat _mouseTexCoords[4 * 2]; + GLint _mouseHotspotX, _mouseHotspotY; + GLint _mouseWidth, _mouseHeight; + GLfloat _mouseScaleX, _mouseScaleY; + + int _scaledShakeOffsetY; + + UITouch *_firstTouch; + UITouch *_secondTouch; } - (id)initWithFrame:(struct CGRect)frame; -- (void)drawRect:(CGRect)frame; +- (VideoContext *)getVideoContext; -- (void *)getSurface; +- (void)drawRect:(CGRect)frame; +- (void)createScreenTexture; - (void)initSurface; +- (void)setViewTransformation; + +- (void)setGraphicsMode; - (void)updateSurface; - (void)updateMainSurface; @@ -69,11 +90,13 @@ - (void)updateMouseSurface; - (void)clearColorBuffer; --(void)updateMouseCursor; +- (void)notifyMouseMove; +- (void)updateMouseCursorScaling; +- (void)updateMouseCursor; - (id)getEvent; -- (void)deviceOrientationChanged:(int)orientation; +- (void)deviceOrientationChanged:(UIDeviceOrientation)orientation; - (void)applicationSuspend; @@ -81,6 +104,6 @@ @end +extern iPhoneView *g_iPhoneViewInstance; - -#endif /* _IPHONE_VIDEO__H */ +#endif diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m deleted file mode 100644 index eb16676428..0000000000 --- a/backends/platform/iphone/iphone_video.m +++ /dev/null @@ -1,756 +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 "iphone_video.h" -#include "iphone_common.h" - -static iPhoneView *sharedInstance = nil; -static int _width = 0; -static int _height = 0; -static int _fullWidth; -static int _fullHeight; -static CGRect _screenRect; - -static char* _textureBuffer = 0; -static int _textureWidth = 0; -static int _textureHeight = 0; - -static char* _overlayTexBuffer = 0; -static int _overlayTexWidth = 0; -static int _overlayTexHeight = 0; -static int _overlayWidth = 0; -static int _overlayHeight = 0; -static float _overlayPortraitRatio = 1.0f; - -NSLock* _lock = nil; -static int _needsScreenUpdate = 0; -static int _overlayIsEnabled = 0; - -static UITouch* _firstTouch = NULL; -static UITouch* _secondTouch = NULL; - -static short* _mouseCursor = NULL; -static int _mouseCursorHeight = 0; -static int _mouseCursorWidth = 0; -static int _mouseX = 0; -static int _mouseY = 0; - -// static long lastTick = 0; -// static int frames = 0; - -#define printOpenGLError() printOglError(__FILE__, __LINE__) - -int printOglError(const char *file, int line) -{ - int retCode = 0; - - // returns 1 if an OpenGL error occurred, 0 otherwise. - GLenum glErr = glGetError(); - while( glErr != GL_NO_ERROR) - { - fprintf(stderr, "glError: %u (%s: %d)\n", glErr, file, line ); - retCode = 1; - glErr = glGetError(); - } - return retCode; -} - -void iPhone_setMouseCursor(short* buffer, int width, int height) { - _mouseCursor = buffer; - - _mouseCursorWidth = width; - _mouseCursorHeight = height; - - [sharedInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES]; -} - -void iPhone_enableOverlay(int state) { - _overlayIsEnabled = state; - - [sharedInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES]; -} - -int iPhone_getScreenHeight() { - return _overlayHeight; -} - -int iPhone_getScreenWidth() { - return _overlayWidth; -} - -bool iPhone_isHighResDevice() { - return _fullHeight > 480; -} - -void iPhone_updateScreen(int mouseX, int mouseY) { - //printf("Mouse: (%i, %i)\n", mouseX, mouseY); - - //_mouseX = _overlayHeight - (float)mouseX / _width * _overlayHeight; - //_mouseY = (float)mouseY / _height * _overlayWidth; - - //_mouseX = _overlayHeight - mouseX; - //_mouseY = mouseY; - - _mouseX = (_overlayWidth - mouseX) / (float)_overlayWidth * _overlayHeight; - _mouseY = mouseY / (float)_overlayHeight * _overlayWidth; - - if (!_needsScreenUpdate) { - _needsScreenUpdate = 1; - [sharedInstance performSelectorOnMainThread:@selector(updateSurface) withObject:nil waitUntilDone: NO]; - } -} - -void iPhone_updateScreenRect(unsigned short* screen, int x1, int y1, int x2, int y2) { - int y; - for (y = y1; y < y2; ++y) - memcpy(&_textureBuffer[(y * _textureWidth + x1 )* 2], &screen[y * _width + x1], (x2 - x1) * 2); -} - -void iPhone_updateOverlayRect(unsigned short* screen, int x1, int y1, int x2, int y2) { - int y; - //printf("Overlaywidth: %u, fullwidth %u\n", _overlayWidth, _fullWidth); - for (y = y1; y < y2; ++y) - memcpy(&_overlayTexBuffer[(y * _overlayTexWidth + x1 )* 2], &screen[y * _overlayWidth + x1], (x2 - x1) * 2); -} - -void iPhone_initSurface(int width, int height) { - _width = width; - _height = height; - [sharedInstance performSelectorOnMainThread:@selector(initSurface) withObject:nil waitUntilDone: YES]; -} - -bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY) { - id event = [sharedInstance getEvent]; - if (event == nil) { - return false; - } - - id type = [event objectForKey:@"type"]; - - if (type == nil) { - printf("fetchEvent says: No type!\n"); - return false; - } - - *outEvent = [type intValue]; - *outX = [[event objectForKey:@"x"] floatValue]; - *outY = [[event objectForKey:@"y"] floatValue]; - return true; -} - -uint getSizeNextPOT(uint size) { - if ((size & (size - 1)) || !size) { - int log = 0; - - while (size >>= 1) - ++log; - - size = (2 << log); - } - - return size; -} - -const char* iPhone_getDocumentsDir() { - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); - NSString *documentsDirectory = [paths objectAtIndex:0]; - return [documentsDirectory UTF8String]; -} - -bool getLocalMouseCoords(CGPoint *point) { - if (_overlayIsEnabled) { - point->x = point->x / _overlayHeight; - point->y = point->y / _overlayWidth; - } else { - if (point->x < _screenRect.origin.x || point->x >= _screenRect.origin.x + _screenRect.size.width || - point->y < _screenRect.origin.y || point->y >= _screenRect.origin.y + _screenRect.size.height) { - return false; - } - - point->x = (point->x - _screenRect.origin.x) / _screenRect.size.width; - point->y = (point->y - _screenRect.origin.y) / _screenRect.size.height; - } - - return true; -} - - -@implementation iPhoneView - -+ (Class) layerClass -{ - return [CAEAGLLayer class]; -} - -- (id)initWithFrame:(struct CGRect)frame { - self = [super initWithFrame: frame]; - - if([[UIScreen mainScreen] respondsToSelector: NSSelectorFromString(@"scale")]) - { - if([self respondsToSelector: NSSelectorFromString(@"contentScaleFactor")]) - { - //self.contentScaleFactor = [[UIScreen mainScreen] scale]; - } - } - - _fullWidth = frame.size.width; - _fullHeight = frame.size.height; - _screenLayer = nil; - - sharedInstance = self; - - _lock = [NSLock new]; - _keyboardView = nil; - _context = nil; - _screenTexture = 0; - _overlayTexture = 0; - _mouseCursorTexture = 0; - - return self; -} - --(void) dealloc { - [super dealloc]; - - if (_keyboardView != nil) { - [_keyboardView dealloc]; - } - - if (_screenTexture) - free(_textureBuffer); - - free(_overlayTexBuffer); -} - -- (void *)getSurface { - return _screenSurface; -} - -- (void)drawRect:(CGRect)frame { - // if (lastTick == 0) { - // lastTick = time(0); - // } - // - // frames++; - // if (time(0) > lastTick) { - // lastTick = time(0); - // printf("FPS: %i\n", frames); - // frames = 0; - // } -} - -- (void)updateSurface { - if (!_needsScreenUpdate) { - return; - } - _needsScreenUpdate = 0; - - if (_overlayIsEnabled) { - glClear(GL_COLOR_BUFFER_BIT); printOpenGLError(); - } - - [self updateMainSurface]; - - if (_overlayIsEnabled) { - [self updateOverlaySurface]; - [self updateMouseSurface]; - } - - glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); - [_context presentRenderbuffer:GL_RENDERBUFFER_OES]; - -} - --(void)updateMouseCursor { - if (_mouseCursorTexture == 0) { - glGenTextures(1, &_mouseCursorTexture); printOpenGLError(); - glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); printOpenGLError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); printOpenGLError(); - } - - glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getSizeNextPOT(_mouseCursorWidth), getSizeNextPOT(_mouseCursorHeight), 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _mouseCursor); printOpenGLError(); - - free(_mouseCursor); - _mouseCursor = NULL; -} - -- (void)updateMainSurface { - GLfloat vertices[] = { - 0.0f + _heightOffset, 0.0f + _widthOffset, - _visibleWidth - _heightOffset, 0.0f + _widthOffset, - 0.0f + _heightOffset, _visibleHeight - _widthOffset, - _visibleWidth - _heightOffset, _visibleHeight - _widthOffset - }; - - float texWidth = _width / (float)_textureWidth; - float texHeight = _height / (float)_textureHeight; - - const GLfloat texCoords[] = { - texWidth, 0.0f, - 0.0f, 0.0f, - texWidth, texHeight, - 0.0f, texHeight - }; - - glVertexPointer(2, GL_FLOAT, 0, vertices); printOpenGLError(); - glTexCoordPointer(2, GL_FLOAT, 0, texCoords); printOpenGLError(); - - glBindTexture(GL_TEXTURE_2D, _screenTexture); printOpenGLError(); - - // Unfortunately we have to update the whole texture every frame, since glTexSubImage2D is actually slower in all cases - // due to the iPhone internals having to convert the whole texture back from its internal format when used. - // In the future we could use several tiled textures instead. - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _textureWidth, _textureHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _textureBuffer); printOpenGLError(); - glDisable(GL_BLEND); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); -} - -- (void)updateOverlaySurface { - GLfloat vertices[] = { - 0.0f, 0.0f, - _overlayHeight, 0.0f, - 0.0f, _overlayWidth * _overlayPortraitRatio, - _overlayHeight, _overlayWidth * _overlayPortraitRatio - }; - - float texWidth = _overlayWidth / (float)_overlayTexWidth; - float texHeight = _overlayHeight / (float)_overlayTexHeight; - - const GLfloat texCoords[] = { - texWidth, 0.0f, - 0.0f, 0.0f, - texWidth, texHeight, - 0.0f, texHeight - }; - - glVertexPointer(2, GL_FLOAT, 0, vertices); printOpenGLError(); - glTexCoordPointer(2, GL_FLOAT, 0, texCoords); printOpenGLError(); - - glBindTexture(GL_TEXTURE_2D, _overlayTexture); printOpenGLError(); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _overlayTexWidth, _overlayTexHeight, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _overlayTexBuffer); printOpenGLError(); - glEnable(GL_BLEND); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); -} - -- (void)updateMouseSurface { - - int width = _mouseCursorWidth / (float)_backingWidth * _backingHeight; - int height = _mouseCursorHeight / (float)_backingHeight * _backingWidth; - - GLfloat vertices[] = { - _mouseX, _mouseY, - _mouseX + height, _mouseY, - _mouseX, _mouseY + width, - _mouseX + height, _mouseY + width - }; - - //printf("Cursor: width %u height %u\n", _mouseCursorWidth, _mouseCursorHeight); - - float texWidth = _mouseCursorWidth / (float)getSizeNextPOT(_mouseCursorWidth); - float texHeight = _mouseCursorHeight / (float)getSizeNextPOT(_mouseCursorHeight); - - const GLfloat texCoords[] = { - texWidth, 0.0f, - 0.0f, 0.0f, - texWidth, texHeight, - 0.0f, texHeight - }; - - glVertexPointer(2, GL_FLOAT, 0, vertices); printOpenGLError(); - glTexCoordPointer(2, GL_FLOAT, 0, texCoords); printOpenGLError(); - - glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); - glEnable(GL_BLEND); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); -} - -- (void)initSurface { - _textureWidth = getSizeNextPOT(_width); - _textureHeight = getSizeNextPOT(_height); - - UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; - - //printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _width, _height, _textureWidth, _textureHeight); - - if (_context == nil) { - orientation = UIDeviceOrientationLandscapeRight; - CAEAGLLayer *eaglLayer = (CAEAGLLayer*) self.layer; - - eaglLayer.opaque = YES; - eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat, nil]; - - _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; - if (!_context || [EAGLContext setCurrentContext:_context]) { - glGenFramebuffersOES(1, &_viewFramebuffer); printOpenGLError(); - glGenRenderbuffersOES(1, &_viewRenderbuffer); printOpenGLError(); - - glBindFramebufferOES(GL_FRAMEBUFFER_OES, _viewFramebuffer); printOpenGLError(); - glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); - [_context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id<EAGLDrawable>)self.layer]; - glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); - - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &_backingWidth); printOpenGLError(); - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &_backingHeight); printOpenGLError(); - - if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { - NSLog(@"Failed to make complete framebuffer object %x.", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); - return; - } - - _overlayHeight = _backingWidth; - _overlayWidth = _backingHeight; - _overlayTexWidth = getSizeNextPOT(_overlayHeight); - _overlayTexHeight = getSizeNextPOT(_overlayWidth); - - int textureSize = _overlayTexWidth * _overlayTexHeight * 2; - _overlayTexBuffer = (char *)malloc(textureSize); - memset(_overlayTexBuffer, 0, textureSize); - - glViewport(0, 0, _backingWidth, _backingHeight); printOpenGLError(); - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); printOpenGLError(); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glEnable(GL_TEXTURE_2D); printOpenGLError(); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); printOpenGLError(); - glEnableClientState(GL_VERTEX_ARRAY); printOpenGLError(); - } - } - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - if (orientation == UIDeviceOrientationLandscapeRight) { - glRotatef(-90, 0, 0, 1); printOpenGLError(); - } else if (orientation == UIDeviceOrientationLandscapeLeft) { - glRotatef(90, 0, 0, 1); printOpenGLError(); - } else { - glRotatef(180, 0, 0, 1); printOpenGLError(); - } - - glOrthof(0, _backingWidth, 0, _backingHeight, 0, 1); printOpenGLError(); - - if (_screenTexture > 0) { - glDeleteTextures(1, &_screenTexture); printOpenGLError(); - } - - glGenTextures(1, &_screenTexture); printOpenGLError(); - glBindTexture(GL_TEXTURE_2D, _screenTexture); printOpenGLError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); printOpenGLError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); printOpenGLError(); - - if (_overlayTexture > 0) { - glDeleteTextures(1, &_overlayTexture); printOpenGLError(); - } - - glGenTextures(1, &_overlayTexture); printOpenGLError(); - glBindTexture(GL_TEXTURE_2D, _overlayTexture); printOpenGLError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); printOpenGLError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); printOpenGLError(); - - if (_textureBuffer) { - free(_textureBuffer); - } - - int textureSize = _textureWidth * _textureHeight * 2; - _textureBuffer = (char*)malloc(textureSize); - memset(_textureBuffer, 0, textureSize); - - glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); - - [self clearColorBuffer]; - - if (_keyboardView != nil) { - [_keyboardView removeFromSuperview]; - [[_keyboardView inputView] removeFromSuperview]; - } - - if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight) { - _visibleHeight = _backingHeight; - _visibleWidth = _backingWidth; - - float ratioDifference = ((float)_height / (float)_width) / ((float)_fullWidth / (float)_fullHeight); - int rectWidth, rectHeight; - if (ratioDifference < 1.0f) { - rectWidth = _fullWidth * ratioDifference; - rectHeight = _fullHeight; - _widthOffset = (_fullWidth - rectWidth) / 2; - _heightOffset = 0; - } else { - rectWidth = _fullWidth; - rectHeight = _fullHeight / ratioDifference; - _heightOffset = (_fullHeight - rectHeight) / 2; - _widthOffset = 0; - } - - //printf("Rect: %i, %i, %i, %i\n", _widthOffset, _heightOffset, rectWidth, rectHeight); - _screenRect = CGRectMake(_widthOffset, _heightOffset, rectWidth, rectHeight); - _overlayPortraitRatio = 1.0f; - } else { - float ratio = (float)_height / (float)_width; - int height = _fullWidth * ratio; - //printf("Making rect (%u, %u)\n", _fullWidth, height); - _screenRect = CGRectMake(0, 0, _fullWidth - 1, height - 1); - - _visibleHeight = height; - _visibleWidth = _backingWidth; - _heightOffset = 0.0f; - _widthOffset = 0.0f; - - CGRect keyFrame = CGRectMake(0.0f, 0.0f, 0.0f, 0.0f); - if (_keyboardView == nil) { - _keyboardView = [[SoftKeyboard alloc] initWithFrame:keyFrame]; - [_keyboardView setInputDelegate:self]; - } - - [self addSubview:[_keyboardView inputView]]; - [self addSubview: _keyboardView]; - [[_keyboardView inputView] becomeFirstResponder]; - _overlayPortraitRatio = (_overlayHeight * ratio) / _overlayWidth; - } -} - -- (void)clearColorBuffer { - // The color buffer is triple-buffered, so we clear it multiple times right away to avid doing any glClears later. - int clearCount = 5; - while (clearCount-- > 0) { - glClear(GL_COLOR_BUFFER_BIT); printOpenGLError(); - [_context presentRenderbuffer:GL_RENDERBUFFER_OES]; - } -} - -- (id)getEvent { - if (_events == nil || [_events count] == 0) { - return nil; - } - - - id event = [_events objectAtIndex: 0]; - - [_events removeObjectAtIndex: 0]; - - return event; -} - -- (void)addEvent:(NSDictionary*)event { - - if (_events == nil) - _events = [[NSMutableArray alloc] init]; - - [_events addObject: event]; -} - -- (void)deviceOrientationChanged:(int)orientation { - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputOrientationChanged], @"type", - [NSNumber numberWithFloat:(float)orientation], @"x", - [NSNumber numberWithFloat:0], @"y", - nil - ] - ]; -} - -- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event -{ - NSSet *allTouches = [event allTouches]; - - switch ([allTouches count]) { - case 1: - { - UITouch *touch = [touches anyObject]; - CGPoint point = [touch locationInView:self]; - if (!getLocalMouseCoords(&point)) - return; - - _firstTouch = touch; - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseDown], @"type", - [NSNumber numberWithFloat:point.x], @"x", - [NSNumber numberWithFloat:point.y], @"y", - nil - ] - ]; - break; - } - case 2: - { - UITouch *touch = [touches anyObject]; - CGPoint point = [touch locationInView:self]; - if (!getLocalMouseCoords(&point)) - return; - - _secondTouch = touch; - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseSecondDown], @"type", - [NSNumber numberWithFloat:point.x], @"x", - [NSNumber numberWithFloat:point.y], @"y", - nil - ] - ]; - break; - } - } -} - -- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event -{ - //NSSet *allTouches = [event allTouches]; - - for (UITouch* touch in touches) { - if (touch == _firstTouch) { - - CGPoint point = [touch locationInView:self]; - if (!getLocalMouseCoords(&point)) - return; - - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseDragged], @"type", - [NSNumber numberWithFloat:point.x], @"x", - [NSNumber numberWithFloat:point.y], @"y", - nil - ] - ]; - - } else if (touch == _secondTouch) { - - CGPoint point = [touch locationInView:self]; - if (!getLocalMouseCoords(&point)) - return; - - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseSecondDragged], @"type", - [NSNumber numberWithFloat:point.x], @"x", - [NSNumber numberWithFloat:point.y], @"y", - nil - ] - ]; - - } - } -} - -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event -{ - NSSet *allTouches = [event allTouches]; - - switch ([allTouches count]) { - case 1: - { - UITouch *touch = [[allTouches allObjects] objectAtIndex:0]; - CGPoint point = [touch locationInView:self]; - if (!getLocalMouseCoords(&point)) - return; - - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseUp], @"type", - [NSNumber numberWithFloat:point.x], @"x", - [NSNumber numberWithFloat:point.y], @"y", - nil - ] - ]; - break; - } - case 2: - { - UITouch *touch = [[allTouches allObjects] objectAtIndex:1]; - CGPoint point = [touch locationInView:self]; - if (!getLocalMouseCoords(&point)) - return; - - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseSecondUp], @"type", - [NSNumber numberWithFloat:point.x], @"x", - [NSNumber numberWithFloat:point.y], @"y", - nil - ] - ]; - break; - } - } -} - -- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event -{ - -} - -- (void)handleKeyPress:(unichar)c { - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputKeyPressed], @"type", - [NSNumber numberWithFloat:(float)c], @"x", - [NSNumber numberWithFloat:0], @"y", - nil - ] - ]; -} - -- (BOOL)canHandleSwipes { - return TRUE; -} - -- (int)swipe:(int)num withEvent:(struct __GSEvent *)event { - //printf("swipe: %i\n", num); - - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputSwipe], @"type", - [NSNumber numberWithFloat:(float)num], @"x", - [NSNumber numberWithFloat:0], @"y", - nil - ] - ]; -} - -- (void)applicationSuspend { - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputApplicationSuspended], @"type", - [NSNumber numberWithFloat:0], @"x", - [NSNumber numberWithFloat:0], @"y", - nil - ] - ]; -} - -- (void)applicationResume { - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputApplicationResumed], @"type", - [NSNumber numberWithFloat:0], @"x", - [NSNumber numberWithFloat:0], @"y", - nil - ] - ]; -} - -@end diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm new file mode 100644 index 0000000000..5b78237ff7 --- /dev/null +++ b/backends/platform/iphone/iphone_video.mm @@ -0,0 +1,851 @@ +/* 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. + * + */ + +// Disable symbol overrides so that we can use system headers. +#define FORBIDDEN_SYMBOL_ALLOW_ALL + +#include "iphone_video.h" + +#include "graphics/colormasks.h" + +iPhoneView *g_iPhoneViewInstance = nil; +static int g_fullWidth; +static int g_fullHeight; + +static int g_needsScreenUpdate = 0; + +#if 0 +static long g_lastTick = 0; +static int g_frames = 0; +#endif + +#define printOpenGLError() printOglError(__FILE__, __LINE__) + +int printOglError(const char *file, int line) { + int retCode = 0; + + // returns 1 if an OpenGL error occurred, 0 otherwise. + GLenum glErr = glGetError(); + while (glErr != GL_NO_ERROR) { + fprintf(stderr, "glError: %u (%s: %d)\n", glErr, file, line); + retCode = 1; + glErr = glGetError(); + } + return retCode; +} + +bool iPhone_isHighResDevice() { + return g_fullHeight > 480; +} + +void iPhone_updateScreen() { + //printf("Mouse: (%i, %i)\n", mouseX, mouseY); + if (!g_needsScreenUpdate) { + g_needsScreenUpdate = 1; + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateSurface) withObject:nil waitUntilDone: NO]; + } +} + +bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY) { + id event = [g_iPhoneViewInstance getEvent]; + if (event == nil) { + return false; + } + + id type = [event objectForKey:@"type"]; + + if (type == nil) { + printf("fetchEvent says: No type!\n"); + return false; + } + + *outEvent = [type intValue]; + *outX = [[event objectForKey:@"x"] intValue]; + *outY = [[event objectForKey:@"y"] intValue]; + return true; +} + +uint getSizeNextPOT(uint size) { + if ((size & (size - 1)) || !size) { + int log = 0; + + while (size >>= 1) + ++log; + + size = (2 << log); + } + + return size; +} + +const char *iPhone_getDocumentsDir() { + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *documentsDirectory = [paths objectAtIndex:0]; + return [documentsDirectory UTF8String]; +} + +@implementation iPhoneView + ++ (Class)layerClass { + return [CAEAGLLayer class]; +} + +- (VideoContext *)getVideoContext { + return &_videoContext; +} + +- (void)createContext { + CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; + + eaglLayer.opaque = YES; + eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat, nil]; + + _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; + + // In case creating the OpenGL ES context failed, we will error out here. + if (_context == nil) { + fprintf(stderr, "Could not create OpenGL ES context\n"); + exit(-1); + } + + if ([EAGLContext setCurrentContext:_context]) { + glGenFramebuffersOES(1, &_viewFramebuffer); printOpenGLError(); + glGenRenderbuffersOES(1, &_viewRenderbuffer); printOpenGLError(); + + glBindFramebufferOES(GL_FRAMEBUFFER_OES, _viewFramebuffer); printOpenGLError(); + glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); + [_context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id<EAGLDrawable>)self.layer]; + + glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); + + // Retrieve the render buffer size. This *should* match the frame size, + // i.e. g_fullWidth and g_fullHeight. + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &_renderBufferWidth); printOpenGLError(); + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &_renderBufferHeight); printOpenGLError(); + + if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { + NSLog(@"Failed to make complete framebuffer object %x.", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); + return; + } + + _videoContext.overlayHeight = _renderBufferWidth; + _videoContext.overlayWidth = _renderBufferHeight; + uint overlayTextureWidth = getSizeNextPOT(_videoContext.overlayHeight); + uint overlayTextureHeight = getSizeNextPOT(_videoContext.overlayWidth); + + // Since the overlay size won't change the whole run, we can + // precalculate the texture coordinates for the overlay texture here + // and just use it later on. + _overlayTexCoords[2] = _overlayTexCoords[6] = _videoContext.overlayWidth / (GLfloat)overlayTextureWidth; + _overlayTexCoords[5] = _overlayTexCoords[7] = _videoContext.overlayHeight / (GLfloat)overlayTextureHeight; + + _videoContext.overlayTexture.create(overlayTextureWidth, overlayTextureHeight, Graphics::createPixelFormat<5551>()); + + glViewport(0, 0, _renderBufferWidth, _renderBufferHeight); printOpenGLError(); + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); printOpenGLError(); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glEnable(GL_TEXTURE_2D); printOpenGLError(); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); printOpenGLError(); + glEnableClientState(GL_VERTEX_ARRAY); printOpenGLError(); + } +} + +- (id)initWithFrame:(struct CGRect)frame { + self = [super initWithFrame: frame]; + + if ([[UIScreen mainScreen] respondsToSelector: NSSelectorFromString(@"scale")]) { + if ([self respondsToSelector: NSSelectorFromString(@"contentScaleFactor")]) { + //self.contentScaleFactor = [[UIScreen mainScreen] scale]; + } + } + + g_fullWidth = (int)frame.size.width; + g_fullHeight = (int)frame.size.height; + + g_iPhoneViewInstance = self; + + _keyboardView = nil; + _screenTexture = 0; + _overlayTexture = 0; + _mouseCursorTexture = 0; + + _scaledShakeOffsetY = 0; + + _firstTouch = NULL; + _secondTouch = NULL; + + _gameScreenVertCoords[0] = _gameScreenVertCoords[1] = + _gameScreenVertCoords[2] = _gameScreenVertCoords[3] = + _gameScreenVertCoords[4] = _gameScreenVertCoords[5] = + _gameScreenVertCoords[6] = _gameScreenVertCoords[7] = 0; + + _gameScreenTexCoords[0] = _gameScreenTexCoords[1] = + _gameScreenTexCoords[2] = _gameScreenTexCoords[3] = + _gameScreenTexCoords[4] = _gameScreenTexCoords[5] = + _gameScreenTexCoords[6] = _gameScreenTexCoords[7] = 0; + + _overlayVertCoords[0] = _overlayVertCoords[1] = + _overlayVertCoords[2] = _overlayVertCoords[3] = + _overlayVertCoords[4] = _overlayVertCoords[5] = + _overlayVertCoords[6] = _overlayVertCoords[7] = 0; + + _overlayTexCoords[0] = _overlayTexCoords[1] = + _overlayTexCoords[2] = _overlayTexCoords[3] = + _overlayTexCoords[4] = _overlayTexCoords[5] = + _overlayTexCoords[6] = _overlayTexCoords[7] = 0; + + _mouseVertCoords[0] = _mouseVertCoords[1] = + _mouseVertCoords[2] = _mouseVertCoords[3] = + _mouseVertCoords[4] = _mouseVertCoords[5] = + _mouseVertCoords[6] = _mouseVertCoords[7] = 0; + + _mouseTexCoords[0] = _mouseTexCoords[1] = + _mouseTexCoords[2] = _mouseTexCoords[3] = + _mouseTexCoords[4] = _mouseTexCoords[5] = + _mouseTexCoords[6] = _mouseTexCoords[7] = 0; + + // Initialize the OpenGL ES context + [self createContext]; + + return self; +} + +- (void)dealloc { + if (_keyboardView != nil) { + [_keyboardView dealloc]; + } + + _videoContext.screenTexture.free(); + _videoContext.overlayTexture.free(); + _videoContext.mouseTexture.free(); + + [super dealloc]; +} + +- (void)drawRect:(CGRect)frame { +#if 0 + if (g_lastTick == 0) { + g_lastTick = time(0); + } + + g_frames++; + if (time(0) > g_lastTick) { + g_lastTick = time(0); + printf("FPS: %i\n", g_frames); + g_frames = 0; + } +#endif +} + +- (void)setFilterModeForTexture:(GLuint)tex { + if (!tex) + return; + + glBindTexture(GL_TEXTURE_2D, tex); printOpenGLError(); + + GLint filter = GL_LINEAR; + + switch (_videoContext.graphicsMode) { + case kGraphicsModeLinear: + filter = GL_LINEAR; + break; + + case kGraphicsModeNone: + filter = GL_NEAREST; + break; + } + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); printOpenGLError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); printOpenGLError(); +} + +- (void)setGraphicsMode { + [self setFilterModeForTexture:_screenTexture]; + [self setFilterModeForTexture:_overlayTexture]; + [self setFilterModeForTexture:_mouseCursorTexture]; +} + +- (void)updateSurface { + if (!g_needsScreenUpdate) { + return; + } + g_needsScreenUpdate = 0; + + glClear(GL_COLOR_BUFFER_BIT); printOpenGLError(); + + [self updateMainSurface]; + + if (_videoContext.overlayVisible) + [self updateOverlaySurface]; + + if (_videoContext.mouseIsVisible) + [self updateMouseSurface]; + + glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); + [_context presentRenderbuffer:GL_RENDERBUFFER_OES]; + +} + +- (void)notifyMouseMove { + const GLint mouseX = (GLint)(_videoContext.mouseX * _mouseScaleX) - _mouseHotspotX; + const GLint mouseY = (GLint)(_videoContext.mouseY * _mouseScaleY) - _mouseHotspotY; + + _mouseVertCoords[0] = _mouseVertCoords[4] = mouseX; + _mouseVertCoords[1] = _mouseVertCoords[3] = mouseY; + _mouseVertCoords[2] = _mouseVertCoords[6] = mouseX + _mouseWidth; + _mouseVertCoords[5] = _mouseVertCoords[7] = mouseY + _mouseHeight; +} + +- (void)updateMouseCursorScaling { + CGRect *rect; + int maxWidth, maxHeight; + + if (!_videoContext.overlayVisible) { + rect = &_gameScreenRect; + maxWidth = _videoContext.screenWidth; + maxHeight = _videoContext.screenHeight; + } else { + rect = &_overlayRect; + maxWidth = _videoContext.overlayWidth; + maxHeight = _videoContext.overlayHeight; + } + + if (!maxWidth || !maxHeight) { + printf("WARNING: updateMouseCursorScaling called when screen was not ready (%d)!\n", _videoContext.overlayVisible); + return; + } + + _mouseScaleX = CGRectGetWidth(*rect) / (GLfloat)maxWidth; + _mouseScaleY = CGRectGetHeight(*rect) / (GLfloat)maxHeight; + + _mouseWidth = (GLint)(_videoContext.mouseWidth * _mouseScaleX); + _mouseHeight = (GLint)(_videoContext.mouseHeight * _mouseScaleY); + + _mouseHotspotX = (GLint)(_videoContext.mouseHotspotX * _mouseScaleX); + _mouseHotspotY = (GLint)(_videoContext.mouseHotspotY * _mouseScaleY); + + // We subtract the screen offset to the hotspot here to simplify the + // screen offset handling in the mouse code. Note the subtraction here + // makes sure that the offset actually gets added to the mouse position, + // since the hotspot offset is substracted from the position. + _mouseHotspotX -= (GLint)CGRectGetMinX(*rect); + _mouseHotspotY -= (GLint)CGRectGetMinY(*rect); + + // FIXME: For now we also adapt the mouse position here. In reality we + // would be better off to also adjust the event position when switching + // from overlay to game screen or vica versa. + [self notifyMouseMove]; +} + +- (void)updateMouseCursor { + if (_mouseCursorTexture == 0) { + glGenTextures(1, &_mouseCursorTexture); printOpenGLError(); + [self setFilterModeForTexture:_mouseCursorTexture]; + } + + [self updateMouseCursorScaling]; + + _mouseTexCoords[2] = _mouseTexCoords[6] = _videoContext.mouseWidth / (GLfloat)_videoContext.mouseTexture.w; + _mouseTexCoords[5] = _mouseTexCoords[7] = _videoContext.mouseHeight / (GLfloat)_videoContext.mouseTexture.h; + + glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.mouseTexture.w, _videoContext.mouseTexture.h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _videoContext.mouseTexture.pixels); printOpenGLError(); +} + +- (void)updateMainSurface { + glVertexPointer(2, GL_FLOAT, 0, _gameScreenVertCoords); printOpenGLError(); + glTexCoordPointer(2, GL_FLOAT, 0, _gameScreenTexCoords); printOpenGLError(); + + glBindTexture(GL_TEXTURE_2D, _screenTexture); printOpenGLError(); + + // Unfortunately we have to update the whole texture every frame, since glTexSubImage2D is actually slower in all cases + // due to the iPhone internals having to convert the whole texture back from its internal format when used. + // In the future we could use several tiled textures instead. + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _videoContext.screenTexture.w, _videoContext.screenTexture.h, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _videoContext.screenTexture.pixels); printOpenGLError(); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); +} + +- (void)updateOverlaySurface { + glVertexPointer(2, GL_FLOAT, 0, _overlayVertCoords); printOpenGLError(); + glTexCoordPointer(2, GL_FLOAT, 0, _overlayTexCoords); printOpenGLError(); + + glBindTexture(GL_TEXTURE_2D, _overlayTexture); printOpenGLError(); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.overlayTexture.w, _videoContext.overlayTexture.h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _videoContext.overlayTexture.pixels); printOpenGLError(); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); +} + +- (void)updateMouseSurface { + glVertexPointer(2, GL_FLOAT, 0, _mouseVertCoords); printOpenGLError(); + glTexCoordPointer(2, GL_FLOAT, 0, _mouseTexCoords); printOpenGLError(); + + glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); +} + +- (void)setUpOrientation:(UIDeviceOrientation)orientation width:(int *)width height:(int *)height { + _orientation = orientation; + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + // We always force the origin (0,0) to be in the upper left corner. + switch (_orientation) { + case UIDeviceOrientationLandscapeRight: + glRotatef( 90, 0, 0, 1); printOpenGLError(); + glOrthof(0, _renderBufferHeight, _renderBufferWidth, 0, 0, 1); printOpenGLError(); + + *width = _renderBufferHeight; + *height = _renderBufferWidth; + break; + + case UIDeviceOrientationLandscapeLeft: + glRotatef(-90, 0, 0, 1); printOpenGLError(); + glOrthof(0, _renderBufferHeight, _renderBufferWidth, 0, 0, 1); printOpenGLError(); + + *width = _renderBufferHeight; + *height = _renderBufferWidth; + break; + + case UIDeviceOrientationPortrait: + default: + // We must force the portrait orientation here, since we might not know + // the real orientation. + _orientation = UIDeviceOrientationPortrait; + + glOrthof(0, _renderBufferWidth, _renderBufferHeight, 0, 0, 1); printOpenGLError(); + + *width = _renderBufferWidth; + *height = _renderBufferHeight; + break; + } +} + +- (void)createScreenTexture { + const uint screenTexWidth = getSizeNextPOT(_videoContext.screenWidth); + const uint screenTexHeight = getSizeNextPOT(_videoContext.screenHeight); + + _gameScreenTexCoords[2] = _gameScreenTexCoords[6] = _videoContext.screenWidth / (GLfloat)screenTexWidth; + _gameScreenTexCoords[5] = _gameScreenTexCoords[7] = _videoContext.screenHeight / (GLfloat)screenTexHeight; + + _videoContext.screenTexture.create(screenTexWidth, screenTexHeight, Graphics::createPixelFormat<565>()); +} + +- (void)initSurface { + int screenWidth, screenHeight; + [self setUpOrientation:[[UIDevice currentDevice] orientation] width:&screenWidth height:&screenHeight]; + + if (_screenTexture > 0) { + glDeleteTextures(1, &_screenTexture); printOpenGLError(); + } + + glGenTextures(1, &_screenTexture); printOpenGLError(); + [self setFilterModeForTexture:_screenTexture]; + + if (_overlayTexture > 0) { + glDeleteTextures(1, &_overlayTexture); printOpenGLError(); + } + + glGenTextures(1, &_overlayTexture); printOpenGLError(); + [self setFilterModeForTexture:_overlayTexture]; + + glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); + + [self clearColorBuffer]; + + if (_keyboardView != nil) { + [_keyboardView removeFromSuperview]; + [[_keyboardView inputView] removeFromSuperview]; + } + + GLfloat adjustedWidth = _videoContext.screenWidth; + GLfloat adjustedHeight = _videoContext.screenHeight; + if (_videoContext.asprectRatioCorrection) { + if (_videoContext.screenWidth == 320 && _videoContext.screenHeight == 200) + adjustedHeight = 240; + else if (_videoContext.screenWidth == 640 && _videoContext.screenHeight == 400) + adjustedHeight = 480; + } + + float overlayPortraitRatio; + + if (_orientation == UIDeviceOrientationLandscapeLeft || _orientation == UIDeviceOrientationLandscapeRight) { + GLfloat gameScreenRatio = adjustedWidth / adjustedHeight; + GLfloat screenRatio = (GLfloat)screenWidth / (GLfloat)screenHeight; + + // These are the width/height according to the portrait layout! + int rectWidth, rectHeight; + int xOffset, yOffset; + + if (gameScreenRatio < screenRatio) { + // When the game screen ratio is less than the screen ratio + // we need to scale the width, since the game screen was higher + // compared to the width than our output screen is. + rectWidth = (int)(screenHeight * gameScreenRatio); + rectHeight = screenHeight; + xOffset = (screenWidth - rectWidth) / 2; + yOffset = 0; + } else { + // When the game screen ratio is bigger than the screen ratio + // we need to scale the height, since the game screen was wider + // compared to the height than our output screen is. + rectWidth = screenWidth; + rectHeight = (int)(screenWidth / gameScreenRatio); + xOffset = 0; + yOffset = (screenHeight - rectHeight) / 2; + } + + //printf("Rect: %i, %i, %i, %i\n", xOffset, yOffset, rectWidth, rectHeight); + _gameScreenRect = CGRectMake(xOffset, yOffset, rectWidth, rectHeight); + overlayPortraitRatio = 1.0f; + } else { + GLfloat ratio = adjustedHeight / adjustedWidth; + int height = (int)(screenWidth * ratio); + //printf("Making rect (%u, %u)\n", screenWidth, height); + _gameScreenRect = CGRectMake(0, 0, screenWidth, height); + + CGRect keyFrame = CGRectMake(0.0f, 0.0f, 0.0f, 0.0f); + if (_keyboardView == nil) { + _keyboardView = [[SoftKeyboard alloc] initWithFrame:keyFrame]; + [_keyboardView setInputDelegate:self]; + } + + [self addSubview:[_keyboardView inputView]]; + [self addSubview: _keyboardView]; + [[_keyboardView inputView] becomeFirstResponder]; + overlayPortraitRatio = (_videoContext.overlayHeight * ratio) / _videoContext.overlayWidth; + } + + _overlayRect = CGRectMake(0, 0, screenWidth, screenHeight * overlayPortraitRatio); + + _gameScreenVertCoords[0] = _gameScreenVertCoords[4] = CGRectGetMinX(_gameScreenRect); + _gameScreenVertCoords[1] = _gameScreenVertCoords[3] = CGRectGetMinY(_gameScreenRect); + _gameScreenVertCoords[2] = _gameScreenVertCoords[6] = CGRectGetMaxX(_gameScreenRect); + _gameScreenVertCoords[5] = _gameScreenVertCoords[7] = CGRectGetMaxY(_gameScreenRect); + + _overlayVertCoords[2] = _overlayVertCoords[6] = CGRectGetMaxX(_overlayRect); + _overlayVertCoords[5] = _overlayVertCoords[7] = CGRectGetMaxY(_overlayRect); + + [self setViewTransformation]; + [self updateMouseCursorScaling]; +} + +- (void)setViewTransformation { + // Set the modelview matrix. This matrix will be used for the shake offset + // support. + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + // Scale the shake offset according to the overlay size. We need this to + // adjust the overlay mouse click coordinates when an offset is set. + _scaledShakeOffsetY = (int)(_videoContext.shakeOffsetY / (GLfloat)_videoContext.screenHeight * CGRectGetHeight(_overlayRect)); + + // Apply the shakeing to the output screen. + glTranslatef(0, -_scaledShakeOffsetY, 0); +} + +- (void)clearColorBuffer { + // The color buffer is triple-buffered, so we clear it multiple times right away to avid doing any glClears later. + int clearCount = 5; + while (clearCount-- > 0) { + glClear(GL_COLOR_BUFFER_BIT); printOpenGLError(); + [_context presentRenderbuffer:GL_RENDERBUFFER_OES]; + } +} + +- (id)getEvent { + if (_events == nil || [_events count] == 0) { + return nil; + } + + id event = [_events objectAtIndex: 0]; + + [_events removeObjectAtIndex: 0]; + + return event; +} + +- (void)addEvent:(NSDictionary *)event { + if (_events == nil) + _events = [[NSMutableArray alloc] init]; + + [_events addObject: event]; +} + +/** + * Converts portrait mode coordinates into rotated mode coordinates. + */ +- (bool)convertToRotatedCoords:(CGPoint)point result:(CGPoint *)result { + switch (_orientation) { + case UIDeviceOrientationLandscapeLeft: + result->x = point.y; + result->y = _renderBufferWidth - point.x; + return true; + + case UIDeviceOrientationLandscapeRight: + result->x = _renderBufferHeight - point.y; + result->y = point.x; + return true; + + case UIDeviceOrientationPortrait: + result->x = point.x; + result->y = point.y; + return true; + + default: + return false; + } +} + +- (bool)getMouseCoords:(CGPoint)point eventX:(int *)x eventY:(int *)y { + if (![self convertToRotatedCoords:point result:&point]) + return false; + + CGRect *area; + int width, height, offsetY; + if (_videoContext.overlayVisible) { + area = &_overlayRect; + width = _videoContext.overlayWidth; + height = _videoContext.overlayHeight; + offsetY = _scaledShakeOffsetY; + } else { + area = &_gameScreenRect; + width = _videoContext.screenWidth; + height = _videoContext.screenHeight; + offsetY = _videoContext.shakeOffsetY; + } + + point.x = (point.x - CGRectGetMinX(*area)) / CGRectGetWidth(*area); + point.y = (point.y - CGRectGetMinY(*area)) / CGRectGetHeight(*area); + + *x = (int)(point.x * width); + // offsetY describes the translation of the screen in the upward direction, + // thus we need to add it here. + *y = (int)(point.y * height + offsetY); + + // Clip coordinates + if (*x < 0 || *x > width || *y < 0 || *y > height) + return false; + + return true; +} + +- (void)deviceOrientationChanged:(UIDeviceOrientation)orientation { + switch (orientation) { + case UIDeviceOrientationLandscapeLeft: + case UIDeviceOrientationLandscapeRight: + case UIDeviceOrientationPortrait: + _orientation = orientation; + break; + + default: + return; + } + + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputOrientationChanged], @"type", + [NSNumber numberWithInt:orientation], @"x", + [NSNumber numberWithInt:0], @"y", + nil + ] + ]; +} + +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { + NSSet *allTouches = [event allTouches]; + int x, y; + + switch ([allTouches count]) { + case 1: { + UITouch *touch = [touches anyObject]; + CGPoint point = [touch locationInView:self]; + if (![self getMouseCoords:point eventX:&x eventY:&y]) + return; + + _firstTouch = touch; + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputMouseDown], @"type", + [NSNumber numberWithInt:x], @"x", + [NSNumber numberWithInt:y], @"y", + nil + ] + ]; + break; + } + + case 2: { + UITouch *touch = [touches anyObject]; + CGPoint point = [touch locationInView:self]; + if (![self getMouseCoords:point eventX:&x eventY:&y]) + return; + + _secondTouch = touch; + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputMouseSecondDown], @"type", + [NSNumber numberWithInt:x], @"x", + [NSNumber numberWithInt:y], @"y", + nil + ] + ]; + break; + } + } +} + +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { + //NSSet *allTouches = [event allTouches]; + int x, y; + + for (UITouch *touch in touches) { + if (touch == _firstTouch) { + CGPoint point = [touch locationInView:self]; + if (![self getMouseCoords:point eventX:&x eventY:&y]) + return; + + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputMouseDragged], @"type", + [NSNumber numberWithInt:x], @"x", + [NSNumber numberWithInt:y], @"y", + nil + ] + ]; + } else if (touch == _secondTouch) { + CGPoint point = [touch locationInView:self]; + if (![self getMouseCoords:point eventX:&x eventY:&y]) + return; + + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputMouseSecondDragged], @"type", + [NSNumber numberWithInt:x], @"x", + [NSNumber numberWithInt:y], @"y", + nil + ] + ]; + } + } +} + +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { + NSSet *allTouches = [event allTouches]; + int x, y; + + switch ([allTouches count]) { + case 1: { + UITouch *touch = [[allTouches allObjects] objectAtIndex:0]; + CGPoint point = [touch locationInView:self]; + if (![self getMouseCoords:point eventX:&x eventY:&y]) + return; + + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputMouseUp], @"type", + [NSNumber numberWithInt:x], @"x", + [NSNumber numberWithInt:y], @"y", + nil + ] + ]; + break; + } + + case 2: { + UITouch *touch = [[allTouches allObjects] objectAtIndex:1]; + CGPoint point = [touch locationInView:self]; + if (![self getMouseCoords:point eventX:&x eventY:&y]) + return; + + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputMouseSecondUp], @"type", + [NSNumber numberWithInt:x], @"x", + [NSNumber numberWithInt:y], @"y", + nil + ] + ]; + break; + } + } +} + +- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { +} + +- (void)handleKeyPress:(unichar)c { + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputKeyPressed], @"type", + [NSNumber numberWithInt:c], @"x", + [NSNumber numberWithInt:0], @"y", + nil + ] + ]; +} + +- (BOOL)canHandleSwipes { + return TRUE; +} + +- (int)swipe:(int)num withEvent:(struct __GSEvent *)event { + //printf("swipe: %i\n", num); + + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputSwipe], @"type", + [NSNumber numberWithInt:num], @"x", + [NSNumber numberWithInt:0], @"y", + nil + ] + ]; + + return 0; +} + +- (void)applicationSuspend { + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputApplicationSuspended], @"type", + [NSNumber numberWithInt:0], @"x", + [NSNumber numberWithInt:0], @"y", + nil + ] + ]; +} + +- (void)applicationResume { + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputApplicationResumed], @"type", + [NSNumber numberWithInt:0], @"x", + [NSNumber numberWithInt:0], @"y", + nil + ] + ]; +} + +@end diff --git a/backends/platform/iphone/module.mk b/backends/platform/iphone/module.mk index 9768e6ded4..ea5115782f 100644 --- a/backends/platform/iphone/module.mk +++ b/backends/platform/iphone/module.mk @@ -7,8 +7,7 @@ MODULE_OBJS := \ osys_video.o \ iphone_main.o \ iphone_video.o \ - iphone_keyboard.o \ - blit_arm.o + iphone_keyboard.o # We don't use rules.mk but rather manually update OBJS and MODULE_DIRS. MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS)) diff --git a/backends/platform/iphone/osys_events.cpp b/backends/platform/iphone/osys_events.cpp index 1ab1db0f27..85efbda208 100644 --- a/backends/platform/iphone/osys_events.cpp +++ b/backends/platform/iphone/osys_events.cpp @@ -40,98 +40,66 @@ bool OSystem_IPHONE::pollEvent(Common::Event &event) { _timerCallbackNext = curTime + _timerCallbackTimer; } - if (_queuedInputEvent.type != (Common::EventType)0 && curTime >= _queuedEventTime) { + if (_queuedInputEvent.type != Common::EVENT_INVALID && curTime >= _queuedEventTime) { event = _queuedInputEvent; - _queuedInputEvent.type = (Common::EventType)0; + _queuedInputEvent.type = Common::EVENT_INVALID; return true; } int eventType; - float xUnit, yUnit; - - if (iPhone_fetchEvent(&eventType, &xUnit, &yUnit)) { - int x = 0; - int y = 0; - switch (_screenOrientation) { - case kScreenOrientationPortrait: - if (_overlayVisible) { - x = (int)(xUnit * _overlayWidth); - y = (int)(yUnit * _overlayHeight); - } else { - x = (int)(xUnit * _screenWidth); - y = (int)(yUnit * _screenHeight); - } - break; - case kScreenOrientationLandscape: - if (_overlayVisible) { - x = (int)(yUnit * _overlayWidth); - y = (int)((1.0 - xUnit) * _overlayHeight); - } else { - x = (int)(yUnit * _screenWidth); - y = (int)((1.0 - xUnit) * _screenHeight); - } - break; - case kScreenOrientationFlippedLandscape: - if (_overlayVisible) { - x = (int)((1.0 - yUnit) * _overlayWidth); - y = (int)(xUnit * _overlayHeight); - } else { - x = (int)((1.0 - yUnit) * _screenWidth); - y = (int)(xUnit * _screenHeight); - } - break; - } + int x, y; + if (iPhone_fetchEvent(&eventType, &x, &y)) { switch ((InputEvent)eventType) { - case kInputMouseDown: - if (!handleEvent_mouseDown(event, x, y)) - return false; - break; + case kInputMouseDown: + if (!handleEvent_mouseDown(event, x, y)) + return false; + break; - case kInputMouseUp: + case kInputMouseUp: if (!handleEvent_mouseUp(event, x, y)) return false; - break; - - case kInputMouseDragged: - if (!handleEvent_mouseDragged(event, x, y)) - return false; - break; - case kInputMouseSecondDragged: - if (!handleEvent_mouseSecondDragged(event, x, y)) - return false; - break; - case kInputMouseSecondDown: - _secondaryTapped = true; - if (!handleEvent_secondMouseDown(event, x, y)) - return false; - break; - case kInputMouseSecondUp: - _secondaryTapped = false; - if (!handleEvent_secondMouseUp(event, x, y)) - return false; - break; - case kInputOrientationChanged: - handleEvent_orientationChanged((int)xUnit); - return false; - break; + break; - case kInputApplicationSuspended: - suspendLoop(); + case kInputMouseDragged: + if (!handleEvent_mouseDragged(event, x, y)) + return false; + break; + case kInputMouseSecondDragged: + if (!handleEvent_mouseSecondDragged(event, x, y)) + return false; + break; + case kInputMouseSecondDown: + _secondaryTapped = true; + if (!handleEvent_secondMouseDown(event, x, y)) + return false; + break; + case kInputMouseSecondUp: + _secondaryTapped = false; + if (!handleEvent_secondMouseUp(event, x, y)) return false; - break; + break; + case kInputOrientationChanged: + handleEvent_orientationChanged(x); + return false; + break; - case kInputKeyPressed: - handleEvent_keyPressed(event, (int)xUnit); - break; + case kInputApplicationSuspended: + suspendLoop(); + return false; + break; - case kInputSwipe: - if (!handleEvent_swipe(event, (int)xUnit)) - return false; - break; + case kInputKeyPressed: + handleEvent_keyPressed(event, x); + break; + + case kInputSwipe: + if (!handleEvent_swipe(event, x)) + return false; + break; - default: - break; + default: + break; } return true; @@ -154,8 +122,8 @@ bool OSystem_IPHONE::handleEvent_mouseDown(Common::Event &event, int x, int y) { if (_mouseClickAndDragEnabled) { event.type = Common::EVENT_LBUTTONDOWN; - event.mouse.x = _mouseX; - event.mouse.y = _mouseY; + event.mouse.x = _videoContext->mouseX; + event.mouse.y = _videoContext->mouseY; return true; } else { _lastMouseDown = getMillis(); @@ -170,20 +138,19 @@ bool OSystem_IPHONE::handleEvent_mouseUp(Common::Event &event, int x, int y) { _secondaryTapped = false; if (!handleEvent_secondMouseUp(event, x, y)) return false; - } - else if (_mouseClickAndDragEnabled) { + } else if (_mouseClickAndDragEnabled) { event.type = Common::EVENT_LBUTTONUP; - event.mouse.x = _mouseX; - event.mouse.y = _mouseY; + event.mouse.x = _videoContext->mouseX; + event.mouse.y = _videoContext->mouseY; } else { if (getMillis() - _lastMouseDown < 250) { event.type = Common::EVENT_LBUTTONDOWN; - event.mouse.x = _mouseX; - event.mouse.y = _mouseY; + event.mouse.x = _videoContext->mouseX; + event.mouse.y = _videoContext->mouseY; _queuedInputEvent.type = Common::EVENT_LBUTTONUP; - _queuedInputEvent.mouse.x = _mouseX; - _queuedInputEvent.mouse.y = _mouseY; + _queuedInputEvent.mouse.x = _videoContext->mouseX; + _queuedInputEvent.mouse.y = _videoContext->mouseY; _lastMouseTap = getMillis(); _queuedEventTime = _lastMouseTap + kQueuedInputEventDelay; } else @@ -200,14 +167,13 @@ bool OSystem_IPHONE::handleEvent_secondMouseDown(Common::Event &event, int x, in if (_mouseClickAndDragEnabled) { event.type = Common::EVENT_LBUTTONUP; - event.mouse.x = _mouseX; - event.mouse.y = _mouseY; + event.mouse.x = _videoContext->mouseX; + event.mouse.y = _videoContext->mouseY; _queuedInputEvent.type = Common::EVENT_RBUTTONDOWN; - _queuedInputEvent.mouse.x = _mouseX; - _queuedInputEvent.mouse.y = _mouseY; - } - else + _queuedInputEvent.mouse.x = _videoContext->mouseX; + _queuedInputEvent.mouse.y = _videoContext->mouseY; + } else return false; return true; @@ -216,9 +182,9 @@ bool OSystem_IPHONE::handleEvent_secondMouseDown(Common::Event &event, int x, in bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int y) { int curTime = getMillis(); - if (curTime - _lastSecondaryDown < 400 ) { + if (curTime - _lastSecondaryDown < 400) { //printf("Right tap!\n"); - if (curTime - _lastSecondaryTap < 400 && !_overlayVisible) { + if (curTime - _lastSecondaryTap < 400 && !_videoContext->overlayVisible) { //printf("Right escape!\n"); event.type = Common::EVENT_KEYDOWN; _queuedInputEvent.type = Common::EVENT_KEYUP; @@ -231,11 +197,11 @@ bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int } else if (!_mouseClickAndDragEnabled) { //printf("Rightclick!\n"); event.type = Common::EVENT_RBUTTONDOWN; - event.mouse.x = _mouseX; - event.mouse.y = _mouseY; + event.mouse.x = _videoContext->mouseX; + event.mouse.y = _videoContext->mouseY; _queuedInputEvent.type = Common::EVENT_RBUTTONUP; - _queuedInputEvent.mouse.x = _mouseX; - _queuedInputEvent.mouse.y = _mouseY; + _queuedInputEvent.mouse.x = _videoContext->mouseX; + _queuedInputEvent.mouse.y = _videoContext->mouseY; _lastSecondaryTap = curTime; _queuedEventTime = curTime + kQueuedInputEventDelay; } else { @@ -245,8 +211,8 @@ bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int } if (_mouseClickAndDragEnabled) { event.type = Common::EVENT_RBUTTONUP; - event.mouse.x = _mouseX; - event.mouse.y = _mouseY; + event.mouse.x = _videoContext->mouseX; + event.mouse.y = _videoContext->mouseY; } return true; @@ -262,17 +228,17 @@ bool OSystem_IPHONE::handleEvent_mouseDragged(Common::Event &event, int x, int y //printf("Mouse dragged at (%u, %u)\n", x, y); int mouseNewPosX; int mouseNewPosY; - if (_touchpadModeEnabled ) { + if (_touchpadModeEnabled) { int deltaX = _lastPadX - x; int deltaY = _lastPadY - y; _lastPadX = x; _lastPadY = y; - mouseNewPosX = (int)(_mouseX - deltaX / 0.5f); - mouseNewPosY = (int)(_mouseY - deltaY / 0.5f); + mouseNewPosX = (int)(_videoContext->mouseX - deltaX / 0.5f); + mouseNewPosY = (int)(_videoContext->mouseY - deltaY / 0.5f); - int widthCap = _overlayVisible ? _overlayWidth : _screenWidth; - int heightCap = _overlayVisible ? _overlayHeight : _screenHeight; + int widthCap = _videoContext->overlayVisible ? _videoContext->overlayWidth : _videoContext->screenWidth; + int heightCap = _videoContext->overlayVisible ? _videoContext->overlayHeight : _videoContext->screenHeight; if (mouseNewPosX < 0) mouseNewPosX = 0; @@ -319,12 +285,9 @@ bool OSystem_IPHONE::handleEvent_mouseSecondDragged(Common::Event &event, int x, if (absX < kMaxDeviation && vecY >= kNeededLength) { // Swipe down - event.type = Common::EVENT_KEYDOWN; - _queuedInputEvent.type = Common::EVENT_KEYUP; + event.type = Common::EVENT_MAINMENU; + _queuedInputEvent.type = Common::EVENT_INVALID; - event.kbd.flags = _queuedInputEvent.kbd.flags = 0; - event.kbd.keycode = _queuedInputEvent.kbd.keycode = Common::KEYCODE_F5; - event.kbd.ascii = _queuedInputEvent.kbd.ascii = Common::ASCII_F5; _queuedEventTime = getMillis() + kQueuedInputEventDelay; return true; } @@ -371,26 +334,26 @@ void OSystem_IPHONE::handleEvent_orientationChanged(int orientation) { ScreenOrientation newOrientation; switch (orientation) { - case 1: - newOrientation = kScreenOrientationPortrait; - break; - case 3: - newOrientation = kScreenOrientationLandscape; - break; - case 4: - newOrientation = kScreenOrientationFlippedLandscape; - break; - default: - return; + case 1: + newOrientation = kScreenOrientationPortrait; + break; + case 3: + newOrientation = kScreenOrientationLandscape; + break; + case 4: + newOrientation = kScreenOrientationFlippedLandscape; + break; + default: + return; } if (_screenOrientation != newOrientation) { _screenOrientation = newOrientation; - iPhone_initSurface(_screenWidth, _screenHeight); + updateOutputSurface(); dirtyFullScreen(); - if (_overlayVisible) + if (_videoContext->overlayVisible) dirtyFullOverlayScreen(); updateScreen(); } @@ -403,50 +366,50 @@ void OSystem_IPHONE::handleEvent_keyPressed(Common::Event &event, int keyPresse // We remap some of the iPhone keyboard keys. // The first ten here are the row of symbols below the numeric keys. switch (keyPressed) { - case 45: - keyPressed = Common::KEYCODE_F1; - ascii = Common::ASCII_F1; - break; - case 47: - keyPressed = Common::KEYCODE_F2; - ascii = Common::ASCII_F2; - break; - case 58: - keyPressed = Common::KEYCODE_F3; - ascii = Common::ASCII_F3; - break; - case 59: - keyPressed = Common::KEYCODE_F4; - ascii = Common::ASCII_F4; - break; - case 40: - keyPressed = Common::KEYCODE_F5; - ascii = Common::ASCII_F5; - break; - case 41: - keyPressed = Common::KEYCODE_F6; - ascii = Common::ASCII_F6; - break; - case 36: - keyPressed = Common::KEYCODE_F7; - ascii = Common::ASCII_F7; - break; - case 38: - keyPressed = Common::KEYCODE_F8; - ascii = Common::ASCII_F8; - break; - case 64: - keyPressed = Common::KEYCODE_F9; - ascii = Common::ASCII_F9; - break; - case 34: - keyPressed = Common::KEYCODE_F10; - ascii = Common::ASCII_F10; - break; - case 10: - keyPressed = Common::KEYCODE_RETURN; - ascii = Common::ASCII_RETURN; - break; + case 45: + keyPressed = Common::KEYCODE_F1; + ascii = Common::ASCII_F1; + break; + case 47: + keyPressed = Common::KEYCODE_F2; + ascii = Common::ASCII_F2; + break; + case 58: + keyPressed = Common::KEYCODE_F3; + ascii = Common::ASCII_F3; + break; + case 59: + keyPressed = Common::KEYCODE_F4; + ascii = Common::ASCII_F4; + break; + case 40: + keyPressed = Common::KEYCODE_F5; + ascii = Common::ASCII_F5; + break; + case 41: + keyPressed = Common::KEYCODE_F6; + ascii = Common::ASCII_F6; + break; + case 36: + keyPressed = Common::KEYCODE_F7; + ascii = Common::ASCII_F7; + break; + case 38: + keyPressed = Common::KEYCODE_F8; + ascii = Common::ASCII_F8; + break; + case 64: + keyPressed = Common::KEYCODE_F9; + ascii = Common::ASCII_F9; + break; + case 34: + keyPressed = Common::KEYCODE_F10; + ascii = Common::ASCII_F10; + break; + case 10: + keyPressed = Common::KEYCODE_RETURN; + ascii = Common::ASCII_RETURN; + break; } event.type = Common::EVENT_KEYDOWN; _queuedInputEvent.type = Common::EVENT_KEYUP; @@ -460,60 +423,60 @@ void OSystem_IPHONE::handleEvent_keyPressed(Common::Event &event, int keyPresse bool OSystem_IPHONE::handleEvent_swipe(Common::Event &event, int direction) { Common::KeyCode keycode = Common::KEYCODE_INVALID; switch (_screenOrientation) { - case kScreenOrientationPortrait: - switch ((UIViewSwipeDirection)direction) { - case kUIViewSwipeUp: - keycode = Common::KEYCODE_UP; - break; - case kUIViewSwipeDown: - keycode = Common::KEYCODE_DOWN; - break; - case kUIViewSwipeLeft: - keycode = Common::KEYCODE_LEFT; - break; - case kUIViewSwipeRight: - keycode = Common::KEYCODE_RIGHT; - break; - default: - return false; - } + case kScreenOrientationPortrait: + switch ((UIViewSwipeDirection)direction) { + case kUIViewSwipeUp: + keycode = Common::KEYCODE_UP; + break; + case kUIViewSwipeDown: + keycode = Common::KEYCODE_DOWN; break; - case kScreenOrientationLandscape: - switch ((UIViewSwipeDirection)direction) { - case kUIViewSwipeUp: - keycode = Common::KEYCODE_LEFT; - break; - case kUIViewSwipeDown: - keycode = Common::KEYCODE_RIGHT; - break; - case kUIViewSwipeLeft: - keycode = Common::KEYCODE_DOWN; - break; - case kUIViewSwipeRight: - keycode = Common::KEYCODE_UP; - break; - default: - return false; - } + case kUIViewSwipeLeft: + keycode = Common::KEYCODE_LEFT; break; - case kScreenOrientationFlippedLandscape: - switch ((UIViewSwipeDirection)direction) { - case kUIViewSwipeUp: - keycode = Common::KEYCODE_RIGHT; - break; - case kUIViewSwipeDown: - keycode = Common::KEYCODE_LEFT; - break; - case kUIViewSwipeLeft: - keycode = Common::KEYCODE_UP; - break; - case kUIViewSwipeRight: - keycode = Common::KEYCODE_DOWN; - break; - default: - return false; - } + case kUIViewSwipeRight: + keycode = Common::KEYCODE_RIGHT; break; + default: + return false; + } + break; + case kScreenOrientationLandscape: + switch ((UIViewSwipeDirection)direction) { + case kUIViewSwipeUp: + keycode = Common::KEYCODE_LEFT; + break; + case kUIViewSwipeDown: + keycode = Common::KEYCODE_RIGHT; + break; + case kUIViewSwipeLeft: + keycode = Common::KEYCODE_DOWN; + break; + case kUIViewSwipeRight: + keycode = Common::KEYCODE_UP; + break; + default: + return false; + } + break; + case kScreenOrientationFlippedLandscape: + switch ((UIViewSwipeDirection)direction) { + case kUIViewSwipeUp: + keycode = Common::KEYCODE_RIGHT; + break; + case kUIViewSwipeDown: + keycode = Common::KEYCODE_LEFT; + break; + case kUIViewSwipeLeft: + keycode = Common::KEYCODE_UP; + break; + case kUIViewSwipeRight: + keycode = Common::KEYCODE_DOWN; + break; + default: + return false; + } + break; } event.kbd.keycode = _queuedInputEvent.kbd.keycode = keycode; diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 4bc567c39d..9a33cd8968 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -45,7 +45,9 @@ const OSystem::GraphicsMode OSystem_IPHONE::s_supportedGraphicsModes[] = { - {0, 0, 0} + { "linear", "Linear filtering", kGraphicsModeLinear }, + { "none", "No filtering", kGraphicsModeNone }, + { 0, 0, 0 } }; AQCallbackStruct OSystem_IPHONE::s_AudioQueue; @@ -53,28 +55,28 @@ SoundProc OSystem_IPHONE::s_soundCallback = NULL; void *OSystem_IPHONE::s_soundParam = NULL; OSystem_IPHONE::OSystem_IPHONE() : - _mixer(NULL), _offscreen(NULL), - _overlayVisible(false), _fullscreen(NULL), - _mouseHeight(0), _mouseWidth(0), _mouseBuf(NULL), _lastMouseTap(0), _queuedEventTime(0), - _secondaryTapped(false), _lastSecondaryTap(0), + _mixer(NULL), _lastMouseTap(0), _queuedEventTime(0), + _mouseNeedTextureUpdate(false), _secondaryTapped(false), _lastSecondaryTap(0), _screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false), _gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false), _mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0), - _overlayHeight(0), _overlayWidth(0), _overlayBuffer(0) -{ - _queuedInputEvent.type = (Common::EventType)0; - _lastDrawnMouseRect = Common::Rect(0, 0, 0, 0); - + _mouseCursorPaletteEnabled(false), _gfxTransactionError(kTransactionSuccess) { + _queuedInputEvent.type = Common::EVENT_INVALID; _touchpadModeEnabled = !iPhone_isHighResDevice(); _fsFactory = new POSIXFilesystemFactory(); + initVideoContext(); } OSystem_IPHONE::~OSystem_IPHONE() { AudioQueueDispose(s_AudioQueue.queue, true); delete _mixer; - delete _offscreen; - delete _fullscreen; + // Prevent accidental freeing of the screen texture here. This needs to be + // checked since we might use the screen texture as framebuffer in the case + // of hi-color games for example. + if (_framebuffer.pixels == _videoContext->screenTexture.pixels) + _framebuffer.free(); + _mouseBuffer.free(); } int OSystem_IPHONE::timerHandler(int t) { @@ -102,26 +104,55 @@ void OSystem_IPHONE::initBackend() { } bool OSystem_IPHONE::hasFeature(Feature f) { - return false; + switch (f) { + case kFeatureCursorPalette: + return true; + + default: + return false; + } } void OSystem_IPHONE::setFeatureState(Feature f, bool enable) { + switch (f) { + case kFeatureCursorPalette: + if (_mouseCursorPaletteEnabled != enable) { + _mouseNeedTextureUpdate = true; + _mouseDirty = true; + _mouseCursorPaletteEnabled = enable; + } + break; + case kFeatureAspectRatioCorrection: + _videoContext->asprectRatioCorrection = enable; + break; + + default: + break; + } } bool OSystem_IPHONE::getFeatureState(Feature f) { - return false; + switch (f) { + case kFeatureCursorPalette: + return _mouseCursorPaletteEnabled; + case kFeatureAspectRatioCorrection: + return _videoContext->asprectRatioCorrection; + + default: + return false; + } } void OSystem_IPHONE::suspendLoop() { bool done = false; int eventType; - float xUnit, yUnit; + int x, y; uint32 startTime = getMillis(); stopSoundsystem(); while (!done) { - if (iPhone_fetchEvent(&eventType, &xUnit, &yUnit)) + if (iPhone_fetchEvent(&eventType, &x, &y)) if ((InputEvent)eventType == kInputApplicationResumed) done = true; usleep(100000); @@ -226,7 +257,6 @@ Common::String OSystem_IPHONE::getDefaultConfigFileName() { #endif } - void OSystem_IPHONE::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { // Get URL of the Resource directory of the .app bundle CFURLRef fileUrl = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); @@ -272,7 +302,7 @@ void iphone_main(int argc, char *argv[]) { } #ifdef IPHONE_OFFICIAL - chdir( iPhone_getDocumentsDir() ); + chdir(iPhone_getDocumentsDir()); #else system("mkdir " SCUMMVM_ROOT_PATH); system("mkdir " SCUMMVM_SAVE_PATH); diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index 37896cceeb..b443e22f56 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -20,6 +20,9 @@ * */ +#ifndef BACKENDS_PLATFORM_IPHONE_OSYS_MAIN_H +#define BACKENDS_PLATFORM_IPHONE_OSYS_MAIN_H + #include "graphics/surface.h" #include "iphone_common.h" #include "backends/base-backend.h" @@ -42,16 +45,15 @@ typedef void (*SoundProc)(void *param, byte *buf, int len); typedef int (*TimerProc)(int interval); -typedef struct AQCallbackStruct { - AudioQueueRef queue; - uint32 frameCount; - AudioQueueBufferRef buffers[AUDIO_BUFFERS]; - AudioStreamBasicDescription dataFormat; -} AQCallbackStruct; +struct AQCallbackStruct { + AudioQueueRef queue; + uint32 frameCount; + AudioQueueBufferRef buffers[AUDIO_BUFFERS]; + AudioStreamBasicDescription dataFormat; +}; class OSystem_IPHONE : public EventsBaseBackend, public PaletteManager { protected: - static const OSystem::GraphicsMode s_supportedGraphicsModes[]; static AQCallbackStruct s_AudioQueue; static SoundProc s_soundCallback; @@ -59,33 +61,31 @@ protected: Audio::MixerImpl *_mixer; + VideoContext *_videoContext; + Graphics::Surface _framebuffer; - byte *_offscreen; - OverlayColor *_overlayBuffer; - uint16 _overlayHeight; - uint16 _overlayWidth; - uint16 *_fullscreen; + // For signaling that screen format set up might have failed. + TransactionError _gfxTransactionError; - uint16 _palette[256]; - bool _overlayVisible; - uint16 _screenWidth; - uint16 _screenHeight; + // For use with the game texture + uint16 _gamePalette[256]; + // For use with the mouse texture + uint16 _gamePaletteRGBA5551[256]; struct timeval _startTime; uint32 _timeSuspended; - bool _mouseVisible; - byte *_mouseBuf; - byte _mouseKeyColor; - uint _mouseWidth, _mouseHeight; - uint _mouseX, _mouseY; - int _mouseHotspotX, _mouseHotspotY; + bool _mouseCursorPaletteEnabled; + uint16 _mouseCursorPalette[256]; + Graphics::Surface _mouseBuffer; + uint16 _mouseKeyColor; bool _mouseDirty; + bool _mouseNeedTextureUpdate; + long _lastMouseDown; long _lastMouseTap; long _queuedEventTime; - Common::Rect _lastDrawnMouseRect; Common::Event _queuedInputEvent; bool _secondaryTapped; long _lastSecondaryDown; @@ -121,13 +121,21 @@ public: virtual bool getFeatureState(Feature f); virtual const GraphicsMode *getSupportedGraphicsModes() const; virtual int getDefaultGraphicsMode() const; - bool setGraphicsMode(const char *name); virtual bool setGraphicsMode(int mode); virtual int getGraphicsMode() const; virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format); + + virtual void beginGFXTransaction(); + virtual TransactionError endGFXTransaction(); + virtual int16 getHeight(); virtual int16 getWidth(); +#ifdef USE_RGB_COLOR + virtual Graphics::PixelFormat getScreenFormat() const { return _framebuffer.format; } + virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const; +#endif + virtual PaletteManager *getPaletteManager() { return this; } protected: // PaletteManager API @@ -154,6 +162,7 @@ public: virtual void warpMouse(int x, int y); virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 255, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL); + virtual void setCursorPalette(const byte *colors, uint start, uint num); virtual bool pollEvent(Common::Event &event); virtual uint32 getMillis(); @@ -167,7 +176,7 @@ public: static void mixCallback(void *sys, byte *samples, int len); virtual void setupMixer(void); virtual void setTimerCallback(TimerProc callback, int interval); - virtual int getScreenChangeID() const { return _screenChangeCount; } + virtual int getScreenChangeID() const { return _screenChangeCount; } virtual void quit(); virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); @@ -183,15 +192,15 @@ public: virtual void logMessage(LogMessageType::Type type, const char *message); protected: + void initVideoContext(); + void updateOutputSurface(); + void internUpdateScreen(); void dirtyFullScreen(); void dirtyFullOverlayScreen(); - void clipRectToScreen(int16 &x, int16 &y, int16 &w, int16 &h); void suspendLoop(); - void drawDirtyRect(const Common::Rect& dirtyRect); - void drawDirtyOverlayRect(const Common::Rect& dirtyRect); - void drawMouseCursorOnRectUpdate(const Common::Rect& updatedRect, const Common::Rect& mouseRect); - void updateHardwareSurfaceForRect(const Common::Rect& updatedRect); + void drawDirtyRect(const Common::Rect &dirtyRect); + void updateMouseTexture(); static void AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB); static int timerHandler(int t); @@ -208,3 +217,5 @@ protected: bool handleEvent_mouseDragged(Common::Event &event, int x, int y); bool handleEvent_mouseSecondDragged(Common::Event &event, int x, int y); }; + +#endif diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp deleted file mode 100644 index fa425b108a..0000000000 --- a/backends/platform/iphone/osys_video.cpp +++ /dev/null @@ -1,503 +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. - * - */ - -// Disable symbol overrides so that we can use system headers. -#define FORBIDDEN_SYMBOL_ALLOW_ALL - -#include "osys_main.h" - -const OSystem::GraphicsMode* OSystem_IPHONE::getSupportedGraphicsModes() const { - return s_supportedGraphicsModes; -} - - -int OSystem_IPHONE::getDefaultGraphicsMode() const { - return -1; -} - -bool OSystem_IPHONE::setGraphicsMode(const char *mode) { - return true; -} - -bool OSystem_IPHONE::setGraphicsMode(int mode) { - return true; -} - -int OSystem_IPHONE::getGraphicsMode() const { - return -1; -} - -void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) { - //printf("initSize(%i, %i)\n", width, height); - - _screenWidth = width; - _screenHeight = height; - - free(_offscreen); - - _offscreen = (byte *)malloc(width * height); - bzero(_offscreen, width * height); - - //free(_overlayBuffer); - - int fullSize = _screenWidth * _screenHeight * sizeof(OverlayColor); - //_overlayBuffer = (OverlayColor *)malloc(fullSize); - clearOverlay(); - - free(_fullscreen); - - _fullscreen = (uint16 *)malloc(fullSize); - bzero(_fullscreen, fullSize); - - iPhone_initSurface(width, height); - - if (_overlayBuffer == NULL) { - _overlayHeight = iPhone_getScreenHeight(); - _overlayWidth = iPhone_getScreenWidth(); - - printf("Overlay: (%u x %u)\n", _overlayWidth, _overlayHeight); - _overlayBuffer = new OverlayColor[_overlayHeight * _overlayWidth]; - } - - _fullScreenIsDirty = false; - dirtyFullScreen(); - _mouseVisible = false; - _screenChangeCount++; - updateScreen(); -} - -int16 OSystem_IPHONE::getHeight() { - return _screenHeight; -} - -int16 OSystem_IPHONE::getWidth() { - return _screenWidth; -} - -void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) { - assert(start + num <= 256); - const byte *b = colors; - - for (uint i = start; i < start + num; ++i) { - _palette[i] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(b[0], b[1], b[2]); - b += 3; - } - - dirtyFullScreen(); -} - -void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) { - assert(start + num <= 256); - byte *b = colors; - - for (uint i = start; i < start + num; ++i) { - Graphics::colorToRGB<Graphics::ColorMasks<565> >(_palette[i], b[0], b[1], b[2]); - b += 3; - } -} - -void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { - //printf("copyRectToScreen(%i, %i, %i, %i)\n", x, y, w, h); - //Clip the coordinates - if (x < 0) { - w += x; - buf -= x; - x = 0; - } - - if (y < 0) { - h += y; - buf -= y * pitch; - y = 0; - } - - if (w > _screenWidth - x) { - w = _screenWidth - x; - } - - if (h > _screenHeight - y) { - h = _screenHeight - y; - } - - if (w <= 0 || h <= 0) - return; - - if (!_fullScreenIsDirty) { - _dirtyRects.push_back(Common::Rect(x, y, x + w, y + h)); - } - - - byte *dst = _offscreen + y * _screenWidth + x; - if (_screenWidth == pitch && pitch == w) - memcpy(dst, buf, h * w); - else { - do { - memcpy(dst, buf, w); - buf += pitch; - dst += _screenWidth; - } while (--h); - } -} - -void OSystem_IPHONE::clipRectToScreen(int16 &x, int16 &y, int16 &w, int16 &h) { - if (x < 0) { - w += x; - x = 0; - } - - if (y < 0) { - h += y; - y = 0; - } - - if (w > _screenWidth - x) - w = _screenWidth - x; - - if (h > _screenHeight - y) - h = _screenHeight - y; - - if (w < 0) { - w = 0; - } - - if (h < 0) { - h = 0; - } -} - -void OSystem_IPHONE::updateScreen() { - //printf("updateScreen(): %i dirty rects.\n", _dirtyRects.size()); - - if (_dirtyRects.size() == 0 && _dirtyOverlayRects.size() == 0 && !_mouseDirty) - return; - - internUpdateScreen(); - _fullScreenIsDirty = false; - _fullScreenOverlayIsDirty = false; - - iPhone_updateScreen(_mouseX - _mouseHotspotX, _mouseY - _mouseHotspotY); -} - -void OSystem_IPHONE::internUpdateScreen() { - int16 mouseX = _mouseX - _mouseHotspotX; - int16 mouseY = _mouseY - _mouseHotspotY; - int16 mouseWidth = _mouseWidth; - int16 mouseHeight = _mouseHeight; - - clipRectToScreen(mouseX, mouseY, mouseWidth, mouseHeight); - - Common::Rect mouseRect(mouseX, mouseY, mouseX + mouseWidth, mouseY + mouseHeight); - - if (_mouseDirty) { - if (!_fullScreenIsDirty) { - _dirtyRects.push_back(_lastDrawnMouseRect); - _dirtyRects.push_back(mouseRect); - } - if (!_fullScreenOverlayIsDirty && _overlayVisible) { - _dirtyOverlayRects.push_back(_lastDrawnMouseRect); - _dirtyOverlayRects.push_back(mouseRect); - } - _mouseDirty = false; - _lastDrawnMouseRect = mouseRect; - } - - while (_dirtyRects.size()) { - Common::Rect dirtyRect = _dirtyRects.remove_at(_dirtyRects.size() - 1); - - //printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); - - drawDirtyRect(dirtyRect); - - if (_overlayVisible) - drawDirtyOverlayRect(dirtyRect); - else - drawMouseCursorOnRectUpdate(dirtyRect, mouseRect); - - updateHardwareSurfaceForRect(dirtyRect); - } - - if (_overlayVisible) { - while (_dirtyOverlayRects.size()) { - Common::Rect dirtyRect = _dirtyOverlayRects.remove_at(_dirtyOverlayRects.size() - 1); - - //printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); - - drawDirtyOverlayRect(dirtyRect); - //drawMouseCursorOnRectUpdate(dirtyRect, mouseRect); - //updateHardwareSurfaceForRect(dirtyRect); - } - } -} - -void OSystem_IPHONE::drawDirtyRect(const Common::Rect& dirtyRect) { - int h = dirtyRect.bottom - dirtyRect.top; - int w = dirtyRect.right - dirtyRect.left; - - byte *src = &_offscreen[dirtyRect.top * _screenWidth + dirtyRect.left]; - uint16 *dst = &_fullscreen[dirtyRect.top * _screenWidth + dirtyRect.left]; - for (int y = h; y > 0; y--) { - for (int x = w; x > 0; x--) - *dst++ = _palette[*src++]; - - dst += _screenWidth - w; - src += _screenWidth - w; - } -} - -void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect& dirtyRect) { - // int h = dirtyRect.bottom - dirtyRect.top; - // - // uint16 *src = (uint16 *)&_overlayBuffer[dirtyRect.top * _screenWidth + dirtyRect.left]; - // uint16 *dst = &_fullscreen[dirtyRect.top * _screenWidth + dirtyRect.left]; - // int x = (dirtyRect.right - dirtyRect.left) * 2; - // for (int y = h; y > 0; y--) { - // memcpy(dst, src, x); - // src += _screenWidth; - // dst += _screenWidth; - // } - iPhone_updateOverlayRect(_overlayBuffer, dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); -} - -void OSystem_IPHONE::drawMouseCursorOnRectUpdate(const Common::Rect& updatedRect, const Common::Rect& mouseRect) { - //draw mouse on top - if (_mouseVisible && (updatedRect.intersects(mouseRect))) { - int srcX = 0; - int srcY = 0; - int left = _mouseX - _mouseHotspotX; - if (left < 0) { - srcX -= left; - left = 0; - } - int top = _mouseY - _mouseHotspotY; - if (top < 0) { - srcY -= top; - top = 0; - } - - int bottom = top + _mouseHeight; - if (bottom > _screenWidth) - bottom = _screenWidth; - - int displayWidth = _mouseWidth; - if (_mouseWidth + left > _screenWidth) - displayWidth = _screenWidth - left; - - int displayHeight = _mouseHeight; - if (_mouseHeight + top > _screenHeight) - displayHeight = _screenHeight - top; - - byte *src = &_mouseBuf[srcY * _mouseWidth + srcX]; - uint16 *dst = &_fullscreen[top * _screenWidth + left]; - for (int y = displayHeight; y > srcY; y--) { - for (int x = displayWidth; x > srcX; x--) { - if (*src != _mouseKeyColor) - *dst = _palette[*src]; - dst++; - src++; - } - dst += _screenWidth - displayWidth + srcX; - src += _mouseWidth - displayWidth + srcX; - } - } -} - -void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect& updatedRect) { - iPhone_updateScreenRect(_fullscreen, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom ); -} - -Graphics::Surface *OSystem_IPHONE::lockScreen() { - //printf("lockScreen()\n"); - - _framebuffer.pixels = _offscreen; - _framebuffer.w = _screenWidth; - _framebuffer.h = _screenHeight; - _framebuffer.pitch = _screenWidth; - _framebuffer.format = Graphics::PixelFormat::createFormatCLUT8(); - - return &_framebuffer; -} - -void OSystem_IPHONE::unlockScreen() { - //printf("unlockScreen()\n"); - dirtyFullScreen(); -} - -void OSystem_IPHONE::setShakePos(int shakeOffset) { - //printf("setShakePos(%i)\n", shakeOffset); -} - -void OSystem_IPHONE::showOverlay() { - //printf("showOverlay()\n"); - _overlayVisible = true; - dirtyFullOverlayScreen(); - updateScreen(); - iPhone_enableOverlay(true); -} - -void OSystem_IPHONE::hideOverlay() { - //printf("hideOverlay()\n"); - _overlayVisible = false; - _dirtyOverlayRects.clear(); - dirtyFullScreen(); - iPhone_enableOverlay(false); -} - -void OSystem_IPHONE::clearOverlay() { - //printf("clearOverlay()\n"); - bzero(_overlayBuffer, _overlayWidth * _overlayHeight * sizeof(OverlayColor)); - dirtyFullOverlayScreen(); -} - -void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) { - //printf("grabOverlay()\n"); - int h = _overlayHeight; - OverlayColor *src = _overlayBuffer; - - do { - memcpy(buf, src, _overlayWidth * sizeof(OverlayColor)); - src += _overlayWidth; - buf += pitch; - } while (--h); -} - -void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { - //printf("copyRectToOverlay(buf, pitch=%i, x=%i, y=%i, w=%i, h=%i)\n", pitch, x, y, w, h); - - //Clip the coordinates - if (x < 0) { - w += x; - buf -= x; - x = 0; - } - - if (y < 0) { - h += y; - buf -= y * pitch; - y = 0; - } - - if (w > _overlayWidth - x) - w = _overlayWidth - x; - - if (h > _overlayHeight - y) - h = _overlayHeight - y; - - if (w <= 0 || h <= 0) - return; - - if (!_fullScreenOverlayIsDirty) { - _dirtyOverlayRects.push_back(Common::Rect(x, y, x + w, y + h)); - } - - OverlayColor *dst = _overlayBuffer + (y * _overlayWidth + x); - if (_overlayWidth == pitch && pitch == w) - memcpy(dst, buf, h * w * sizeof(OverlayColor)); - else { - do { - memcpy(dst, buf, w * sizeof(OverlayColor)); - buf += pitch; - dst += _overlayWidth; - } while (--h); - } -} - -int16 OSystem_IPHONE::getOverlayHeight() { - return _overlayHeight; -} - -int16 OSystem_IPHONE::getOverlayWidth() { - return _overlayWidth; -} - -bool OSystem_IPHONE::showMouse(bool visible) { - bool last = _mouseVisible; - _mouseVisible = visible; - _mouseDirty = true; - - return last; -} - -void OSystem_IPHONE::warpMouse(int x, int y) { - //printf("warpMouse()\n"); - - _mouseX = x; - _mouseY = y; - _mouseDirty = true; -} - -void OSystem_IPHONE::dirtyFullScreen() { - if (!_fullScreenIsDirty) { - _dirtyRects.clear(); - _dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight)); - _fullScreenIsDirty = true; - } -} - -void OSystem_IPHONE::dirtyFullOverlayScreen() { - if (!_fullScreenOverlayIsDirty) { - _dirtyOverlayRects.clear(); - _dirtyOverlayRects.push_back(Common::Rect(0, 0, _overlayWidth, _overlayHeight)); - _fullScreenOverlayIsDirty = true; - } -} - -void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { - //printf("setMouseCursor(%i, %i, scale %u)\n", hotspotX, hotspotY, cursorTargetScale); - - int texWidth = getSizeNextPOT(w); - int texHeight = getSizeNextPOT(h); - int bufferSize = texWidth * texHeight * sizeof(int16); - int16* mouseBuf = (int16*)malloc(bufferSize); - memset(mouseBuf, 0, bufferSize); - - for (uint x = 0; x < w; ++x) { - for (uint y = 0; y < h; ++y) { - byte color = buf[y * w + x]; - if (color != keycolor) - mouseBuf[y * texWidth + x] = _palette[color] | 0x1; - else - mouseBuf[y * texWidth + x] = 0x0; - } - } - - iPhone_setMouseCursor(mouseBuf, w, h); - - if (_mouseBuf != NULL && (_mouseWidth != w || _mouseHeight != h)) { - free(_mouseBuf); - _mouseBuf = NULL; - } - - if (_mouseBuf == NULL) - _mouseBuf = (byte *)malloc(w * h); - - _mouseWidth = w; - _mouseHeight = h; - - _mouseHotspotX = hotspotX; - _mouseHotspotY = hotspotY; - - _mouseKeyColor = (byte)keycolor; - - memcpy(_mouseBuf, buf, w * h); - - _mouseDirty = true; -} diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm new file mode 100644 index 0000000000..6f80a6cba3 --- /dev/null +++ b/backends/platform/iphone/osys_video.mm @@ -0,0 +1,491 @@ +/* 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. + * + */ + +// Disable symbol overrides so that we can use system headers. +#define FORBIDDEN_SYMBOL_ALLOW_ALL + +#include "osys_main.h" +#include "iphone_video.h" + +#include "graphics/conversion.h" + +void OSystem_IPHONE::initVideoContext() { + _videoContext = [g_iPhoneViewInstance getVideoContext]; +} + +const OSystem::GraphicsMode *OSystem_IPHONE::getSupportedGraphicsModes() const { + return s_supportedGraphicsModes; +} + +int OSystem_IPHONE::getDefaultGraphicsMode() const { + return kGraphicsModeLinear; +} + +bool OSystem_IPHONE::setGraphicsMode(int mode) { + switch (mode) { + case kGraphicsModeNone: + case kGraphicsModeLinear: + _videoContext->graphicsMode = (GraphicsModes)mode; + return true; + + default: + return false; + } +} + +int OSystem_IPHONE::getGraphicsMode() const { + return _videoContext->graphicsMode; +} + +#ifdef USE_RGB_COLOR +Common::List<Graphics::PixelFormat> OSystem_IPHONE::getSupportedFormats() const { + Common::List<Graphics::PixelFormat> list; + // RGB565 + list.push_back(Graphics::createPixelFormat<565>()); + // CLUT8 + list.push_back(Graphics::PixelFormat::createFormatCLUT8()); + return list; +} +#endif + +void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) { + //printf("initSize(%u, %u, %p)\n", width, height, (const void *)format); + + _videoContext->screenWidth = width; + _videoContext->screenHeight = height; + _videoContext->shakeOffsetY = 0; + + // In case we use the screen texture as frame buffer we reset the pixels + // pointer here to avoid freeing the screen texture. + if (_framebuffer.pixels == _videoContext->screenTexture.pixels) + _framebuffer.pixels = 0; + + // Create the screen texture right here. We need to do this here, since + // when a game requests hi-color mode, we actually set the framebuffer + // to the texture buffer to avoid an additional copy step. + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(createScreenTexture) withObject:nil waitUntilDone: YES]; + + // In case the client code tries to set up a non supported mode, we will + // fall back to CLUT8 and set the transaction error accordingly. + if (format && format->bytesPerPixel != 1 && *format != _videoContext->screenTexture.format) { + format = 0; + _gfxTransactionError = kTransactionFormatNotSupported; + } + + if (!format || format->bytesPerPixel == 1) { + _framebuffer.create(width, height, Graphics::PixelFormat::createFormatCLUT8()); + } else { +#if 0 + printf("bytesPerPixel: %u RGBAlosses: %u,%u,%u,%u RGBAshifts: %u,%u,%u,%u\n", format->bytesPerPixel, + format->rLoss, format->gLoss, format->bLoss, format->aLoss, + format->rShift, format->gShift, format->bShift, format->aShift); +#endif + // We directly draw on the screen texture in hi-color mode. Thus + // we copy over its settings here and just replace the width and + // height to avoid any problems. + _framebuffer = _videoContext->screenTexture; + _framebuffer.w = width; + _framebuffer.h = height; + } + + _fullScreenIsDirty = false; + dirtyFullScreen(); + _mouseCursorPaletteEnabled = false; +} + +void OSystem_IPHONE::beginGFXTransaction() { + _gfxTransactionError = kTransactionSuccess; +} + +OSystem::TransactionError OSystem_IPHONE::endGFXTransaction() { + _screenChangeCount++; + updateOutputSurface(); + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES]; + + return _gfxTransactionError; +} + +void OSystem_IPHONE::updateOutputSurface() { + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(initSurface) withObject:nil waitUntilDone: YES]; +} + +int16 OSystem_IPHONE::getHeight() { + return _videoContext->screenHeight; +} + +int16 OSystem_IPHONE::getWidth() { + return _videoContext->screenWidth; +} + +void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) { + assert(start + num <= 256); + const byte *b = colors; + + for (uint i = start; i < start + num; ++i) { + _gamePalette[i] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(b[0], b[1], b[2]); + _gamePaletteRGBA5551[i] = Graphics::RGBToColor<Graphics::ColorMasks<5551> >(b[0], b[1], b[2]); + b += 3; + } + + dirtyFullScreen(); +} + +void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) { + assert(start + num <= 256); + byte *b = colors; + + for (uint i = start; i < start + num; ++i) { + Graphics::colorToRGB<Graphics::ColorMasks<565> >(_gamePalette[i], b[0], b[1], b[2]); + b += 3; + } +} + +void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { + //printf("copyRectToScreen(%i, %i, %i, %i)\n", x, y, w, h); + //Clip the coordinates + if (x < 0) { + w += x; + buf -= x; + x = 0; + } + + if (y < 0) { + h += y; + buf -= y * pitch; + y = 0; + } + + if (w > (int)_framebuffer.w - x) { + w = _framebuffer.w - x; + } + + if (h > (int)_framebuffer.h - y) { + h = _framebuffer.h - y; + } + + if (w <= 0 || h <= 0) + return; + + if (!_fullScreenIsDirty) { + _dirtyRects.push_back(Common::Rect(x, y, x + w, y + h)); + } + + byte *dst = (byte *)_framebuffer.getBasePtr(x, y); + if (_framebuffer.pitch == pitch && _framebuffer.w == w) { + memcpy(dst, buf, h * pitch); + } else { + do { + memcpy(dst, buf, w * _framebuffer.format.bytesPerPixel); + buf += pitch; + dst += _framebuffer.pitch; + } while (--h); + } +} + +void OSystem_IPHONE::updateScreen() { + //printf("updateScreen(): %i dirty rects.\n", _dirtyRects.size()); + + if (_dirtyRects.size() == 0 && _dirtyOverlayRects.size() == 0 && !_mouseDirty) + return; + + internUpdateScreen(); + _mouseDirty = false; + _fullScreenIsDirty = false; + _fullScreenOverlayIsDirty = false; + + iPhone_updateScreen(); +} + +void OSystem_IPHONE::internUpdateScreen() { + if (_mouseNeedTextureUpdate) { + updateMouseTexture(); + _mouseNeedTextureUpdate = false; + } + + while (_dirtyRects.size()) { + Common::Rect dirtyRect = _dirtyRects.remove_at(_dirtyRects.size() - 1); + + //printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); + drawDirtyRect(dirtyRect); + // TODO: Implement dirty rect code + //updateHardwareSurfaceForRect(dirtyRect); + } + + if (_videoContext->overlayVisible) { + // TODO: Implement dirty rect code + _dirtyOverlayRects.clear(); + /*while (_dirtyOverlayRects.size()) { + Common::Rect dirtyRect = _dirtyOverlayRects.remove_at(_dirtyOverlayRects.size() - 1); + + //printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); + drawDirtyOverlayRect(dirtyRect); + }*/ + } +} + +void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) { + // We only need to do a color look up for CLUT8 + if (_framebuffer.format.bytesPerPixel != 1) + return; + + int h = dirtyRect.bottom - dirtyRect.top; + int w = dirtyRect.right - dirtyRect.left; + + const byte *src = (const byte *)_framebuffer.getBasePtr(dirtyRect.left, dirtyRect.top); + byte *dstRaw = (byte *)_videoContext->screenTexture.getBasePtr(dirtyRect.left, dirtyRect.top); + + // When we use CLUT8 do a color look up + for (int y = h; y > 0; y--) { + uint16 *dst = (uint16 *)dstRaw; + for (int x = w; x > 0; x--) + *dst++ = _gamePalette[*src++]; + + dstRaw += _videoContext->screenTexture.pitch; + src += _framebuffer.pitch - w; + } +} + +Graphics::Surface *OSystem_IPHONE::lockScreen() { + //printf("lockScreen()\n"); + return &_framebuffer; +} + +void OSystem_IPHONE::unlockScreen() { + //printf("unlockScreen()\n"); + dirtyFullScreen(); +} + +void OSystem_IPHONE::setShakePos(int shakeOffset) { + //printf("setShakePos(%i)\n", shakeOffset); + _videoContext->shakeOffsetY = shakeOffset; + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(setViewTransformation) withObject:nil waitUntilDone: YES]; + // HACK: We use this to force a redraw. + _mouseDirty = true; +} + +void OSystem_IPHONE::showOverlay() { + //printf("showOverlay()\n"); + _videoContext->overlayVisible = true; + dirtyFullOverlayScreen(); + updateScreen(); + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursorScaling) withObject:nil waitUntilDone: YES]; + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES]; +} + +void OSystem_IPHONE::hideOverlay() { + //printf("hideOverlay()\n"); + _videoContext->overlayVisible = false; + _dirtyOverlayRects.clear(); + dirtyFullScreen(); + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursorScaling) withObject:nil waitUntilDone: YES]; + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES]; +} + +void OSystem_IPHONE::clearOverlay() { + //printf("clearOverlay()\n"); + bzero(_videoContext->overlayTexture.getBasePtr(0, 0), _videoContext->overlayTexture.h * _videoContext->overlayTexture.pitch); + dirtyFullOverlayScreen(); +} + +void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) { + //printf("grabOverlay()\n"); + int h = _videoContext->overlayHeight; + + const byte *src = (const byte *)_videoContext->overlayTexture.getBasePtr(0, 0); + do { + memcpy(buf, src, _videoContext->overlayWidth * sizeof(OverlayColor)); + src += _videoContext->overlayTexture.pitch; + buf += pitch; + } while (--h); +} + +void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { + //printf("copyRectToOverlay(buf, pitch=%i, x=%i, y=%i, w=%i, h=%i)\n", pitch, x, y, w, h); + + //Clip the coordinates + if (x < 0) { + w += x; + buf -= x; + x = 0; + } + + if (y < 0) { + h += y; + buf -= y * pitch; + y = 0; + } + + if (w > (int)_videoContext->overlayWidth - x) + w = _videoContext->overlayWidth - x; + + if (h > (int)_videoContext->overlayHeight - y) + h = _videoContext->overlayHeight - y; + + if (w <= 0 || h <= 0) + return; + + if (!_fullScreenOverlayIsDirty) { + _dirtyOverlayRects.push_back(Common::Rect(x, y, x + w, y + h)); + } + + byte *dst = (byte *)_videoContext->overlayTexture.getBasePtr(x, y); + do { + memcpy(dst, buf, w * sizeof(OverlayColor)); + buf += pitch; + dst += _videoContext->overlayTexture.pitch; + } while (--h); +} + +int16 OSystem_IPHONE::getOverlayHeight() { + return _videoContext->overlayHeight; +} + +int16 OSystem_IPHONE::getOverlayWidth() { + return _videoContext->overlayWidth; +} + +bool OSystem_IPHONE::showMouse(bool visible) { + bool last = _videoContext->mouseIsVisible; + _videoContext->mouseIsVisible = visible; + _mouseDirty = true; + + return last; +} + +void OSystem_IPHONE::warpMouse(int x, int y) { + //printf("warpMouse()\n"); + _videoContext->mouseX = x; + _videoContext->mouseY = y; + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(notifyMouseMove) withObject:nil waitUntilDone: YES]; + _mouseDirty = true; +} + +void OSystem_IPHONE::dirtyFullScreen() { + if (!_fullScreenIsDirty) { + _dirtyRects.clear(); + _dirtyRects.push_back(Common::Rect(0, 0, _videoContext->screenWidth, _videoContext->screenHeight)); + _fullScreenIsDirty = true; + } +} + +void OSystem_IPHONE::dirtyFullOverlayScreen() { + if (!_fullScreenOverlayIsDirty) { + _dirtyOverlayRects.clear(); + _dirtyOverlayRects.push_back(Common::Rect(0, 0, _videoContext->overlayWidth, _videoContext->overlayHeight)); + _fullScreenOverlayIsDirty = true; + } +} + +void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { + //printf("setMouseCursor(%i, %i, scale %u)\n", hotspotX, hotspotY, cursorTargetScale); + + const Graphics::PixelFormat pixelFormat = format ? *format : Graphics::PixelFormat::createFormatCLUT8(); +#if 0 + printf("bytesPerPixel: %u RGBAlosses: %u,%u,%u,%u RGBAshifts: %u,%u,%u,%u\n", pixelFormat.bytesPerPixel, + pixelFormat.rLoss, pixelFormat.gLoss, pixelFormat.bLoss, pixelFormat.aLoss, + pixelFormat.rShift, pixelFormat.gShift, pixelFormat.bShift, pixelFormat.aShift); +#endif + assert(pixelFormat.bytesPerPixel == 1 || pixelFormat.bytesPerPixel == 2); + + if (_mouseBuffer.w != w || _mouseBuffer.h != h || _mouseBuffer.format != pixelFormat || !_mouseBuffer.pixels) + _mouseBuffer.create(w, h, pixelFormat); + + _videoContext->mouseWidth = w; + _videoContext->mouseHeight = h; + + _videoContext->mouseHotspotX = hotspotX; + _videoContext->mouseHotspotY = hotspotY; + + _mouseKeyColor = keycolor; + + memcpy(_mouseBuffer.getBasePtr(0, 0), buf, h * _mouseBuffer.pitch); + + _mouseDirty = true; + _mouseNeedTextureUpdate = true; +} + +void OSystem_IPHONE::setCursorPalette(const byte *colors, uint start, uint num) { + assert(start + num <= 256); + + 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; + + if (_mouseCursorPaletteEnabled) + _mouseDirty = _mouseNeedTextureUpdate = true; +} + +void OSystem_IPHONE::updateMouseTexture() { + uint texWidth = getSizeNextPOT(_videoContext->mouseWidth); + uint texHeight = getSizeNextPOT(_videoContext->mouseHeight); + + Graphics::Surface &mouseTexture = _videoContext->mouseTexture; + if (mouseTexture.w != texWidth || mouseTexture.h != texHeight) + mouseTexture.create(texWidth, texHeight, Graphics::createPixelFormat<5551>()); + + if (_mouseBuffer.format.bytesPerPixel == 1) { + const uint16 *palette; + if (_mouseCursorPaletteEnabled) + palette = _mouseCursorPalette; + else + palette = _gamePaletteRGBA5551; + + uint16 *mouseBuf = (uint16 *)mouseTexture.getBasePtr(0, 0); + for (uint x = 0; x < _videoContext->mouseWidth; ++x) { + for (uint y = 0; y < _videoContext->mouseHeight; ++y) { + const byte color = *(const byte *)_mouseBuffer.getBasePtr(x, y); + if (color != _mouseKeyColor) + mouseBuf[y * texWidth + x] = palette[color] | 0x1; + else + mouseBuf[y * texWidth + x] = 0x0; + } + } + } else { + if (crossBlit((byte *)mouseTexture.getBasePtr(0, 0), (const byte *)_mouseBuffer.getBasePtr(0, 0), mouseTexture.pitch, + _mouseBuffer.pitch, _mouseBuffer.w, _mouseBuffer.h, mouseTexture.format, _mouseBuffer.format)) { + if (!_mouseBuffer.format.aBits()) { + // Apply color keying since the original cursor had no alpha channel. + const uint16 *src = (const uint16 *)_mouseBuffer.getBasePtr(0, 0); + uint8 *dstRaw = (uint8 *)mouseTexture.getBasePtr(0, 0); + + for (uint y = 0; y < _mouseBuffer.h; ++y, dstRaw += mouseTexture.pitch) { + uint16 *dst = (uint16 *)dstRaw; + for (uint x = 0; x < _mouseBuffer.w; ++x, ++dst) { + if (*src++ == _mouseKeyColor) + *dst &= ~1; + else + *dst |= 1; + } + } + } + } else { + // TODO: Log this! + // Make the cursor all transparent... we really need a better fallback ;-). + memset(mouseTexture.getBasePtr(0, 0), 0, mouseTexture.h * mouseTexture.pitch); + } + } + + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES]; +} diff --git a/backends/platform/linuxmoto/hardwarekeys.cpp b/backends/platform/linuxmoto/hardwarekeys.cpp index e10e39a23d..e1a5757430 100644 --- a/backends/platform/linuxmoto/hardwarekeys.cpp +++ b/backends/platform/linuxmoto/hardwarekeys.cpp @@ -33,60 +33,59 @@ struct Key { KeyCode keycode; uint16 ascii; const char *desc; - KeyType preferredAction; bool shiftable; }; static const Key keys[] = { - { "FIRE", KEYCODE_RETURN, ASCII_RETURN, "Fire", kActionKeyType, false }, - { "CAMERA", KEYCODE_PAUSE, 0, "Camera", kActionKeyType, false }, - { "HANGUP", KEYCODE_ESCAPE, ASCII_ESCAPE, "Hangup", kStartKeyType, false }, - { "CALL", KEYCODE_SPACE, ASCII_SPACE, "Call", kActionKeyType, false }, - { "PLUS", KEYCODE_PLUS, '+', "+", kActionKeyType, false }, - { "MINUS", KEYCODE_MINUS, '-', "-", kActionKeyType, false }, + { "FIRE", KEYCODE_RETURN, ASCII_RETURN, "Fire", false }, + { "CAMERA", KEYCODE_PAUSE, 0, "Camera", false }, + { "HANGUP", KEYCODE_ESCAPE, ASCII_ESCAPE, "Hangup", false }, + { "CALL", KEYCODE_SPACE, ASCII_SPACE, "Call", false }, + { "PLUS", KEYCODE_PLUS, '+', "+", false }, + { "MINUS", KEYCODE_MINUS, '-', "-", false }, #ifdef MOTOMAGX - {"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", kActionKeyType, false}, - {"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", kActionKeyType, false}, - {"HASH", KEYCODE_HASH, '#', "#", kActionKeyType, false}, - {"ASTERISK", KEYCODE_ASTERISK, '*', "*", kActionKeyType, false}, - {"LEFTSOFT", KEYCODE_F9, ASCII_F9, "LeftSoft", kActionKeyType, false}, - {"RIGHTSOFT", KEYCODE_F11, ASCII_F11, "RightSoft", kActionKeyType, false}, - {"0", KEYCODE_0, '0', "0", kActionKeyType, false}, - {"1", KEYCODE_1, '1', "1", kActionKeyType, false}, - {"2", KEYCODE_2, '2', "2", kActionKeyType, false}, - {"3", KEYCODE_3, '3', "3", kActionKeyType, false}, - {"4", KEYCODE_4, '4', "4", kActionKeyType, false}, - {"5", KEYCODE_5, '5', "5", kActionKeyType, false}, - {"6", KEYCODE_6, '6', "6", kActionKeyType, false}, - {"7", KEYCODE_7, '7', "7", kActionKeyType, false}, - {"8", KEYCODE_8, '8', "8", kActionKeyType, false}, - {"9", KEYCODE_9, '9', "9", kActionKeyType, false}, + {"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", false}, + {"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", false}, + {"HASH", KEYCODE_HASH, '#', "#", false}, + {"ASTERISK", KEYCODE_ASTERISK, '*', "*", false}, + {"LEFTSOFT", KEYCODE_F9, ASCII_F9, "LeftSoft", false}, + {"RIGHTSOFT", KEYCODE_F11, ASCII_F11, "RightSoft", false}, + {"0", KEYCODE_0, '0', "0", false}, + {"1", KEYCODE_1, '1', "1", false}, + {"2", KEYCODE_2, '2', "2", false}, + {"3", KEYCODE_3, '3', "3", false}, + {"4", KEYCODE_4, '4', "4", false}, + {"5", KEYCODE_5, '5', "5", false}, + {"6", KEYCODE_6, '6', "6", false}, + {"7", KEYCODE_7, '7', "7", false}, + {"8", KEYCODE_8, '8', "8", false}, + {"9", KEYCODE_9, '9', "9", false}, #endif #ifdef MOTOEZX - { "a", KEYCODE_a, 'a', "a", kActionKeyType, true }, - { "b", KEYCODE_b, 'b', "b", kActionKeyType, true }, - { "c", KEYCODE_c, 'c', "c", kActionKeyType, true }, - { "d", KEYCODE_d, 'd', "d", kActionKeyType, true }, - { "e", KEYCODE_e, 'e', "e", kActionKeyType, true }, - { "f", KEYCODE_f, 'f', "f", kActionKeyType, true }, - { "g", KEYCODE_g, 'g', "g", kActionKeyType, true }, - { "h", KEYCODE_h, 'h', "h", kActionKeyType, true }, - { "i", KEYCODE_i, 'i', "i", kActionKeyType, true }, - { "j", KEYCODE_j, 'j', "j", kActionKeyType, true }, + { "a", KEYCODE_a, 'a', "a", true }, + { "b", KEYCODE_b, 'b', "b", true }, + { "c", KEYCODE_c, 'c', "c", true }, + { "d", KEYCODE_d, 'd', "d", true }, + { "e", KEYCODE_e, 'e', "e", true }, + { "f", KEYCODE_f, 'f', "f", true }, + { "g", KEYCODE_g, 'g', "g", true }, + { "h", KEYCODE_h, 'h', "h", true }, + { "i", KEYCODE_i, 'i', "i", true }, + { "j", KEYCODE_j, 'j', "j", true }, #endif // Numeric keypad // Arrows + Home/End pad - {"UP", KEYCODE_UP, 0, "Up", kDirUpKeyType, false}, - {"DOWN", KEYCODE_DOWN, 0, "Down", kDirDownKeyType, false}, - {"RIGHT", KEYCODE_RIGHT, 0, "Right", kDirRightKeyType, false}, - {"LEFT", KEYCODE_LEFT, 0, "Left", kDirLeftKeyType, false}, + {"UP", KEYCODE_UP, 0, "Up", false}, + {"DOWN", KEYCODE_DOWN, 0, "Down", false}, + {"RIGHT", KEYCODE_RIGHT, 0, "Right", false}, + {"LEFT", KEYCODE_LEFT, 0, "Left", false}, // Function keys // Miscellaneous function keys - {0, KEYCODE_INVALID, 0, 0, kGenericKeyType, false} + {0, KEYCODE_INVALID, 0, 0, false} }; struct Mod { @@ -106,9 +105,8 @@ static const Mod modifiers[] = { { KBD_SHIFT | KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+", true }, { 0, 0, 0, false } }; -#endif - -Common::HardwareKeySet *OSystem_LINUXMOTO::getHardwareKeySet() { - return OSystem_SDL::getHardwareKeySet(); +Common::HardwareInputSet *OSystem_LINUXMOTO::getHardwareInputSet() { + return OSystem_SDL::getHardwareInputSet(); } +#endif diff --git a/backends/platform/linuxmoto/linuxmoto-sdl.h b/backends/platform/linuxmoto/linuxmoto-sdl.h index 97262ccbca..27f4e744bc 100644 --- a/backends/platform/linuxmoto/linuxmoto-sdl.h +++ b/backends/platform/linuxmoto/linuxmoto-sdl.h @@ -29,8 +29,10 @@ class OSystem_LINUXMOTO : public OSystem_POSIX { public: virtual void initBackend(); +#ifdef ENABLE_KEYMAPPER // FIXME: This just calls parent methods, is it needed? - virtual Common::HardwareKeySet *getHardwareKeySet(); + virtual Common::HardwareInputSet *getHardwareInputSet(); +#endif }; #endif diff --git a/backends/platform/maemo/debian/changelog b/backends/platform/maemo/debian/changelog index d3e0287186..8a9d8ee3c3 100644 --- a/backends/platform/maemo/debian/changelog +++ b/backends/platform/maemo/debian/changelog @@ -1,8 +1,14 @@ -scummvm (1.4.0~git) unstable; urgency=low +scummvm (1.5.0~git) unstable; urgency=low - * development snapshot + * Development snapshot - -- Tarek Soliman <tsoliman@scummvm.org> Wed, 05 Oct 2011 19:01:25 -0500 + -- Tarek Soliman <tsoliman@scummvm.org> Tue, 15 Nov 2011 14:56:57 -0600 + +scummvm (1.4.0) unstable; urgency=low + + * 1.4.0 release + + -- Tarek Soliman <tsoliman@scummvm.org> Thu, 03 Nov 2011 13:54:04 -0500 scummvm (1.2.1~pre) unstable; urgency=low diff --git a/backends/platform/maemo/debian/control b/backends/platform/maemo/debian/control index a1f0d95002..6e1dfe2fd4 100644 --- a/backends/platform/maemo/debian/control +++ b/backends/platform/maemo/debian/control @@ -7,7 +7,7 @@ Build-Depends: debhelper (>> 4.0.0), libsdl1.2-dev, libmad0-dev, libasound2-dev, Standards-Version: 3.6.1.1 Package: scummvm Depends: ${shlibs:Depends} -Architecture: i386 armel +Architecture: armel Section: user/games Description: interpreter that will play graphic adventure games written for LucasArts' SCUMM virtual machine, Sierra's AGI adventures, @@ -17,6 +17,8 @@ Description: interpreter that will play graphic adventure games Coktel Vision's Gobliiins, Wyrmkeep's Inherit the Earth, Westwood's Legend of Kyrandia, and various others. This package does not contain any actual games. +XSBC-Bugtracker: https://sourceforge.net/tracker/?atid=418820&group_id=37116&func=browse +XB-Maemo-Display-Name: ScummVM XBS-Maemo-Icon-26: iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAMAAACelLz8AAAC/VBMVEUICwcH CQUKDAgLDQoMDwsOEAwREAUPEQ0QEg8PFQoRExAUEwoVFAwPGAcTFBIRFg0W diff --git a/backends/platform/maemo/debian/rules b/backends/platform/maemo/debian/rules index 7613df25b4..64add08de8 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/m4.dat dists/engine-data/mads.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/toon.dat debian/scummvm/opt/scummvm/share install -m0644 -d debian/scummvm/usr/share/doc/scummvm install -m0644 NEWS README COPYRIGHT debian/scummvm/usr/share/doc/scummvm diff --git a/backends/platform/maemo/maemo-common.h b/backends/platform/maemo/maemo-common.h index f33aa24278..0442b9c0ae 100644 --- a/backends/platform/maemo/maemo-common.h +++ b/backends/platform/maemo/maemo-common.h @@ -28,9 +28,10 @@ namespace Maemo { enum ModelType { - kModelTypeN800 = 1, - kModelTypeN810 = 2, - kModelTypeN900 = 4, + kModelType770 = 1 << 0, + kModelTypeN800 = 1 << 1, + kModelTypeN810 = 1 << 2, + kModelTypeN900 = 1 << 3, kModelTypeInvalid = 0 }; @@ -38,15 +39,13 @@ struct Model { const char *hwId; ModelType modelType; const char *hwAlias; - bool hwKeyboard; + bool hasHwKeyboard; + bool hasMenuKey; }; -static const Model models[] = { - {"RX-34", kModelTypeN800, "N800", false}, - {"RX-44", kModelTypeN810, "N810", true}, - {"RX-48", kModelTypeN810, "N810W", true}, - {"RX-51", kModelTypeN900, "N900", true}, - {0, kModelTypeInvalid, 0, true} +enum CustomEventType { + kEventClickMode = 1, + kEventInvalid = 0 }; } // namespace Maemo diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index 3571039e62..e296d4787c 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -29,7 +29,11 @@ #include "backends/platform/maemo/maemo.h" #include "backends/events/maemosdl/maemosdl-events.h" +#include "backends/graphics/maemosdl/maemosdl-graphics.h" +#include "backends/keymapper/keymapper.h" +#include "backends/keymapper/keymapper-defaults.h" #include "common/textconsole.h" +#include "common/translation.h" #include <SDL/SDL_syswm.h> @@ -42,17 +46,70 @@ OSystem_SDL_Maemo::OSystem_SDL_Maemo() OSystem_POSIX() { } +OSystem_SDL_Maemo::~OSystem_SDL_Maemo() { + delete _eventObserver; +#ifdef ENABLE_KEYMAPPER + delete _keymapperDefaultBindings; +#endif +} + +#ifdef ENABLE_KEYMAPPER +static void registerDefaultKeyBindings(Common::KeymapperDefaultBindings *_keymapperDefaultBindings, Model _model) { + _keymapperDefaultBindings->setDefaultBinding("gui", "REM", "HOME"); + _keymapperDefaultBindings->setDefaultBinding("global", "REM", "HOME"); + + if (_model.hasMenuKey && _model.hasHwKeyboard) { + _keymapperDefaultBindings->setDefaultBinding("gui", "FUL", "FULLSCREEN"); + _keymapperDefaultBindings->setDefaultBinding("global", "FUL", "FULLSCREEN"); + } + + if (_model.hasHwKeyboard) { + _keymapperDefaultBindings->setDefaultBinding("gui", "VIR", "C+ZOOMMINUS"); + _keymapperDefaultBindings->setDefaultBinding("global", "VIR", "C+ZOOMMINUS"); + } else { + _keymapperDefaultBindings->setDefaultBinding("gui", "VIR", "FULLSCREEN"); + _keymapperDefaultBindings->setDefaultBinding("global", "VIR", "FULLSCREEN"); + } + + if (_model.hasMenuKey ) + _keymapperDefaultBindings->setDefaultBinding("global", "MEN", "MENU"); + else + _keymapperDefaultBindings->setDefaultBinding("global", "MEN", "S+C+M"); + + _keymapperDefaultBindings->setDefaultBinding("gui", "CLO", "ESCAPE"); + + _keymapperDefaultBindings->setDefaultBinding("maemo", "RCL", "ZOOMPLUS"); + _keymapperDefaultBindings->setDefaultBinding("maemo", "CLK", "ZOOMMINUS"); +} +#endif + void OSystem_SDL_Maemo::initBackend() { // Create the events manager if (_eventSource == 0) _eventSource = new MaemoSdlEventSource(); + if (_graphicsManager == 0) + _graphicsManager = new MaemoSdlGraphicsManager(_eventSource); + + if (_eventObserver == 0) + _eventObserver = new MaemoSdlEventObserver((MaemoSdlEventSource *)_eventSource); + +#ifdef ENABLE_KEYMAPPER + if (_keymapperDefaultBindings == 0) + _keymapperDefaultBindings = new Common::KeymapperDefaultBindings(); +#endif + ConfMan.set("vkeybdpath", DATA_PATH); - _model = Model(detectModel()); + _model = detectModel(); + +#ifdef ENABLE_KEYMAPPER + registerDefaultKeyBindings(_keymapperDefaultBindings, _model); +#endif // Call parent implementation of this method OSystem_POSIX::initBackend(); + initObserver(); } void OSystem_SDL_Maemo::quit() { @@ -98,16 +155,77 @@ void OSystem_SDL_Maemo::setWindowCaption(const char *caption) { setXWindowName(cap.c_str()); } +static const Model models[] = { + {"SU-18", kModelType770, "770", false, true}, + {"RX-34", kModelTypeN800, "N800", false, true}, + {"RX-44", kModelTypeN810, "N810", true, true}, + {"RX-48", kModelTypeN810, "N810W", true, true}, + {"RX-51", kModelTypeN900, "N900", true, false}, + {0, kModelTypeInvalid, 0, true, true} +}; + const Maemo::Model OSystem_SDL_Maemo::detectModel() { Common::String deviceHwId = Common::String(getenv("SCUMMVM_MAEMO_DEVICE")); const Model *model; - for (model = models; model->hwId; model++) { + for (model = models; model->hwId; ++model) { if (deviceHwId.equals(model->hwId)) return *model; } return *model; } +void OSystem_SDL_Maemo::setupIcon() { + // no Maemo version needs setupIcon + // also N900 is hit by SDL_WM_SetIcon bug (window cannot receive input) + // http://bugzilla.libsdl.org/show_bug.cgi?id=586 +} + +static const Common::KeyTableEntry maemoKeys[] = { + // Function keys + {"MENU", Common::KEYCODE_F11, 0, "Menu", false}, + {"HOME", Common::KEYCODE_F12, 0, "Home", false}, + {"FULLSCREEN", Common::KEYCODE_F13, 0, "FullScreen", false}, + {"ZOOMPLUS", Common::KEYCODE_F14, 0, "Zoom+", false}, + {"ZOOMMINUS", Common::KEYCODE_F15, 0, "Zoom-", false}, + + {0, Common::KEYCODE_INVALID, 0, 0, false} +}; + +#ifdef ENABLE_KEYMAPPER +Common::HardwareInputSet *OSystem_SDL_Maemo::getHardwareInputSet() { + return new Common::HardwareInputSet(true, maemoKeys); +} + +Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() { + using namespace Common; + Keymap *globalMap = new Keymap("maemo"); + + Action *act; + + act = new Action(globalMap, "CLKM", _("Click Mode")); + Event evt = Event(); + evt.type = EVENT_CUSTOM_BACKEND_ACTION; + evt.customType = Maemo::kEventClickMode; + act->addEvent(evt); + + act = new Action(globalMap, "LCLK", _("Left Click")); + act->addLeftClickEvent(); + + act = new Action(globalMap, "MCLK", _("Middle Click")); + act->addMiddleClickEvent(); + + act = new Action(globalMap, "RCLK", _("Right Click")); + act->addRightClickEvent(); + + return globalMap; +} +#endif + +void OSystem_SDL_Maemo::initObserver() { + assert(_eventManager); + _eventManager->getEventDispatcher()->registerObserver(_eventObserver, 10, false); +} + } //namespace Maemo #endif diff --git a/backends/platform/maemo/maemo.h b/backends/platform/maemo/maemo.h index e42936ddf0..43bc262ade 100644 --- a/backends/platform/maemo/maemo.h +++ b/backends/platform/maemo/maemo.h @@ -29,24 +29,36 @@ #include "backends/platform/maemo/maemo-common.h" namespace Maemo { +class MaemoSdlEventObserver; class OSystem_SDL_Maemo : public OSystem_POSIX { public: OSystem_SDL_Maemo(); + ~OSystem_SDL_Maemo(); virtual void initBackend(); virtual void quit(); virtual void fatalError(); virtual void setWindowCaption(const char *caption); + virtual void setupIcon(); +#ifdef ENABLE_KEYMAPPER + virtual Common::HardwareInputSet *getHardwareInputSet(); + virtual Common::Keymap *getGlobalKeymap(); + virtual Common::KeymapperDefaultBindings *getKeymapperDefaultBindings() { return _keymapperDefaultBindings; } +#endif Model getModel() { return _model; } private: virtual void setXWindowName(const char *caption); + void initObserver(); const Model detectModel(); Model _model; - + MaemoSdlEventObserver *_eventObserver; +#ifdef ENABLE_KEYMAPPER + Common::KeymapperDefaultBindings *_keymapperDefaultBindings; +#endif }; } // namespace Maemo diff --git a/backends/platform/n64/osys_n64_utilities.cpp b/backends/platform/n64/osys_n64_utilities.cpp index 94d727e421..f007a1bd25 100644 --- a/backends/platform/n64/osys_n64_utilities.cpp +++ b/backends/platform/n64/osys_n64_utilities.cpp @@ -100,9 +100,9 @@ void refillAudioBuffers(void) { Audio::MixerImpl *localmixer = (Audio::MixerImpl *)osys->getMixer(); while (_requiredSoundSlots) { - sndBuf = (byte*)getAIBuffer(); + sndBuf = (byte *)getAIBuffer(); - localmixer->mixCallback((byte*)sndBuf, osys->_audioBufferSize); + localmixer->mixCallback((byte *)sndBuf, osys->_audioBufferSize); putAIBuffer(); diff --git a/backends/platform/n64/portdefs.h b/backends/platform/n64/portdefs.h index 677ad48477..10f5ed6488 100644 --- a/backends/platform/n64/portdefs.h +++ b/backends/platform/n64/portdefs.h @@ -31,6 +31,7 @@ #include <stdio.h> #include <ctype.h> #include <math.h> +#include <new> #undef assert #define assert(x) ((x) ? 0 : (print_error("ASSERT TRIGGERED:\n\n("#x")\n%s\nline: %d", __FILE__, __LINE__))) diff --git a/backends/platform/openpandora/build/PXML.xml b/backends/platform/openpandora/build/PXML.xml deleted file mode 100755 index a87c49e2b8..0000000000 --- a/backends/platform/openpandora/build/PXML.xml +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<PXML xmlns="http://openpandora.org/namespaces/PXML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PXML_schema.xsd"> - <!-- This is the package, in our case ScummVM --> - <package id="scummvm.djwillis.0001"> - <author name="DJWillis" website="http://www.scummvm.org/"/> - <!-- version type can be alpha, beta or release, set to release in branch --> - <version major="1" minor="4" release="0" build="1" type="alpha"/> - <!-- Both title and titles are needed --> - <title lang="en_US">ScummVM</title> - <titles> - <title lang="en_US">ScummVM</title> - </titles> - <descriptions> - <description lang="en_US"> - ScummVM is a program which allows you to run certain classic graphical point-and-click adventure games, provided you already have their data files. The clever part about this: ScummVM just replaces the executables shipped with the games, allowing you to play them on systems for which they were never designed! - - ScummVM supports many adventure games, including LucasArts SCUMM games (such as Monkey Island 1-3, Day of the Tentacle, Sam & Max, ...), many of Sierra's AGI and SCI games (such as King's Quest 1-6, Space Quest 1-5, ...), Discworld 1 and 2, Simon the Sorcerer 1 and 2, Beneath A Steel Sky, Lure of the Temptress, Broken Sword 1 and 2, Flight of the Amazon Queen, Gobliiins 1-3, The Legend of Kyrandia 1-3, many of Humongous Entertainment's children's SCUMM games (including Freddi Fish and Putt Putt games) and many more. - </description> - </descriptions> - <icon src="icon/scummvm.png"/> - </package> - - <!-- This is the application, the ScummVM binary --> - <application id="scummvm.djwillis.0001" appdata="scummvm"> - <exec command="./runscummvm.sh"/> - <author name="DJWillis" website="http://www.scummvm.org/"/> - <!-- version type can be alpha, beta or release, set to release in branch --> - <version major="1" minor="4" release="0" build="1" type="alpha"/> - <!-- Both title and titles are needed --> - <title lang="en_US">ScummVM</title> - <titles> - <title lang="en_US">ScummVM</title> - </titles> - <descriptions> - <description lang="en_US"> - ScummVM is a program which allows you to run certain classic graphical point-and-click adventure games, provided you already have their data files. The clever part about this: ScummVM just replaces the executables shipped with the games, allowing you to play them on systems for which they were never designed! - - ScummVM supports many adventure games, including LucasArts SCUMM games (such as Monkey Island 1-3, Day of the Tentacle, Sam & Max, ...), many of Sierra's AGI and SCI games (such as King's Quest 1-6, Space Quest 1-5, ...), Discworld 1 and 2, Simon the Sorcerer 1 and 2, Beneath A Steel Sky, Lure of the Temptress, Broken Sword 1 and 2, Flight of the Amazon Queen, Gobliiins 1-3, The Legend of Kyrandia 1-3, many of Humongous Entertainment's children's SCUMM games (including Freddi Fish and Putt Putt games) and many more. - </description> - </descriptions> - <licenses> - <license name="GPLv2" url="http://www.gnu.org/licenses/gpl-2.0.html" sourcecodeurl="http://www.scummvm.org"/> - </licenses> - <icon src="icon/scummvm.png"/> - <previewpics> - <pic src="icon/preview-pic.png"/> - </previewpics> - <info name="ScummVM Documentation" type="text/html" src="docs/index.html"/> - <categories> - <category name="Game"> - <subcategory name="AdventureGame"/> - </category> - </categories> - </application> -</PXML> diff --git a/backends/platform/openpandora/build/PXML_schema.xsd b/backends/platform/openpandora/build/PXML_schema.xsd deleted file mode 100644 index 7c0d635016..0000000000 --- a/backends/platform/openpandora/build/PXML_schema.xsd +++ /dev/null @@ -1,341 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<xs:schema targetNamespace="http://openpandora.org/namespaces/PXML" xmlns="http://openpandora.org/namespaces/PXML" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified"> - - - <!-- declare some simpleTypes for later usage --> - - <!-- Specify params allows with the 'x11' entry in exec --> - <xs:simpleType name="x11Param"> - <xs:restriction base="xs:string"> - <xs:enumeration value="req" /> - <xs:enumeration value="stop" /> - <xs:enumeration value="ignore" /> - </xs:restriction> - </xs:simpleType> - - <!-- Specify the valid documentation formats in the <info> block --> - <xs:simpleType name="docType"> - <xs:restriction base="xs:string"> - <xs:enumeration value="text/html" /> - <xs:enumeration value="text/plain" /> - </xs:restriction> - </xs:simpleType> - - <!-- Make sure that version numbers only consist of letters, numbers and + as well as - --> - <xs:simpleType name="versionNumber"> - <xs:restriction base="xs:string"> - <xs:minLength value="1"/> - <xs:pattern value="[a-zA-Z0-9+-]*" /> - </xs:restriction> - </xs:simpleType> - - <!-- Specify what is valid as release type --> - <xs:simpleType name="releaseType"> - <xs:restriction base="xs:string"> - <xs:enumeration value="alpha" /> - <xs:enumeration value="beta" /> - <xs:enumeration value="release" /> - </xs:restriction> - </xs:simpleType> - - <!-- Specify what makes an email address "valid" --> - <xs:simpleType name="emailAddress"> - <xs:restriction base="xs:string"> - <xs:pattern value="[^@]+@[^\.]+\..+"/> - </xs:restriction> - </xs:simpleType> - - <!-- some restrictions regarding file names that are eg not allowed/possible when using sd cards formated as fat32 --> - <xs:simpleType name="dumbPath"> - <xs:restriction base="xs:normalizedString"> - <xs:pattern value="[^?>:]+" /> - </xs:restriction> - </xs:simpleType> - <xs:simpleType name="dumbFolderName"> - <xs:restriction base="xs:normalizedString"> - <xs:pattern value="[^?>:/]+" /> - </xs:restriction> - </xs:simpleType> - - <!-- Specify lang codes --> - <xs:simpleType name="isoLangcode"> - <xs:restriction base="xs:string"> - <xs:minLength value="2"/> - <xs:pattern value="[a-zA-Z]{2,3}(_[a-zA-Z0-9]{2,3})*" /> - </xs:restriction> - </xs:simpleType> - <xs:simpleType name="isoLangcode_en_US"> - <xs:restriction base="xs:string"> - <xs:enumeration value="en_US" /> - </xs:restriction> - </xs:simpleType> - - <!-- Definition of all allowed categories following the FDO specs --> - <xs:simpleType name="fdoCategory"> - <xs:restriction base="xs:string"> - <xs:pattern value="AudioVideo|Audio|Video|Development|Education|Game|Graphics|Network|Office|Settings|System|Utility"/> - </xs:restriction> - </xs:simpleType> - <!-- Definition of all allowed subcategories following the FDO specs (should be based upon the given main categories, but would significantly increase complexity of the schema) --> - <xs:simpleType name="fdoSubCategory"> - <xs:restriction base="xs:string"> - <xs:pattern value="Building|Debugger|IDE|GUIDesigner|Profiling|RevisionControl|Translation|Calendar|ContactManagement|Database|Dictionary|Chart|Email|Finance|FlowChart|PDA|ProjectManagement|Presentation|Spreadsheet|WordProcessor|2DGraphics|VectorGraphics|RasterGraphics|3DGraphics|Scanning|OCR|Photography|Publishing|Viewer|TextTools|DesktopSettings|HardwareSettings|Printing|PackageManager|Dialup|InstantMessaging|Chat|IRCClient|FileTransfer|HamRadio|News|P2P|RemoteAccess|Telephony|TelephonyTools|VideoConference|WebBrowser|WebDevelopment|Midi|Mixer|Sequencer|Tuner|TV|AudioVideoEditing|Player|Recorder|DiscBurning|ActionGame|AdventureGame|ArcadeGame|BoardGame|BlocksGame|CardGame|KidsGame|LogicGame|RolePlaying|Simulation|SportsGame|StrategyGame|Art|Construction|Music|Languages|Science|ArtificialIntelligence|Astronomy|Biology|Chemistry|ComputerScience|DataVisualization|Economy|Electricity|Geography|Geology|Geoscience|History|ImageProcessing|Literature|Math|NumericalAnalysis|MedicalSoftware|Physics|Robotics|Sports|ParallelComputing|Amusement|Archiving|Compression|Electronics|Emulator|Engineering|FileTools|FileManager|TerminalEmulator|Filesystem|Monitor|Security|Accessibility|Calculator|Clock|TextEditor|Documentation|Core|KDE|GNOME|GTK|Qt|Motif|Java|ConsoleOnly"/> - </xs:restriction> - </xs:simpleType> - - <!-- Create some way to enforce entries to be nonempty --> - <xs:simpleType name="nonempty_token"> - <xs:restriction base="xs:token"> - <xs:minLength value="1"/> - </xs:restriction> - </xs:simpleType> - <xs:simpleType name="nonempty_string"> - <xs:restriction base="xs:string"> - <xs:minLength value="1"/> - </xs:restriction> - </xs:simpleType> - <xs:simpleType name="nonempty_normalizedString"> - <xs:restriction base="xs:string"> - <xs:minLength value="1"/> - </xs:restriction> - </xs:simpleType> - - - - <!-- declare some complexTypes for later usage --> - - <!-- type used for file associations --> - <xs:complexType name="association_data"> - <xs:attribute name="name" use="required" type="nonempty_normalizedString" /> - <xs:attribute name="filetype" use="required" type="nonempty_token" /> - <xs:attribute name="exec" use="required" type="nonempty_token" /> - </xs:complexType> - - <!-- type used for author info --> - <xs:complexType name="author_data"> - <xs:attribute name="name" use="required" type="nonempty_normalizedString" /> - <xs:attribute name="website" use="optional" type="xs:anyURI" /> - <xs:attribute name="email" use="optional" type="emailAddress" /> - </xs:complexType> - - <!-- type used for version informations (full entry as well as os version) --> - <xs:complexType name="app_version_info"> - <xs:attribute name="major" use="required" type="versionNumber" /> - <xs:attribute name="minor" use="required" type="versionNumber" /> - <xs:attribute name="release" use="required" type="versionNumber" /> - <xs:attribute name="build" use="required" type="versionNumber" /> - <xs:attribute name="type" use="optional" type="releaseType" /> - </xs:complexType> - <xs:complexType name="os_version_info"> - <xs:attribute name="major" use="required" type="versionNumber" /> - <xs:attribute name="minor" use="required" type="versionNumber" /> - <xs:attribute name="release" use="required" type="versionNumber" /> - <xs:attribute name="build" use="required" type="versionNumber" /> - </xs:complexType> - - <!-- type used for exec entries --> - <xs:complexType name="exec_params"> - <xs:attribute name="command" use="required" type="nonempty_token" /> - <xs:attribute name="arguments" use="optional" type="nonempty_token" /> - <xs:attribute name="background" use="optional" type="xs:boolean" /> - <xs:attribute name="startdir" use="optional" type="dumbPath" /> - <xs:attribute name="standalone" use="optional" type="xs:boolean" /> - <xs:attribute name="x11" use="optional" type="x11Param" /> - </xs:complexType> - - <!-- type used for tiles or descriptions, once in 'normal' version, once enforcing usage of en_US --> - <xs:complexType name="title_or_description"> - <xs:simpleContent> - <xs:extension base="nonempty_string"> - <xs:attribute name="lang" use="required" type="isoLangcode" /> - </xs:extension> - </xs:simpleContent> - </xs:complexType> - <xs:complexType name="title_or_description_enUS"> - <xs:simpleContent> - <xs:extension base="nonempty_string"> - <xs:attribute name="lang" use="required" type="isoLangcode_en_US" /> - </xs:extension> - </xs:simpleContent> - </xs:complexType> - - <!-- type used for referencing images --> - <xs:complexType name="image_entry"> - <xs:attribute name="src" use="required" type="dumbPath" /> - </xs:complexType> - - <!-- type for referencing manuals/readme docs --> - <xs:complexType name="information_entry"> - <xs:attribute name="name" use="required" type="nonempty_normalizedString" /> - <xs:attribute name="type" use="required" type="docType" /> - <xs:attribute name="src" use="required" type="dumbPath" /> - </xs:complexType> - - <!-- type used for the license information --> - <xs:complexType name="license_info"> - <xs:attribute name="name" use="required" type="nonempty_normalizedString" /> - <xs:attribute name="url" use="optional" type="xs:anyURI" /> - <xs:attribute name="sourcecodeurl" use="optional" type="xs:anyURI" /> - </xs:complexType> - - - - <!-- Combine the symple and complex types into the "real" PXML specification --> - - <xs:element name="PXML"> - <xs:complexType> - <xs:sequence> - <!-- specify the <package> tag with info about the complete package, information providable: - author - version - title(s) - description(s) - icon - --> - <xs:element name="package" minOccurs="1" maxOccurs="1"> - <xs:complexType> - <xs:all> - <!--Author info--> - <xs:element name="author" type="author_data" minOccurs="1" /> - <!--App version info--> - <xs:element name="version" type="app_version_info" minOccurs="1" /> - <!--Title--> - <xs:element name="titles" minOccurs="1"> - <xs:complexType> - <xs:sequence> - <xs:element name="title" type="title_or_description_enUS" minOccurs="1" maxOccurs="1" /> - <xs:element name="title" type="title_or_description" minOccurs="0" maxOccurs="unbounded" /> - </xs:sequence> - </xs:complexType> - </xs:element> - <!--Description--> - <xs:element name="descriptions" minOccurs="0"> - <xs:complexType> - <xs:sequence> - <xs:element name="title" type="title_or_description_enUS" minOccurs="0" maxOccurs="1" /> - <xs:element name="description" type="title_or_description" minOccurs="0" maxOccurs="unbounded" /> - </xs:sequence> - </xs:complexType> - </xs:element> - <!--Icon--> - <xs:element name="icon" type="image_entry" minOccurs="0" /> - </xs:all> - <!--Package ID--> - <xs:attribute name="id" use="required" type="dumbFolderName" /> - </xs:complexType> - </xs:element> - <!-- specify the <application> tag with info about a single program - executable call - author - version (of the application) - osversion (min OS version supported) - title(s) (allowing compatibility to <HF6, too!) - description(s) (allowing compatibility to <HF6, too!) - icon - license - preview pictures - info/manual/readme entry - categories - associations to file types - clockspeed - --> - <xs:element name="application" minOccurs="1" maxOccurs="unbounded"> - <xs:complexType> - <xs:all> - <!--Execution params --> - <xs:element name="exec" type="exec_params" minOccurs="1" /> - <!--Author info--> - <xs:element name="author" type="author_data" minOccurs="1" /> - <!--App version info--> - <xs:element name="version" type="app_version_info" minOccurs="1" /> - <!--OS Version info--> - <xs:element name="osversion" type="os_version_info" minOccurs="0" /> - <!--Title--> - <!-- via <titles> element, used for HF6+ --> - <xs:element name="titles" minOccurs="1"> - <xs:complexType> - <xs:sequence> - <xs:element name="title" type="title_or_description_enUS" minOccurs="1" maxOccurs="1" /> - <xs:element name="title" type="title_or_description" minOccurs="0" maxOccurs="unbounded" /> - </xs:sequence> - </xs:complexType> - </xs:element> - <!--Title--> - <!-- via <title> element, only one for en_US allowed, meant for backwards compatibility with libpnd from <HF6 --> - <xs:element name="title" type="title_or_description_enUS" minOccurs="0" /> - <!--Description--> - <!-- via <descriptions> element, used for HF6+ --> - <xs:element name="descriptions" minOccurs="0"> - <xs:complexType> - <xs:sequence> - <xs:element name="description" type="title_or_description_enUS" minOccurs="1" maxOccurs="1" /> - <xs:element name="description" type="title_or_description" minOccurs="0" maxOccurs="unbounded" /> - </xs:sequence> - </xs:complexType> - </xs:element> - <!--Description--> - <!-- via <description> element, only one for en_US allowed, meant for backwards compatibility with libpnd from <HF6 --> - <xs:element name="description" type="title_or_description_enUS" minOccurs="0" /> - <!--Icon--> - <xs:element name="icon" type="image_entry" minOccurs="0" /> - <!--License--> - <xs:element name="licenses" minOccurs="1"> - <xs:complexType> - <xs:sequence> - <xs:element name="license" type="license_info" minOccurs="1" maxOccurs="unbounded" /> - </xs:sequence> - </xs:complexType> - </xs:element> - <!--Preview pics--> - <xs:element name="previewpics" minOccurs="0"> - <xs:complexType> - <xs:sequence> - <xs:element name="pic" type="image_entry" minOccurs="0" maxOccurs="unbounded" /> - </xs:sequence> - </xs:complexType> - </xs:element> - <!--Info (aka manual or readme entry)--> - <xs:element name="info" type="information_entry" minOccurs="0" /> - <!--Categories--> - <xs:element name="categories" minOccurs="1"> - <xs:complexType> - <xs:sequence> - <xs:element name="category" minOccurs="1" maxOccurs="unbounded"> - <xs:complexType> - <xs:sequence> - <xs:element name="subcategory" minOccurs="0" maxOccurs="unbounded"> - <xs:complexType> - <xs:attribute name="name" type="fdoSubCategory" /> - </xs:complexType> - </xs:element> - </xs:sequence> - <xs:attribute name="name" use="required" type="fdoCategory" /> - </xs:complexType> - </xs:element> - </xs:sequence> - </xs:complexType> - </xs:element> - <!--Associations--> - <xs:element name="associations" minOccurs="0"> - <xs:complexType> - <xs:sequence> - <xs:element name="association" type="association_data" maxOccurs="unbounded" /> - </xs:sequence> - </xs:complexType> - </xs:element> - <!--Clockspeed--> - <xs:element name="clockspeed" minOccurs="0"> - <xs:complexType> - <xs:attribute name="frequency" use="required" type="xs:positiveInteger" /> - </xs:complexType> - </xs:element> - </xs:all> - <!--AppID--> - <xs:attribute name="id" use="required" type="dumbFolderName" /> - <xs:attribute name="appdata" use="optional" type="dumbFolderName" /> - </xs:complexType> - </xs:element> - </xs:sequence> - </xs:complexType> - </xs:element> -</xs:schema> diff --git a/backends/platform/openpandora/build/README-OPENPANDORA b/backends/platform/openpandora/build/README-OPENPANDORA deleted file mode 100755 index c8aabcbb7a..0000000000 --- a/backends/platform/openpandora/build/README-OPENPANDORA +++ /dev/null @@ -1,19 +0,0 @@ -ScummVM - OPENPANDORA SPECIFIC README ------------------------------------------------------------------------- -Please refer to the: - -ScummVM Forum: <http://forums.scummvm.org/> -WiKi: <http://wiki.scummvm.org/index.php/OpenPandora> - -for the most current information on the port and any updates to this -documentation. - -The wiki includes detailed instructions on how to use the port and -control information. - ------------------------------------------------------------------------- -Credits - -Core ScummVM code (c) The ScummVM Team -OpenPandora backend (c) John Willis -Detailed (c) information can be found within the source code diff --git a/backends/platform/openpandora/build/README-PND.txt b/backends/platform/openpandora/build/README-PND.txt deleted file mode 100755 index 942c3a43e2..0000000000 --- a/backends/platform/openpandora/build/README-PND.txt +++ /dev/null @@ -1,38 +0,0 @@ -ScummVM - OPENPANDORA README - HOW TO INSTALL ------------------------------------------------------------------------- - -Please refer to the: - -ScummVM Forum: <http://forums.scummvm.org/> -WiKi: <http://wiki.scummvm.org/index.php/OpenPandora> - -for the most current information on the port and any updates to this -documentation. - ------------------------------------------------------------------------- -Installing: - -This archive contains ScummVM in a PND format ready to be copied to the -OpenPandora and used. - -To install just copy the .pnd file from this archive to your device. - -You will need to place the .pnd file in a suitable location on your SD -card. - -/pandora/desktop <- place here if you wish the icon to show on the - desktop. Documentation will show in the menu. - -/pandora/menu <- place here if you wish the icon to show on the - Xfce menu. Documentation will show in the menu. - -/pandora/apps <- place here if you wish the icon to show on the - desktop and in the menu. Documentation will show - in the menu. - ------------------------------------------------------------------------- -Credits - -Core ScummVM code (c) The ScummVM Team -OpenPandora backend (c) John Willis -Detailed (c) information can be found within the source code diff --git a/backends/platform/openpandora/build/icon/preview-pic.png b/backends/platform/openpandora/build/icon/preview-pic.png Binary files differdeleted file mode 100755 index 2f4a536d30..0000000000 --- a/backends/platform/openpandora/build/icon/preview-pic.png +++ /dev/null diff --git a/backends/platform/openpandora/build/icon/scummvm.png b/backends/platform/openpandora/build/icon/scummvm.png Binary files differdeleted file mode 100755 index 128e59efc4..0000000000 --- a/backends/platform/openpandora/build/icon/scummvm.png +++ /dev/null diff --git a/backends/platform/openpandora/build/index.html b/backends/platform/openpandora/build/index.html deleted file mode 100755 index 34d381d0f8..0000000000 --- a/backends/platform/openpandora/build/index.html +++ /dev/null @@ -1,26 +0,0 @@ -<html> - -<h3> - <p>Welcome to the ScummVM!</p> -</h3> - -<h4> - <p>ScummVM: OpenPandora Specific Documentation</p> -</h4> - -<A href="docs/README-OPENPANDORA">ScummVM OpenPandora README</a><br/> -<A href="http://scummvm.distant-earth.com/">ScummVM OpenPandora Website</a><br/> -<A href="http://wiki.scummvm.org/index.php/OpenPandora">ScummVM OpenPandora WiKi</a><br/> - -<h4> - <p>ScummVM: General Documentation</p> -</h4> - -<A href="http://www.scummvm.org/">ScummVM website</a><br/> -<A href="docs/README">ScummVM README</a><br/> -<A href="docs/NEWS">ScummVM NEWS</a><br/> -<A href="docs/AUTHORS">ScummVM Authors</a><br/> -<A href="docs/COPYRIGHT">ScummVM Copyright</a><br/> -<A href="docs/COPYING">GPL Licence</a><br/> - -</html> diff --git a/backends/platform/openpandora/build/pnd_make.sh b/backends/platform/openpandora/build/pnd_make.sh deleted file mode 100755 index 0c03e8154d..0000000000 --- a/backends/platform/openpandora/build/pnd_make.sh +++ /dev/null @@ -1,321 +0,0 @@ -#!/bin/bash -# -# pnd_make.sh -# -# This script is meant to ease generation of a pnd file. Please consult the output -# when running --help for a list of available parameters and an explaination of -# those. -# -# Required tools when running the script: -# bash -# echo, cat, mv, rm -# mkisofs or mksquashfs (the latter when using the -c param!) -# xmllint (optional, only for validation of the PXML against the schema) - - -PXML_schema=$(dirname ${0})/PXML_schema.xsd -GENPXML_PATH=$(dirname ${0})/genpxml.sh - -# useful functions ... -black='\E[30m' -red='\E[31m' -green='\E[32m' -yellow='\E[33m' -blue='\E[34m' -magenta='\E[35m' -cyan='\E[36m' -white='\E[37m' - -check_for_tool() -{ - which $1 &> /dev/null - if [ "$?" -ne "0" ]; - then - cecho "ERROR: Could not find the program '$1'. Please make sure -that it is available in your PATH since it is required to complete your request." $red - exit 1 - fi -} - -cecho () # Color-echo. Argument $1 = message, Argument $2 = color -{ - local default_msg="No message passed." # Doesn't really need to be a local variable. - message=${1:-$default_msg} # Defaults to default message. - color=${2:-$black} # Defaults to black, if not specified. - echo -e "$color$message" - tput sgr0 # Reset to normal. - return -} - - -print_help() -{ - cat << EOSTREAM -pnd_make.sh - A script to package "something" into a PND. - -Usage: - $(basename ${0}) {--directory|-d} <folder> {--pndname|-p} <file> [{--compress-squashfs|-c}] - [{--genpxml} <file>] [{--icon|-i} <file>] [{--pxml|-x} <file>] - [{--schema|-s} <file>] [{--help|-h}] - - -Switches: - --compress-squashfs / -c Define whether or not the pnd should be compressed using - squashfs. If this parameter is selected, a compressed pnd - will be created. - - --directory / -d Sets the folder that is to be used for the resulting pnd - to <folder>. This option is mandatory for the script to - function correctly. - - --genpxml Sets the script used for generating a PXML file (if none - is available already) to <file>. Please make sure to either - provide a full path or prefix a script in the current folder - with './' so that the script can actually be executed. If - this variable is not specified, $GENPXML_PATH - will be used. - - --help / -h Displays this help text. - - --icon / -i Sets the icon that will be appended in the pnd to <file>. - - --pndname / -p Sets the output filename of the resulting pnd to <file>. - This option is mandatory for the script to function - correctly. - - --pxml / -x Sets the PXML file that is to be used to <file>. If you - neither provide a PXML file or set this entry to 'guess', - an existing 'PXML.xml' in your selected '--directory' - will be used, or the script $GENPXML_PATH - will be called to try to generate a basic PXML file for you. - - --schema / -s Sets the schema file, that is to be used for validation, - to <file. If this is not defined, the script will try to - use the file '$PXML_schema'. If this fails, - a warning is issued. - -If you select the option to create a compressed squashfs, a version >=4.0 of squashfs -is required to be available in your PATH. -EOSTREAM -} - - -# Parse command line parameters -while [ "${1}" != "" ]; do - if [ "${1}" = "--compress-squashfs" ] || [ "${1}" = "-c" ]; - then - SQUASH=1 - shift 1 - elif [ "${1}" = "--directory" ] || [ "${1}" = "-d" ]; - then - FOLDER=$2 - shift 2 - elif [ "${1}" = "--genpxml" ]; - then - GENPXML_PATH=$2 - shift 2 - elif [ "${1}" = "--help" ] || [ "${1}" = "-h" ]; - then - print_help - exit 0 - elif [ "${1}" = "--icon" ] || [ "${1}" = "-i" ]; - then - ICON=$2 - shift 2 - elif [ "${1}" = "--pndname" ] || [ "${1}" = "-p" ]; - then - PNDNAME=$2 - shift 2 - elif [ "${1}" = "--pxml" ] || [ "${1}" = "-x" ]; - then - PXML=$2 - shift 2 - elif [ "${1}" = "--schema" ] || [ "${1}" = "-f" ] - then - PXML_schema=$2 - shift 2 - else - cecho "ERROR: '$1' is not a known argument. Printing --help and aborting." $red - print_help - exit 1 - fi -done - - -# Generate a PXML if the param is set to Guess or it is empty. -if [ ! $PXML ] || [ $PXML = "guess" ] && [ $PNDNAME ] && [ $FOLDER ]; -then - if [ -f $FOLDER/PXML.xml ]; # use the already existing PXML.xml file if there is one... - then - PXML=$FOLDER/PXML.xml - PXML_ALREADY_EXISTING="true" - else - if [ -f $GENPXML_PATH ]; - then - $GENPXML_PATH --src $FOLDER --dest $FOLDER --author $USER - if [ -f $FOLDER/PXML.xml ]; - then - PXML_GENERATED="true" - else - cecho "ERROR: Generating a PXML file using '$GENPXML_PATH' failed. -Please generate a PXML file manually." $red - exit 1 - fi - else - cecho "ERROR: Could not find '$GENPXML_PATH' for generating a PXML file." $red - exit 1 - fi - fi -fi - - -# Probe if required variables were set -echo -e -cecho "Checking if all required variables were set." $green -if [ ! $PNDNAME ] || [ ! $FOLDER ] || [ ! $PXML ]; -then - echo -e - cecho "ERROR: Not all required options were set! Please see the --help information below." $red - echo -e - print_help - exit 1 -else - echo "PNDNAME set to '$PNDNAME'." -fi -# Check if the selected folder actually exists -if [ ! -d $FOLDER ]; -then - echo -e - cecho "ERROR: '$FOLDER' doesn't exist or is not a folder." $red - exit 1 -else - echo "FOLDER set to '$FOLDER'." -fi -# Check if the selected PXML file actually exists -if [ ! -f $PXML ]; -then - echo -e - cecho "ERROR: '$PXML' doesn't exist or is not a file." $red - exit 1 -else - if [ $PXML_ALREADY_EXISTING ]; - then - echo "You have not explicitly specified a PXML to use, but an existing file was -found. Will be using this one." - elif [ $PXML_GENERATED ]; - then - echo "A PXML file was generated for you using '$GENPXML_PATH'. This file will -not be removed at the end of this script because you might want to review it, adjust -single entries and rerun the script to generate a pnd with a PXML file with all the -information you want to have listed." - fi - echo "PXML set to '$PXML'." -fi - -# Print the other variables: -if [ $ICON ]; -then - if [ ! -f $ICON ] - then - cecho "WARNING: '$ICON' doesn't exist, will not append the selected icon to the pnd." $red - else - echo "ICON set to '$ICON'." - USE_ICON="true" - fi -fi -if [ $SQUASH ]; -then - echo "Will use a squashfs for '$PNDNAME'." -fi - - -# Validate the PXML file (if xmllint is available) -# Errors and problems in this section will be shown but are not fatal. -echo -e -cecho "Trying to validate '$PXML' now. Will be using '$PXML_schema' to do so." $green -which xmllint &> /dev/null -if [ "$?" -ne "0" ]; -then - VALIDATED=false - cecho "WARNING: Could not find 'xmllint'. Validity check of '$PXML' is not possible!" $red -else - if [ ! -f "$PXML_schema" ]; - then - VALIDATED=false - cecho "WARNING: Could not find '$PXML_schema'. If you want to validate your -PXML file please make sure to provide a schema using the --schema option." $red - else - xmllint --noout --schema $PXML_schema $PXML - if [ "$?" -ne "0" ]; then VALIDATED=false; else VALIDATED=true; fi - fi -fi -# Print some message at the end about the validation in case the user missed the output above -if [ $VALIDATED = "false" ] -then - cecho "WARNING: Could not successfully validate '$PXML'. Please check the output -above. This does not mean that your pnd will be broken. Either you are not following the strict -syntax required for validation or you don't have all files/programs required for validating." $red -else - cecho "Your file '$PXML' was validated successfully. The resulting pnd should -work nicely with libpnd." $green -fi - - -# Make iso from folder -echo -e -cecho "Creating an iso file based on '$FOLDER'." $green -if [ $SQUASH ]; -then - check_for_tool mksquashfs - if [ $(mksquashfs -version | awk 'BEGIN{r=0} $3>=4{r=1} END{print r}') -eq 0 ]; - then - cecho "ERROR: Your squashfs version is older then version 4, please upgrade to 4.0 or later" $red - exit 1 - fi - mksquashfs $FOLDER $PNDNAME.iso -nopad -no-recovery -else - check_for_tool mkisofs - mkisofs -o $PNDNAME.iso -R $FOLDER -fi - -# Check that the iso file was actually created before continuing -if [ ! -f $PNDNAME.iso ]; -then - cecho "ERROR: The temporary file '$PNDNAME.iso' could not be created. -Please check the output above for any errors and retry after fixing them. Aborting." $red - exit 1 -fi - - -# Append pxml to iso -echo -e -cecho "Appending '$PXML' to the created iso file." $green -cat $PNDNAME.iso $PXML > $PNDNAME -rm $PNDNAME.iso #cleanup - - -# Append icon if specified and available -if [ $USE_ICON ]; -then - echo -e - cecho "Appending the icon '$ICON' to the pnd." $green - mv $PNDNAME $PNDNAME.tmp - cat $PNDNAME.tmp $ICON > $PNDNAME # append icon - rm $PNDNAME.tmp #cleanup -fi - - -# Final message -echo -e -if [ -f $PNDNAME ]; -then - cecho "Successfully finished creating the pnd '$PNDNAME'." $green -else - cecho "There seems to have been a problem and '$PNDNAME' was not created. Please check -the output above for any error messages. A possible cause for this is that there was -not enough space available." $red - exit 1 -fi - - -#if [ $PXML = "guess" ];then rm $FOLDER/PXML.xml; fi #cleanup diff --git a/backends/platform/openpandora/build/runscummvm.sh b/backends/platform/openpandora/build/runscummvm.sh deleted file mode 100755 index 9c9d8362cb..0000000000 --- a/backends/platform/openpandora/build/runscummvm.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -# Make sure any extra libs not in the firmware are pulled in. -LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../lib -export LD_LIBRARY_PATH - -# Ensure we have a folder to store save games on the SD card. -mkdir saves - -# make a runtime dir, just incase it creates anything in CWD -mkdir runtime -cd runtime - -../bin/scummvm --fullscreen --gfx-mode=2x --config=../scummvm.config --themepath=../data diff --git a/backends/platform/openpandora/op-bundle.mk b/backends/platform/openpandora/op-bundle.mk index 089430f43c..284a0497a8 100755 --- a/backends/platform/openpandora/op-bundle.mk +++ b/backends/platform/openpandora/op-bundle.mk @@ -14,15 +14,15 @@ op-bundle: $(EXECUTABLE) $(MKDIR) "$(bundle_name)/scummvm/icon" $(MKDIR) "$(bundle_name)/scummvm/lib" - $(CP) $(srcdir)/backends/platform/openpandora/build/runscummvm.sh $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/openpandora/build/PXML.xml $(bundle_name)/scummvm/data/ + $(CP) $(srcdir)/dists/openpandora/runscummvm.sh $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/openpandora/PXML.xml $(bundle_name)/scummvm/data/ - $(CP) $(srcdir)/backends/platform/openpandora/build/icon/scummvm.png $(bundle_name)/scummvm/icon/ - $(CP) $(srcdir)/backends/platform/openpandora/build/icon/preview-pic.png $(bundle_name)/scummvm/icon/ + $(CP) $(srcdir)/dists/openpandora/icon/scummvm.png $(bundle_name)/scummvm/icon/ + $(CP) $(srcdir)/dists/openpandora/icon/preview-pic.png $(bundle_name)/scummvm/icon/ - $(CP) $(srcdir)/backends/platform/openpandora/build/README-OPENPANDORA $(bundle_name)/scummvm/docs/ - $(CP) $(srcdir)/backends/platform/openpandora/build/index.html $(bundle_name)/scummvm/docs/ + $(CP) $(srcdir)/dists/openpandora/README-OPENPANDORA $(bundle_name)/scummvm/docs/ + $(CP) $(srcdir)/dists/openpandora/index.html $(bundle_name)/scummvm/docs/ $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/docs/ @@ -50,15 +50,15 @@ op-pnd: $(EXECUTABLE) $(MKDIR) "$(bundle_name)/scummvm/icon" $(MKDIR) "$(bundle_name)/scummvm/lib" - $(CP) $(srcdir)/backends/platform/openpandora/build/runscummvm.sh $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/openpandora/build/PXML.xml $(bundle_name)/scummvm/data/ + $(CP) $(srcdir)/dists/openpandora/runscummvm.sh $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/openpandora/PXML.xml $(bundle_name)/scummvm/data/ - $(CP) $(srcdir)/backends/platform/openpandora/build/icon/scummvm.png $(bundle_name)/scummvm/icon/ - $(CP) $(srcdir)/backends/platform/openpandora/build/icon/preview-pic.png $(bundle_name)/scummvm/icon/ + $(CP) $(srcdir)/dists/openpandora/icon/scummvm.png $(bundle_name)/scummvm/icon/ + $(CP) $(srcdir)/dists/openpandora/icon/preview-pic.png $(bundle_name)/scummvm/icon/ - $(CP) $(srcdir)/backends/platform/openpandora/build/README-OPENPANDORA $(bundle_name)/scummvm/docs/ - $(CP) $(srcdir)/backends/platform/openpandora/build/index.html $(bundle_name)/scummvm/docs/ + $(CP) $(srcdir)/dists/openpandora/README-OPENPANDORA $(bundle_name)/scummvm/docs/ + $(CP) $(srcdir)/dists/openpandora/index.html $(bundle_name)/scummvm/docs/ $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/docs/ @@ -75,9 +75,10 @@ endif $(CP) $(libloc)/../arm-angstrom-linux-gnueabi/usr/lib/libFLAC.so.8.2.0 $(bundle_name)/scummvm/lib/libFLAC.so.8 - $(srcdir)/backends/platform/openpandora/build/pnd_make.sh -p $(bundle_name).pnd -c -d $(bundle_name)/scummvm -x $(bundle_name)/scummvm/data/PXML.xml -i $(bundle_name)/scummvm/icon/scummvm.png + $(srcdir)/dists/openpandora/pnd_make.sh -p $(bundle_name).pnd -c -d $(bundle_name)/scummvm -x $(bundle_name)/scummvm/data/PXML.xml -i $(bundle_name)/scummvm/icon/scummvm.png + + $(CP) $(srcdir)/dists/openpandora/README-PND.txt $(bundle_name) - $(CP) $(srcdir)/backends/platform/openpandora/build/README-PND.txt $(bundle_name) tar -cvjf $(bundle_name)-pnd.tar.bz2 $(bundle_name).pnd $(bundle_name)/README-PND.txt rm -R ./$(bundle_name) diff --git a/backends/platform/ps2/DmaPipe.cpp b/backends/platform/ps2/DmaPipe.cpp index c6f6ab72ac..a346a67566 100644 --- a/backends/platform/ps2/DmaPipe.cpp +++ b/backends/platform/ps2/DmaPipe.cpp @@ -48,7 +48,7 @@ private: DmaPipe::DmaPipe(uint32 size) { size &= ~0x1F; - _buf = (uint64*)memalign(64, size); + _buf = (uint64 *)memalign(64, size); _curPipe = 0; _pipes[0] = new SinglePipe(_buf, size >> 4); _pipes[1] = new SinglePipe(_buf + (size >> 4), size >> 4); @@ -260,7 +260,7 @@ void SinglePipe::init(void) { _buf[0] = 0x0000000070000000; _buf[1] = 0; _chainHead = _buf; - _chainSize = (uint16*)_chainHead; + _chainSize = (uint16 *)_chainHead; _bufPos = _buf + 2; } @@ -272,7 +272,7 @@ void SinglePipe::appendChain(uint64 dmaTag) { _chainHead = _bufPos; _chainHead[0] = dmaTag; _chainHead[1] = 0; - _chainSize = (uint16*)_chainHead; + _chainSize = (uint16 *)_chainHead; _bufPos += 2; } diff --git a/backends/platform/ps2/Gs2dScreen.cpp b/backends/platform/ps2/Gs2dScreen.cpp index ddc1bdf668..8df6198c38 100644 --- a/backends/platform/ps2/Gs2dScreen.cpp +++ b/backends/platform/ps2/Gs2dScreen.cpp @@ -130,9 +130,9 @@ Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode tvMode) { _height = height; _pitch = (width + 127) & ~127; - _screenBuf = (uint8*)memalign(64, _width * _height); - _overlayBuf = (uint16*)memalign(64, _width * _height * 2); - _clut = (uint32*)memalign(64, 256 * 4); + _screenBuf = (uint8 *)memalign(64, _width * _height); + _overlayBuf = (uint16 *)memalign(64, _width * _height * 2); + _clut = (uint32 *)memalign(64, 256 * 4); memset(_screenBuf, 0, _width * _height); memset(_clut, 0, 256 * sizeof(uint32)); @@ -291,11 +291,11 @@ void Gs2dScreen::quit(void) { } void Gs2dScreen::createAnimTextures(void) { - uint8 *buf = (uint8*)memalign(64, 16 * 64); + uint8 *buf = (uint8 *)memalign(64, 16 * 64); memset(buf, 0, 16 * 64); uint32 vramDest = _texPtrs[TEXT]; for (int i = 0; i < 16; i++) { - uint32 *destPos = (uint32*)buf; + uint32 *destPos = (uint32 *)buf; for (int ch = 15; ch >= 0; ch--) { const uint32 *src = (const uint32*)(_binaryData + ((_binaryPattern[i] >> ch) & 1) * 4 * 14); for (int line = 0; line < 14; line++) @@ -331,8 +331,8 @@ void Gs2dScreen::newScreenSize(uint16 width, uint16 height) { // malloc new buffers free(_screenBuf); free(_overlayBuf); - _screenBuf = (uint8*)memalign(64, _width * _height); - _overlayBuf = (uint16*)memalign(64, _width * _height * 2); + _screenBuf = (uint8 *)memalign(64, _width * _height); + _overlayBuf = (uint16 *)memalign(64, _width * _height * 2); memset(_screenBuf, 0, _width * height); memset(_overlayBuf, 0, _width * height * 2); memset(_clut, 0, 256 * sizeof(uint32)); @@ -437,14 +437,6 @@ void Gs2dScreen::grabPalette(uint8 *pal, uint8 start, uint16 num) { } } -void Gs2dScreen::grabScreen(Graphics::Surface *surf) { - assert(surf); - WaitSema(g_DmacSema); - surf->create(_width, _height, Graphics::PixelFormat::createFormatCLUT8()); - memcpy(surf->pixels, _screenBuf, _width * _height); - SignalSema(g_DmacSema); -} - void Gs2dScreen::uploadToVram(void) { if (_clutChanged) { _clutChanged = false; @@ -564,7 +556,7 @@ void Gs2dScreen::copyPrintfOverlay(const uint8 *buf) { } void Gs2dScreen::clearPrintfOverlay(void) { - uint8 *tmpBuf = (uint8*)memalign(64, 320 * 200); + uint8 *tmpBuf = (uint8 *)memalign(64, 320 * 200); memset(tmpBuf, 4, 320 * 200); _dmaPipe->uploadTex(_texPtrs[PRINTF], 3 * 128, 0, 0, GS_PSMT8H, tmpBuf, 320, 200); _dmaPipe->flush(); @@ -627,7 +619,7 @@ void Gs2dScreen::setMouseOverlay(const uint8 *buf, uint16 width, uint16 height, _mTraCol = transpCol; _clutChanged = true; } - uint8 *bufCopy = (uint8*)memalign(64, M_SIZE * M_SIZE); // make a copy to align to 64 bytes + uint8 *bufCopy = (uint8 *)memalign(64, M_SIZE * M_SIZE); // make a copy to align to 64 bytes memset(bufCopy, _mTraCol, M_SIZE * M_SIZE); for (int cnt = 0; cnt < height; cnt++) memcpy(bufCopy + cnt * M_SIZE, buf + cnt * width, width); diff --git a/backends/platform/ps2/Gs2dScreen.h b/backends/platform/ps2/Gs2dScreen.h index dffdce5b36..4fbb3fdef8 100644 --- a/backends/platform/ps2/Gs2dScreen.h +++ b/backends/platform/ps2/Gs2dScreen.h @@ -42,10 +42,6 @@ enum GsInterlace { }; -namespace Graphics { -struct Surface; -} - class Gs2dScreen { public: Gs2dScreen(uint16 width, uint16 height, TVMode tvMode); @@ -65,7 +61,6 @@ public: void setPalette(const uint8 *pal, uint8 start, uint16 num); void updateScreen(void); void grabPalette(uint8 *pal, uint8 start, uint16 num); - void grabScreen(Graphics::Surface *surf); //- overlay routines void copyOverlayRect(const uint16 *buf, uint16 pitch, uint16 x, uint16 y, uint16 w, uint16 h); void grabOverlay(uint16 *buf, uint16 pitch); diff --git a/backends/platform/ps2/fileio.cpp b/backends/platform/ps2/fileio.cpp index ef01f3a693..1ec16a3817 100644 --- a/backends/platform/ps2/fileio.cpp +++ b/backends/platform/ps2/fileio.cpp @@ -52,7 +52,7 @@ Ps2File::Ps2File() { _eof = false; _err = false; - _cacheBuf = (uint8*)memalign(64, CACHE_SIZE * 2); + _cacheBuf = (uint8 *)memalign(64, CACHE_SIZE * 2); _cacheOpRunning = 0; _filePos = _physFilePos = _cachePos = 0; @@ -362,7 +362,7 @@ uint32 Ps2File::read(void *dest, uint32 len) { _eof = true; } - uint8 *destBuf = (uint8*)dest; + uint8 *destBuf = (uint8 *)dest; if ((_filePos < _cachePos) || (_filePos + len > _cachePos + _bytesInCache)) cacheReadSync(); // we have to read from CD, sync cache. @@ -413,7 +413,7 @@ uint32 Ps2File::read(void *dest, uint32 len) { #ifdef __PS2_FILE_SEMA__ SignalSema(_sema); #endif - return destBuf - (uint8*)dest; + return destBuf - (uint8 *)dest; } uint32 Ps2File::write(const void *src, uint32 len) { @@ -518,7 +518,7 @@ FILE *ps2_fopen(const char *fname, const char *mode) { } int ps2_fclose(FILE *stream) { - Ps2File *file = (Ps2File*)stream; + Ps2File *file = (Ps2File *)stream; delete file; @@ -528,10 +528,10 @@ int ps2_fclose(FILE *stream) { size_t ps2_fread(void *buf, size_t r, size_t n, FILE *stream) { assert(r != 0); - return ((Ps2File*)stream)->read(buf, r * n) / r; + return ((Ps2File *)stream)->read(buf, r * n) / r; } size_t ps2_fwrite(const void *buf, size_t r, size_t n, FILE *stream) { assert(r != 0); - return ((Ps2File*)stream)->write(buf, r * n) / r; + return ((Ps2File *)stream)->write(buf, r * n) / r; } diff --git a/backends/platform/ps2/icon.cpp b/backends/platform/ps2/icon.cpp index 9852e6d40b..bda4843647 100644 --- a/backends/platform/ps2/icon.cpp +++ b/backends/platform/ps2/icon.cpp @@ -960,13 +960,13 @@ void PS2Icon::setup(mcIcon *icon) { memcpy(icon->head, "PS2D", 4); icon->nlOffset = strlen(_info) + 1; strcpy(title, _info); - strcpy_sjis((short*)&(icon->title), title); + strcpy_sjis((short *)&(icon->title), title); icon->trans = 0x10; memcpy(icon->bgCol, _bgcolor, sizeof(_bgcolor)); memcpy(icon->lightDir, _lightdir, sizeof(_lightdir)); memcpy(icon->lightCol, _lightcol, sizeof(_lightcol)); memcpy(icon->lightAmbient, _ambient, sizeof(_ambient)); - strcpy((char*)icon->view, "scummvm.icn"); - strcpy((char*)icon->copy, "scummvm.icn"); - strcpy((char*)icon->del, "scummvm.icn"); + strcpy((char *)icon->view, "scummvm.icn"); + strcpy((char *)icon->copy, "scummvm.icn"); + strcpy((char *)icon->del, "scummvm.icn"); } diff --git a/backends/platform/ps2/ps2mutex.cpp b/backends/platform/ps2/ps2mutex.cpp index 5b30fa7862..ae63fe5724 100644 --- a/backends/platform/ps2/ps2mutex.cpp +++ b/backends/platform/ps2/ps2mutex.cpp @@ -57,7 +57,7 @@ OSystem::MutexRef OSystem_PS2::createMutex(void) { void OSystem_PS2::lockMutex(MutexRef mutex) { WaitSema(_mutexSema); - Ps2Mutex *sysMutex = (Ps2Mutex*)mutex; + Ps2Mutex *sysMutex = (Ps2Mutex *)mutex; int tid = GetThreadId(); assert(tid != 0); @@ -75,7 +75,7 @@ void OSystem_PS2::lockMutex(MutexRef mutex) { void OSystem_PS2::unlockMutex(MutexRef mutex) { WaitSema(_mutexSema); - Ps2Mutex *sysMutex = (Ps2Mutex*)mutex; + Ps2Mutex *sysMutex = (Ps2Mutex *)mutex; int tid = GetThreadId(); if (sysMutex->owner && sysMutex->count && (sysMutex->owner == tid)) @@ -90,7 +90,7 @@ void OSystem_PS2::unlockMutex(MutexRef mutex) { void OSystem_PS2::deleteMutex(MutexRef mutex) { WaitSema(_mutexSema); - Ps2Mutex *sysMutex = (Ps2Mutex*)mutex; + Ps2Mutex *sysMutex = (Ps2Mutex *)mutex; if (sysMutex->owner || sysMutex->count) printf("WARNING: Deleting LOCKED mutex!\n"); DeleteSema(sysMutex->sema); diff --git a/backends/platform/ps2/ps2pad.cpp b/backends/platform/ps2/ps2pad.cpp index eeb9dfbd93..b6afc217e6 100644 --- a/backends/platform/ps2/ps2pad.cpp +++ b/backends/platform/ps2/ps2pad.cpp @@ -30,7 +30,7 @@ Ps2Pad::Ps2Pad(OSystem_PS2 *system) { _system = system; - _padBuf = (uint8*)memalign(64, 256); + _padBuf = (uint8 *)memalign(64, 256); _padStatus = STAT_NONE; padInit(0); // initialize library diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp index c75d7493a2..d4e993da63 100644 --- a/backends/platform/ps2/systemps2.cpp +++ b/backends/platform/ps2/systemps2.cpp @@ -384,8 +384,8 @@ void OSystem_PS2::initTimer(void) { ee_thread_t timerThread, soundThread, thisThread; ReferThreadStatus(GetThreadId(), &thisThread); - _timerStack = (uint8*)malloc(TIMER_STACK_SIZE); - _soundStack = (uint8*)malloc(SOUND_STACK_SIZE); + _timerStack = (uint8 *)malloc(TIMER_STACK_SIZE); + _soundStack = (uint8 *)malloc(SOUND_STACK_SIZE); // give timer thread a higher priority than main thread timerThread.initial_priority = thisThread.current_priority - 1; @@ -435,7 +435,7 @@ void OSystem_PS2::timerThreadCallback(void) { } void OSystem_PS2::soundThreadCallback(void) { - int16 *soundBufL = (int16*)memalign(64, SMP_PER_BLOCK * sizeof(int16) * 2); + int16 *soundBufL = (int16 *)memalign(64, SMP_PER_BLOCK * sizeof(int16) * 2); int16 *soundBufR = soundBufL + SMP_PER_BLOCK; int bufferedSamples = 0; @@ -453,9 +453,9 @@ void OSystem_PS2::soundThreadCallback(void) { if (bufferedSamples <= 8 * SMP_PER_BLOCK) { // we have to produce more samples, call sound mixer // the scratchpad at 0x70000000 is used as temporary soundbuffer - //_scummSoundProc(_scummSoundParam, (uint8*)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); - // Audio::Mixer::mixCallback(_scummMixer, (byte*)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); - _scummMixer->mixCallback((byte*)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); + //_scummSoundProc(_scummSoundParam, (uint8 *)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); + // Audio::Mixer::mixCallback(_scummMixer, (byte *)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); + _scummMixer->mixCallback((byte *)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); // demux data into 2 buffers, L and R __asm__ ( @@ -558,11 +558,6 @@ void OSystem_PS2::copyRectToScreen(const byte *buf, int pitch, int x, int y, int _screen->copyScreenRect((const uint8*)buf, pitch, x, y, w, h); } -bool OSystem_PS2::grabRawScreen(Graphics::Surface *surf) { - _screen->grabScreen(surf); - return true; -} - void OSystem_PS2::updateScreen(void) { if (_msgClearTime && (_msgClearTime < getMillis())) { _screen->clearPrintfOverlay(); @@ -640,7 +635,7 @@ void OSystem_PS2::clearOverlay(void) { } void OSystem_PS2::grabOverlay(OverlayColor *buf, int pitch) { - _screen->grabOverlay((uint16*)buf, (uint16)pitch); + _screen->grabOverlay((uint16 *)buf, (uint16)pitch); } void OSystem_PS2::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { @@ -743,12 +738,12 @@ void OSystem_PS2::msgPrintf(int millis, const char *format, ...) { lnSta = lnEnd + 1; } - uint8 *scrBuf = (uint8*)memalign(64, 320 * 200); + uint8 *scrBuf = (uint8 *)memalign(64, 320 * 200); memset(scrBuf, 4, 320 * 200); uint8 *dstPos = scrBuf + ((200 - posY) >> 1) * 320 + (320 - maxWidth) / 2; for (int y = 0; y < posY; y++) { - uint8 *srcPos = (uint8*)surf.getBasePtr((300 - maxWidth) / 2, y); + uint8 *srcPos = (uint8 *)surf.getBasePtr((300 - maxWidth) / 2, y); for (int x = 0; x < maxWidth; x++) dstPos[x] = srcPos[x] + 5; dstPos += 320; diff --git a/backends/platform/ps2/systemps2.h b/backends/platform/ps2/systemps2.h index 35ceaf829e..3a0e247737 100644 --- a/backends/platform/ps2/systemps2.h +++ b/backends/platform/ps2/systemps2.h @@ -64,7 +64,6 @@ public: virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); virtual void setShakePos(int shakeOffset); - virtual bool grabRawScreen(Graphics::Surface *surf); virtual Graphics::Surface *lockScreen(); virtual void unlockScreen(); virtual void updateScreen(); diff --git a/backends/platform/psp/display_manager.cpp b/backends/platform/psp/display_manager.cpp index cdb130e2a0..10a732b1e3 100644 --- a/backends/platform/psp/display_manager.cpp +++ b/backends/platform/psp/display_manager.cpp @@ -210,14 +210,14 @@ void MasterGuRenderer::guProgramDisplayBufferSizes() { switch (GuRenderer::_displayManager->getOutputBitsPerPixel()) { case 16: sceGuDrawBuffer(GU_PSM_4444, (void *)0, PSP_BUFFER_WIDTH); - sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, (void*)(PSP_FRAME_SIZE * sizeof(uint16)), PSP_BUFFER_WIDTH); - sceGuDepthBuffer((void*)(PSP_FRAME_SIZE * sizeof(uint16) * 2), PSP_BUFFER_WIDTH); + sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, (void *)(PSP_FRAME_SIZE * sizeof(uint16)), PSP_BUFFER_WIDTH); + sceGuDepthBuffer((void *)(PSP_FRAME_SIZE * sizeof(uint16) * 2), PSP_BUFFER_WIDTH); VramAllocator::instance().allocate(PSP_FRAME_SIZE * sizeof(uint16) * 2); break; case 32: sceGuDrawBuffer(GU_PSM_8888, (void *)0, PSP_BUFFER_WIDTH); - sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, (void*)(PSP_FRAME_SIZE * sizeof(uint32)), PSP_BUFFER_WIDTH); - sceGuDepthBuffer((void*)(PSP_FRAME_SIZE * sizeof(uint32) * 2), PSP_BUFFER_WIDTH); + sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, (void *)(PSP_FRAME_SIZE * sizeof(uint32)), PSP_BUFFER_WIDTH); + sceGuDepthBuffer((void *)(PSP_FRAME_SIZE * sizeof(uint32) * 2), PSP_BUFFER_WIDTH); VramAllocator::instance().allocate(PSP_FRAME_SIZE * sizeof(uint32) * 2); break; } diff --git a/backends/platform/psp/portdefs.h b/backends/platform/psp/portdefs.h index e8a28b31e2..620a27a601 100644 --- a/backends/platform/psp/portdefs.h +++ b/backends/platform/psp/portdefs.h @@ -38,6 +38,7 @@ #include <time.h> #include <ctype.h> #include <assert.h> +#include <new> #include <pspkernel.h> #include <pspdebug.h> diff --git a/backends/platform/sdl/hardwarekeys.cpp b/backends/platform/sdl/hardwarekeys.cpp deleted file mode 100644 index 9a33e357da..0000000000 --- a/backends/platform/sdl/hardwarekeys.cpp +++ /dev/null @@ -1,230 +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 "backends/platform/sdl/sdl.h" -#include "backends/keymapper/keymapper.h" -#include "common/keyboard.h" - -#ifdef ENABLE_KEYMAPPER - -using namespace Common; - -struct Key { - const char *hwId; - KeyCode keycode; - uint16 ascii; - const char *desc; - KeyType preferredAction; - bool shiftable; -}; - -static const Key keys[] = { - {"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", kActionKeyType, false}, - {"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", kActionKeyType, false}, - {"CLEAR", KEYCODE_CLEAR, 0, "Clear", kActionKeyType, false}, - {"RETURN", KEYCODE_RETURN, ASCII_RETURN, "Return", kActionKeyType, false}, - {"PAUSE", KEYCODE_PAUSE, 0, "Pause", kActionKeyType, false}, - {"ESCAPE", KEYCODE_ESCAPE, ASCII_ESCAPE, "Esc", kStartKeyType, false}, - {"SPACE", KEYCODE_SPACE, ASCII_SPACE, "Space", kActionKeyType, false}, - {"EXCLAIM", KEYCODE_EXCLAIM, '!', "!", kActionKeyType, false}, - {"QUOTEDBL", KEYCODE_QUOTEDBL, '"', "\"", kActionKeyType, false}, - {"HASH", KEYCODE_HASH, '#', "#", kActionKeyType, false}, - {"DOLLAR", KEYCODE_DOLLAR, '$', "$", kActionKeyType, false}, - {"AMPERSAND", KEYCODE_AMPERSAND, '&', "&", kActionKeyType, false}, - {"QUOTE", KEYCODE_QUOTE, '\'', "'", kActionKeyType, false}, - {"LEFTPAREN", KEYCODE_LEFTPAREN, '(', "(", kActionKeyType, false}, - {"RIGHTPAREN", KEYCODE_RIGHTPAREN, ')', ")", kActionKeyType, false}, - {"ASTERISK", KEYCODE_ASTERISK, '*', "*", kActionKeyType, false}, - {"PLUS", KEYCODE_PLUS, '+', "+", kActionKeyType, false}, - {"COMMA", KEYCODE_COMMA, ',', ",", kActionKeyType, false}, - {"MINUS", KEYCODE_MINUS, '-', "-", kActionKeyType, false}, - {"PERIOD", KEYCODE_PERIOD, '.', ".", kActionKeyType, false}, - {"SLASH", KEYCODE_SLASH, '/', "/", kActionKeyType, false}, - {"0", KEYCODE_0, '0', "0", kActionKeyType, false}, - {"1", KEYCODE_1, '1', "1", kActionKeyType, false}, - {"2", KEYCODE_2, '2', "2", kActionKeyType, false}, - {"3", KEYCODE_3, '3', "3", kActionKeyType, false}, - {"4", KEYCODE_4, '4', "4", kActionKeyType, false}, - {"5", KEYCODE_5, '5', "5", kActionKeyType, false}, - {"6", KEYCODE_6, '6', "6", kActionKeyType, false}, - {"7", KEYCODE_7, '7', "7", kActionKeyType, false}, - {"8", KEYCODE_8, '8', "8", kActionKeyType, false}, - {"9", KEYCODE_9, '9', "9", kActionKeyType, false}, - {"COLON", KEYCODE_COLON, ':', ":", kActionKeyType, false}, - {"SEMICOLON", KEYCODE_SEMICOLON, ';', ";", kActionKeyType, false}, - {"LESS", KEYCODE_LESS, '<', "<", kActionKeyType, false}, - {"EQUALS", KEYCODE_EQUALS, '=', "=", kActionKeyType, false}, - {"GREATER", KEYCODE_GREATER, '>', ">", kActionKeyType, false}, - {"QUESTION", KEYCODE_QUESTION, '?', "?", kActionKeyType, false}, - {"AT", KEYCODE_AT, '@', "@", kActionKeyType, false}, - - {"LEFTBRACKET", KEYCODE_LEFTBRACKET, '[', "[", kActionKeyType, false}, - {"BACKSLASH", KEYCODE_BACKSLASH, '\\', "\\", kActionKeyType, false}, - {"RIGHTBRACKET", KEYCODE_RIGHTBRACKET, ']', "]", kActionKeyType, false}, - {"CARET", KEYCODE_CARET, '^', "^", kActionKeyType, false}, - {"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", kActionKeyType, false}, - {"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", kActionKeyType, false}, - {"a", KEYCODE_a, 'a', "a", kActionKeyType, true}, - {"b", KEYCODE_b, 'b', "b", kActionKeyType, true}, - {"c", KEYCODE_c, 'c', "c", kActionKeyType, true}, - {"d", KEYCODE_d, 'd', "d", kActionKeyType, true}, - {"e", KEYCODE_e, 'e', "e", kActionKeyType, true}, - {"f", KEYCODE_f, 'f', "f", kActionKeyType, true}, - {"g", KEYCODE_g, 'g', "g", kActionKeyType, true}, - {"h", KEYCODE_h, 'h', "h", kActionKeyType, true}, - {"i", KEYCODE_i, 'i', "i", kActionKeyType, true}, - {"j", KEYCODE_j, 'j', "j", kActionKeyType, true}, - {"k", KEYCODE_k, 'k', "k", kActionKeyType, true}, - {"l", KEYCODE_l, 'l', "l", kActionKeyType, true}, - {"m", KEYCODE_m, 'm', "m", kActionKeyType, true}, - {"n", KEYCODE_n, 'n', "n", kActionKeyType, true}, - {"o", KEYCODE_o, 'o', "o", kActionKeyType, true}, - {"p", KEYCODE_p, 'p', "p", kActionKeyType, true}, - {"q", KEYCODE_q, 'q', "q", kActionKeyType, true}, - {"r", KEYCODE_r, 'r', "r", kActionKeyType, true}, - {"s", KEYCODE_s, 's', "s", kActionKeyType, true}, - {"t", KEYCODE_t, 't', "t", kActionKeyType, true}, - {"u", KEYCODE_u, 'u', "u", kActionKeyType, true}, - {"v", KEYCODE_v, 'v', "v", kActionKeyType, true}, - {"w", KEYCODE_w, 'w', "w", kActionKeyType, true}, - {"x", KEYCODE_x, 'x', "x", kActionKeyType, true}, - {"y", KEYCODE_y, 'y', "y", kActionKeyType, true}, - {"z", KEYCODE_z, 'z', "z", kActionKeyType, true}, - {"DELETE", KEYCODE_DELETE, 0, "Del", kActionKeyType, false}, - - // Numeric keypad - {"KP0", KEYCODE_KP0, 0, "KP0", kActionKeyType, false}, - {"KP1", KEYCODE_KP1, 0, "KP1", kActionKeyType, false}, - {"KP2", KEYCODE_KP2, 0, "KP2", kActionKeyType, false}, - {"KP3", KEYCODE_KP3, 0, "KP3", kActionKeyType, false}, - {"KP4", KEYCODE_KP4, 0, "KP4", kActionKeyType, false}, - {"KP5", KEYCODE_KP5, 0, "KP5", kActionKeyType, false}, - {"KP6", KEYCODE_KP6, 0, "KP6", kActionKeyType, false}, - {"KP7", KEYCODE_KP7, 0, "KP7", kActionKeyType, false}, - {"KP8", KEYCODE_KP8, 0, "KP8", kActionKeyType, false}, - {"KP9", KEYCODE_KP9, 0, "KP9", kActionKeyType, false}, - {"KP_PERIOD", KEYCODE_KP_PERIOD, 0, "KP.", kActionKeyType, false}, - {"KP_DIVIDE", KEYCODE_KP_DIVIDE, 0, "KP/", kActionKeyType, false}, - {"KP_MULTIPLY", KEYCODE_KP_MULTIPLY, 0, "KP*", kActionKeyType, false}, - {"KP_MINUS", KEYCODE_KP_MINUS, 0, "KP-", kActionKeyType, false}, - {"KP_PLUS", KEYCODE_KP_PLUS, 0, "KP+", kActionKeyType, false}, - {"KP_ENTER", KEYCODE_KP_ENTER, 0, "KP Enter", kActionKeyType, false}, - {"KP_EQUALS", KEYCODE_KP_EQUALS, 0, "KP=", kActionKeyType, false}, - - // Arrows + Home/End pad - {"UP", KEYCODE_UP, 0, "Up", kDirUpKeyType, false}, - {"DOWN", KEYCODE_DOWN, 0, "Down", kDirDownKeyType, false}, - {"RIGHT", KEYCODE_RIGHT, 0, "Right", kDirRightKeyType, false}, - {"LEFT", KEYCODE_LEFT, 0, "Left", kDirLeftKeyType, false}, - {"INSERT", KEYCODE_INSERT, 0, "Insert", kActionKeyType, false}, - {"HOME", KEYCODE_HOME, 0, "Home", kActionKeyType, false}, - {"END", KEYCODE_END, 0, "End", kActionKeyType, false}, - {"PAGEUP", KEYCODE_PAGEUP, 0, "PgUp", kActionKeyType, false}, - {"PAGEDOWN", KEYCODE_PAGEDOWN, 0, "PgDn", kActionKeyType, false}, - - // Function keys - {"F1", KEYCODE_F1, ASCII_F1, "F1", kActionKeyType, false}, - {"F2", KEYCODE_F2, ASCII_F2, "F2", kActionKeyType, false}, - {"F3", KEYCODE_F3, ASCII_F3, "F3", kActionKeyType, false}, - {"F4", KEYCODE_F4, ASCII_F4, "F4", kActionKeyType, false}, - {"F5", KEYCODE_F5, ASCII_F5, "F5", kActionKeyType, false}, - {"F6", KEYCODE_F6, ASCII_F6, "F6", kActionKeyType, false}, - {"F7", KEYCODE_F7, ASCII_F7, "F7", kActionKeyType, false}, - {"F8", KEYCODE_F8, ASCII_F8, "F8", kActionKeyType, false}, - {"F9", KEYCODE_F9, ASCII_F9, "F9", kActionKeyType, false}, - {"F10", KEYCODE_F10, ASCII_F10, "F10", kActionKeyType, false}, - {"F11", KEYCODE_F11, ASCII_F11, "F11", kActionKeyType, false}, - {"F12", KEYCODE_F12, ASCII_F12, "F12", kActionKeyType, false}, - {"F13", KEYCODE_F13, 0, "F13", kActionKeyType, false}, - {"F14", KEYCODE_F14, 0, "F14", kActionKeyType, false}, - {"F15", KEYCODE_F15, 0, "F15", kActionKeyType, false}, - - // Miscellaneous function keys - {"HELP", KEYCODE_HELP, 0, "Help", kActionKeyType, false}, - {"PRINT", KEYCODE_PRINT, 0, "Print", kActionKeyType, false}, - {"SYSREQ", KEYCODE_SYSREQ, 0, "SysRq", kActionKeyType, false}, - {"BREAK", KEYCODE_BREAK, 0, "Break", kActionKeyType, false}, - {"MENU", KEYCODE_MENU, 0, "Menu", kActionKeyType, false}, - // Power Macintosh power key - {"POWER", KEYCODE_POWER, 0, "Power", kActionKeyType, false}, - // Some european keyboards - {"EURO", KEYCODE_EURO, 0, "Euro", kActionKeyType, false}, - // Atari keyboard has Undo - {"UNDO", KEYCODE_UNDO, 0, "Undo", kActionKeyType, false}, - {0, KEYCODE_INVALID, 0, 0, kGenericKeyType, false} -}; - -struct Mod { - byte flag; - const char *id; - const char *desc; - bool shiftable; -}; - -static const Mod modifiers[] = { - { 0, "", "", false }, - { KBD_CTRL, "C+", "Ctrl+", false }, - { KBD_ALT, "A+", "Alt+", false }, - { KBD_SHIFT, "", "", true }, - { KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+", false }, - { KBD_SHIFT | KBD_CTRL, "S+C+", "Shift+Ctrl+", true }, - { KBD_SHIFT | KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+", true }, - { 0, 0, 0, false } -}; -#endif - - -Common::HardwareKeySet *OSystem_SDL::getHardwareKeySet() { -#ifdef ENABLE_KEYMAPPER - HardwareKeySet *keySet = new HardwareKeySet(); - const Key *key; - const Mod *mod; - char fullKeyId[50]; - char fullKeyDesc[100]; - uint16 ascii; - - for (mod = modifiers; mod->id; mod++) { - for (key = keys; key->hwId; key++) { - ascii = key->ascii; - - if (mod->shiftable && key->shiftable) { - snprintf(fullKeyId, 50, "%s%c", mod->id, toupper(key->hwId[0])); - snprintf(fullKeyDesc, 100, "%s%c", mod->desc, toupper(key->desc[0])); - ascii = toupper(key->ascii); - } else if (mod->shiftable) { - snprintf(fullKeyId, 50, "S+%s%s", mod->id, key->hwId); - snprintf(fullKeyDesc, 100, "Shift+%s%s", mod->desc, key->desc); - } else { - snprintf(fullKeyId, 50, "%s%s", mod->id, key->hwId); - snprintf(fullKeyDesc, 100, "%s%s", mod->desc, key->desc); - } - - keySet->addHardwareKey(new HardwareKey(fullKeyId, KeyState(key->keycode, ascii, mod->flag), fullKeyDesc, key->preferredAction )); - } - } - - return keySet; - -#else - return 0; -#endif -} diff --git a/backends/platform/sdl/macosx/appmenu_osx.mm b/backends/platform/sdl/macosx/appmenu_osx.mm index bb089a6b61..97c7edba3e 100755 --- a/backends/platform/sdl/macosx/appmenu_osx.mm +++ b/backends/platform/sdl/macosx/appmenu_osx.mm @@ -35,6 +35,11 @@ - (void)setAppleMenu:(NSMenu *)menu; @end +NSString *constructNSStringFromCString(const char* rawCString, NSStringEncoding stringEncoding) { + NSData *nsData = [NSData dataWithBytes:rawCString length:strlen(rawCString)]; + return [[NSString alloc] initWithData:nsData encoding:stringEncoding]; +} + void replaceApplicationMenuItems() { // Code mainly copied and adapted from SDLmain.m @@ -50,34 +55,47 @@ void replaceApplicationMenuItems() { // Create new application menu appleMenu = [[NSMenu alloc] initWithTitle:@""]; + NSString *nsString = NULL; + // Get current encoding #ifdef USE_TRANSLATION - NSStringEncoding stringEncoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)[NSString stringWithCString:(TransMan.getCurrentCharset()).c_str() encoding:NSASCIIStringEncoding])); + nsString = constructNSStringFromCString((TransMan.getCurrentCharset()).c_str(), NSASCIIStringEncoding); + NSStringEncoding stringEncoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)nsString)); + [nsString release]; #else NSStringEncoding stringEncoding = NSASCIIStringEncoding; #endif - + // Add "About ScummVM" menu item - [appleMenu addItemWithTitle:[NSString stringWithCString:_("About ScummVM") encoding:stringEncoding] action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; + nsString = constructNSStringFromCString(_("About ScummVM"), stringEncoding); + [appleMenu addItemWithTitle:nsString action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; + [nsString release]; // Add separator [appleMenu addItem:[NSMenuItem separatorItem]]; // Add "Hide ScummVM" menu item - [appleMenu addItemWithTitle:[NSString stringWithCString:_("Hide ScummVM") encoding:stringEncoding] action:@selector(hide:) keyEquivalent:@"h"]; + nsString = constructNSStringFromCString(_("Hide ScummVM"), stringEncoding); + [appleMenu addItemWithTitle:nsString action:@selector(hide:) keyEquivalent:@"h"]; + [nsString release]; // Add "Hide Others" menu item - menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:[NSString stringWithCString:_("Hide Others") encoding:stringEncoding] action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; + nsString = constructNSStringFromCString(_("Hide Others"), stringEncoding); + menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:nsString action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)]; // Add "Show All" menu item - [appleMenu addItemWithTitle:[NSString stringWithCString:_("Show All") encoding:stringEncoding] action:@selector(unhideAllApplications:) keyEquivalent:@""]; + nsString = constructNSStringFromCString(_("Show All"), stringEncoding); + [appleMenu addItemWithTitle:nsString action:@selector(unhideAllApplications:) keyEquivalent:@""]; + [nsString release]; // Add separator [appleMenu addItem:[NSMenuItem separatorItem]]; // Add "Quit ScummVM" menu item - [appleMenu addItemWithTitle:[NSString stringWithCString:_("Quit ScummVM") encoding:stringEncoding] action:@selector(terminate:) keyEquivalent:@"q"]; + nsString = constructNSStringFromCString(_("Quit ScummVM"), stringEncoding); + [appleMenu addItemWithTitle:nsString action:@selector(terminate:) keyEquivalent:@"q"]; + [nsString release]; // Put application menu into the menubar menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; @@ -89,16 +107,22 @@ void replaceApplicationMenuItems() { // Create new "Window" menu - windowMenu = [[NSMenu alloc] initWithTitle:[NSString stringWithCString:_("Window") encoding:stringEncoding]]; + nsString = constructNSStringFromCString(_("Window"), stringEncoding); + windowMenu = [[NSMenu alloc] initWithTitle:nsString]; + [nsString release]; // Add "Minimize" menu item - menuItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithCString:_("Minimize") encoding:stringEncoding] action:@selector(performMiniaturize:) keyEquivalent:@"m"]; + nsString = constructNSStringFromCString(_("Minimize"), stringEncoding); + menuItem = [[NSMenuItem alloc] initWithTitle:nsString action:@selector(performMiniaturize:) keyEquivalent:@"m"]; [windowMenu addItem:menuItem]; + [nsString release]; // Put menu into the menubar - menuItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithCString:_("Window") encoding:stringEncoding] action:nil keyEquivalent:@""]; + nsString = constructNSStringFromCString(_("Window"), stringEncoding); + menuItem = [[NSMenuItem alloc] initWithTitle:nsString action:nil keyEquivalent:@""]; [menuItem setSubmenu:windowMenu]; [[NSApp mainMenu] addItem:menuItem]; + [nsString release]; // Tell the application object that this is now the window menu. [NSApp setWindowsMenu:windowMenu]; diff --git a/backends/platform/sdl/module.mk b/backends/platform/sdl/module.mk index f1afe37349..98a8265301 100644 --- a/backends/platform/sdl/module.mk +++ b/backends/platform/sdl/module.mk @@ -1,7 +1,6 @@ MODULE := backends/platform/sdl MODULE_OBJS := \ - hardwarekeys.o \ main.o \ sdl.o diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp index 05c779a4e0..7a8b1e7b70 100644 --- a/backends/platform/sdl/posix/posix.cpp +++ b/backends/platform/sdl/posix/posix.cpp @@ -175,7 +175,7 @@ bool OSystem_POSIX::displayLogFile() { } else if (pid == 0) { // Try xdg-open first - execlp("xdg-open", "xdg-open", _logFilePath.c_str(), (char*)0); + execlp("xdg-open", "xdg-open", _logFilePath.c_str(), (char *)0); // If we're here, that clearly failed. @@ -184,7 +184,7 @@ bool OSystem_POSIX::displayLogFile() { // Try xterm+less next - execlp("xterm", "xterm", "-e", "less", _logFilePath.c_str(), (char*)0); + execlp("xterm", "xterm", "-e", "less", _logFilePath.c_str(), (char *)0); // TODO: If less does not exist we could fall back to 'more'. // However, we'll have to use 'xterm -hold' for that to prevent the diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 22d79dbfe7..f05207b482 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -58,7 +58,6 @@ public: virtual void engineInit(); virtual void engineDone(); #endif - virtual Common::HardwareKeySet *getHardwareKeySet(); virtual void quit(); virtual void fatalError(); diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index a2c8e43424..453d566c7b 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -38,6 +38,7 @@ #include <SDL_syswm.h> // For setting the icon #include "backends/platform/sdl/win32/win32.h" +#include "backends/saves/windows/windows-saves.h" #include "backends/fs/windows/windows-fs-factory.h" #include "backends/taskbar/win32/win32-taskbar.h" @@ -74,6 +75,10 @@ void OSystem_Win32::initBackend() { FreeConsole(); } + // Create the savefile manager + if (_savefileManager == 0) + _savefileManager = new WindowsSaveFileManager(); + // Invoke parent implementation of this method OSystem_SDL::initBackend(); } @@ -256,9 +261,9 @@ class Win32ResourceArchive : public Common::Archive { public: Win32ResourceArchive(); - virtual bool hasFile(const Common::String &name); - virtual int listMembers(Common::ArchiveMemberList &list); - virtual Common::ArchiveMemberPtr getMember(const Common::String &name); + virtual bool hasFile(const Common::String &name) const; + virtual int listMembers(Common::ArchiveMemberList &list) const; + virtual const Common::ArchiveMemberPtr getMember(const Common::String &name) const; virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; private: typedef Common::List<Common::String> FilenameList; @@ -279,7 +284,7 @@ Win32ResourceArchive::Win32ResourceArchive() { EnumResourceNames(NULL, MAKEINTRESOURCE(256), &EnumResNameProc, (LONG_PTR)this); } -bool Win32ResourceArchive::hasFile(const Common::String &name) { +bool Win32ResourceArchive::hasFile(const Common::String &name) const { for (FilenameList::const_iterator i = _files.begin(); i != _files.end(); ++i) { if (i->equalsIgnoreCase(name)) return true; @@ -288,7 +293,7 @@ bool Win32ResourceArchive::hasFile(const Common::String &name) { return false; } -int Win32ResourceArchive::listMembers(Common::ArchiveMemberList &list) { +int Win32ResourceArchive::listMembers(Common::ArchiveMemberList &list) const { int count = 0; for (FilenameList::const_iterator i = _files.begin(); i != _files.end(); ++i, ++count) @@ -297,7 +302,7 @@ int Win32ResourceArchive::listMembers(Common::ArchiveMemberList &list) { return count; } -Common::ArchiveMemberPtr Win32ResourceArchive::getMember(const Common::String &name) { +const Common::ArchiveMemberPtr Win32ResourceArchive::getMember(const Common::String &name) const { return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); } diff --git a/backends/platform/symbian/README b/backends/platform/symbian/README index 83e98a534a..31bc3d8fce 100644 --- a/backends/platform/symbian/README +++ b/backends/platform/symbian/README @@ -1,7 +1,7 @@ ScummVM - ScummVM ported to EPOC/SymbianOS - Copyright (C) 2008-2011 ScummVM Team + Copyright (C) 2008-2012 ScummVM Team Copyright (C) 2003-2008 Lars 'AnotherGuest' Persson Copyright (C) 2002-2008 Jurgen 'SumthinWicked' Braam diff --git a/backends/platform/symbian/S60/ScummVM_S60.mmp.in b/backends/platform/symbian/S60/ScummVM_S60.mmp.in index 7b401fd310..81068ba073 100644 --- a/backends/platform/symbian/S60/ScummVM_S60.mmp.in +++ b/backends/platform/symbian/S60/ScummVM_S60.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/S60/ScummVM_S60_App.mmp b/backends/platform/symbian/S60/ScummVM_S60_App.mmp index 940997cc73..e00987e2ad 100644 --- a/backends/platform/symbian/S60/ScummVM_S60_App.mmp +++ b/backends/platform/symbian/S60/ScummVM_S60_App.mmp @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/S60v3/ScummVM_A0000658_S60v3.mmp.in b/backends/platform/symbian/S60v3/ScummVM_A0000658_S60v3.mmp.in index 583d1a35e7..ccf38818dc 100644 --- a/backends/platform/symbian/S60v3/ScummVM_A0000658_S60v3.mmp.in +++ b/backends/platform/symbian/S60v3/ScummVM_A0000658_S60v3.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in b/backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in index 5367bf0d1f..0162061284 100644 --- a/backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in +++ b/backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/S80/ScummVM_S80.mmp.in b/backends/platform/symbian/S80/ScummVM_S80.mmp.in index 5e4b6d447e..7987ccd639 100644 --- a/backends/platform/symbian/S80/ScummVM_S80.mmp.in +++ b/backends/platform/symbian/S80/ScummVM_S80.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/S80/ScummVM_S80_App.mmp b/backends/platform/symbian/S80/ScummVM_S80_App.mmp index e91b504087..b66bef7518 100644 --- a/backends/platform/symbian/S80/ScummVM_S80_App.mmp +++ b/backends/platform/symbian/S80/ScummVM_S80_App.mmp @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/S90/Scummvm_S90.mmp.in b/backends/platform/symbian/S90/Scummvm_S90.mmp.in index 06d65f1641..d803ce5647 100644 --- a/backends/platform/symbian/S90/Scummvm_S90.mmp.in +++ b/backends/platform/symbian/S90/Scummvm_S90.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/S90/Scummvm_S90_App.mmp b/backends/platform/symbian/S90/Scummvm_S90_App.mmp index 3aa2cc2a65..0d8d2b8710 100644 --- a/backends/platform/symbian/S90/Scummvm_S90_App.mmp +++ b/backends/platform/symbian/S90/Scummvm_S90_App.mmp @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/UIQ2/ScummVM.rss b/backends/platform/symbian/UIQ2/ScummVM.rss index 374bd50680..a6ba4021e4 100644 --- a/backends/platform/symbian/UIQ2/ScummVM.rss +++ b/backends/platform/symbian/UIQ2/ScummVM.rss @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/backends/platform/symbian/UIQ3/ScummVM.rss b/backends/platform/symbian/UIQ3/ScummVM.rss index 2021b0506e..00ed4e3b5c 100644 --- a/backends/platform/symbian/UIQ3/ScummVM.rss +++ b/backends/platform/symbian/UIQ3/ScummVM.rss @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/UIQ3/ScummVM_A0000658.rss b/backends/platform/symbian/UIQ3/ScummVM_A0000658.rss index 2021b0506e..00ed4e3b5c 100644 --- a/backends/platform/symbian/UIQ3/ScummVM_A0000658.rss +++ b/backends/platform/symbian/UIQ3/ScummVM_A0000658.rss @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/UIQ3/ScummVM_A0000658_UIQ3.mmp.in b/backends/platform/symbian/UIQ3/ScummVM_A0000658_UIQ3.mmp.in index 3bc93d8ce3..9e419ad6d9 100644 --- a/backends/platform/symbian/UIQ3/ScummVM_A0000658_UIQ3.mmp.in +++ b/backends/platform/symbian/UIQ3/ScummVM_A0000658_UIQ3.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2009 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2009 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in b/backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in index bd5016f8d1..41452127ca 100644 --- a/backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in +++ b/backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/UIQ3/scummvm_A0000658_loc.rss b/backends/platform/symbian/UIQ3/scummvm_A0000658_loc.rss index 7f3b71ef84..9af9a33a75 100644 --- a/backends/platform/symbian/UIQ3/scummvm_A0000658_loc.rss +++ b/backends/platform/symbian/UIQ3/scummvm_A0000658_loc.rss @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_agi.mmp.in b/backends/platform/symbian/mmp/scummvm_agi.mmp.in index 5805d36133..7d197f786f 100644 --- a/backends/platform/symbian/mmp/scummvm_agi.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_agi.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_agos.mmp.in b/backends/platform/symbian/mmp/scummvm_agos.mmp.in index 236a62f1b8..587d1f0b69 100644 --- a/backends/platform/symbian/mmp/scummvm_agos.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_agos.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_base.mmp.in b/backends/platform/symbian/mmp/scummvm_base.mmp.in index 0387bfaf26..05cf526233 100644 --- a/backends/platform/symbian/mmp/scummvm_base.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_base.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_cine.mmp.in b/backends/platform/symbian/mmp/scummvm_cine.mmp.in index e75ece95f1..79806eb8c2 100644 --- a/backends/platform/symbian/mmp/scummvm_cine.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_cine.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_cruise.mmp.in b/backends/platform/symbian/mmp/scummvm_cruise.mmp.in index a91d33b5f5..53d52c80e7 100644 --- a/backends/platform/symbian/mmp/scummvm_cruise.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_cruise.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_draci.mmp.in b/backends/platform/symbian/mmp/scummvm_draci.mmp.in index 044247fac7..9a7c87c963 100644 --- a/backends/platform/symbian/mmp/scummvm_draci.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_draci.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_drascula.mmp.in b/backends/platform/symbian/mmp/scummvm_drascula.mmp.in index 0561e494c1..fcd7ce7585 100644 --- a/backends/platform/symbian/mmp/scummvm_drascula.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_drascula.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_gob.mmp.in b/backends/platform/symbian/mmp/scummvm_gob.mmp.in index 7c92611fd2..23f110bc7d 100644 --- a/backends/platform/symbian/mmp/scummvm_gob.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_gob.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_groovie.mmp.in b/backends/platform/symbian/mmp/scummvm_groovie.mmp.in index c0294b3b0d..6bdeb06b10 100644 --- a/backends/platform/symbian/mmp/scummvm_groovie.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_groovie.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_hugo.mmp.in b/backends/platform/symbian/mmp/scummvm_hugo.mmp.in index 66e22fc34b..69888bb0ee 100644 --- a/backends/platform/symbian/mmp/scummvm_hugo.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_hugo.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_kyra.mmp.in b/backends/platform/symbian/mmp/scummvm_kyra.mmp.in index d5f2ec951c..4a2a87216e 100644 --- a/backends/platform/symbian/mmp/scummvm_kyra.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_kyra.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_lastexpress.mmp.in b/backends/platform/symbian/mmp/scummvm_lastexpress.mmp.in index 57efa31a85..27ec0b2148 100644 --- a/backends/platform/symbian/mmp/scummvm_lastexpress.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_lastexpress.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_lure.mmp.in b/backends/platform/symbian/mmp/scummvm_lure.mmp.in index 2ac1f8f8ff..20b938a83f 100644 --- a/backends/platform/symbian/mmp/scummvm_lure.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_lure.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_m4.mmp.in b/backends/platform/symbian/mmp/scummvm_m4.mmp.in index 81ec94dbd4..fafd5e1e5f 100644 --- a/backends/platform/symbian/mmp/scummvm_m4.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_m4.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_made.mmp.in b/backends/platform/symbian/mmp/scummvm_made.mmp.in index dc24aee279..4d5ab6cc33 100644 --- a/backends/platform/symbian/mmp/scummvm_made.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_made.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_mohawk.mmp.in b/backends/platform/symbian/mmp/scummvm_mohawk.mmp.in index cb5b18ba18..3fc7c4ca5b 100644 --- a/backends/platform/symbian/mmp/scummvm_mohawk.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_mohawk.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_parallaction.mmp.in b/backends/platform/symbian/mmp/scummvm_parallaction.mmp.in index e86473e47a..05578b5994 100644 --- a/backends/platform/symbian/mmp/scummvm_parallaction.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_parallaction.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_queen.mmp.in b/backends/platform/symbian/mmp/scummvm_queen.mmp.in index b5326abe74..bfc0a2f760 100644 --- a/backends/platform/symbian/mmp/scummvm_queen.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_queen.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_saga.mmp.in b/backends/platform/symbian/mmp/scummvm_saga.mmp.in index 55d89f7868..831f02bdb6 100644 --- a/backends/platform/symbian/mmp/scummvm_saga.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_saga.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_sci.mmp.in b/backends/platform/symbian/mmp/scummvm_sci.mmp.in index dc06f44a5d..705f8d0c43 100644 --- a/backends/platform/symbian/mmp/scummvm_sci.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_sci.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_scumm.mmp.in b/backends/platform/symbian/mmp/scummvm_scumm.mmp.in index 527ce75181..6b2ad35594 100644 --- a/backends/platform/symbian/mmp/scummvm_scumm.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_scumm.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_sky.mmp.in b/backends/platform/symbian/mmp/scummvm_sky.mmp.in index eeb517ffcc..5fdfb56320 100644 --- a/backends/platform/symbian/mmp/scummvm_sky.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_sky.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_sword1.mmp.in b/backends/platform/symbian/mmp/scummvm_sword1.mmp.in index 0adc156719..075968cf98 100644 --- a/backends/platform/symbian/mmp/scummvm_sword1.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_sword1.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_sword2.mmp.in b/backends/platform/symbian/mmp/scummvm_sword2.mmp.in index c8034c3015..32ab259ee4 100644 --- a/backends/platform/symbian/mmp/scummvm_sword2.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_sword2.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_teenagent.mmp.in b/backends/platform/symbian/mmp/scummvm_teenagent.mmp.in index f065bf4376..61c50bd307 100644 --- a/backends/platform/symbian/mmp/scummvm_teenagent.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_teenagent.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_tinsel.mmp.in b/backends/platform/symbian/mmp/scummvm_tinsel.mmp.in index d61492de6b..375d948190 100644 --- a/backends/platform/symbian/mmp/scummvm_tinsel.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_tinsel.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_toon.mmp.in b/backends/platform/symbian/mmp/scummvm_toon.mmp.in index 01924614b4..d105156107 100644 --- a/backends/platform/symbian/mmp/scummvm_toon.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_toon.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_touche.mmp.in b/backends/platform/symbian/mmp/scummvm_touche.mmp.in index b9cb53b4bf..36588e051f 100644 --- a/backends/platform/symbian/mmp/scummvm_touche.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_touche.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_tsage.mmp.in b/backends/platform/symbian/mmp/scummvm_tsage.mmp.in index fa4968f704..fb9b075435 100644 --- a/backends/platform/symbian/mmp/scummvm_tsage.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_tsage.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_tucker.mmp.in b/backends/platform/symbian/mmp/scummvm_tucker.mmp.in index 1ea564c0c0..f8954e6d21 100644 --- a/backends/platform/symbian/mmp/scummvm_tucker.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_tucker.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/res/ScummVmAif.rss b/backends/platform/symbian/res/ScummVmAif.rss index b2addc3f21..3e7a86a3bc 100644 --- a/backends/platform/symbian/res/ScummVmAif.rss +++ b/backends/platform/symbian/res/ScummVmAif.rss @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/res/scummvm.rss b/backends/platform/symbian/res/scummvm.rss index 62da39e6a8..361f831e3c 100644 --- a/backends/platform/symbian/res/scummvm.rss +++ b/backends/platform/symbian/res/scummvm.rss @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/res/scummvm_A0000658.rss b/backends/platform/symbian/res/scummvm_A0000658.rss index 5615bbda9f..14d591c990 100644 --- a/backends/platform/symbian/res/scummvm_A0000658.rss +++ b/backends/platform/symbian/res/scummvm_A0000658.rss @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/src/ScummVm.hrh b/backends/platform/symbian/src/ScummVm.hrh index c18048c922..a84664f995 100644 --- a/backends/platform/symbian/src/ScummVm.hrh +++ b/backends/platform/symbian/src/ScummVm.hrh @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/webos/webos.cpp b/backends/platform/webos/webos.cpp index bfb19ed3bc..4ec153a7e9 100644 --- a/backends/platform/webos/webos.cpp +++ b/backends/platform/webos/webos.cpp @@ -51,20 +51,18 @@ void OSystem_SDL_WebOS::initBackend() { * * @return The hardware key set with added webOS specific keys. */ -HardwareKeySet *OSystem_SDL_WebOS::getHardwareKeySet() { #ifdef ENABLE_KEYMAPPER +HardwareInputSet *OSystem_SDL_WebOS::getHardwareInputSet() { // Get the original SDL hardware key set - HardwareKeySet *keySet = OSystem_SDL::getHardwareKeySet(); + HardwareInputSet *inputSet = OSystem_SDL::getHardwareInputSet(); // Add WebOS specific keys - keySet->addHardwareKey(new HardwareKey("FORWARD", - KeyState((KeyCode) 229, 229, 0), "Forward", kActionKeyType)); + inputSet->addHardwareInput(new HardwareInput("FORWARD", + KeyState((KeyCode) 229, 229, 0), "Forward")); // Return the modified hardware key set - return keySet; -#else - return 0; -#endif + return inputSet; } +#endif #endif diff --git a/backends/platform/webos/webos.h b/backends/platform/webos/webos.h index 850aaf9ce2..8dfa43239c 100644 --- a/backends/platform/webos/webos.h +++ b/backends/platform/webos/webos.h @@ -31,7 +31,9 @@ public: OSystem_SDL_WebOS(); virtual void initBackend(); - virtual Common::HardwareKeySet *getHardwareKeySet(); +#ifdef ENABLE_KEYMAPPER + virtual Common::HardwareInputSet *getHardwareInputSet(); +#endif }; #endif diff --git a/backends/platform/wince/README-WinCE.txt b/backends/platform/wince/README-WinCE.txt index 429168c293..11467fd482 100644 --- a/backends/platform/wince/README-WinCE.txt +++ b/backends/platform/wince/README-WinCE.txt @@ -1,10 +1,17 @@ ScummVM Windows CE FAQ -Last updated: 2011-10-15 -Release version: 1.4.0 +Last updated: 2011-12-05 +Release version: x.x.x ------------------------------------------------------------------------ New in this version ------------------- +x.x.x: +- Removed FLAC support for audio datafiles (now for real, this was originally + announced for 1.0.0, but the library was still included until now). This is + done because of size constrains of the executable and also FLAC on a mobile + device isn't really recommended - so please use MP3 or Ogg for your audio + datafiles. + 1.4.0: - Changed the memory management so that it is finally possible to break the 32MB per process barrier on Windows CE. It should be possible now (finally) @@ -18,6 +25,8 @@ New in this version - Discworld 2 is now playable (works now because of the new memory management) - Replaced the game mass-adding functionality with the functionality used on all other platforms. It now shows progress while searching for games. +- Mapped "Skip" button to F10 for AGI games +- Mapped "Multi Function" to F10 in Simon 1 & 2 (enables hotspot highlighting) 1.3.1: - Fix for Normal2xAspect scaler which was causing screen update issues in some @@ -60,7 +69,7 @@ scummvm2.exe: - agos, cine, drascula, gob, groovie, kyra, made, parallaction, saga, teenagent, tucker scummvm3.exe: - - hugo, mohawk, sci, sword2, toon + - hugo, mohawk, sci, sword2, toon, tsage There are no other port specific changes. @@ -264,6 +273,7 @@ The following actions are available : * Quit : quit ScummVM (without saving, be careful when using it) * Skip : skip a non interactive sequence, the current dialog or behaves like the ESC key on a regular keyboard + All AGI games -> F10 to quit full-screen dialogs * Hide : hide or display the toolbar * Keyboard : hide or display the virtual keyboard * Sound : turns all sound effects and music off and on @@ -282,6 +292,7 @@ The following actions are available : Fate of Atlantis -> sucker punch (cheat) Bargon -> F1 (start the game) All AGI games -> bring up the predictive input dialog + Simon 1 & 2 -> highlight all hotspots in screen * Bind keys map a key action to a device button * Up,Down,Left : Right, : emulate mouse/stylus behavior diff --git a/backends/platform/wince/portdefs.h b/backends/platform/wince/portdefs.h index 93df6cd39e..289406c2a4 100644 --- a/backends/platform/wince/portdefs.h +++ b/backends/platform/wince/portdefs.h @@ -73,6 +73,7 @@ #include <mmsystem.h> #include <ctype.h> //#include <direct.h> +#include <new> #ifdef __MINGW32CE__ void *bsearch(const void *, const void *, size_t, size_t, int (*x)(const void *, const void *)); diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp index 4e17827e5c..a57fcb9628 100644 --- a/backends/platform/wince/wince-sdl.cpp +++ b/backends/platform/wince/wince-sdl.cpp @@ -87,15 +87,15 @@ extern "C" void *__wrap_malloc(size_t size) { void *ptr = __real_malloc(size+4); // printf("malloc(%d) = %p\n", size, ptr); if (ptr != NULL) { - *((HANDLE*)ptr) = 0; - return 4+(char*)ptr; + *((HANDLE *)ptr) = 0; + return 4+(char *)ptr; } return NULL; } HANDLE H = CreateFileMapping((HANDLE)INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size+4, 0); void *ptr = MapViewOfFile(H, FILE_MAP_ALL_ACCESS, 0, 0, 0); - *((HANDLE*)ptr) = H; - return 4+(char*)ptr; + *((HANDLE *)ptr) = H; + return 4+(char *)ptr; } extern "C" void __wrap_free(void *ptr) { @@ -104,9 +104,9 @@ extern "C" void __wrap_free(void *ptr) { printf("free(%p)\n", ptr); */ if (ptr != NULL) { - HANDLE H = *(HANDLE*)((char *)ptr-4); + HANDLE H = *(HANDLE *)((char *)ptr-4); if (H == 0) { - __real_free((char*)ptr-4); + __real_free((char *)ptr-4); return; } UnmapViewOfFile((char *)ptr-4); diff --git a/backends/plugins/elf/elf-loader.cpp b/backends/plugins/elf/elf-loader.cpp index d75010196a..d60ddce57e 100644 --- a/backends/plugins/elf/elf-loader.cpp +++ b/backends/plugins/elf/elf-loader.cpp @@ -480,7 +480,7 @@ void *DLObject::symbol(const char *name) { !strcmp(name, _strtab + s->st_name)) { // We found the symbol debug(2, "elfloader: => 0x%08x", s->st_value); - return (void*)s->st_value; + return (void *)s->st_value; } // We didn't find the symbol diff --git a/backends/saves/windows/windows-saves.cpp b/backends/saves/windows/windows-saves.cpp new file mode 100644 index 0000000000..87348c3416 --- /dev/null +++ b/backends/saves/windows/windows-saves.cpp @@ -0,0 +1,78 @@ +/* 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" + +#include "backends/saves/windows/windows-saves.h" + +#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(DISABLE_DEFAULT_SAVEFILEMANAGER) + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> + +#include "common/config-manager.h" +#include "common/savefile.h" + +WindowsSaveFileManager::WindowsSaveFileManager() { + char defaultSavepath[MAXPATHLEN]; + + OSVERSIONINFO win32OsVersion; + ZeroMemory(&win32OsVersion, sizeof(OSVERSIONINFO)); + win32OsVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&win32OsVersion); + // Check for non-9X version of Windows. + if (win32OsVersion.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) { + // Use the Application Data directory of the user profile. + if (win32OsVersion.dwMajorVersion >= 5) { + if (!GetEnvironmentVariable("APPDATA", defaultSavepath, sizeof(defaultSavepath))) + error("Unable to access application data directory"); + } else { + if (!GetEnvironmentVariable("USERPROFILE", defaultSavepath, sizeof(defaultSavepath))) + error("Unable to access user profile directory"); + + strcat(defaultSavepath, "\\Application Data"); + + // If the directory already exists (as it should in most cases), + // we don't want to fail, but we need to stop on other errors (such as ERROR_PATH_NOT_FOUND) + if (!CreateDirectory(defaultSavepath, NULL)) { + if (GetLastError() != ERROR_ALREADY_EXISTS) + error("Cannot create Application data folder"); + } + } + + strcat(defaultSavepath, "\\ScummVM"); + if (!CreateDirectory(defaultSavepath, NULL)) { + if (GetLastError() != ERROR_ALREADY_EXISTS) + error("Cannot create ScummVM application data folder"); + } + + strcat(defaultSavepath, "\\Saved games"); + if (!CreateDirectory(defaultSavepath, NULL)) { + if (GetLastError() != ERROR_ALREADY_EXISTS) + error("Cannot create ScummVM Saved games folder"); + } + + ConfMan.registerDefault("savepath", defaultSavepath); + } +} + +#endif diff --git a/backends/platform/iphone/blit_arm.h b/backends/saves/windows/windows-saves.h index 77bb3578ab..a705aa2b7f 100644 --- a/backends/platform/iphone/blit_arm.h +++ b/backends/saves/windows/windows-saves.h @@ -20,16 +20,17 @@ * */ -extern "C" void blitLandscapeScreenRect16bpp(uint16 *dst, uint16 *src, - int width, - int height, - int screenWidth, - int screenHeight); +#ifndef BACKEND_WINDOWS_SAVES_H +#define BACKEND_WINDOWS_SAVES_H -extern "C" void blitLandscapeScreenRect8bpp(uint16 *dst, - byte *src, - int width, - int height, - uint16 *palette, - int screenWidth, - int screenHeight); +#include "backends/saves/default/default-saves.h" + +/** + * Provides a default savefile manager implementation for common platforms. + */ +class WindowsSaveFileManager : public DefaultSaveFileManager { +public: + WindowsSaveFileManager(); +}; + +#endif diff --git a/backends/taskbar/win32/win32-taskbar.cpp b/backends/taskbar/win32/win32-taskbar.cpp index 046ddb1cd0..5c9105b0eb 100644 --- a/backends/taskbar/win32/win32-taskbar.cpp +++ b/backends/taskbar/win32/win32-taskbar.cpp @@ -29,13 +29,9 @@ #if defined(WIN32) && defined(USE_TASKBAR) // Needed for taskbar functions -#if defined(__GNUC__) -#ifdef __MINGW32__ +#if defined(__GNUC__) && defined(__MINGW32__) && !defined(__MINGW64__) #include "backends/taskbar/win32/mingw-compat.h" #else - #error Only compilation with MingW is supported -#endif -#else // We need certain functions that are excluded by default #undef NONLS #undef NOICONS @@ -44,9 +40,12 @@ #undef ARRAYSIZE #endif - // Default MSVC headers for ITaskbarList3 and IShellLink - #include <SDKDDKVer.h> + #if defined(_MSC_VER) + // Default MSVC headers for ITaskbarList3 and IShellLink + #include <SDKDDKVer.h> + #endif #endif + #include <shlobj.h> // For HWND @@ -75,7 +74,7 @@ Win32TaskbarManager::Win32TaskbarManager() : _taskbar(NULL), _count(0), _icon(NU 0, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, - reinterpret_cast<void**> (&(_taskbar))); + reinterpret_cast<void **> (&(_taskbar))); if (SUCCEEDED(hr)) { // Initialize taskbar object @@ -275,7 +274,7 @@ void Win32TaskbarManager::addRecent(const Common::String &name, const Common::St GetModuleFileNameW(NULL, path, MAX_PATH); // Create a shell link. - if (SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC, IID_IShellLinkW, reinterpret_cast<void**> (&link)))) { + if (SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC, IID_IShellLinkW, reinterpret_cast<void **> (&link)))) { // Convert game name and description to Unicode. LPWSTR game = ansiToUnicode(name.c_str()); LPWSTR desc = ansiToUnicode(description.c_str()); @@ -297,7 +296,7 @@ void Win32TaskbarManager::addRecent(const Common::String &name, const Common::St // The link's display name must be set via property store. IPropertyStore* propStore; - HRESULT hr = link->QueryInterface(IID_IPropertyStore, reinterpret_cast<void**> (&(propStore))); + HRESULT hr = link->QueryInterface(IID_IPropertyStore, reinterpret_cast<void **> (&(propStore))); if (SUCCEEDED(hr)) { PROPVARIANT pv; pv.vt = VT_LPWSTR; diff --git a/backends/timer/bada/timer.cpp b/backends/timer/bada/timer.cpp index 8f5620401f..faddacb3c3 100755 --- a/backends/timer/bada/timer.cpp +++ b/backends/timer/bada/timer.cpp @@ -76,7 +76,7 @@ BadaTimerManager::BadaTimerManager() { BadaTimerManager::~BadaTimerManager() {
for (Common::List<TimerSlot>::iterator slot = _timers.begin();
- slot != _timers.end(); ++slot) {
+ slot != _timers.end(); ) {
slot->Stop();
slot = _timers.erase(slot);
}
diff --git a/backends/timer/default/default-timer.cpp b/backends/timer/default/default-timer.cpp index e1aadb62b8..8681102cd0 100644 --- a/backends/timer/default/default-timer.cpp +++ b/backends/timer/default/default-timer.cpp @@ -122,7 +122,7 @@ bool DefaultTimerManager::installTimerProc(TimerProc callback, int32 interval, v for (i = _callbacks.begin(); i != _callbacks.end(); ++i) { if (i->_value == callback) { - error("Same callback is referred by different names (%s vs %s)", i->_key.c_str(), id.c_str()); + error("Same callback added twice (old name: %s, new name: %s)", i->_key.c_str(), id.c_str()); } } _callbacks[id] = callback; @@ -136,12 +136,6 @@ bool DefaultTimerManager::installTimerProc(TimerProc callback, int32 interval, v slot->nextFireTimeMicro = interval % 1000; slot->next = 0; - // FIXME: It seems we do allow the client to add one callback multiple times over here, - // but "removeTimerProc" will remove *all* added instances. We should either prevent - // multiple additions of a timer proc OR we should change removeTimerProc to only remove - // a specific timer proc entry. - // Probably we can safely just allow a single addition of a specific function once - // and just update our Timer documentation accordingly. insertPrioQueue(_head, slot); return true; diff --git a/backends/vkeybd/image-map.cpp b/backends/vkeybd/image-map.cpp index 275ec865ed..359fc58d20 100644 --- a/backends/vkeybd/image-map.cpp +++ b/backends/vkeybd/image-map.cpp @@ -35,7 +35,7 @@ ImageMap::~ImageMap() { removeAllAreas(); } -Polygon *ImageMap::createArea(const String& id) { +Polygon *ImageMap::createArea(const String &id) { if (_areas.contains(id)) { warning("Image map already contains an area with target of '%s'", id.c_str()); return 0; @@ -45,7 +45,7 @@ Polygon *ImageMap::createArea(const String& id) { return p; } -void ImageMap::removeArea(const String& id) { +void ImageMap::removeArea(const String &id) { if (!_areas.contains(id)) return; delete _areas[id]; @@ -53,19 +53,18 @@ void ImageMap::removeArea(const String& id) { } void ImageMap::removeAllAreas() { - HashMap<String, Polygon*>::iterator it; - for (it = _areas.begin(); it != _areas.end(); ++it) { + for (AreaMap::iterator it = _areas.begin(); it != _areas.end(); ++it) { delete it->_value; } _areas.clear(); } String ImageMap::findMapArea(int16 x, int16 y) { - HashMap<String, Polygon*>::iterator it; - for (it = _areas.begin(); it != _areas.end(); ++it) { + for (AreaMap::iterator it = _areas.begin(); it != _areas.end(); ++it) { if (it->_value->contains(x, y)) return it->_key; } + return String(); } diff --git a/backends/vkeybd/image-map.h b/backends/vkeybd/image-map.h index 3bd8cfa0db..952ba624b0 100644 --- a/backends/vkeybd/image-map.h +++ b/backends/vkeybd/image-map.h @@ -35,18 +35,17 @@ namespace Common { struct Polygon; class ImageMap { - public: - ~ImageMap(); - Polygon *createArea(const String& id); - void removeArea(const String& id); + Polygon *createArea(const String &id); + void removeArea(const String &id); void removeAllAreas(); String findMapArea(int16 x, int16 y); protected: - HashMap<String, Polygon *> _areas; + typedef HashMap<String, Polygon *> AreaMap; + AreaMap _areas; }; diff --git a/backends/vkeybd/polygon.cpp b/backends/vkeybd/polygon.cpp index ac42cb1d2e..08727a6fe8 100644 --- a/backends/vkeybd/polygon.cpp +++ b/backends/vkeybd/polygon.cpp @@ -42,7 +42,7 @@ bool Polygon::contains(int16 x, int16 y) const { yflag1 = (vtx1->y >= y); if (yflag0 != yflag1) { if (((vtx1->y - y) * (vtx0->x - vtx1->x) >= - (vtx1->x - x) * (vtx0->y - vtx1->y)) == yflag1) { + (vtx1->x - x) * (vtx0->y - vtx1->y)) == yflag1) { inside_flag = !inside_flag; } } diff --git a/backends/vkeybd/polygon.h b/backends/vkeybd/polygon.h index 19a12a0409..91c8d017b2 100644 --- a/backends/vkeybd/polygon.h +++ b/backends/vkeybd/polygon.h @@ -46,13 +46,13 @@ struct Polygon { } } - void addPoint(const Point& p) { + void addPoint(const Point &p) { _points.push_back(p); _bound.extend(Rect(p.x, p.y, p.x, p.y)); } void addPoint(int16 x, int16 y) { - addPoint(Point(x,y)); + addPoint(Point(x, y)); } uint getPointCount() { diff --git a/backends/vkeybd/virtual-keyboard-gui.cpp b/backends/vkeybd/virtual-keyboard-gui.cpp index 1c05d62316..42f9707ddc 100644 --- a/backends/vkeybd/virtual-keyboard-gui.cpp +++ b/backends/vkeybd/virtual-keyboard-gui.cpp @@ -75,8 +75,8 @@ static void blit(Graphics::Surface *surf_dst, Graphics::Surface *surf_src, int16 VirtualKeyboardGUI::VirtualKeyboardGUI(VirtualKeyboard *kbd) : _kbd(kbd), _displaying(false), _drag(false), - _drawCaret(false), _displayEnabled(false), _firstRun(true), - _cursorAnimateTimer(0), _cursorAnimateCounter(0) { + _drawCaret(false), _displayEnabled(false), _firstRun(true), + _cursorAnimateTimer(0), _cursorAnimateCounter(0) { assert(_kbd); assert(g_system); @@ -111,7 +111,7 @@ void VirtualKeyboardGUI::initMode(VirtualKeyboard::Mode *mode) { } } -void VirtualKeyboardGUI::setupDisplayArea(Rect& r, OverlayColor forecolor) { +void VirtualKeyboardGUI::setupDisplayArea(Rect &r, OverlayColor forecolor) { _dispFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); if (!fontIsSuitable(_dispFont, r)) { @@ -135,9 +135,9 @@ void VirtualKeyboardGUI::setupDisplayArea(Rect& r, OverlayColor forecolor) { _displayEnabled = true; } -bool VirtualKeyboardGUI::fontIsSuitable(const Graphics::Font *font, const Rect& rect) { +bool VirtualKeyboardGUI::fontIsSuitable(const Graphics::Font *font, const Rect &rect) { return (font->getMaxCharWidth() < rect.width() && - font->getFontHeight() < rect.height()); + font->getFontHeight() < rect.height()); } void VirtualKeyboardGUI::checkScreenChanged() { @@ -161,7 +161,7 @@ void VirtualKeyboardGUI::run() { _system->clearOverlay(); } _overlayBackup.create(_screenW, _screenH, _system->getOverlayFormat()); - _system->grabOverlay((OverlayColor*)_overlayBackup.pixels, _overlayBackup.w); + _system->grabOverlay((OverlayColor *)_overlayBackup.pixels, _overlayBackup.w); setupCursor(); @@ -171,7 +171,7 @@ void VirtualKeyboardGUI::run() { removeCursor(); - _system->copyRectToOverlay((OverlayColor*)_overlayBackup.pixels, _overlayBackup.w, 0, 0, _overlayBackup.w, _overlayBackup.h); + _system->copyRectToOverlay((OverlayColor *)_overlayBackup.pixels, _overlayBackup.w, 0, 0, _overlayBackup.w, _overlayBackup.h); if (!g_gui.isActive()) _system->hideOverlay(); _overlayBackup.free(); @@ -183,16 +183,15 @@ void VirtualKeyboardGUI::close() { } void VirtualKeyboardGUI::reset() { - _kbdBound.left = _kbdBound.top - = _kbdBound.right = _kbdBound.bottom = 0; + _kbdBound.left = _kbdBound.top = 0; + _kbdBound.right = _kbdBound.bottom = 0; _displaying = _drag = false; _firstRun = true; _lastScreenChanged = _system->getScreenChangeID(); _kbdSurface = 0; } -void VirtualKeyboardGUI::moveToDefaultPosition() -{ +void VirtualKeyboardGUI::moveToDefaultPosition() { int16 kbdW = _kbdBound.width(), kbdH = _kbdBound.height(); int16 x = 0, y = 0; if (_screenW != kbdW) { @@ -263,7 +262,7 @@ void VirtualKeyboardGUI::screenChanged() { _screenH = newScreenH; _overlayBackup.create(_screenW, _screenH, _system->getOverlayFormat()); - _system->grabOverlay((OverlayColor*)_overlayBackup.pixels, _overlayBackup.w); + _system->grabOverlay((OverlayColor *)_overlayBackup.pixels, _overlayBackup.w); if (!_kbd->checkModeResolutions()) { _displaying = false; @@ -290,19 +289,19 @@ void VirtualKeyboardGUI::mainLoop() { case Common::EVENT_LBUTTONDOWN: if (_kbdBound.contains(event.mouse)) { _kbd->handleMouseDown(event.mouse.x - _kbdBound.left, - event.mouse.y - _kbdBound.top); + event.mouse.y - _kbdBound.top); } break; case Common::EVENT_LBUTTONUP: if (_kbdBound.contains(event.mouse)) { _kbd->handleMouseUp(event.mouse.x - _kbdBound.left, - event.mouse.y - _kbdBound.top); + event.mouse.y - _kbdBound.top); } break; case Common::EVENT_MOUSEMOVE: if (_drag) move(event.mouse.x - _dragPoint.x, - event.mouse.y - _dragPoint.y); + event.mouse.y - _dragPoint.y); break; case Common::EVENT_SCREEN_CHANGED: screenChanged(); @@ -367,20 +366,20 @@ void VirtualKeyboardGUI::redraw() { } blit(&surf, _kbdSurface, _kbdBound.left - _dirtyRect.left, - _kbdBound.top - _dirtyRect.top, _kbdTransparentColor); + _kbdBound.top - _dirtyRect.top, _kbdTransparentColor); if (_displayEnabled) { blit(&surf, &_dispSurface, _dispX - _dirtyRect.left, - _dispY - _dirtyRect.top, _dispBackColor); + _dispY - _dirtyRect.top, _dispBackColor); } - _system->copyRectToOverlay((OverlayColor*)surf.pixels, surf.w, - _dirtyRect.left, _dirtyRect.top, surf.w, surf.h); + _system->copyRectToOverlay((OverlayColor *)surf.pixels, surf.w, + _dirtyRect.left, _dirtyRect.top, surf.w, surf.h); surf.free(); resetDirtyRect(); } -uint VirtualKeyboardGUI::calculateEndIndex(const String& str, uint startIndex) { +uint VirtualKeyboardGUI::calculateEndIndex(const String &str, uint startIndex) { int16 w = 0; while (w <= _dispSurface.w && startIndex < str.size()) { w += _dispFont->getCharWidth(str[startIndex++]); @@ -436,10 +435,10 @@ void VirtualKeyboardGUI::updateDisplay() { void VirtualKeyboardGUI::setupCursor() { const byte palette[] = { - 255, 255, 255, 0, - 255, 255, 255, 0, - 171, 171, 171, 0, - 87, 87, 87, 0 + 255, 255, 255, + 255, 255, 255, + 171, 171, 171, + 87, 87, 87 }; CursorMan.pushCursorPalette(palette, 0, 4); diff --git a/backends/vkeybd/virtual-keyboard-gui.h b/backends/vkeybd/virtual-keyboard-gui.h index da80ef2223..d0f9c884ed 100644 --- a/backends/vkeybd/virtual-keyboard-gui.h +++ b/backends/vkeybd/virtual-keyboard-gui.h @@ -121,7 +121,7 @@ private: bool _displaying; bool _firstRun; - void setupDisplayArea(Rect& r, OverlayColor forecolor); + void setupDisplayArea(Rect &r, OverlayColor forecolor); void move(int16 x, int16 y); void moveToDefaultPosition(); void screenChanged(); @@ -131,8 +131,8 @@ private: void redraw(); void forceRedraw(); void updateDisplay(); - bool fontIsSuitable(const Graphics::Font *font, const Rect& rect); - uint calculateEndIndex(const String& str, uint startIndex); + bool fontIsSuitable(const Graphics::Font *font, const Rect &rect); + uint calculateEndIndex(const String &str, uint startIndex); bool _drawCaret; int16 _caretX; @@ -141,7 +141,7 @@ private: static const int kCursorAnimateDelay = 250; int _cursorAnimateCounter; - int _cursorAnimateTimer; + int _cursorAnimateTimer; byte _cursor[2048]; void setupCursor(); void removeCursor(); diff --git a/backends/vkeybd/virtual-keyboard-parser.cpp b/backends/vkeybd/virtual-keyboard-parser.cpp index 58f0c468f6..1958113578 100644 --- a/backends/vkeybd/virtual-keyboard-parser.cpp +++ b/backends/vkeybd/virtual-keyboard-parser.cpp @@ -116,7 +116,7 @@ bool VirtualKeyboardParser::parserCallback_mode(ParserNode *node) { _keyboard->_initialMode = _mode; String resolutions = node->values["resolutions"]; - StringTokenizer tok (resolutions, " ,"); + StringTokenizer tok(resolutions, " ,"); // select best resolution simply by minimising the difference between the // overlay size and the resolution dimensions. @@ -189,7 +189,7 @@ bool VirtualKeyboardParser::parserCallback_event(ParserNode *node) { } evt->type = VirtualKeyboard::kVKEventKey; - KeyState *ks = (KeyState*) malloc(sizeof(KeyState)); + KeyState *ks = (KeyState *)malloc(sizeof(KeyState)); ks->keycode = (KeyCode)atoi(node->values["code"].c_str()); ks->ascii = atoi(node->values["ascii"].c_str()); ks->flags = 0; @@ -204,7 +204,7 @@ bool VirtualKeyboardParser::parserCallback_event(ParserNode *node) { } evt->type = VirtualKeyboard::kVKEventModifier; - byte *flags = (byte*) malloc(sizeof(byte)); + byte *flags = (byte *)malloc(sizeof(byte)); if (!flags) error("[VirtualKeyboardParser::parserCallback_event] Cannot allocate memory"); @@ -218,8 +218,8 @@ bool VirtualKeyboardParser::parserCallback_event(ParserNode *node) { } evt->type = VirtualKeyboard::kVKEventSwitchMode; - String& mode = node->values["mode"]; - char *str = (char*) malloc(sizeof(char) * mode.size() + 1); + String &mode = node->values["mode"]; + char *str = (char *)malloc(sizeof(char) * mode.size() + 1); if (!str) error("[VirtualKeyboardParser::parserCallback_event] Cannot allocate memory"); @@ -302,9 +302,9 @@ bool VirtualKeyboardParser::parserCallback_map(ParserNode *node) { } bool VirtualKeyboardParser::parserCallback_area(ParserNode *node) { - String& shape = node->values["shape"]; - String& target = node->values["target"]; - String& coords = node->values["coords"]; + String &shape = node->values["shape"]; + String &target = node->values["target"]; + String &coords = node->values["coords"]; if (target.equalsIgnoreCase("display_area")) { if (!shape.equalsIgnoreCase("rect")) @@ -313,15 +313,21 @@ bool VirtualKeyboardParser::parserCallback_area(ParserNode *node) { return parseRect(_mode->displayArea, coords); } else if (shape.equalsIgnoreCase("rect")) { Polygon *poly = _mode->imageMap.createArea(target); - return parseRectAsPolygon(*poly, coords); + if (!poly) + return parserError(Common::String::format("Cannot define area '%s' again", target.c_str())); + else + return parseRectAsPolygon(*poly, coords); } else if (shape.equalsIgnoreCase("poly")) { Polygon *poly = _mode->imageMap.createArea(target); - return parsePolygon(*poly, coords); + if (!poly) + return parserError(Common::String::format("Cannot define area '%s' again", target.c_str())); + else + return parsePolygon(*poly, coords); } return parserError("Area shape '" + shape + "' not known"); } -byte VirtualKeyboardParser::parseFlags(const String& flags) { +byte VirtualKeyboardParser::parseFlags(const String &flags) { if (flags.empty()) return 0; @@ -338,7 +344,7 @@ byte VirtualKeyboardParser::parseFlags(const String& flags) { return val; } -bool VirtualKeyboardParser::parseRect(Rect &rect, const String& coords) { +bool VirtualKeyboardParser::parseRect(Rect &rect, const String &coords) { int x1, y1, x2, y2; if (!parseIntegerKey(coords, 4, &x1, &y1, &x2, &y2)) return parserError("Invalid coords for rect area"); @@ -351,7 +357,7 @@ bool VirtualKeyboardParser::parseRect(Rect &rect, const String& coords) { return true; } -bool VirtualKeyboardParser::parsePolygon(Polygon &poly, const String& coords) { +bool VirtualKeyboardParser::parsePolygon(Polygon &poly, const String &coords) { StringTokenizer tok(coords, ", "); for (String st = tok.nextToken(); !st.empty(); st = tok.nextToken()) { int x, y; @@ -368,7 +374,7 @@ bool VirtualKeyboardParser::parsePolygon(Polygon &poly, const String& coords) { return true; } -bool VirtualKeyboardParser::parseRectAsPolygon(Polygon &poly, const String& coords) { +bool VirtualKeyboardParser::parseRectAsPolygon(Polygon &poly, const String &coords) { Rect rect; if (!parseRect(rect, coords)) return false; diff --git a/backends/vkeybd/virtual-keyboard-parser.h b/backends/vkeybd/virtual-keyboard-parser.h index eb25ebe6fd..c8a2c4158e 100644 --- a/backends/vkeybd/virtual-keyboard-parser.h +++ b/backends/vkeybd/virtual-keyboard-parser.h @@ -56,31 +56,31 @@ keyboard layouts for different screen resolutions. <area shape="poly" coords="65,50,67,48,94,48,96,50,96,77,94,79,67,79,65,77" target="q" /> <area shape="poly" coords="105,50,107,48,134,48,136,50,136,77,134,79,107,79,105,77" target="w" /> <area shape="poly" coords="146,50,148,48,174,48,176,50,176,77,174,79,148,79,146,77" target="e" /> - ... + ... <area shape="poly" coords="11,89,12,88,69,88,70,89,70,116,69,117,12,117,11,116" target="caps" /> </map> - </layout> - <layout resolution="320x200" bitmap="normal_320x200.bmp" transparent_color="255,0,255"> - ... - </layout> + </layout> + <layout resolution="320x200" bitmap="normal_320x200.bmp" transparent_color="255,0,255"> + ... + </layout> <event name="a" type="key" code="97" ascii="97" modifiers="" /> <event name="b" type="key" code="98" ascii="98" modifiers="" /> <event name="c" type="key" code="99" ascii="99" modifiers="" /> - ... - <event name="caps" type="switch_mode" mode="caps" /> + ... + <event name="caps" type="switch_mode" mode="caps" /> </mode> <mode name="caps" resolutions="640x400"> <layout resolution="640x400" bitmap="caps_640x480.bmp" transparent_color="255,0,255"> <map> <area shape="poly" coords="65,50,67,48,94,48,96,50,96,77,94,79,67,79,65,77" target="Q" /> - ... + ... </map> </layout> <event name="A" type="key" code="97" ascii="65" modifiers="shift" /> <event name="B" type="key" code="98" ascii="66" modifiers="shift" /> <event name="C" type="key" code="99" ascii="67" modifiers="shift" /> - ... + ... </mode> </keyboard> @@ -188,6 +188,7 @@ public: * Full parse - when loading keyboard pack for first time */ kParseFull, + /** * Just check resolutions and reload layouts if needed - following a * change in screen size @@ -257,10 +258,10 @@ protected: virtual bool closedKeyCallback(ParserNode *node); /** Parse helper functions */ - byte parseFlags(const String& flags); - bool parseRect(Rect &rect, const String& coords); - bool parsePolygon(Polygon &poly, const String& coords); - bool parseRectAsPolygon(Polygon &poly, const String& coords); + byte parseFlags(const String &flags); + bool parseRect(Rect &rect, const String &coords); + bool parsePolygon(Polygon &poly, const String &coords); + bool parseRectAsPolygon(Polygon &poly, const String &coords); }; } // End of namespace GUI diff --git a/backends/vkeybd/virtual-keyboard.cpp b/backends/vkeybd/virtual-keyboard.cpp index 1dada06951..678c751410 100644 --- a/backends/vkeybd/virtual-keyboard.cpp +++ b/backends/vkeybd/virtual-keyboard.cpp @@ -56,11 +56,9 @@ VirtualKeyboard::~VirtualKeyboard() { } void VirtualKeyboard::deleteEvents() { - ModeMap::iterator it_m; - VKEventMap::iterator it_e; - for (it_m = _modes.begin(); it_m != _modes.end(); ++it_m) { - VKEventMap *evt = &(it_m->_value.events); - for (it_e = evt->begin(); it_e != evt->end(); ++it_e) + for (ModeMap::iterator it_m = _modes.begin(); it_m != _modes.end(); ++it_m) { + VKEventMap &evt = it_m->_value.events; + for (VKEventMap::iterator it_e = evt.begin(); it_e != evt.end(); ++it_e) delete it_e->_value; } } @@ -160,7 +158,7 @@ String VirtualKeyboard::findArea(int16 x, int16 y) { return _currentMode->imageMap.findMapArea(x, y); } -void VirtualKeyboard::processAreaClick(const String& area) { +void VirtualKeyboard::processAreaClick(const String &area) { if (!_currentMode->events.contains(area)) return; @@ -169,10 +167,10 @@ void VirtualKeyboard::processAreaClick(const String& area) { switch (evt->type) { case kVKEventKey: // add virtual keypress to queue - _keyQueue.insertKey(*(KeyState*)evt->data); + _keyQueue.insertKey(*(KeyState *)evt->data); break; case kVKEventModifier: - _keyQueue.toggleFlags(*(byte*)(evt->data)); + _keyQueue.toggleFlags(*(byte *)(evt->data)); break; case kVKEventSwitchMode: // switch to new mode @@ -332,7 +330,7 @@ void VirtualKeyboard::KeyPressQueue::insertKey(KeyState key) { void VirtualKeyboard::KeyPressQueue::deleteKey() { if (_keyPos == _keys.begin()) return; - List<VirtualKeyPress>::iterator it = _keyPos; + KeyPressList::iterator it = _keyPos; it--; _strPos -= it->strLen; while ((it->strLen)-- > 0) diff --git a/backends/vkeybd/virtual-keyboard.h b/backends/vkeybd/virtual-keyboard.h index 21db5a47da..4ab5ad446d 100644 --- a/backends/vkeybd/virtual-keyboard.h +++ b/backends/vkeybd/virtual-keyboard.h @@ -102,21 +102,21 @@ protected: } }; - typedef HashMap<String, VKEvent*> VKEventMap; + typedef HashMap<String, VKEvent *> VKEventMap; /** * Mode struct encapsulates all the data for each mode of the keyboard */ struct Mode { - String name; - String resolution; - String bitmapName; - Graphics::Surface *image; - OverlayColor transparentColor; - ImageMap imageMap; - VKEventMap events; - Rect displayArea; - OverlayColor displayFontColor; + String name; + String resolution; + String bitmapName; + Graphics::Surface *image; + OverlayColor transparentColor; + ImageMap imageMap; + VKEventMap events; + Rect displayArea; + OverlayColor displayFontColor; Mode() : image(0) {} ~Mode() { @@ -172,13 +172,13 @@ protected: byte _flags; String _flagsStr; - - List<VirtualKeyPress> _keys; + typedef List<VirtualKeyPress> KeyPressList; + KeyPressList _keys; String _keysStr; bool _strChanged; - List<VirtualKeyPress>::iterator _keyPos; + KeyPressList::iterator _keyPos; uint _strPos; }; @@ -193,7 +193,7 @@ public: * The system first looks for an uncompressed keyboard pack by searching * for packName.xml in the filesystem, if this does not exist then it * searches for a compressed keyboard pack by looking for packName.zip. - * @param packName name of the keyboard pack + * @param packName name of the keyboard pack */ bool loadKeyboardPack(const String &packName); @@ -206,8 +206,8 @@ public: /** * Hides the keyboard, ending the event loop. - * @param submit if true all accumulated key presses are submitted to - * the event manager + * @param submit if true all accumulated key presses are submitted to + * the event manager */ void close(bool submit); @@ -229,7 +229,7 @@ protected: Archive *_fileArchive; friend class VirtualKeyboardGUI; - VirtualKeyboardGUI *_kbdGUI; + VirtualKeyboardGUI *_kbdGUI; KeyPressQueue _keyQueue; @@ -241,7 +241,7 @@ protected: void deleteEvents(); bool checkModeResolutions(); void switchMode(Mode *newMode); - void switchMode(const String& newMode); + void switchMode(const String &newMode); void handleMouseDown(int16 x, int16 y); void handleMouseUp(int16 x, int16 y); String findArea(int16 x, int16 y); |