DINGUX: fix compilation for the opengl branch

Moved events related code to backends/events/dinguxsdl/*
and move graphics related code to backends/graphics/dinguxsdl/*
Subclass OSystem_POSIX instead of OSystem_SDL

svn-id: r53730
This commit is contained in:
Fabio Battaglia 2010-10-23 09:30:26 +00:00
parent b713beed18
commit 74a53df11b
11 changed files with 241 additions and 109 deletions

View file

@ -23,11 +23,10 @@
*
*/
#include "backends/platform/dingux/dingux.h"
#if defined(DINGUX)
#include "graphics/scaler/aspect.h" // for aspect2Real
#if defined (DINGUX)
#include "backends/events/dinguxsdl/dinguxsdl-events.h"
#include "graphics/scaler/aspect.h" // for aspect2Real
#define PAD_UP SDLK_UP
#define PAD_DOWN SDLK_DOWN
@ -59,7 +58,11 @@ static int mapKey(SDLKey key, SDLMod mod, Uint16 unicode) {
return key;
}
bool OSystem_SDL_Dingux::remapKey(SDL_Event &ev, Common::Event &event) {
DINGUXSdlEventSource::DINGUXSdlEventSource() : SdlEventSource() {
;
}
bool DINGUXSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
if (ev.key.keysym.sym == PAD_UP) {
if (ev.type == SDL_KEYDOWN) {
_km.y_vel = -1;
@ -179,8 +182,8 @@ bool OSystem_SDL_Dingux::remapKey(SDL_Event &ev, Common::Event &event) {
return false;
}
void OSystem_SDL_Dingux::fillMouseEvent(Common::Event &event, int x, int y) {
if (_videoMode.mode == GFX_HALF && !_overlayVisible) {
void DINGUXSdlEventSource::fillMouseEvent(Common::Event &event, int x, int y) {
if (_grpMan->getVideoMode()->mode == GFX_HALF && !(_grpMan->isOverlayVisible())) {
event.mouse.x = x * 2;
event.mouse.y = y * 2;
} else {
@ -193,23 +196,31 @@ void OSystem_SDL_Dingux::fillMouseEvent(Common::Event &event, int x, int y) {
_km.y = y;
// Adjust for the screen scaling
if (!_overlayVisible) {
event.mouse.x /= _videoMode.scaleFactor;
event.mouse.y /= _videoMode.scaleFactor;
if (_videoMode.aspectRatioCorrection)
if (!(_grpMan->isOverlayVisible())) {
event.mouse.x /= (_grpMan->getVideoMode())->scaleFactor;
event.mouse.y /= (_grpMan->getVideoMode())->scaleFactor;
#if 0
if (_grpMan->getVideoMode()->aspectRatioCorrection)
event.mouse.y = aspect2Real(event.mouse.y);
#endif
}
}
void OSystem_SDL_Dingux::warpMouse(int x, int y) {
if (_mouseCurState.x != x || _mouseCurState.y != y) {
if (_videoMode.mode == GFX_HALF && !_overlayVisible) {
void DINGUXSdlEventSource::warpMouse(int x, int y) {
int mouse_cur_x = _grpMan->getMouseCurState()->x;
int mouse_cur_y = _grpMan->getMouseCurState()->y;
if ((mouse_cur_x != x) || (mouse_cur_y != y)) {
if (_grpMan->getVideoMode()->mode == GFX_HALF && !(_grpMan->isOverlayVisible())) {
x = x / 2;
y = y / 2;
}
}
OSystem_SDL::warpMouse(x, y);
SDL_WarpMouse(x, y);
}
#endif
void DINGUXSdlEventSource::setCurrentGraphMan(DINGUXSdlGraphicsManager *_graphicManager) {
_grpMan = _graphicManager;
}
#endif /* DINGUX */

View file

@ -0,0 +1,47 @@
/* 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.
*
* $URL$
* $Id$
*
*/
#ifndef BACKENDS_EVENTS_SDL_DINGUX_H
#define BACKENDS_EVENTS_SDL_DINGUX_H
#if defined(DINGUX)
#include "backends/platform/dingux/dingux.h"
#include "backends/events/dinguxsdl/dinguxsdl-events.h"
class DINGUXSdlEventSource : public SdlEventSource {
public:
DINGUXSdlEventSource();
void setCurrentGraphMan(DINGUXSdlGraphicsManager *_graphicManager);
protected:
DINGUXSdlGraphicsManager *_grpMan;
bool remapKey(SDL_Event &ev, Common::Event &event);
void fillMouseEvent(Common::Event &event, int x, int y);
void warpMouse(int x, int y);
};
#endif /* DINGUX */
#endif /* BACKENDS_EVENTS_SDL_DINGUX_H */

View file

@ -23,30 +23,30 @@
*
*/
#include "backends/platform/dingux/dingux.h"
#include "common/mutex.h"
#include "graphics/scaler.h"
#include "graphics/scaler/aspect.h"
#include "graphics/scaler/downscaler.h"
#include "graphics/surface.h"
#if defined (DINGUX)
#include "backends/graphics/dinguxsdl/dinguxsdl-graphics.h"
#include "backends/events/dinguxsdl/dinguxsdl-events.h"
#include "graphics/scaler/aspect.h"
static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
{"1x", "Standard", GFX_NORMAL},
{0, 0, 0}
};
int OSystem_SDL_Dingux::getDefaultGraphicsMode() const {
return GFX_NORMAL;
DINGUXSdlGraphicsManager::DINGUXSdlGraphicsManager(SdlEventSource *boss) : SdlGraphicsManager(boss) {
_evSrc = boss;
}
const OSystem::GraphicsMode *OSystem_SDL_Dingux::getSupportedGraphicsModes() const {
const OSystem::GraphicsMode *DINGUXSdlGraphicsManager::getSupportedGraphicsModes() const {
return s_supportedGraphicsModes;
}
bool OSystem_SDL_Dingux::setGraphicsMode(int mode) {
int DINGUXSdlGraphicsManager::getDefaultGraphicsMode() const {
return GFX_NORMAL;
}
bool DINGUXSdlGraphicsManager::setGraphicsMode(int mode) {
Common::StackLock lock(_graphicsMutex);
assert(_transactionMode == kTransactionActive);
@ -80,7 +80,7 @@ bool OSystem_SDL_Dingux::setGraphicsMode(int mode) {
return true;
}
void OSystem_SDL_Dingux::setGraphicsModeIntern() {
void DINGUXSdlGraphicsManager::setGraphicsModeIntern() {
Common::StackLock lock(_graphicsMutex);
ScalerProc *newScalerProc = 0;
@ -109,7 +109,7 @@ void OSystem_SDL_Dingux::setGraphicsModeIntern() {
blitCursor();
}
void OSystem_SDL_Dingux::initSize(uint w, uint h) {
void DINGUXSdlGraphicsManager::initSize(uint w, uint h) {
assert(_transactionMode == kTransactionActive);
// Avoid redundant res changes
@ -121,13 +121,13 @@ void OSystem_SDL_Dingux::initSize(uint w, uint h) {
if (w > 320 || h > 240) {
setGraphicsMode(GFX_HALF);
setGraphicsModeIntern();
toggleMouseGrab();
_evSrc->toggleMouseGrab();
}
_transactionDetails.sizeChanged = true;
}
void OSystem_SDL_Dingux::drawMouse() {
void DINGUXSdlGraphicsManager::drawMouse() {
if (!_mouseVisible || !_mouseSurface) {
_mouseBackup.x = _mouseBackup.y = _mouseBackup.w = _mouseBackup.h = 0;
return;
@ -193,7 +193,7 @@ void OSystem_SDL_Dingux::drawMouse() {
addDirtyRect(dst.x, dst.y, dst.w, dst.h, true);
}
void OSystem_SDL_Dingux::undrawMouse() {
void DINGUXSdlGraphicsManager::undrawMouse() {
const int x = _mouseBackup.x;
const int y = _mouseBackup.y;
@ -211,7 +211,7 @@ void OSystem_SDL_Dingux::undrawMouse() {
}
}
void OSystem_SDL_Dingux::internUpdateScreen() {
void DINGUXSdlGraphicsManager::internUpdateScreen() {
SDL_Surface *srcSurf, *origSurf;
int height, width;
ScalerProc *scalerProc;
@ -409,23 +409,23 @@ void OSystem_SDL_Dingux::internUpdateScreen() {
_mouseNeedsRedraw = false;
}
void OSystem_SDL_Dingux::showOverlay() {
void DINGUXSdlGraphicsManager::showOverlay() {
if (_videoMode.mode == GFX_HALF) {
_mouseCurState.x = _mouseCurState.x / 2;
_mouseCurState.y = _mouseCurState.y / 2;
}
OSystem_SDL::showOverlay();
SdlGraphicsManager::showOverlay();
}
void OSystem_SDL_Dingux::hideOverlay() {
void DINGUXSdlGraphicsManager::hideOverlay() {
if (_videoMode.mode == GFX_HALF) {
_mouseCurState.x = _mouseCurState.x * 2;
_mouseCurState.y = _mouseCurState.y * 2;
}
OSystem_SDL::hideOverlay();
SdlGraphicsManager::hideOverlay();
}
bool OSystem_SDL_Dingux::loadGFXMode() {
bool DINGUXSdlGraphicsManager::loadGFXMode() {
// Forcefully disable aspect ratio correction for games
// which starts with a native 240px height resolution.
@ -461,8 +461,46 @@ bool OSystem_SDL_Dingux::loadGFXMode() {
}
return OSystem_SDL::loadGFXMode();
return SdlGraphicsManager::loadGFXMode();
}
bool DINGUXSdlGraphicsManager::hasFeature(OSystem::Feature f) {
return
(f == OSystem::kFeatureAspectRatioCorrection) ||
(f == OSystem::kFeatureCursorHasPalette);
}
void DINGUXSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {
switch (f) {
case OSystem::kFeatureAspectRatioCorrection:
setAspectRatioCorrection(enable);
break;
default:
break;
}
}
bool DINGUXSdlGraphicsManager::getFeatureState(OSystem::Feature f) {
assert(_transactionMode == kTransactionNone);
switch (f) {
case OSystem::kFeatureAspectRatioCorrection:
return _videoMode.aspectRatioCorrection;
default:
return false;
}
}
SdlGraphicsManager::MousePos* DINGUXSdlGraphicsManager::getMouseCurState() {
return &_mouseCurState;
}
SdlGraphicsManager::VideoState* DINGUXSdlGraphicsManager::getVideoMode() {
return &_videoMode;
}
bool DINGUXSdlGraphicsManager::isOverlayVisible() {
return _overlayVisible;
}
#endif

View file

@ -0,0 +1,69 @@
/* 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.
*
* $URL$
* $Id$
*
*/
#ifndef BACKENDS_GRAPHICS_SDL_DINGUX_H
#define BACKENDS_GRAPHICS_SDL_DINGUX_H
#if defined (DINGUX)
#include "backends/graphics/sdl/sdl-graphics.h"
#include "graphics/scaler/aspect.h" // for aspect2Real
#include "graphics/scaler/downscaler.h"
enum {
GFX_HALF = 12
};
class DINGUXSdlGraphicsManager : public SdlGraphicsManager {
public:
DINGUXSdlGraphicsManager(SdlEventSource *boss);
bool hasFeature(OSystem::Feature f);
void setFeatureState(OSystem::Feature f, bool enable);
bool getFeatureState(OSystem::Feature f);
int getDefaultGraphicsMode() const;
void initSize(uint w, uint h);
const OSystem::GraphicsMode *getSupportedGraphicsModes() const;
bool setGraphicsMode(const char *name);
bool setGraphicsMode(int mode);
void setGraphicsModeIntern();
void internUpdateScreen();
void showOverlay();
void hideOverlay();
bool loadGFXMode();
void drawMouse();
void undrawMouse();
SdlGraphicsManager::MousePos *getMouseCurState();
SdlGraphicsManager::VideoState *getVideoMode();
bool isOverlayVisible();
protected:
SdlEventSource *_evSrc;
};
#endif /* DINGUX */
#endif /* BACKENDS_GRAPHICS_SDL_DINGUX_H */

View file

@ -698,7 +698,7 @@ static void fixupResolutionForAspectRatio(AspectRatio desiredAspectRatio, int &w
bool SdlGraphicsManager::loadGFXMode() {
_forceFull = true;
#if !defined(__MAEMO__) && !defined(GP2XWIZ) && !defined(LINUXMOTO)
#if !defined(__MAEMO__) && !defined(GP2XWIZ) && !defined(LINUXMOTO) && !defined(DINGUX)
_videoMode.overlayWidth = _videoMode.screenWidth * _videoMode.scaleFactor;
_videoMode.overlayHeight = _videoMode.screenHeight * _videoMode.scaleFactor;

View file

@ -6,6 +6,7 @@ MODULE_OBJS := \
audiocd/default/default-audiocd.o \
audiocd/sdl/sdl-audiocd.o \
events/default/default-events.o \
events/dinguxsdl/dinguxsdl-events.o \
events/gp2xsdl/gp2xsdl-events.o \
events/linuxmotosdl/linuxmotosdl-events.o \
events/samsungtvsdl/samsungtvsdl-events.o \
@ -17,6 +18,7 @@ MODULE_OBJS := \
fs/posix/posix-fs-factory.o \
fs/symbian/symbian-fs-factory.o \
fs/windows/windows-fs-factory.o \
graphics/dinguxsdl/dinguxsdl-graphics.o \
graphics/gp2xsdl/gp2xsdl-graphics.o \
graphics/gp2xwizsdl/gp2xwizsdl-graphics.o \
graphics/linuxmotosdl/linuxmotosdl-graphics.o \

View file

@ -23,35 +23,25 @@
*
*/
#include "backends/platform/dingux/dingux.h"
#if defined(DINGUX)
bool OSystem_SDL_Dingux::hasFeature(Feature f) {
return
(f == kFeatureAspectRatioCorrection) ||
(f == kFeatureCursorHasPalette);
}
#include "backends/platform/dingux/dingux.h"
#include "backends/events/dinguxsdl/dinguxsdl-events.h"
#include "backends/graphics/dinguxsdl/dinguxsdl-graphics.h"
void OSystem_SDL_Dingux::setFeatureState(Feature f, bool enable) {
switch (f) {
case kFeatureAspectRatioCorrection:
setAspectRatioCorrection(enable);
break;
default:
break;
void OSystem_SDL_Dingux::initBackend() {
// Create the events manager
if (_eventSource == 0)
_eventSource = new DINGUXSdlEventSource();
// Create the graphics manager
if (_graphicsManager == 0) {
_graphicsManager = new DINGUXSdlGraphicsManager(_eventSource);
((DINGUXSdlEventSource*)_eventSource)->setCurrentGraphMan((DINGUXSdlGraphicsManager*)_graphicsManager);
}
}
bool OSystem_SDL_Dingux::getFeatureState(Feature f) {
assert(_transactionMode == kTransactionNone);
switch (f) {
case kFeatureAspectRatioCorrection:
return _videoMode.aspectRatioCorrection;
default:
return false;
}
// Call parent implementation of this method
OSystem_POSIX::initBackend();
}
#endif

View file

@ -26,44 +26,21 @@
#ifndef SDL_DINGUX_COMMON_H
#define SDL_DINGUX_COMMON_H
#include <SDL.h>
#include "backends/base-backend.h"
#include "backends/platform/sdl/sdl.h"
#if defined(DINGUX)
enum {
GFX_HALF = 12
};
#include <SDL.h>
#include "backends/base-backend.h"
#include "backends/platform/sdl/sdl.h"
#include "backends/platform/sdl/posix/posix.h"
#include "backends/graphics/dinguxsdl/dinguxsdl-graphics.h"
#include "backends/events/dinguxsdl/dinguxsdl-events.h"
class OSystem_SDL_Dingux : public OSystem_SDL {
class OSystem_SDL_Dingux : public OSystem_POSIX {
public:
virtual bool hasFeature(Feature f);
virtual void setFeatureState(Feature f, bool enable);
virtual bool getFeatureState(Feature f);
virtual int getDefaultGraphicsMode() const;
void initSize(uint w, uint h);
const OSystem::GraphicsMode *getSupportedGraphicsModes() const;
bool setGraphicsMode(const char *name);
bool setGraphicsMode(int mode);
void setGraphicsModeIntern();
void internUpdateScreen();
void showOverlay();
void hideOverlay();
bool loadGFXMode();
void drawMouse();
void undrawMouse();
void warpMouse(int, int);
void fillMouseEvent(Common::Event&, int, int);
protected:
virtual bool remapKey(SDL_Event &ev, Common::Event &event);
void initBackend();
};
#endif
#endif
#endif /* DINGUX */
#endif /* SDL_DINGUX_COMMON_H */

View file

@ -24,8 +24,7 @@
*/
#include "backends/platform/dingux/dingux.h"
#include "backends/plugins/sdl/sdl-provider.h"
//#include "backends/plugins/posix/posix-provider.h"
#include "backends/plugins/posix/posix-provider.h"
#include "base/main.h"
#if defined(DINGUX)
@ -37,16 +36,17 @@ int main(int argc, char* argv[]) {
g_system = new OSystem_SDL_Dingux();
assert(g_system);
((OSystem_SDL_Dingux *)g_system)->init();
#ifdef DYNAMIC_MODULES
PluginManager::instance().addPluginProvider(new SDLPluginProvider());
// PluginManager::instance().addPluginProvider(new POSIXPluginProvider());
PluginManager::instance().addPluginProvider(new POSIXPluginProvider());
#endif
// Invoke the actual ScummVM main entry point:
int res = scummvm_main(argc, argv);
((OSystem_SDL *)g_system)->deinit();
return res;
((OSystem_SDL_Dingux *)g_system)->deinit();
return res;
}
#endif

View file

@ -2,9 +2,7 @@ MODULE := backends/platform/dingux
MODULE_OBJS := \
main.o \
dingux.o \
dingux-events.o \
dingux-graphics.o \
dingux.o
MODULE_DIRS += \
backends/platform/dingux/

View file

@ -23,7 +23,7 @@
*
*/
#if defined(UNIX) && !defined(MACOSX) && !defined(SAMSUNGTV) && !defined(LINUXMOTO) && !defined(GP2XWIZ) && !defined(GP2X)
#if defined(UNIX) && !defined(MACOSX) && !defined(SAMSUNGTV) && !defined(LINUXMOTO) && !defined(GP2XWIZ) && !defined(GP2X) && !defined(DINGUX)
#include "backends/platform/sdl/posix/posix.h"
#include "backends/plugins/sdl/sdl-provider.h"