[Scummvm-cvs-logs] SF.net SVN: scummvm:[53433] scummvm/branches/gsoc2010-opengl/backends

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Wed Oct 13 17:42:16 CEST 2010


Revision: 53433
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53433&view=rev
Author:   lordhoto
Date:     2010-10-13 15:42:16 +0000 (Wed, 13 Oct 2010)

Log Message:
-----------
OPENGL: Replace SdlEventManager by SdlEventSource.

Formerly SdlEventManager was a subclass of DefaultEventManager but did not
really have anything in common with the idea of our EventManager interface.
Now I made a new object SdlEventSource which only subclasses EventSource
and which is responsible for obtaining events from SDL (and processing them).

Modified Paths:
--------------
    scummvm/branches/gsoc2010-opengl/backends/events/sdl/sdl-events.cpp
    scummvm/branches/gsoc2010-opengl/backends/events/sdl/sdl-events.h
    scummvm/branches/gsoc2010-opengl/backends/graphics/sdl/sdl-graphics.cpp
    scummvm/branches/gsoc2010-opengl/backends/modular-backend.h
    scummvm/branches/gsoc2010-opengl/backends/platform/sdl/sdl.cpp
    scummvm/branches/gsoc2010-opengl/backends/platform/sdl/sdl.h

Modified: scummvm/branches/gsoc2010-opengl/backends/events/sdl/sdl-events.cpp
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/events/sdl/sdl-events.cpp	2010-10-13 15:41:55 UTC (rev 53432)
+++ scummvm/branches/gsoc2010-opengl/backends/events/sdl/sdl-events.cpp	2010-10-13 15:42:16 UTC (rev 53433)
@@ -48,13 +48,8 @@
 #define JOY_BUT_SPACE 4
 #define JOY_BUT_F5 5
 
-SdlEventManager::SdlEventManager(Common::EventSource *boss)
-	:
-	_scrollLock(false),
-	_joystick(0),
-	_lastScreenID(0),
-	DefaultEventManager(boss) {
-
+SdlEventSource::SdlEventSource()
+    : _scrollLock(false), _joystick(0), _lastScreenID(0), EventSource() {
 	// Reset mouse state
 	memset(&_km, 0, sizeof(_km));
 
@@ -73,12 +68,12 @@
 	}
 }
 
