aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/sdl/graphics.cpp212
-rw-r--r--backends/platform/sdl/hardwarekeys.cpp302
-rw-r--r--backends/platform/sdl/sdl.cpp4
-rw-r--r--backends/platform/sdl/sdl.h27
4 files changed, 379 insertions, 166 deletions
diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp
index 1192c1abff..efcade834d 100644
--- a/backends/platform/sdl/graphics.cpp
+++ b/backends/platform/sdl/graphics.cpp
@@ -26,6 +26,9 @@
#include "backends/platform/sdl/sdl.h"
#include "common/mutex.h"
#include "common/util.h"
+#ifdef ENABLE_RGB_COLOR
+#include "common/list.h"
+#endif
#include "graphics/font.h"
#include "graphics/fontman.h"
#include "graphics/scaler.h"
@@ -97,6 +100,9 @@ void OSystem_SDL::beginGFXTransaction(void) {
_transactionDetails.needUpdatescreen = false;
_transactionDetails.normal1xScaler = false;
+#ifdef ENABLE_RGB_COLOR
+ _transactionDetails.formatChanged = false;
+#endif
_oldVideoMode = _videoMode;
}
@@ -120,6 +126,13 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) {
_videoMode.mode = _oldVideoMode.mode;
_videoMode.scaleFactor = _oldVideoMode.scaleFactor;
+#ifdef ENABLE_RGB_COLOR
+ } else if (_videoMode.format != _oldVideoMode.format) {
+ errors |= kTransactionFormatNotSupported;
+
+ _videoMode.format = _oldVideoMode.format;
+ _screenFormat = _videoMode.format;
+#endif
} else if (_videoMode.screenWidth != _oldVideoMode.screenWidth || _videoMode.screenHeight != _oldVideoMode.screenHeight) {
errors |= kTransactionSizeChangeFailed;
@@ -143,7 +156,11 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) {
}
}
+#ifdef ENABLE_RGB_COLOR
+ if (_transactionDetails.sizeChanged || _transactionDetails.formatChanged) {
+#else
if (_transactionDetails.sizeChanged) {
+#endif
unloadGFXMode();
if (!loadGFXMode()) {
if (_oldVideoMode.setup) {
@@ -186,12 +203,94 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) {
} else if (_transactionDetails.needUpdatescreen) {
setGraphicsModeIntern();
internUpdateScreen();
- }
+ }
_transactionMode = kTransactionNone;
return (TransactionError)errors;
}
+#ifdef ENABLE_RGB_COLOR
+const Graphics::PixelFormat RGBList[] = {
+#ifdef ENABLE_32BIT
+ // RGBA8888, ARGB8888, RGB888
+ Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0),
+ Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24),
+ Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0),
+#endif
+ // RGB565, XRGB1555, RGB555, RGBA4444, ARGB4444
+ Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0),
+ Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15),
+ Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0),
+ Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0),
+ Graphics::PixelFormat(2, 4, 4, 4, 4, 8, 4, 0, 12)
+};
+const Graphics::PixelFormat BGRList[] = {
+#ifdef ENABLE_32BIT
+ // ABGR8888, BGRA8888, BGR888
+ Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24),
+ Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0),
+ Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0),
+#endif
+ // BGR565, XBGR1555, BGR555, ABGR4444, BGRA4444
+ Graphics::PixelFormat(2, 5, 6, 5, 0, 0, 5, 11, 0),
+ Graphics::PixelFormat(2, 5, 5, 5, 1, 0, 5, 10, 15),
+ Graphics::PixelFormat(2, 5, 5, 5, 0, 0, 5, 10, 0),
+ Graphics::PixelFormat(2, 4, 4, 4, 4, 0, 4, 8, 12),
+ Graphics::PixelFormat(2, 4, 4, 4, 4, 4, 8, 12, 0)
+};
+
+// TODO: prioritize matching alpha masks
+Common::List<Graphics::PixelFormat> OSystem_SDL::getSupportedFormats() {
+ static Common::List<Graphics::PixelFormat> list;
+ static bool inited = false;
+
+ if (inited)
+ return list;
+
+ bool BGR = false;
+ int listLength = ARRAYSIZE(RGBList);
+
+ Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8();
+ if (_hwscreen) {
+ // Get our currently set hardware format
+ format = Graphics::PixelFormat(_hwscreen->format->BytesPerPixel,
+ 8 - _hwscreen->format->Rloss, 8 - _hwscreen->format->Gloss,
+ 8 - _hwscreen->format->Bloss, 8 - _hwscreen->format->Aloss,
+ _hwscreen->format->Rshift, _hwscreen->format->Gshift,
+ _hwscreen->format->Bshift, _hwscreen->format->Ashift);
+
+ // Workaround to MacOSX SDL not providing an accurate Aloss value.
+ if (_hwscreen->format->Amask == 0)
+ format.aLoss = 8;
+
+ // Push it first, as the prefered format.
+ list.push_back(format);
+
+ if (format.bShift > format.rShift)
+ BGR = true;
+
+ // Mark that we don't need to do this any more.
+ inited = true;
+ }
+
+ for (int i = 0; i < listLength; i++) {
+ if (inited && (RGBList[i].bytesPerPixel > format.bytesPerPixel))
+ continue;
+ if (BGR) {
+ if (BGRList[i] != format)
+ list.push_back(BGRList[i]);
+ list.push_back(RGBList[i]);
+ } else {
+ if (RGBList[i] != format)
+ list.push_back(RGBList[i]);
+ list.push_back(BGRList[i]);
+ }
+ }
+ list.push_back(Graphics::PixelFormat::createFormatCLUT8());
+ return list;
+}
+#endif
+
bool OSystem_SDL::setGraphicsMode(int mode) {
Common::StackLock lock(_graphicsMutex);
@@ -340,9 +439,27 @@ int OSystem_SDL::getGraphicsMode() const {
return _videoMode.mode;
}
-void OSystem_SDL::initSize(uint w, uint h) {
+void OSystem_SDL::initSize(uint w, uint h, const Graphics::PixelFormat *format) {
assert(_transactionMode == kTransactionActive);
+#ifdef ENABLE_RGB_COLOR
+ //avoid redundant format changes
+ Graphics::PixelFormat newFormat;
+ if (!format)
+ newFormat = Graphics::PixelFormat::createFormatCLUT8();
+ else
+ newFormat = *format;
+
+ assert(newFormat.bytesPerPixel > 0);
+
+ if (newFormat != _videoMode.format)
+ {
+ _videoMode.format = newFormat;
+ _transactionDetails.formatChanged = true;
+ _screenFormat = newFormat;
+ }
+#endif
+
// Avoid redundant res changes
if ((int)w == _videoMode.screenWidth && (int)h == _videoMode.screenHeight)
return;
@@ -426,9 +543,21 @@ bool OSystem_SDL::loadGFXMode() {
//
// Create the surface that contains the 8 bit game data
//
+#ifdef ENABLE_RGB_COLOR
+ _screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth, _videoMode.screenHeight,
+ _screenFormat.bytesPerPixel << 3,
+ ((1 << _screenFormat.rBits()) - 1) << _screenFormat.rShift ,
+ ((1 << _screenFormat.gBits()) - 1) << _screenFormat.gShift ,
+ ((1 << _screenFormat.bBits()) - 1) << _screenFormat.bShift ,
+ ((1 << _screenFormat.aBits()) - 1) << _screenFormat.aShift );
+ if (_screen == NULL)
+ error("allocating _screen failed");
+
+#else
_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth, _videoMode.screenHeight, 8, 0, 0, 0, 0);
if (_screen == NULL)
error("allocating _screen failed");
+#endif
//
// Create the surface that contains the scaled graphics in 16 bit mode
@@ -571,8 +700,8 @@ bool OSystem_SDL::hotswapGFXMode() {
// Keep around the old _screen & _overlayscreen so we can restore the screen data
// after the mode switch.
SDL_Surface *old_screen = _screen;
- SDL_Surface *old_overlayscreen = _overlayscreen;
_screen = NULL;
+ SDL_Surface *old_overlayscreen = _overlayscreen;
_overlayscreen = NULL;
// Release the HW screen surface
@@ -878,8 +1007,19 @@ void OSystem_SDL::copyRectToScreen(const byte *src, int pitch, int x, int y, int
if (SDL_LockSurface(_screen) == -1)
error("SDL_LockSurface failed: %s", SDL_GetError());
+#ifdef ENABLE_RGB_COLOR
+ byte *dst = (byte *)_screen->pixels + y * _videoMode.screenWidth * _screenFormat.bytesPerPixel + x * _screenFormat.bytesPerPixel;
+ if (_videoMode.screenWidth == w && pitch == w * _screenFormat.bytesPerPixel) {
+ memcpy(dst, src, h*w*_screenFormat.bytesPerPixel);
+ } else {
+ do {
+ memcpy(dst, src, w * _screenFormat.bytesPerPixel);
+ src += pitch;
+ dst += _videoMode.screenWidth * _screenFormat.bytesPerPixel;
+ } while (--h);
+ }
+#else
byte *dst = (byte *)_screen->pixels + y * _videoMode.screenWidth + x;
-
if (_videoMode.screenWidth == pitch && pitch == w) {
memcpy(dst, src, h*w);
} else {
@@ -889,6 +1029,7 @@ void OSystem_SDL::copyRectToScreen(const byte *src, int pitch, int x, int y, int
dst += _videoMode.screenWidth;
} while (--h);
}
+#endif
// Unlock the screen surface
SDL_UnlockSurface(_screen);
@@ -912,7 +1053,11 @@ Graphics::Surface *OSystem_SDL::lockScreen() {
_framebuffer.w = _screen->w;
_framebuffer.h = _screen->h;
_framebuffer.pitch = _screen->pitch;
+#ifdef ENABLE_RGB_COLOR
+ _framebuffer.bytesPerPixel = _screenFormat.bytesPerPixel;
+#else
_framebuffer.bytesPerPixel = 1;
+#endif
return &_framebuffer;
}
@@ -1096,6 +1241,11 @@ int16 OSystem_SDL::getWidth() {
void OSystem_SDL::setPalette(const byte *colors, uint start, uint num) {
assert(colors);
+#ifdef ENABLE_RGB_COLOR
+ if (_screenFormat.bytesPerPixel > 1)
+ return; //not using a paletted pixel format
+#endif
+
// Setting the palette before _screen is created is allowed - for now -
// since we don't actually set the palette until the screen is updated.
// But it could indicate a programming error, so let's warn about it.
@@ -1149,10 +1299,10 @@ void OSystem_SDL::setCursorPalette(const byte *colors, uint start, uint num) {
}
_cursorPaletteDisabled = false;
-
blitCursor();
}
+
void OSystem_SDL::setShakePos(int shake_pos) {
assert (_transactionMode == kTransactionNone);
@@ -1357,7 +1507,17 @@ void OSystem_SDL::warpMouse(int x, int y) {
}
}
-void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale) {
+void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) {
+#ifdef ENABLE_RGB_COLOR
+ if (!format)
+ _cursorFormat = Graphics::PixelFormat::createFormatCLUT8();
+ else if (format->bytesPerPixel <= _screenFormat.bytesPerPixel)
+ _cursorFormat = *format;
+ keycolor &= (1 << (_cursorFormat.bytesPerPixel << 3)) - 1;
+#else
+ keycolor &= 0xFF;
+#endif
+
if (w == 0 || h == 0)
return;
@@ -1391,16 +1551,26 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x,
}
free(_mouseData);
-
+#ifdef ENABLE_RGB_COLOR
+ _mouseData = (byte *)malloc(w * h * _cursorFormat.bytesPerPixel);
+ memcpy(_mouseData, buf, w * h * _cursorFormat.bytesPerPixel);
+#else
_mouseData = (byte *)malloc(w * h);
memcpy(_mouseData, buf, w * h);
+#endif
+
blitCursor();
}
void OSystem_SDL::blitCursor() {
byte *dstPtr;
const byte *srcPtr = _mouseData;
+#ifdef ENABLE_RGB_COLOR
+ uint32 color;
+ uint32 colormask = (1 << (_cursorFormat.bytesPerPixel << 3)) - 1;
+#else
byte color;
+#endif
int w, h, i, j;
if (!_mouseOrigSurface || !_mouseData)
@@ -1434,13 +1604,29 @@ void OSystem_SDL::blitCursor() {
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
- color = *srcPtr;
- if (color != _mouseKeyColor) { // transparent, don't draw
- *(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format,
- palette[color].r, palette[color].g, palette[color].b);
+#ifdef ENABLE_RGB_COLOR
+ if (_cursorFormat.bytesPerPixel > 1) {
+ color = (*(uint32 *) srcPtr) & colormask;
+ if (color != _mouseKeyColor) { // transparent, don't draw
+ uint8 r,g,b;
+ _cursorFormat.colorToRGB(color,r,g,b);
+ *(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format,
+ r, g, b);
+ }
+ dstPtr += 2;
+ srcPtr += _cursorFormat.bytesPerPixel;
+ } else {
+#endif
+ color = *srcPtr;
+ if (color != _mouseKeyColor) { // transparent, don't draw
+ *(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format,
+ palette[color].r, palette[color].g, palette[color].b);
+ }
+ dstPtr += 2;
+ srcPtr++;
+#ifdef ENABLE_RGB_COLOR
}
- dstPtr += 2;
- srcPtr++;
+#endif
}
dstPtr += _mouseOrigSurface->pitch - w * 2;
}
diff --git a/backends/platform/sdl/hardwarekeys.cpp b/backends/platform/sdl/hardwarekeys.cpp
index 1a8124bbf3..c063ea5bff 100644
--- a/backends/platform/sdl/hardwarekeys.cpp
+++ b/backends/platform/sdl/hardwarekeys.cpp
@@ -37,161 +37,170 @@ struct Key {
uint16 ascii;
const char *desc;
KeyType preferredAction;
- bool shiftable;
+ int32 modableMask;
};
static const Key keys[] = {
- {"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", kActionKeyType, false},
- {"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", kActionKeyType, false},
- {"CLEAR", KEYCODE_CLEAR, 0, "Clear", kActionKeyType, false},
- {"RETURN", KEYCODE_RETURN, ASCII_RETURN, "Return", kActionKeyType, false},
- {"PAUSE", KEYCODE_PAUSE, 0, "Pause", kActionKeyType, false},
- {"ESCAPE", KEYCODE_ESCAPE, ASCII_ESCAPE, "Esc", kStartKeyType, false},
- {"SPACE", KEYCODE_SPACE, ASCII_SPACE, "Space", kActionKeyType, false},
- {"EXCLAIM", KEYCODE_EXCLAIM, '!', "!", kActionKeyType, false},
- {"QUOTEDBL", KEYCODE_QUOTEDBL, '"', "\"", kActionKeyType, false},
- {"HASH", KEYCODE_HASH, '#', "#", kActionKeyType, false},
- {"DOLLAR", KEYCODE_DOLLAR, '$', "$", kActionKeyType, false},
- {"AMPERSAND", KEYCODE_AMPERSAND, '&', "&", kActionKeyType, false},
- {"QUOTE", KEYCODE_QUOTE, '\'', "'", kActionKeyType, false},
- {"LEFTPAREN", KEYCODE_LEFTPAREN, '(', "(", kActionKeyType, false},
- {"RIGHTPAREN", KEYCODE_RIGHTPAREN, ')', ")", kActionKeyType, false},
- {"ASTERISK", KEYCODE_ASTERISK, '*', "*", kActionKeyType, false},
- {"PLUS", KEYCODE_PLUS, '+', "+", kActionKeyType, false},
- {"COMMA", KEYCODE_COMMA, ',', ",", kActionKeyType, false},
- {"MINUS", KEYCODE_MINUS, '-', "-", kActionKeyType, false},
- {"PERIOD", KEYCODE_PERIOD, '.', ".", kActionKeyType, false},
- {"SLASH", KEYCODE_SLASH, '/', "/", kActionKeyType, false},
- {"0", KEYCODE_0, '0', "0", kActionKeyType, false},
- {"1", KEYCODE_1, '1', "1", kActionKeyType, false},
- {"2", KEYCODE_2, '2', "2", kActionKeyType, false},
- {"3", KEYCODE_3, '3', "3", kActionKeyType, false},
- {"4", KEYCODE_4, '4', "4", kActionKeyType, false},
- {"5", KEYCODE_5, '5', "5", kActionKeyType, false},
- {"6", KEYCODE_6, '6', "6", kActionKeyType, false},
- {"7", KEYCODE_7, '7', "7", kActionKeyType, false},
- {"8", KEYCODE_8, '8', "8", kActionKeyType, false},
- {"9", KEYCODE_9, '9', "9", kActionKeyType, false},
- {"COLON", KEYCODE_COLON, ':', ":", kActionKeyType, false},
- {"SEMICOLON", KEYCODE_SEMICOLON, ';', ";", kActionKeyType, false},
- {"LESS", KEYCODE_LESS, '<', "<", kActionKeyType, false},
- {"EQUALS", KEYCODE_EQUALS, '=', "=", kActionKeyType, false},
- {"GREATER", KEYCODE_GREATER, '>', ">", kActionKeyType, false},
- {"QUESTION", KEYCODE_QUESTION, '?', "?", kActionKeyType, false},
- {"AT", KEYCODE_AT, '@', "@", kActionKeyType, false},
-
- {"LEFTBRACKET", KEYCODE_LEFTBRACKET, '[', "[", kActionKeyType, false},
- {"BACKSLASH", KEYCODE_BACKSLASH, '\\', "\\", kActionKeyType, false},
- {"RIGHTBRACKET", KEYCODE_RIGHTBRACKET, ']', "]", kActionKeyType, false},
- {"CARET", KEYCODE_CARET, '^', "^", kActionKeyType, false},
- {"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", kActionKeyType, false},
- {"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", kActionKeyType, false},
- {"a", KEYCODE_a, 'a', "a", kActionKeyType, true},
- {"b", KEYCODE_b, 'b', "b", kActionKeyType, true},
- {"c", KEYCODE_c, 'c', "c", kActionKeyType, true},
- {"d", KEYCODE_d, 'd', "d", kActionKeyType, true},
- {"e", KEYCODE_e, 'e', "e", kActionKeyType, true},
- {"f", KEYCODE_f, 'f', "f", kActionKeyType, true},
- {"g", KEYCODE_g, 'g', "g", kActionKeyType, true},
- {"h", KEYCODE_h, 'h', "h", kActionKeyType, true},
- {"i", KEYCODE_i, 'i', "i", kActionKeyType, true},
- {"j", KEYCODE_j, 'j', "j", kActionKeyType, true},
- {"k", KEYCODE_k, 'k', "k", kActionKeyType, true},
- {"l", KEYCODE_l, 'l', "l", kActionKeyType, true},
- {"m", KEYCODE_m, 'm', "m", kActionKeyType, true},
- {"n", KEYCODE_n, 'n', "n", kActionKeyType, true},
- {"o", KEYCODE_o, 'o', "o", kActionKeyType, true},
- {"p", KEYCODE_p, 'p', "p", kActionKeyType, true},
- {"q", KEYCODE_q, 'q', "q", kActionKeyType, true},
- {"r", KEYCODE_r, 'r', "r", kActionKeyType, true},
- {"s", KEYCODE_s, 's', "s", kActionKeyType, true},
- {"t", KEYCODE_t, 't', "t", kActionKeyType, true},
- {"u", KEYCODE_u, 'u', "u", kActionKeyType, true},
- {"v", KEYCODE_v, 'v', "v", kActionKeyType, true},
- {"w", KEYCODE_w, 'w', "w", kActionKeyType, true},
- {"x", KEYCODE_x, 'x', "x", kActionKeyType, true},
- {"y", KEYCODE_y, 'y', "y", kActionKeyType, true},
- {"z", KEYCODE_z, 'z', "z", kActionKeyType, true},
- {"DELETE", KEYCODE_DELETE, 0, "Del", kActionKeyType, false},
+ {"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", kActionKeyType, ~0},
+ {"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", kActionKeyType, ~0},
+ {"CLEAR", KEYCODE_CLEAR, 0, "Clear", kActionKeyType, ~0},
+ {"RETURN", KEYCODE_RETURN, ASCII_RETURN, "Return", kActionKeyType, ~0},
+ {"PAUSE", KEYCODE_PAUSE, 0, "Pause", kActionKeyType, ~0},
+ {"ESCAPE", KEYCODE_ESCAPE, ASCII_ESCAPE, "Esc", kStartKeyType, ~0},
+ {"SPACE", KEYCODE_SPACE, ASCII_SPACE, "Space", kActionKeyType, ~0},
+ {"EXCLAIM", KEYCODE_EXCLAIM, '!', "!", kActionKeyType, ~0},
+ {"QUOTEDBL", KEYCODE_QUOTEDBL, '"', "\"", kActionKeyType, ~0},
+ {"HASH", KEYCODE_HASH, '#', "#", kActionKeyType, ~0},
+ {"DOLLAR", KEYCODE_DOLLAR, '$', "$", kActionKeyType, ~0},
+ {"AMPERSAND", KEYCODE_AMPERSAND, '&', "&", kActionKeyType, ~0},
+ {"QUOTE", KEYCODE_QUOTE, '\'', "'", kActionKeyType, ~0},
+ {"LEFTPAREN", KEYCODE_LEFTPAREN, '(', "(", kActionKeyType, ~0},
+ {"RIGHTPAREN", KEYCODE_RIGHTPAREN, ')', ")", kActionKeyType, ~0},
+ {"ASTERISK", KEYCODE_ASTERISK, '*', "*", kActionKeyType, ~0},
+ {"PLUS", KEYCODE_PLUS, '+', "+", kActionKeyType, ~0},
+ {"COMMA", KEYCODE_COMMA, ',', ",", kActionKeyType, ~0},
+ {"MINUS", KEYCODE_MINUS, '-', "-", kActionKeyType, ~0},
+ {"PERIOD", KEYCODE_PERIOD, '.', ".", kActionKeyType, ~0},
+ {"SLASH", KEYCODE_SLASH, '/', "/", kActionKeyType, ~0},
+ {"0", KEYCODE_0, '0', "0", kActionKeyType, ~0},
+ {"1", KEYCODE_1, '1', "1", kActionKeyType, ~0},
+ {"2", KEYCODE_2, '2', "2", kActionKeyType, ~0},
+ {"3", KEYCODE_3, '3', "3", kActionKeyType, ~0},
+ {"4", KEYCODE_4, '4', "4", kActionKeyType, ~0},
+ {"5", KEYCODE_5, '5', "5", kActionKeyType, ~0},
+ {"6", KEYCODE_6, '6', "6", kActionKeyType, ~0},
+ {"7", KEYCODE_7, '7', "7", kActionKeyType, ~0},
+ {"8", KEYCODE_8, '8', "8", kActionKeyType, ~0},
+ {"9", KEYCODE_9, '9', "9", kActionKeyType, ~0},
+ {"COLON", KEYCODE_COLON, ':', ":", kActionKeyType, ~0},
+ {"SEMICOLON", KEYCODE_SEMICOLON, ';', ";", kActionKeyType, ~0},
+ {"LESS", KEYCODE_LESS, '<', "<", kActionKeyType, ~0},
+ {"EQUALS", KEYCODE_EQUALS, '=', "=", kActionKeyType, ~0},
+ {"GREATER", KEYCODE_GREATER, '>', ">", kActionKeyType, ~0},
+ {"QUESTION", KEYCODE_QUESTION, '?', "?", kActionKeyType, ~0},
+ {"AT", KEYCODE_AT, '@', "@", kActionKeyType, ~0},
+
+ {"LEFTBRACKET", KEYCODE_LEFTBRACKET, '[', "[", kActionKeyType, ~0},
+ {"BACKSLASH", KEYCODE_BACKSLASH, '\\', "\\", kActionKeyType, ~0},
+ {"RIGHTBRACKET", KEYCODE_RIGHTBRACKET, ']', "]", kActionKeyType, ~0},
+ {"CARET", KEYCODE_CARET, '^', "^", kActionKeyType, ~0},
+ {"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", kActionKeyType, ~0},
+ {"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", kActionKeyType, ~0},
+ {"a", KEYCODE_a, 'a', "A", kActionKeyType, ~0},
+ {"b", KEYCODE_b, 'b', "B", kActionKeyType, ~0},
+ {"c", KEYCODE_c, 'c', "C", kActionKeyType, ~0},
+ {"d", KEYCODE_d, 'd', "D", kActionKeyType, ~0},
+ {"e", KEYCODE_e, 'e', "E", kActionKeyType, ~0},
+ {"f", KEYCODE_f, 'f', "F", kActionKeyType, ~0},
+ {"g", KEYCODE_g, 'g', "G", kActionKeyType, ~0},
+ {"h", KEYCODE_h, 'h', "H", kActionKeyType, ~0},
+ {"i", KEYCODE_i, 'i', "I", kActionKeyType, ~0},
+ {"j", KEYCODE_j, 'j', "J", kActionKeyType, ~0},
+ {"k", KEYCODE_k, 'k', "K", kActionKeyType, ~0},
+ {"l", KEYCODE_l, 'l', "L", kActionKeyType, ~0},
+ {"m", KEYCODE_m, 'm', "M", kActionKeyType, ~0},
+ {"n", KEYCODE_n, 'n', "N", kActionKeyType, ~0},
+ {"o", KEYCODE_o, 'o', "O", kActionKeyType, ~0},
+ {"p", KEYCODE_p, 'p', "P", kActionKeyType, ~0},
+ {"q", KEYCODE_q, 'q', "Q", kActionKeyType, ~0},
+ {"r", KEYCODE_r, 'r', "R", kActionKeyType, ~0},
+ {"s", KEYCODE_s, 's', "S", kActionKeyType, ~0},
+ {"t", KEYCODE_t, 't', "T", kActionKeyType, ~0},
+ {"u", KEYCODE_u, 'u', "U", kActionKeyType, ~0},
+ {"v", KEYCODE_v, 'v', "V", kActionKeyType, ~0},
+ {"w", KEYCODE_w, 'w', "W", kActionKeyType, ~0},
+ {"x", KEYCODE_x, 'x', "X", kActionKeyType, ~0},
+ {"y", KEYCODE_y, 'y', "Y", kActionKeyType, ~0},
+ {"z", KEYCODE_z, 'z', "Z", kActionKeyType, ~0},
+ {"DELETE", KEYCODE_DELETE, 0, "Del", kActionKeyType, ~0},
// Numeric keypad
- {"KP0", KEYCODE_KP0, 0, "KP0", kActionKeyType, false},
- {"KP1", KEYCODE_KP1, 0, "KP1", kActionKeyType, false},
- {"KP2", KEYCODE_KP2, 0, "KP2", kActionKeyType, false},
- {"KP3", KEYCODE_KP3, 0, "KP3", kActionKeyType, false},
- {"KP4", KEYCODE_KP4, 0, "KP4", kActionKeyType, false},
- {"KP5", KEYCODE_KP5, 0, "KP5", kActionKeyType, false},
- {"KP6", KEYCODE_KP6, 0, "KP6", kActionKeyType, false},
- {"KP7", KEYCODE_KP7, 0, "KP7", kActionKeyType, false},
- {"KP8", KEYCODE_KP8, 0, "KP8", kActionKeyType, false},
- {"KP9", KEYCODE_KP9, 0, "KP9", kActionKeyType, false},
- {"KP_PERIOD", KEYCODE_KP_PERIOD, 0, "KP.", kActionKeyType, false},
- {"KP_DIVIDE", KEYCODE_KP_DIVIDE, 0, "KP/", kActionKeyType, false},
- {"KP_MULTIPLY", KEYCODE_KP_MULTIPLY, 0, "KP*", kActionKeyType, false},
- {"KP_MINUS", KEYCODE_KP_MINUS, 0, "KP-", kActionKeyType, false},
- {"KP_PLUS", KEYCODE_KP_PLUS, 0, "KP+", kActionKeyType, false},
- {"KP_ENTER", KEYCODE_KP_ENTER, 0, "KP Enter", kActionKeyType, false},
- {"KP_EQUALS", KEYCODE_KP_EQUALS, 0, "KP=", kActionKeyType, false},
+ {"KP0", KEYCODE_KP0, 0, "KP0", kActionKeyType, ~0},
+ {"KP1", KEYCODE_KP1, 0, "KP1", kActionKeyType, ~0},
+ {"KP2", KEYCODE_KP2, 0, "KP2", kActionKeyType, ~0},
+ {"KP3", KEYCODE_KP3, 0, "KP3", kActionKeyType, ~0},
+ {"KP4", KEYCODE_KP4, 0, "KP4", kActionKeyType, ~0},
+ {"KP5", KEYCODE_KP5, 0, "KP5", kActionKeyType, ~0},
+ {"KP6", KEYCODE_KP6, 0, "KP6", kActionKeyType, ~0},
+ {"KP7", KEYCODE_KP7, 0, "KP7", kActionKeyType, ~0},
+ {"KP8", KEYCODE_KP8, 0, "KP8", kActionKeyType, ~0},
+ {"KP9", KEYCODE_KP9, 0, "KP9", kActionKeyType, ~0},
+ {"KP_PERIOD", KEYCODE_KP_PERIOD, 0, "KP.", kActionKeyType, ~0},
+ {"KP_DIVIDE", KEYCODE_KP_DIVIDE, 0, "KP/", kActionKeyType, ~0},
+ {"KP_MULTIPLY", KEYCODE_KP_MULTIPLY, 0, "KP*", kActionKeyType, ~0},
+ {"KP_MINUS", KEYCODE_KP_MINUS, 0, "KP-", kActionKeyType, ~0},
+ {"KP_PLUS", KEYCODE_KP_PLUS, 0, "KP+", kActionKeyType, ~0},
+ {"KP_ENTER", KEYCODE_KP_ENTER, 0, "KP Enter", kActionKeyType, ~0},
+ {"KP_EQUALS", KEYCODE_KP_EQUALS, 0, "KP=", kActionKeyType, ~0},
// Arrows + Home/End pad
- {"UP", KEYCODE_UP, 0, "Up", kDirUpKeyType, false},
- {"DOWN", KEYCODE_DOWN, 0, "Down", kDirDownKeyType, false},
- {"RIGHT", KEYCODE_RIGHT, 0, "Right", kDirRightKeyType, false},
- {"LEFT", KEYCODE_LEFT, 0, "Left", kDirLeftKeyType, false},
- {"INSERT", KEYCODE_INSERT, 0, "Insert", kActionKeyType, false},
- {"HOME", KEYCODE_HOME, 0, "Home", kActionKeyType, false},
- {"END", KEYCODE_END, 0, "End", kActionKeyType, false},
- {"PAGEUP", KEYCODE_PAGEUP, 0, "PgUp", kActionKeyType, false},
- {"PAGEDOWN", KEYCODE_PAGEDOWN, 0, "PgDn", kActionKeyType, false},
+ {"UP", KEYCODE_UP, 0, "Up", kDirUpKeyType, ~0},
+ {"DOWN", KEYCODE_DOWN, 0, "Down", kDirDownKeyType, ~0},
+ {"RIGHT", KEYCODE_RIGHT, 0, "Right", kDirRightKeyType, ~0},
+ {"LEFT", KEYCODE_LEFT, 0, "Left", kDirLeftKeyType, ~0},
+ {"INSERT", KEYCODE_INSERT, 0, "Insert", kActionKeyType, ~0},
+ {"HOME", KEYCODE_HOME, 0, "Home", kActionKeyType, ~0},
+ {"END", KEYCODE_END, 0, "End", kActionKeyType, ~0},
+ {"PAGEUP", KEYCODE_PAGEUP, 0, "PgUp", kActionKeyType, ~0},
+ {"PAGEDOWN", KEYCODE_PAGEDOWN, 0, "PgDn", kActionKeyType, ~0},
// Function keys
- {"F1", KEYCODE_F1, ASCII_F1, "F1", kActionKeyType, false},
- {"F2", KEYCODE_F2, ASCII_F2, "F2", kActionKeyType, false},
- {"F3", KEYCODE_F3, ASCII_F3, "F3", kActionKeyType, false},
- {"F4", KEYCODE_F4, ASCII_F4, "F4", kActionKeyType, false},
- {"F5", KEYCODE_F5, ASCII_F5, "F5", kActionKeyType, false},
- {"F6", KEYCODE_F6, ASCII_F6, "F6", kActionKeyType, false},
- {"F7", KEYCODE_F7, ASCII_F7, "F7", kActionKeyType, false},
- {"F8", KEYCODE_F8, ASCII_F8, "F8", kActionKeyType, false},
- {"F9", KEYCODE_F9, ASCII_F9, "F9", kActionKeyType, false},
- {"F10", KEYCODE_F10, ASCII_F10, "F10", kActionKeyType, false},
- {"F11", KEYCODE_F11, ASCII_F11, "F11", kActionKeyType, false},
- {"F12", KEYCODE_F12, ASCII_F12, "F12", kActionKeyType, false},
- {"F13", KEYCODE_F13, 0, "F13", kActionKeyType, false},
- {"F14", KEYCODE_F14, 0, "F14", kActionKeyType, false},
- {"F15", KEYCODE_F15, 0, "F15", kActionKeyType, false},
+ {"F1", KEYCODE_F1, ASCII_F1, "F1", kActionKeyType, ~0},
+ {"F2", KEYCODE_F2, ASCII_F2, "F2", kActionKeyType, ~0},
+ {"F3", KEYCODE_F3, ASCII_F3, "F3", kActionKeyType, ~0},
+ {"F4", KEYCODE_F4, ASCII_F4, "F4", kActionKeyType, ~0},
+ {"F5", KEYCODE_F5, ASCII_F5, "F5", kActionKeyType, ~0},
+ {"F6", KEYCODE_F6, ASCII_F6, "F6", kActionKeyType, ~0},
+ {"F7", KEYCODE_F7, ASCII_F7, "F7", kActionKeyType, ~0},
+ {"F8", KEYCODE_F8, ASCII_F8, "F8", kActionKeyType, ~0},
+ {"F9", KEYCODE_F9, ASCII_F9, "F9", kActionKeyType, ~0},
+ {"F10", KEYCODE_F10, ASCII_F10, "F10", kActionKeyType, ~0},
+ {"F11", KEYCODE_F11, ASCII_F11, "F11", kActionKeyType, ~0},
+ {"F12", KEYCODE_F12, ASCII_F12, "F12", kActionKeyType, ~0},
+ {"F13", KEYCODE_F13, 0, "F13", kActionKeyType, ~0},
+ {"F14", KEYCODE_F14, 0, "F14", kActionKeyType, ~0},
+ {"F15", KEYCODE_F15, 0, "F15", kActionKeyType, ~0},
+
+
+// // Modifier keys pressed alone
+// {"RSHIFT", KEYCODE_RSHIFT, 0, "Right Shift", kModiferKeyType, ~KBD_SHIFT},
+// {"LSHIFT", KEYCODE_LSHIFT, 0, "Left Shift", kModiferKeyType, ~KBD_SHIFT},
+// {"RCTRL", KEYCODE_RCTRL, 0, "Right Ctrl", kModiferKeyType, ~KBD_CTRL},
+// {"LCTRL", KEYCODE_LCTRL, 0, "Left Ctrl", kModiferKeyType, ~KBD_CTRL},
+// {"RALT", KEYCODE_RALT, 0, "Right Alt", kModiferKeyType, ~KBD_ALT},
+// {"LALT", KEYCODE_LALT, 0, "Left Alt", kModiferKeyType, ~KBD_ALT},
+
// Miscellaneous function keys
- {"HELP", KEYCODE_HELP, 0, "Help", kActionKeyType, false},
- {"PRINT", KEYCODE_PRINT, 0, "Print", kActionKeyType, false},
- {"SYSREQ", KEYCODE_SYSREQ, 0, "SysRq", kActionKeyType, false},
- {"BREAK", KEYCODE_BREAK, 0, "Break", kActionKeyType, false},
- {"MENU", KEYCODE_MENU, 0, "Menu", kActionKeyType, false},
+ {"HELP", KEYCODE_HELP, 0, "Help", kActionKeyType, ~0},
+ {"PRINT", KEYCODE_PRINT, 0, "Print", kActionKeyType, ~0},
+ {"SYSREQ", KEYCODE_SYSREQ, 0, "SysRq", kActionKeyType, ~0},
+ {"BREAK", KEYCODE_BREAK, 0, "Break", kActionKeyType, ~0},
+ {"MENU", KEYCODE_MENU, 0, "Menu", kActionKeyType, ~0},
// Power Macintosh power key
- {"POWER", KEYCODE_POWER, 0, "Power", kActionKeyType, false},
+ {"POWER", KEYCODE_POWER, 0, "Power", kActionKeyType, ~0},
// Some european keyboards
- {"EURO", KEYCODE_EURO, 0, "Euro", kActionKeyType, false},
+ {"EURO", KEYCODE_EURO, 0, "Euro", kActionKeyType, ~0},
// Atari keyboard has Undo
- {"UNDO", KEYCODE_UNDO, 0, "Undo", kActionKeyType, false},
- {0, KEYCODE_INVALID, 0, 0, kGenericKeyType, false}
+ {"UNDO", KEYCODE_UNDO, 0, "Undo", kActionKeyType, ~0},
+ {0, KEYCODE_INVALID, 0, 0, kGenericKeyType, ~0}
};
struct Mod {
byte flag;
const char *id;
const char *desc;
- bool shiftable;
};
static const Mod modifiers[] = {
- { 0, "", "", false },
- { KBD_CTRL, "C+", "Ctrl+", false },
- { KBD_ALT, "A+", "Alt+", false },
- { KBD_SHIFT, "", "", true },
- { KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+", false },
- { KBD_SHIFT | KBD_CTRL, "S+C+", "Shift+Ctrl+", true },
- { KBD_SHIFT | KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+", true },
- { 0, 0, 0, false }
+ { 0, "", "" },
+ { KBD_CTRL, "C+", "Ctrl+" },
+ { KBD_ALT, "A+", "Alt+" },
+ { KBD_SHIFT, "S+", "Shift+" },
+ { KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+" },
+ { KBD_SHIFT | KBD_CTRL, "S+C+", "Shift+Ctrl+" },
+ { KBD_SHIFT | KBD_CTRL | KBD_ALT, "S+C+A+", "Shift+Ctrl+Alt+" },
+ { 0, 0, 0 }
};
#endif
@@ -206,23 +215,18 @@ Common::HardwareKeySet *OSystem_SDL::getHardwareKeySet() {
uint16 ascii;
for (mod = modifiers; mod->id; mod++) {
- for (key = keys; key->hwId; key++) {
- ascii = key->ascii;
-
- if (mod->shiftable && key->shiftable) {
- snprintf(fullKeyId, 50, "%s%c", mod->id, toupper(key->hwId[0]));
- snprintf(fullKeyDesc, 100, "%s%c", mod->desc, toupper(key->desc[0]));
- ascii = toupper(key->ascii);
- } else if (mod->shiftable) {
- snprintf(fullKeyId, 50, "S+%s%s", mod->id, key->hwId);
- snprintf(fullKeyDesc, 100, "Shift+%s%s", mod->desc, key->desc);
- } else {
- snprintf(fullKeyId, 50, "%s%s", mod->id, key->hwId);
- snprintf(fullKeyDesc, 100, "%s%s", mod->desc, key->desc);
- }
-
- keySet->addHardwareKey(new HardwareKey(fullKeyId, KeyState(key->keycode, ascii, mod->flag), fullKeyDesc, key->preferredAction ));
- }
+ snprintf(fullKeyId, 50, "S+%s", mod->id);
+ snprintf(fullKeyDesc, 100, "Shift+%s", mod->desc);
+
+ keySet->addHardwareMod(new HardwareMod(fullKeyId, mod->flag, fullKeyDesc));
+ }
+ for (key = keys; key->hwId; key++) {
+ ascii = key->ascii;
+
+ snprintf(fullKeyId, 50, "%s", key->hwId);
+ snprintf(fullKeyDesc, 100, "%s", key->desc);
+
+ keySet->addHardwareKey(new HardwareKey(fullKeyId, KeyState(key->keycode, ascii, 0), fullKeyDesc, key->preferredAction));
}
return keySet;
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 7b3cf4eaa1..b6b46af9d7 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -222,6 +222,10 @@ OSystem_SDL::OSystem_SDL()
_osdSurface(0), _osdAlpha(SDL_ALPHA_TRANSPARENT), _osdFadeStartTime(0),
#endif
_hwscreen(0), _screen(0), _tmpscreen(0),
+#ifdef ENABLE_RGB_COLOR
+ _screenFormat(Graphics::PixelFormat::createFormatCLUT8()),
+ _cursorFormat(Graphics::PixelFormat::createFormatCLUT8()),
+#endif
_overlayVisible(false),
_overlayscreen(0), _tmpscreen2(0),
_samplesPerSec(0),
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 2a5fda30bd..6c8a721701 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -93,9 +93,17 @@ public:
void beginGFXTransaction(void);
TransactionError endGFXTransaction(void);
- // Set the size of the video bitmap.
- // Typically, 320x200
- virtual void initSize(uint w, uint h); // overloaded by CE backend
+#ifdef ENABLE_RGB_COLOR
+ // Game screen
+ virtual Graphics::PixelFormat getScreenFormat() const { return _screenFormat; }
+
+ // Highest supported
+ virtual Common::List<Graphics::PixelFormat> getSupportedFormats();
+#endif
+
+ // Set the size and format of the video bitmap.
+ // Typically, 320x200 CLUT8
+ virtual void initSize(uint w, uint h, const Graphics::PixelFormat *format); // overloaded by CE backend
virtual int getScreenChangeID() const { return _screenChangeCount; }
@@ -124,7 +132,7 @@ public:
virtual void warpMouse(int x, int y); // overloaded by CE backend (FIXME)
// Set the bitmap that's used when drawing the cursor.
- virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale); // overloaded by CE backend (FIXME)
+ virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format); // overloaded by CE backend (FIXME)
// Set colors of cursor palette
void setCursorPalette(const byte *colors, uint start, uint num);
@@ -186,6 +194,7 @@ public:
// Overlay
virtual Graphics::PixelFormat getOverlayFormat() const { return _overlayFormat; }
+
virtual void showOverlay();
virtual void hideOverlay();
virtual void clearOverlay();
@@ -239,6 +248,10 @@ protected:
// unseen game screen
SDL_Surface *_screen;
+#ifdef ENABLE_RGB_COLOR
+ Graphics::PixelFormat _screenFormat;
+ Graphics::PixelFormat _cursorFormat;
+#endif
// temporary screen (for scalers)
SDL_Surface *_tmpscreen;
@@ -272,6 +285,9 @@ protected:
bool needHotswap;
bool needUpdatescreen;
bool normal1xScaler;
+#ifdef ENABLE_RGB_COLOR
+ bool formatChanged;
+#endif
};
TransactionDetails _transactionDetails;
@@ -287,6 +303,9 @@ protected:
int screenWidth, screenHeight;
int overlayWidth, overlayHeight;
+#ifdef ENABLE_RGB_COLOR
+ Graphics::PixelFormat format;
+#endif
int hardwareWidth, hardwareHeight;
};
VideoState _videoMode, _oldVideoMode;