Skip to content

Commit

Permalink
DINGUX: fix compilation for the opengl branch
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hkzlab committed Oct 23, 2010
1 parent b713bee commit 74a53df
Show file tree
Hide file tree
Showing 11 changed files with 240 additions and 108 deletions.
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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 */
47 changes: 47 additions & 0 deletions backends/events/dinguxsdl/dinguxsdl-events.h
@@ -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 */
Expand Up @@ -23,30 +23,30 @@
*
*/

#include "backends/platform/dingux/dingux.h"
#if defined (DINGUX)

#include "common/mutex.h"
#include "graphics/scaler.h"
#include "backends/graphics/dinguxsdl/dinguxsdl-graphics.h"
#include "backends/events/dinguxsdl/dinguxsdl-events.h"
#include "graphics/scaler/aspect.h"
#include "graphics/scaler/downscaler.h"
#include "graphics/surface.h"

#if defined (DINGUX)

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);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -461,8 +461,46 @@ bool OSystem_SDL_Dingux::loadGFXMode() {
}


return OSystem_SDL::loadGFXMode();
return SdlGraphicsManager::loadGFXMode();
}

#endif
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
69 changes: 69 additions & 0 deletions backends/graphics/dinguxsdl/dinguxsdl-graphics.h
@@ -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 */
2 changes: 1 addition & 1 deletion backends/graphics/sdl/sdl-graphics.cpp
Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions backends/module.mk
Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down

0 comments on commit 74a53df

Please sign in to comment.