-SdlEventManager::~SdlEventManager() {
+SdlEventSource::~SdlEventSource() {
 	if (_joystick)
 		SDL_JoystickClose(_joystick);
 }
 
-int SdlEventManager::mapKey(SDLKey key, SDLMod mod, Uint16 unicode) {
+int SdlEventSource::mapKey(SDLKey key, SDLMod mod, Uint16 unicode) {
 	if (key >= SDLK_F1 && key <= SDLK_F9) {
 		return key - SDLK_F1 + Common::ASCII_F1;
 	} else if (key >= SDLK_KP0 && key <= SDLK_KP9) {
@@ -95,7 +90,7 @@
 	return key;
 }
 
-void SdlEventManager::fillMouseEvent(Common::Event &event, int x, int y) {
+void SdlEventSource::fillMouseEvent(Common::Event &event, int x, int y) {
 	event.mouse.x = x;
 	event.mouse.y = y;
 
@@ -104,7 +99,7 @@
 	_km.y = y;
 }
 
-void SdlEventManager::handleKbdMouse() {
+void SdlEventSource::handleKbdMouse() {
 	uint32 curTime = g_system->getMillis();
 	if (curTime >= _km.last_time + _km.delay_time) {
 		_km.last_time = curTime;
@@ -173,7 +168,7 @@
 	}
 }
 
-void SdlEventManager::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) {
+void SdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) {
 
 	event.kbd.flags = 0;
 
@@ -198,7 +193,7 @@
 		event.kbd.flags |= Common::KBD_CAPS;
 }
 
-bool SdlEventManager::pollSdlEvent(Common::Event &event) {
+bool SdlEventSource::pollEvent(Common::Event &event) {
 	handleKbdMouse();
 
 	// If the screen changed, send an Common::EVENT_SCREEN_CHANGED
@@ -219,7 +214,7 @@
 	return false;
 }
 
-bool SdlEventManager::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
 	switch (ev.type) {
 	case SDL_KEYDOWN:
 		return handleKeyDown(ev, event);
@@ -260,7 +255,7 @@
 }
 
 
-bool SdlEventManager::handleKeyDown(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleKeyDown(SDL_Event &ev, Common::Event &event) {
 
 	SDLModToOSystemKeyFlags(SDL_GetModState(), event);
 
@@ -312,7 +307,7 @@
 	return true;
 }
 
-bool SdlEventManager::handleKeyUp(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleKeyUp(SDL_Event &ev, Common::Event &event) {
 	if (remapKey(ev, event))
 		return true;
 
@@ -330,14 +325,14 @@
 	return true;
 }
 
-bool SdlEventManager::handleMouseMotion(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleMouseMotion(SDL_Event &ev, Common::Event &event) {
 	event.type = Common::EVENT_MOUSEMOVE;
 	fillMouseEvent(event, ev.motion.x, ev.motion.y);
 
 	return true;
 }
 
-bool SdlEventManager::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) {
 	if (ev.button.button == SDL_BUTTON_LEFT)
 		event.type = Common::EVENT_LBUTTONDOWN;
 	else if (ev.button.button == SDL_BUTTON_RIGHT)
@@ -360,7 +355,7 @@
 	return true;
 }
 
-bool SdlEventManager::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
 	if (ev.button.button == SDL_BUTTON_LEFT)
 		event.type = Common::EVENT_LBUTTONUP;
 	else if (ev.button.button == SDL_BUTTON_RIGHT)
@@ -376,7 +371,7 @@
 	return true;
 }
 
-bool SdlEventManager::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
 	if (ev.jbutton.button == JOY_BUT_LMOUSE) {
 		event.type = Common::EVENT_LBUTTONDOWN;
 		fillMouseEvent(event, _km.x, _km.y);
@@ -407,7 +402,7 @@
 	return true;
 }
 
-bool SdlEventManager::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
 	if (ev.jbutton.button == JOY_BUT_LMOUSE) {
 		event.type = Common::EVENT_LBUTTONUP;
 		fillMouseEvent(event, _km.x, _km.y);
@@ -438,7 +433,7 @@
 	return true;
 }
 
-bool SdlEventManager::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {
 	int axis = ev.jaxis.value;
 	if ( axis > JOY_DEADZONE) {
 		axis -= JOY_DEADZONE;
@@ -486,7 +481,7 @@
 	return true;
 }
 
-bool SdlEventManager::remapKey(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
 #ifdef LINUPY
 	// On Yopy map the End button to quit
 	if ((ev.key.keysym.sym == 293)) {
@@ -554,14 +549,14 @@
 	return false;
 }
 
-void SdlEventManager::toggleMouseGrab() {
+void SdlEventSource::toggleMouseGrab() {
 	if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF)
 		SDL_WM_GrabInput(SDL_GRAB_ON);
 	else
 		SDL_WM_GrabInput(SDL_GRAB_OFF);
 }
 
-void SdlEventManager::resetKeyboadEmulation(int16 x_max, int16 y_max) {
+void SdlEventSource::resetKeyboadEmulation(int16 x_max, int16 y_max) {
 	_km.x_max = x_max;
 	_km.y_max = y_max;
 	_km.delay_time = 25;

Modified: scummvm/branches/gsoc2010-opengl/backends/events/sdl/sdl-events.h
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/events/sdl/sdl-events.h	2010-10-13 15:41:55 UTC (rev 53432)
+++ scummvm/branches/gsoc2010-opengl/backends/events/sdl/sdl-events.h	2010-10-13 15:42:16 UTC (rev 53433)
@@ -35,17 +35,17 @@
 #endif
 
 /**
- * The SDL event manager class.
+ * The SDL event source.
  */
-class SdlEventManager : public DefaultEventManager {
-public:
-	SdlEventManager(Common::EventSource *boss);
-	virtual ~SdlEventManager();
+class SdlEventSource : public virtual Common::EventSource {
+public: 
+	SdlEventSource();
+	virtual ~SdlEventSource();
 
 	/**
-	 * Gets and proccess SDL events
+	 * Gets and processes SDL events.
 	 */
-	virtual bool pollSdlEvent(Common::Event &event);
+	virtual bool pollEvent(Common::Event &event);
 
 	/**
 	 * Resets keyboard emulation after a video screen change

Modified: scummvm/branches/gsoc2010-opengl/backends/graphics/sdl/sdl-graphics.cpp
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/graphics/sdl/sdl-graphics.cpp	2010-10-13 15:41:55 UTC (rev 53432)
+++ scummvm/branches/gsoc2010-opengl/backends/graphics/sdl/sdl-graphics.cpp	2010-10-13 15:42:16 UTC (rev 53433)
@@ -821,7 +821,7 @@
 	SDL_SetColorKey(_osdSurface, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, kOSDColorKey);
 #endif
 
-	((SdlEventManager *)g_system->getEventManager())->resetKeyboadEmulation(
+	((SdlEventSource *)g_system)->resetKeyboadEmulation(
 		_videoMode.screenWidth * _videoMode.scaleFactor - 1,
 		effectiveScreenHeight() - 1);
 

Modified: scummvm/branches/gsoc2010-opengl/backends/modular-backend.h
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/modular-backend.h	2010-10-13 15:41:55 UTC (rev 53432)
+++ scummvm/branches/gsoc2010-opengl/backends/modular-backend.h	2010-10-13 15:42:16 UTC (rev 53433)
@@ -52,7 +52,7 @@
  * And, it should also initialize all the managers variables
  * declared in this class, or override their related functions.
  */
-class ModularBackend : public OSystem, public Common::EventSource {
+class ModularBackend : public OSystem, public virtual Common::EventSource {
 public:
 	ModularBackend();
 	virtual ~ModularBackend();

Modified: scummvm/branches/gsoc2010-opengl/backends/platform/sdl/sdl.cpp
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/platform/sdl/sdl.cpp	2010-10-13 15:41:55 UTC (rev 53432)
+++ scummvm/branches/gsoc2010-opengl/backends/platform/sdl/sdl.cpp	2010-10-13 15:42:16 UTC (rev 53433)
@@ -112,7 +112,7 @@
 	// Creates the backend managers, if they don't exist yet (we check
 	// for this to allow subclasses to provide their own).
 	if (_eventManager == 0)
-		_eventManager = new SdlEventManager(this);
+		_eventManager = new DefaultEventManager(this);
 
 	// We have to initialize the graphics manager before the event manager
 	// so the virtual keyboard can be initialized, but we have to add the
@@ -289,11 +289,6 @@
 	free(icon);
 }
 
-bool OSystem_SDL::pollEvent(Common::Event &event) {
-	assert(_eventManager);
-	return ((SdlEventManager *)_eventManager)->pollSdlEvent(event);
-}
-
 uint32 OSystem_SDL::getMillis() {
 	uint32 millis = SDL_GetTicks();
 	g_eventRec.processMillis(millis);

Modified: scummvm/branches/gsoc2010-opengl/backends/platform/sdl/sdl.h
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/platform/sdl/sdl.h	2010-10-13 15:41:55 UTC (rev 53432)
+++ scummvm/branches/gsoc2010-opengl/backends/platform/sdl/sdl.h	2010-10-13 15:42:16 UTC (rev 53433)
@@ -34,11 +34,12 @@
 
 #include "backends/modular-backend.h"
 #include "backends/mixer/sdl/sdl-mixer.h"
+#include "backends/events/sdl/sdl-events.h"
 
 /** 
  * Base OSystem class for all SDL ports.
  */
-class OSystem_SDL : public ModularBackend {
+class OSystem_SDL : public ModularBackend, public SdlEventSource {
 public:
 	OSystem_SDL();
 	virtual ~OSystem_SDL();
@@ -66,7 +67,6 @@
 	virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
 	virtual Common::SeekableReadStream *createConfigReadStream();
 	virtual Common::WriteStream *createConfigWriteStream();
-	virtual bool pollEvent(Common::Event &event);
 	virtual uint32 getMillis();
 	virtual void delayMillis(uint msecs);
 	virtual void getTimeAndDate(TimeDate &td) const;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list