aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorMax Horn2005-07-11 10:54:53 +0000
committerMax Horn2005-07-11 10:54:53 +0000
commit71bc3a3ba631e99ca5a6f905f1c2973db5115b50 (patch)
treee341b70cea2d609c8f9517d2da035cb8c36412eb /backends
parent8a59ff208c41625caf3823787ebc596fa3a6335a (diff)
downloadscummvm-rg350-71bc3a3ba631e99ca5a6f905f1c2973db5115b50.tar.gz
scummvm-rg350-71bc3a3ba631e99ca5a6f905f1c2973db5115b50.tar.bz2
scummvm-rg350-71bc3a3ba631e99ca5a6f905f1c2973db5115b50.zip
Move scaler key handling to a separate method (this helps to fix a GCC 4.0 warning, makes pollEvent() cleaner); fixed some code formatting issues
svn-id: r18534
Diffstat (limited to 'backends')
-rw-r--r--backends/sdl/events.cpp203
-rw-r--r--backends/sdl/graphics.cpp95
-rw-r--r--backends/sdl/sdl-common.h17
3 files changed, 163 insertions, 152 deletions
diff --git a/backends/sdl/events.cpp b/backends/sdl/events.cpp
index f195b11e86..83a12c7ae0 100644
--- a/backends/sdl/events.cpp
+++ b/backends/sdl/events.cpp
@@ -255,85 +255,12 @@ bool OSystem_SDL::pollEvent(Event &event) {
// Ctrl-Alt-<key> will change the GFX mode
if ((b & (KBD_CTRL|KBD_ALT)) == (KBD_CTRL|KBD_ALT)) {
- // Ctrl-Alt-a toggles aspect ratio correction
- if (ev.key.keysym.sym == 'a') {
- setFeatureState(kFeatureAspectRatioCorrection, !_adjustAspectRatio);
-#ifdef USE_OSD
- char buffer[128];
- if (_adjustAspectRatio)
- sprintf(buffer, "Enabled aspect ratio correction\n%d x %d -> %d x %d",
- _screenWidth, _screenHeight,
- _hwscreen->w, _hwscreen->h
- );
- else
- sprintf(buffer, "Disabled aspect ratio correction\n%d x %d -> %d x %d",
- _screenWidth, _screenHeight,
- _hwscreen->w, _hwscreen->h
- );
- displayMessageOnOSD(buffer);
-#endif
-
- break;
- }
-
-
- int newMode = -1;
- int factor = _scaleFactor - 1;
-
- // Increase/decrease the scale factor
- if (ev.key.keysym.sym == SDLK_EQUALS || ev.key.keysym.sym == SDLK_PLUS || ev.key.keysym.sym == SDLK_MINUS ||
- ev.key.keysym.sym == SDLK_KP_PLUS || ev.key.keysym.sym == SDLK_KP_MINUS) {
- factor += (ev.key.keysym.sym == SDLK_MINUS || ev.key.keysym.sym == SDLK_KP_MINUS) ? -1 : +1;
- if (0 <= factor && factor <= 3) {
- newMode = s_gfxModeSwitchTable[_scalerType][factor];
- }
- }
-
- const bool isNormalNumber = (SDLK_1 <= ev.key.keysym.sym && ev.key.keysym.sym <= SDLK_9);
- const bool isKeypadNumber = (SDLK_KP1 <= ev.key.keysym.sym && ev.key.keysym.sym <= SDLK_KP9);
- if (isNormalNumber || isKeypadNumber) {
- _scalerType = ev.key.keysym.sym - (isNormalNumber ? SDLK_1 : SDLK_KP1);
- if (_scalerType >= ARRAYSIZE(s_gfxModeSwitchTable))
- break;
-
- while (s_gfxModeSwitchTable[_scalerType][factor] < 0) {
- assert(factor > 0);
- factor--;
- }
- newMode = s_gfxModeSwitchTable[_scalerType][factor];
- }
-
- if (newMode >= 0) {
- setGraphicsMode(newMode);
-#ifdef USE_OSD
- if (_osdSurface) {
- const char *newScalerName = 0;
- const GraphicsMode *g = getSupportedGraphicsModes();
- while (g->name) {
- if (g->id == _mode) {
- newScalerName = g->description;
- break;
- }
- g++;
- }
- if (newScalerName) {
- char buffer[128];
- sprintf(buffer, "Active graphics filter: %s\n%d x %d -> %d x %d",
- newScalerName,
- _screenWidth, _screenHeight,
- _hwscreen->w, _hwscreen->h
- );
- displayMessageOnOSD(buffer);
- }
- }
-#endif
-
- }
+ handleScalerHotkeys(ev.key);
break;
}
- const bool event_complete= remapKey(ev,event);
+ const bool event_complete = remapKey(ev,event);
- if(event_complete)
+ if (event_complete)
return true;
event.type = EVENT_KEYDOWN;
@@ -344,9 +271,9 @@ bool OSystem_SDL::pollEvent(Event &event) {
}
case SDL_KEYUP:
{
- const bool event_complete= remapKey(ev,event);
+ const bool event_complete = remapKey(ev,event);
- if(event_complete)
+ if (event_complete)
return true;
event.type = EVENT_KEYUP;
@@ -517,71 +444,71 @@ bool OSystem_SDL::pollEvent(Event &event) {
return false;
}
-bool OSystem_SDL::remapKey(SDL_Event &ev,Event &event){
+bool OSystem_SDL::remapKey(SDL_Event &ev,Event &event) {
#ifdef LINUPY
- // On Yopy map the End button to quit
- if ((ev.key.keysym.sym == 293)) {
- event.type = EVENT_QUIT;
- return true;
- }
- // Map menu key to f5 (scumm menu)
- if (ev.key.keysym.sym == 306) {
- event.type = 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.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.kbd.keycode = SDLK_ESCAPE;
- event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0);
- return true;
- }
+ // On Yopy map the End button to quit
+ if ((ev.key.keysym.sym == 293)) {
+ event.type = EVENT_QUIT;
+ return true;
+ }
+ // Map menu key to f5 (scumm menu)
+ if (ev.key.keysym.sym == 306) {
+ event.type = 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.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.kbd.keycode = SDLK_ESCAPE;
+ event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0);
+ return true;
+ }
#endif
#ifdef QTOPIA
- // quit on fn+backspace on zaurus
- if (ev.key.keysym.sym == 127) {
- event.type = EVENT_QUIT;
- return true;
- }
+ // Quit on fn+backspace on zaurus
+ if (ev.key.keysym.sym == 127) {
+ event.type = EVENT_QUIT;
+ return true;
+ }
- // map menu key (f11) to f5 (scumm menu)
- if (ev.key.keysym.sym == SDLK_F11) {
- event.type = EVENT_KEYDOWN;
- event.kbd.keycode = SDLK_F5;
- event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
- }
- // map center (space) to tab (default action )
- // 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.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.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.kbd.keycode = ev.key.keysym.sym;
- event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
- }
+ // Map menu key (f11) to f5 (scumm menu)
+ if (ev.key.keysym.sym == SDLK_F11) {
+ event.type = EVENT_KEYDOWN;
+ event.kbd.keycode = SDLK_F5;
+ event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
+ }
+ // Nap center (space) to tab (default action )
+ // 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.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.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.kbd.keycode = ev.key.keysym.sym;
+ event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
+ }
#endif
- return false;
+ return false;
}
diff --git a/backends/sdl/graphics.cpp b/backends/sdl/graphics.cpp
index 606e58167a..a23bffc81d 100644
--- a/backends/sdl/graphics.cpp
+++ b/backends/sdl/graphics.cpp
@@ -59,6 +59,17 @@ static ScalerProc *scalersMagn[3][3] = {
#endif
};
+static const int s_gfxModeSwitchTable[][4] = {
+ { GFX_NORMAL, GFX_DOUBLESIZE, GFX_TRIPLESIZE, -1 },
+ { GFX_NORMAL, GFX_ADVMAME2X, GFX_ADVMAME3X, -1 },
+ { GFX_NORMAL, GFX_HQ2X, GFX_HQ3X, -1 },
+ { GFX_NORMAL, GFX_2XSAI, -1, -1 },
+ { GFX_NORMAL, GFX_SUPER2XSAI, -1, -1 },
+ { GFX_NORMAL, GFX_SUPEREAGLE, -1, -1 },
+ { GFX_NORMAL, GFX_TV2X, -1, -1 },
+ { GFX_NORMAL, GFX_DOTMATRIX, -1, -1 }
+ };
+
static int cursorStretch200To240(uint8 *buf, uint32 pitch, int width, int height, int srcX, int srcY, int origSrcY);
const OSystem::GraphicsMode *OSystem_SDL::getSupportedGraphicsModes() const {
@@ -1535,7 +1546,7 @@ void OSystem_SDL::drawMouse() {
}
#pragma mark -
-#pragma mark --- Mouse ---
+#pragma mark --- On Screen Display ---
#pragma mark -
#ifdef USE_OSD
@@ -1619,3 +1630,85 @@ void OSystem_SDL::displayMessageOnOSD(const char *msg) {
_forceFull = true;
}
#endif
+
+
+#pragma mark -
+#pragma mark --- Misc ---
+#pragma mark -
+
+void OSystem_SDL::handleScalerHotkeys(const SDL_KeyboardEvent &key) {
+ // Ctrl-Alt-a toggles aspect ratio correction
+ if (key.keysym.sym == 'a') {
+ setFeatureState(kFeatureAspectRatioCorrection, !_adjustAspectRatio);
+#ifdef USE_OSD
+ char buffer[128];
+ if (_adjustAspectRatio)
+ sprintf(buffer, "Enabled aspect ratio correction\n%d x %d -> %d x %d",
+ _screenWidth, _screenHeight,
+ _hwscreen->w, _hwscreen->h
+ );
+ else
+ sprintf(buffer, "Disabled aspect ratio correction\n%d x %d -> %d x %d",
+ _screenWidth, _screenHeight,
+ _hwscreen->w, _hwscreen->h
+ );
+ displayMessageOnOSD(buffer);
+#endif
+
+ return;
+ }
+
+ int newMode = -1;
+ int factor = _scaleFactor - 1;
+
+ // Increase/decrease the scale factor
+ if (key.keysym.sym == SDLK_EQUALS || key.keysym.sym == SDLK_PLUS || key.keysym.sym == SDLK_MINUS ||
+ key.keysym.sym == SDLK_KP_PLUS || key.keysym.sym == SDLK_KP_MINUS) {
+ factor += (key.keysym.sym == SDLK_MINUS || key.keysym.sym == SDLK_KP_MINUS) ? -1 : +1;
+ if (0 <= factor && factor <= 3) {
+ newMode = s_gfxModeSwitchTable[_scalerType][factor];
+ }
+ }
+
+ const bool isNormalNumber = (SDLK_1 <= key.keysym.sym && key.keysym.sym <= SDLK_9);
+ const bool isKeypadNumber = (SDLK_KP1 <= key.keysym.sym && key.keysym.sym <= SDLK_KP9);
+ if (isNormalNumber || isKeypadNumber) {
+ _scalerType = key.keysym.sym - (isNormalNumber ? SDLK_1 : SDLK_KP1);
+ if (_scalerType >= ARRAYSIZE(s_gfxModeSwitchTable))
+ return;
+
+ while (s_gfxModeSwitchTable[_scalerType][factor] < 0) {
+ assert(factor > 0);
+ factor--;
+ }
+ newMode = s_gfxModeSwitchTable[_scalerType][factor];
+ }
+
+ if (newMode >= 0) {
+ setGraphicsMode(newMode);
+#ifdef USE_OSD
+ if (_osdSurface) {
+ const char *newScalerName = 0;
+ const GraphicsMode *g = getSupportedGraphicsModes();
+ while (g->name) {
+ if (g->id == _mode) {
+ newScalerName = g->description;
+ break;
+ }
+ g++;
+ }
+ if (newScalerName) {
+ char buffer[128];
+ sprintf(buffer, "Active graphics filter: %s\n%d x %d -> %d x %d",
+ newScalerName,
+ _screenWidth, _screenHeight,
+ _hwscreen->w, _hwscreen->h
+ );
+ displayMessageOnOSD(buffer);
+ }
+ }
+#endif
+
+ }
+
+}
diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h
index 87e2eb3a34..6c3265b2dc 100644
--- a/backends/sdl/sdl-common.h
+++ b/backends/sdl/sdl-common.h
@@ -52,17 +52,6 @@ enum {
GFX_DOTMATRIX = 11
};
-static const int s_gfxModeSwitchTable[][4] = {
- { GFX_NORMAL, GFX_DOUBLESIZE, GFX_TRIPLESIZE, -1 },
- { GFX_NORMAL, GFX_ADVMAME2X, GFX_ADVMAME3X, -1 },
- { GFX_NORMAL, GFX_HQ2X, GFX_HQ3X, -1 },
- { GFX_NORMAL, GFX_2XSAI, -1, -1 },
- { GFX_NORMAL, GFX_SUPER2XSAI, -1, -1 },
- { GFX_NORMAL, GFX_SUPEREAGLE, -1, -1 },
- { GFX_NORMAL, GFX_TV2X, -1, -1 },
- { GFX_NORMAL, GFX_DOTMATRIX, -1, -1 }
- };
-
class OSystem_SDL : public OSystem {
public:
@@ -196,8 +185,6 @@ public:
#endif
protected:
- virtual bool remapKey(SDL_Event &ev, Event &event);
-
bool _inited;
#ifdef USE_OSD
@@ -380,6 +367,10 @@ protected:
void setupIcon();
void handleKbdMouse();
+
+ virtual bool remapKey(SDL_Event &ev, Event &event);
+
+ void handleScalerHotkeys(const SDL_KeyboardEvent &key);
};
#endif