mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-06 01:31:39 +00:00
Replaced the extra SDL functions added to GraphicsManager with an EventObserver in SdlGraphicsManager.
svn-id: r50900
This commit is contained in:
parent
84ceae9328
commit
f53028d4a2
@ -102,9 +102,6 @@ void SdlEventManager::fillMouseEvent(Common::Event &event, int x, int y) {
|
|||||||
// Update the "keyboard mouse" coords
|
// Update the "keyboard mouse" coords
|
||||||
_km.x = x;
|
_km.x = x;
|
||||||
_km.y = y;
|
_km.y = y;
|
||||||
|
|
||||||
// Adjust for the screen scaling
|
|
||||||
((OSystem_SDL *)g_system)->getGraphicsManager()->adjustMouseEvent(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdlEventManager::handleKbdMouse() {
|
void SdlEventManager::handleKbdMouse() {
|
||||||
@ -241,10 +238,6 @@ bool SdlEventManager::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
|
|||||||
case SDL_JOYAXISMOTION:
|
case SDL_JOYAXISMOTION:
|
||||||
return handleJoyAxisMotion(ev, event);
|
return handleJoyAxisMotion(ev, event);
|
||||||
|
|
||||||
case SDL_VIDEOEXPOSE:
|
|
||||||
((OSystem_SDL *) g_system)->getGraphicsManager()->forceFullRedraw();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
event.type = Common::EVENT_QUIT;
|
event.type = Common::EVENT_QUIT;
|
||||||
return true;
|
return true;
|
||||||
@ -266,32 +259,6 @@ bool SdlEventManager::handleKeyDown(SDL_Event &ev, Common::Event &event) {
|
|||||||
if (_scrollLock)
|
if (_scrollLock)
|
||||||
event.kbd.flags |= Common::KBD_SCRL;
|
event.kbd.flags |= Common::KBD_SCRL;
|
||||||
|
|
||||||
// Alt-Return and Alt-Enter toggle full screen mode
|
|
||||||
if (event.kbd.hasFlags(Common::KBD_ALT) && (ev.key.keysym.sym == SDLK_RETURN || ev.key.keysym.sym == SDLK_KP_ENTER)) {
|
|
||||||
((OSystem_SDL *) g_system)->getGraphicsManager()->toggleFullScreen();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Alt-S: Create a screenshot
|
|
||||||
if (event.kbd.hasFlags(Common::KBD_ALT) && ev.key.keysym.sym == 's') {
|
|
||||||
char filename[20];
|
|
||||||
|
|
||||||
for (int n = 0;; n++) {
|
|
||||||
SDL_RWops *file;
|
|
||||||
|
|
||||||
sprintf(filename, "scummvm%05d.bmp", n);
|
|
||||||
file = SDL_RWFromFile(filename, "r");
|
|
||||||
if (!file)
|
|
||||||
break;
|
|
||||||
SDL_RWclose(file);
|
|
||||||
}
|
|
||||||
if (((OSystem_SDL *) g_system)->getGraphicsManager()->saveScreenshot(filename))
|
|
||||||
printf("Saved '%s'\n", filename);
|
|
||||||
else
|
|
||||||
printf("Could not save screenshot!\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ctrl-m toggles mouse capture
|
// Ctrl-m toggles mouse capture
|
||||||
if (event.kbd.hasFlags(Common::KBD_CTRL) && ev.key.keysym.sym == 'm') {
|
if (event.kbd.hasFlags(Common::KBD_CTRL) && ev.key.keysym.sym == 'm') {
|
||||||
toggleMouseGrab();
|
toggleMouseGrab();
|
||||||
@ -323,12 +290,6 @@ bool SdlEventManager::handleKeyDown(SDL_Event &ev, Common::Event &event) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ctrl-Alt-<key> will change the GFX mode
|
|
||||||
if ((event.kbd.flags & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) {
|
|
||||||
if (((OSystem_SDL *) g_system)->getGraphicsManager()->handleScalerHotkeys((Common::KeyCode)ev.key.keysym.sym))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (remapKey(ev, event))
|
if (remapKey(ev, event))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -354,10 +315,6 @@ bool SdlEventManager::handleKeyUp(SDL_Event &ev, Common::Event &event) {
|
|||||||
if (_scrollLock)
|
if (_scrollLock)
|
||||||
event.kbd.flags |= Common::KBD_SCRL;
|
event.kbd.flags |= Common::KBD_SCRL;
|
||||||
|
|
||||||
if (((OSystem_SDL *) g_system)->getGraphicsManager()->isScalerHotkey(event))
|
|
||||||
// Swallow these key up events
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +322,6 @@ bool SdlEventManager::handleMouseMotion(SDL_Event &ev, Common::Event &event) {
|
|||||||
event.type = Common::EVENT_MOUSEMOVE;
|
event.type = Common::EVENT_MOUSEMOVE;
|
||||||
fillMouseEvent(event, ev.motion.x, ev.motion.y);
|
fillMouseEvent(event, ev.motion.x, ev.motion.y);
|
||||||
|
|
||||||
((OSystem_SDL *) g_system)->getGraphicsManager()->setMousePos(event.mouse.x, event.mouse.y);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,41 +85,6 @@ public:
|
|||||||
virtual void disableCursorPalette(bool disable) = 0;
|
virtual void disableCursorPalette(bool disable) = 0;
|
||||||
|
|
||||||
virtual void displayMessageOnOSD(const char *msg) {}
|
virtual void displayMessageOnOSD(const char *msg) {}
|
||||||
|
|
||||||
/**
|
|
||||||
* Marks the screen for a full redraw
|
|
||||||
*/
|
|
||||||
virtual void forceFullRedraw() {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles the scalar hotkeys
|
|
||||||
*/
|
|
||||||
virtual bool handleScalerHotkeys(Common::KeyCode key) { return false; };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns if the event passed is a hotkey for the graphics scalers
|
|
||||||
*/
|
|
||||||
virtual bool isScalerHotkey(const Common::Event &event) { return false; };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adjusts mouse event coords for the current scaler
|
|
||||||
*/
|
|
||||||
virtual void adjustMouseEvent(Common::Event &event) {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the mouse cursor position
|
|
||||||
*/
|
|
||||||
virtual void setMousePos(int x, int y) {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Toggles fullscreen
|
|
||||||
*/
|
|
||||||
virtual void toggleFullScreen() {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Saves a screenshot to a file
|
|
||||||
*/
|
|
||||||
virtual bool saveScreenshot(const char *filename) { return false; };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -474,16 +474,21 @@ void LinuxmotoSdlGraphicsManager::warpMouse(int x, int y) {
|
|||||||
SdlGraphicsManager::warpMouse(x, y);
|
SdlGraphicsManager::warpMouse(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinuxmotoSdlGraphicsManager::adjustMouseEvent(Common::Event &event) {
|
void LinuxmotoSdlGraphicsManager::adjustMouseEvent(const Common::Event &event) {
|
||||||
if (!_overlayVisible) {
|
if (!event.synthetic) {
|
||||||
if (_videoMode.mode == GFX_HALF) {
|
Common::Event newEvent(event);
|
||||||
event.mouse.x *= 2;
|
newEvent.synthetic = true;
|
||||||
event.mouse.y *= 2;
|
if (!_overlayVisible) {
|
||||||
|
if (_videoMode.mode == GFX_HALF) {
|
||||||
|
event.mouse.x *= 2;
|
||||||
|
event.mouse.y *= 2;
|
||||||
|
}
|
||||||
|
newEvent.mouse.x /= _videoMode.scaleFactor;
|
||||||
|
newEvent.mouse.y /= _videoMode.scaleFactor;
|
||||||
|
if (_videoMode.aspectRatioCorrection)
|
||||||
|
newEvent.mouse.y = aspect2Real(newEvent.mouse.y);
|
||||||
}
|
}
|
||||||
event.mouse.x /= _videoMode.scaleFactor;
|
g_system->getEventManager()->pushEvent(newEvent);
|
||||||
event.mouse.y /= _videoMode.scaleFactor;
|
|
||||||
if (_videoMode.aspectRatioCorrection)
|
|
||||||
event.mouse.y = aspect2Real(event.mouse.y);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,9 @@ public:
|
|||||||
virtual void showOverlay();
|
virtual void showOverlay();
|
||||||
virtual void hideOverlay();
|
virtual void hideOverlay();
|
||||||
virtual void warpMouse(int x, int y);
|
virtual void warpMouse(int x, int y);
|
||||||
virtual void adjustMouseEvent(Common::Event &event);
|
|
||||||
|
protected:
|
||||||
|
virtual void adjustMouseEvent(const Common::Event &event);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -122,30 +122,6 @@ void OpenGLSdlGraphicsManager::warpMouse(int x, int y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OpenGLSdlGraphicsManager::forceFullRedraw() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenGLSdlGraphicsManager::handleScalerHotkeys(const SDL_KeyboardEvent &key) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenGLSdlGraphicsManager::isScalerHotkey(const Common::Event &event) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLSdlGraphicsManager::adjustMouseEvent(Common::Event &event) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLSdlGraphicsManager::toggleFullScreen() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenGLSdlGraphicsManager::saveScreenshot(const char *filename) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Intern
|
// Intern
|
||||||
//
|
//
|
||||||
|
@ -50,13 +50,6 @@ public:
|
|||||||
|
|
||||||
virtual void warpMouse(int x, int y);
|
virtual void warpMouse(int x, int y);
|
||||||
|
|
||||||
virtual void forceFullRedraw();
|
|
||||||
virtual bool handleScalerHotkeys(const SDL_KeyboardEvent &key);
|
|
||||||
virtual bool isScalerHotkey(const Common::Event &event);
|
|
||||||
virtual void adjustMouseEvent(Common::Event &event);
|
|
||||||
virtual void toggleFullScreen();
|
|
||||||
virtual bool saveScreenshot(const char *filename);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void internUpdateScreen();
|
virtual void internUpdateScreen();
|
||||||
|
|
||||||
|
@ -184,6 +184,9 @@ SdlGraphicsManager::SdlGraphicsManager()
|
|||||||
#else
|
#else
|
||||||
_videoMode.fullscreen = true;
|
_videoMode.fullscreen = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Register the graphics manager as a event observer
|
||||||
|
g_system->getEventManager()->getEventDispatcher()->registerObserver(this, 2, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
SdlGraphicsManager::~SdlGraphicsManager() {
|
SdlGraphicsManager::~SdlGraphicsManager() {
|
||||||
@ -2087,16 +2090,17 @@ bool SdlGraphicsManager::isScalerHotkey(const Common::Event &event) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdlGraphicsManager::forceFullRedraw() {
|
void SdlGraphicsManager::adjustMouseEvent(const Common::Event &event) {
|
||||||
_forceFull = true;
|
if (!event.synthetic) {
|
||||||
}
|
Common::Event newEvent(event);
|
||||||
|
newEvent.synthetic = true;
|
||||||
void SdlGraphicsManager::adjustMouseEvent(Common::Event &event) {
|
if (!_overlayVisible) {
|
||||||
if (!_overlayVisible) {
|
newEvent.mouse.x /= _videoMode.scaleFactor;
|
||||||
event.mouse.x /= _videoMode.scaleFactor;
|
newEvent.mouse.y /= _videoMode.scaleFactor;
|
||||||
event.mouse.y /= _videoMode.scaleFactor;
|
if (_videoMode.aspectRatioCorrection)
|
||||||
if (_videoMode.aspectRatioCorrection)
|
newEvent.mouse.y = aspect2Real(newEvent.mouse.y);
|
||||||
event.mouse.y = aspect2Real(event.mouse.y);
|
}
|
||||||
|
g_system->getEventManager()->pushEvent(newEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2112,4 +2116,63 @@ void SdlGraphicsManager::toggleFullScreen() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SdlGraphicsManager::notifyEvent(const Common::Event &event) {
|
||||||
|
switch (event.type) {
|
||||||
|
case Common::EVENT_KEYDOWN:
|
||||||
|
// Alt-Return and Alt-Enter toggle full screen mode
|
||||||
|
if (event.kbd.hasFlags(Common::KBD_ALT) &&
|
||||||
|
(event.kbd.keycode == Common::KEYCODE_RETURN ||
|
||||||
|
event.kbd.keycode == SDLK_KP_ENTER)) {
|
||||||
|
toggleFullScreen();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Alt-S: Create a screenshot
|
||||||
|
if (event.kbd.hasFlags(Common::KBD_ALT) && event.kbd.keycode == 's') {
|
||||||
|
char filename[20];
|
||||||
|
|
||||||
|
for (int n = 0;; n++) {
|
||||||
|
SDL_RWops *file;
|
||||||
|
|
||||||
|
sprintf(filename, "scummvm%05d.bmp", n);
|
||||||
|
file = SDL_RWFromFile(filename, "r");
|
||||||
|
if (!file)
|
||||||
|
break;
|
||||||
|
SDL_RWclose(file);
|
||||||
|
}
|
||||||
|
if (saveScreenshot(filename))
|
||||||
|
printf("Saved '%s'\n", filename);
|
||||||
|
else
|
||||||
|
printf("Could not save screenshot!\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctrl-Alt-<key> will change the GFX mode
|
||||||
|
if ((event.kbd.flags & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) {
|
||||||
|
if (handleScalerHotkeys(event.kbd.keycode))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case Common::EVENT_KEYUP:
|
||||||
|
return isScalerHotkey(event);
|
||||||
|
case Common::EVENT_MOUSEMOVE:
|
||||||
|
if (event.synthetic)
|
||||||
|
setMousePos(event.mouse.x, event.mouse.y);
|
||||||
|
case Common::EVENT_LBUTTONDOWN:
|
||||||
|
case Common::EVENT_RBUTTONDOWN:
|
||||||
|
case Common::EVENT_WHEELUP:
|
||||||
|
case Common::EVENT_WHEELDOWN:
|
||||||
|
case Common::EVENT_MBUTTONDOWN:
|
||||||
|
case Common::EVENT_LBUTTONUP:
|
||||||
|
case Common::EVENT_RBUTTONUP:
|
||||||
|
case Common::EVENT_MBUTTONUP:
|
||||||
|
adjustMouseEvent(event);
|
||||||
|
return !event.synthetic;
|
||||||
|
/*case SDL_VIDEOEXPOSE:
|
||||||
|
_forceFull = true;
|
||||||
|
return false;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -27,8 +27,9 @@
|
|||||||
#define BACKENDS_GRAPHICS_SDL_H
|
#define BACKENDS_GRAPHICS_SDL_H
|
||||||
|
|
||||||
#include "backends/graphics/graphics.h"
|
#include "backends/graphics/graphics.h"
|
||||||
#include "common/system.h"
|
|
||||||
#include "graphics/scaler.h"
|
#include "graphics/scaler.h"
|
||||||
|
#include "common/events.h"
|
||||||
|
#include "common/system.h"
|
||||||
|
|
||||||
#if defined(__SYMBIAN32__)
|
#if defined(__SYMBIAN32__)
|
||||||
#include <esdl\SDL.h>
|
#include <esdl\SDL.h>
|
||||||
@ -72,7 +73,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* SDL graphics manager
|
* SDL graphics manager
|
||||||
*/
|
*/
|
||||||
class SdlGraphicsManager : public GraphicsManager {
|
class SdlGraphicsManager : public GraphicsManager, public Common::EventObserver {
|
||||||
public:
|
public:
|
||||||
SdlGraphicsManager();
|
SdlGraphicsManager();
|
||||||
virtual ~SdlGraphicsManager();
|
virtual ~SdlGraphicsManager();
|
||||||
@ -127,13 +128,8 @@ public:
|
|||||||
virtual void displayMessageOnOSD(const char *msg);
|
virtual void displayMessageOnOSD(const char *msg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual void forceFullRedraw();
|
// Override from Common::EventObserver
|
||||||
virtual bool handleScalerHotkeys(Common::KeyCode key);
|
bool notifyEvent(const Common::Event &event);
|
||||||
virtual bool isScalerHotkey(const Common::Event &event);
|
|
||||||
virtual void adjustMouseEvent(Common::Event &event);
|
|
||||||
virtual void setMousePos(int x, int y);
|
|
||||||
virtual void toggleFullScreen();
|
|
||||||
virtual bool saveScreenshot(const char *filename);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#ifdef USE_OSD
|
#ifdef USE_OSD
|
||||||
@ -313,6 +309,13 @@ protected:
|
|||||||
virtual int effectiveScreenHeight() const;
|
virtual int effectiveScreenHeight() const;
|
||||||
|
|
||||||
virtual void setGraphicsModeIntern();
|
virtual void setGraphicsModeIntern();
|
||||||
|
|
||||||
|
virtual bool handleScalerHotkeys(Common::KeyCode key);
|
||||||
|
virtual bool isScalerHotkey(const Common::Event &event);
|
||||||
|
virtual void adjustMouseEvent(const Common::Event &event);
|
||||||
|
virtual void setMousePos(int x, int y);
|
||||||
|
virtual void toggleFullScreen();
|
||||||
|
virtual bool saveScreenshot(const char *filename);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user