aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/sdl
diff options
context:
space:
mode:
authorMax Horn2007-03-17 19:02:05 +0000
committerMax Horn2007-03-17 19:02:05 +0000
commited54ea9155961d8ca5d5fb3c7777fc57a29f2751 (patch)
tree467b926af11cd4129ba003d04ba01de044c7a6df /backends/platform/sdl
parentf272d1957084098c5b53975ad3501074f6971af8 (diff)
downloadscummvm-rg350-ed54ea9155961d8ca5d5fb3c7777fc57a29f2751.tar.gz
scummvm-rg350-ed54ea9155961d8ca5d5fb3c7777fc57a29f2751.tar.bz2
scummvm-rg350-ed54ea9155961d8ca5d5fb3c7777fc57a29f2751.zip
Moved Event/EventType/keyboard enum from common/system.h (part of class OSystem) to common/events.h (part of namespace Common). Porters may have to make minor changes to their backends to get them to compile again
svn-id: r26180
Diffstat (limited to 'backends/platform/sdl')
-rw-r--r--backends/platform/sdl/events.cpp91
-rw-r--r--backends/platform/sdl/graphics.cpp8
-rw-r--r--backends/platform/sdl/sdl-common.h6
3 files changed, 53 insertions, 52 deletions
diff --git a/backends/platform/sdl/events.cpp b/backends/platform/sdl/events.cpp
index 325222f8be..09c49405d8 100644
--- a/backends/platform/sdl/events.cpp
+++ b/backends/platform/sdl/events.cpp
@@ -23,6 +23,7 @@
#include "backends/platform/sdl/sdl-common.h"
#include "common/util.h"
+#include "common/events.h"
// FIXME move joystick defines out and replace with confile file options
// we should really allow users to map any key to a joystick button
@@ -64,7 +65,7 @@ static int mapKey(SDLKey key, SDLMod mod, Uint16 unicode)
return key;
}
-void OSystem_SDL::fillMouseEvent(Event &event, int x, int y) {
+void OSystem_SDL::fillMouseEvent(Common::Event &event, int x, int y) {
event.mouse.x = x;
event.mouse.y = y;
@@ -156,30 +157,30 @@ static byte SDLModToOSystemKeyFlags(SDLMod mod) {
// Yopy has no ALT key, steal the SHIFT key
// (which isn't used much anyway)
if (mod & KMOD_SHIFT)
- b |= OSystem::KBD_ALT;
+ b |= Common::KBD_ALT;
#else
if (mod & KMOD_SHIFT)
- b |= OSystem::KBD_SHIFT;
+ b |= Common::KBD_SHIFT;
if (mod & KMOD_ALT)
- b |= OSystem::KBD_ALT;
+ b |= Common::KBD_ALT;
#endif
if (mod & KMOD_CTRL)
- b |= OSystem::KBD_CTRL;
+ b |= Common::KBD_CTRL;
return b;
}
-bool OSystem_SDL::pollEvent(Event &event) {
+bool OSystem_SDL::pollEvent(Common::Event &event) {
SDL_Event ev;
int axis;
byte b = 0;
handleKbdMouse();
- // If the screen mode changed, send an EVENT_SCREEN_CHANGED
+ // If the screen mode changed, send an Common::EVENT_SCREEN_CHANGED
if (_modeChanged) {
_modeChanged = false;
- event.type = EVENT_SCREEN_CHANGED;
+ event.type = Common::EVENT_SCREEN_CHANGED;
_screenChangeCount++;
return true;
}
@@ -190,7 +191,7 @@ bool OSystem_SDL::pollEvent(Event &event) {
b = event.kbd.flags = SDLModToOSystemKeyFlags(SDL_GetModState());
// Alt-Return and Alt-Enter toggle full screen mode
- if (b == KBD_ALT && (ev.key.keysym.sym == SDLK_RETURN
+ if (b == Common::KBD_ALT && (ev.key.keysym.sym == SDLK_RETURN
|| ev.key.keysym.sym == SDLK_KP_ENTER)) {
setFullscreenMode(!_fullscreen);
#ifdef USE_OSD
@@ -204,7 +205,7 @@ bool OSystem_SDL::pollEvent(Event &event) {
}
// Alt-S: Create a screenshot
- if (b == KBD_ALT && ev.key.keysym.sym == 's') {
+ if (b == Common::KBD_ALT && ev.key.keysym.sym == 's') {
char filename[20];
for (int n = 0;; n++) {
@@ -224,7 +225,7 @@ bool OSystem_SDL::pollEvent(Event &event) {
}
// Ctrl-m toggles mouse capture
- if (b == KBD_CTRL && ev.key.keysym.sym == 'm') {
+ if (b == Common::KBD_CTRL && ev.key.keysym.sym == 'm') {
toggleMouseGrab();
break;
}
@@ -233,25 +234,25 @@ bool OSystem_SDL::pollEvent(Event &event) {
// On Macintosh', Cmd-Q quits
// On Amigas, Amiga-Q quits
if ((ev.key.keysym.mod & KMOD_META) && ev.key.keysym.sym == 'q') {
- event.type = EVENT_QUIT;
+ event.type = Common::EVENT_QUIT;
return true;
}
#elif defined(UNIX)
// On other unices, Control-Q quits
if ((ev.key.keysym.mod & KMOD_CTRL) && ev.key.keysym.sym == 'q') {
- event.type = EVENT_QUIT;
+ event.type = Common::EVENT_QUIT;
return true;
}
#else
// Ctrl-z and Alt-X quit
- if ((b == KBD_CTRL && ev.key.keysym.sym == 'z') || (b == KBD_ALT && ev.key.keysym.sym == 'x')) {
- event.type = EVENT_QUIT;
+ if ((b == Common::KBD_CTRL && ev.key.keysym.sym == 'z') || (b == Common::KBD_ALT && ev.key.keysym.sym == 'x')) {
+ event.type = Common::EVENT_QUIT;
return true;
}
#endif
// Ctrl-Alt-<key> will change the GFX mode
- if ((b & (KBD_CTRL|KBD_ALT)) == (KBD_CTRL|KBD_ALT)) {
+ if ((b & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) {
handleScalerHotkeys(ev.key);
break;
@@ -261,7 +262,7 @@ bool OSystem_SDL::pollEvent(Event &event) {
if (event_complete)
return true;
- event.type = EVENT_KEYDOWN;
+ event.type = Common::EVENT_KEYDOWN;
event.kbd.keycode = ev.key.keysym.sym;
event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
@@ -274,13 +275,13 @@ bool OSystem_SDL::pollEvent(Event &event) {
if (event_complete)
return true;
- event.type = EVENT_KEYUP;
+ event.type = Common::EVENT_KEYUP;
event.kbd.keycode = ev.key.keysym.sym;
event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
b = event.kbd.flags = SDLModToOSystemKeyFlags(SDL_GetModState());
// Ctrl-Alt-<key> will change the GFX mode
- if ((b & (KBD_CTRL|KBD_ALT)) == (KBD_CTRL|KBD_ALT)) {
+ if ((b & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) {
// Swallow these key up events
break;
}
@@ -288,7 +289,7 @@ bool OSystem_SDL::pollEvent(Event &event) {
return true;
}
case SDL_MOUSEMOTION:
- event.type = EVENT_MOUSEMOVE;
+ event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, ev.motion.x, ev.motion.y);
setMousePos(event.mouse.x, event.mouse.y);
@@ -296,14 +297,14 @@ bool OSystem_SDL::pollEvent(Event &event) {
case SDL_MOUSEBUTTONDOWN:
if (ev.button.button == SDL_BUTTON_LEFT)
- event.type = EVENT_LBUTTONDOWN;
+ event.type = Common::EVENT_LBUTTONDOWN;
else if (ev.button.button == SDL_BUTTON_RIGHT)
- event.type = EVENT_RBUTTONDOWN;
+ event.type = Common::EVENT_RBUTTONDOWN;
#if defined(SDL_BUTTON_WHEELUP) && defined(SDL_BUTTON_WHEELDOWN)
else if (ev.button.button == SDL_BUTTON_WHEELUP)
- event.type = EVENT_WHEELUP;
+ event.type = Common::EVENT_WHEELUP;
else if (ev.button.button == SDL_BUTTON_WHEELDOWN)
- event.type = EVENT_WHEELDOWN;
+ event.type = Common::EVENT_WHEELDOWN;
#endif
else
break;
@@ -314,9 +315,9 @@ bool OSystem_SDL::pollEvent(Event &event) {
case SDL_MOUSEBUTTONUP:
if (ev.button.button == SDL_BUTTON_LEFT)
- event.type = EVENT_LBUTTONUP;
+ event.type = Common::EVENT_LBUTTONUP;
else if (ev.button.button == SDL_BUTTON_RIGHT)
- event.type = EVENT_RBUTTONUP;
+ event.type = Common::EVENT_RBUTTONUP;
else
break;
fillMouseEvent(event, ev.button.x, ev.button.y);
@@ -325,13 +326,13 @@ bool OSystem_SDL::pollEvent(Event &event) {
case SDL_JOYBUTTONDOWN:
if (ev.jbutton.button == JOY_BUT_LMOUSE) {
- event.type = EVENT_LBUTTONDOWN;
+ event.type = Common::EVENT_LBUTTONDOWN;
fillMouseEvent(event, _km.x, _km.y);
} else if (ev.jbutton.button == JOY_BUT_RMOUSE) {
- event.type = EVENT_RBUTTONDOWN;
+ event.type = Common::EVENT_RBUTTONDOWN;
fillMouseEvent(event, _km.x, _km.y);
} else {
- event.type = EVENT_KEYDOWN;
+ event.type = Common::EVENT_KEYDOWN;
switch (ev.jbutton.button) {
case JOY_BUT_ESCAPE:
event.kbd.keycode = SDLK_ESCAPE;
@@ -355,13 +356,13 @@ bool OSystem_SDL::pollEvent(Event &event) {
case SDL_JOYBUTTONUP:
if (ev.jbutton.button == JOY_BUT_LMOUSE) {
- event.type = EVENT_LBUTTONUP;
+ event.type = Common::EVENT_LBUTTONUP;
fillMouseEvent(event, _km.x, _km.y);
} else if (ev.jbutton.button == JOY_BUT_RMOUSE) {
- event.type = EVENT_RBUTTONUP;
+ event.type = Common::EVENT_RBUTTONUP;
fillMouseEvent(event, _km.x, _km.y);
} else {
- event.type = EVENT_KEYUP;
+ event.type = Common::EVENT_KEYUP;
switch (ev.jbutton.button) {
case JOY_BUT_ESCAPE:
event.kbd.keycode = SDLK_ESCAPE;
@@ -387,10 +388,10 @@ bool OSystem_SDL::pollEvent(Event &event) {
axis = ev.jaxis.value;
if ( axis > JOY_DEADZONE) {
axis -= JOY_DEADZONE;
- event.type = EVENT_MOUSEMOVE;
+ event.type = Common::EVENT_MOUSEMOVE;
} else if ( axis < -JOY_DEADZONE ) {
axis += JOY_DEADZONE;
- event.type = EVENT_MOUSEMOVE;
+ event.type = Common::EVENT_MOUSEMOVE;
} else
axis = 0;
@@ -435,37 +436,37 @@ bool OSystem_SDL::pollEvent(Event &event) {
break;
case SDL_QUIT:
- event.type = EVENT_QUIT;
+ event.type = Common::EVENT_QUIT;
return true;
}
}
return false;
}
-bool OSystem_SDL::remapKey(SDL_Event &ev,Event &event) {
+bool OSystem_SDL::remapKey(SDL_Event &ev,Common::Event &event) {
#ifdef LINUPY
// On Yopy map the End button to quit
if ((ev.key.keysym.sym == 293)) {
- event.type = EVENT_QUIT;
+ event.type = Common::EVENT_QUIT;
return true;
}
// Map menu key to f5 (scumm menu)
if (ev.key.keysym.sym == 306) {
- event.type = EVENT_KEYDOWN;
+ event.type = Common::EVENT_KEYDOWN;
event.kbd.keycode = SDLK_F5;
event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
return true;
}
// Map action key to action
if (ev.key.keysym.sym == 291) {
- event.type = EVENT_KEYDOWN;
+ event.type = Common::EVENT_KEYDOWN;
event.kbd.keycode = SDLK_TAB;
event.kbd.ascii = mapKey(SDLK_TAB, ev.key.keysym.mod, 0);
return true;
}
// Map OK key to skip cinematic
if (ev.key.keysym.sym == 292) {
- event.type = EVENT_KEYDOWN;
+ event.type = Common::EVENT_KEYDOWN;
event.kbd.keycode = SDLK_ESCAPE;
event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0);
return true;
@@ -475,13 +476,13 @@ bool OSystem_SDL::remapKey(SDL_Event &ev,Event &event) {
#ifdef QTOPIA
// Quit on fn+backspace on zaurus
if (ev.key.keysym.sym == 127) {
- event.type = EVENT_QUIT;
+ event.type = Common::EVENT_QUIT;
return true;
}
// Map menu key (f11) to f5 (scumm menu)
if (ev.key.keysym.sym == SDLK_F11) {
- event.type = EVENT_KEYDOWN;
+ event.type = Common::EVENT_KEYDOWN;
event.kbd.keycode = SDLK_F5;
event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
}
@@ -489,20 +490,20 @@ bool OSystem_SDL::remapKey(SDL_Event &ev,Event &event) {
// I wanted to map the calendar button but the calendar comes up
//
else if (ev.key.keysym.sym == SDLK_SPACE) {
- event.type = EVENT_KEYDOWN;
+ event.type = Common::EVENT_KEYDOWN;
event.kbd.keycode = SDLK_TAB;
event.kbd.ascii = mapKey(SDLK_TAB, ev.key.keysym.mod, 0);
}
// Since we stole space (pause) above we'll rebind it to the tab key on the keyboard
else if (ev.key.keysym.sym == SDLK_TAB) {
- event.type = EVENT_KEYDOWN;
+ event.type = Common::EVENT_KEYDOWN;
event.kbd.keycode = SDLK_SPACE;
event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0);
} else {
// Let the events fall through if we didn't change them, this may not be the best way to
// set it up, but i'm not sure how sdl would like it if we let if fall through then redid it though.
// and yes i have an huge terminal size so i dont wrap soon enough.
- event.type = EVENT_KEYDOWN;
+ event.type = Common::EVENT_KEYDOWN;
event.kbd.keycode = ev.key.keysym.sym;
event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
}
diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp
index cb8457fbdb..2ffabd9aba 100644
--- a/backends/platform/sdl/graphics.cpp
+++ b/backends/platform/sdl/graphics.cpp
@@ -261,7 +261,7 @@ bool OSystem_SDL::setGraphicsMode(int mode) {
if (_transactionMode != kTransactionCommit)
internUpdateScreen();
- // Make sure that an EVENT_SCREEN_CHANGED gets sent later
+ // Make sure that an Common::EVENT_SCREEN_CHANGED gets sent later
_modeChanged = true;
return true;
@@ -500,7 +500,7 @@ void OSystem_SDL::hotswapGFXMode() {
// Blit everything to the screen
internUpdateScreen();
- // Make sure that an EVENT_SCREEN_CHANGED gets sent later
+ // Make sure that an Common::EVENT_SCREEN_CHANGED gets sent later
_modeChanged = true;
}
@@ -727,7 +727,7 @@ void OSystem_SDL::setFullscreenMode(bool enable) {
// Blit everything to the screen
internUpdateScreen();
- // Make sure that an EVENT_SCREEN_CHANGED gets sent later
+ // Make sure that an Common::EVENT_SCREEN_CHANGED gets sent later
_modeChanged = true;
}
#endif
@@ -754,7 +754,7 @@ void OSystem_SDL::setAspectRatioCorrection(bool enable) {
hotswapGFXMode();
}
- // Make sure that an EVENT_SCREEN_CHANGED gets sent later
+ // Make sure that an Common::EVENT_SCREEN_CHANGED gets sent later
_modeChanged = true;
}
}
diff --git a/backends/platform/sdl/sdl-common.h b/backends/platform/sdl/sdl-common.h
index 2a5b88cef2..58ebb72bd1 100644
--- a/backends/platform/sdl/sdl-common.h
+++ b/backends/platform/sdl/sdl-common.h
@@ -130,7 +130,7 @@ public:
// Get the next event.
// Returns true if an event was retrieved.
- virtual bool pollEvent(Event &event); // overloaded by CE backend
+ virtual bool pollEvent(Common::Event &event); // overloaded by CE backend
// Set function that generates samples
typedef void (*SoundProc)(void *param, byte *buf, int len);
@@ -382,7 +382,7 @@ protected:
/** Set the position of the virtual mouse cursor. */
void setMousePos(int x, int y);
- virtual void fillMouseEvent(Event &event, int x, int y); // overloaded by CE backend
+ virtual void fillMouseEvent(Common::Event &event, int x, int y); // overloaded by CE backend
void toggleMouseGrab();
virtual void internUpdateScreen(); // overloaded by CE backend
@@ -404,7 +404,7 @@ protected:
void setupIcon();
void handleKbdMouse();
- virtual bool remapKey(SDL_Event &ev, Event &event);
+ virtual bool remapKey(SDL_Event &ev, Common::Event &event);
void handleScalerHotkeys(const SDL_KeyboardEvent &key);
};