aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
Diffstat (limited to 'backends')
-rw-r--r--backends/cloud/storage.cpp11
-rw-r--r--backends/events/androidsdl/androidsdl-events.cpp5
-rw-r--r--backends/events/sdl/sdl-events.cpp38
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp6
-rw-r--r--backends/graphics/opengl/opengl-graphics.h8
-rw-r--r--backends/platform/androidsdl/androidsdl-sdl.cpp4
6 files changed, 49 insertions, 23 deletions
diff --git a/backends/cloud/storage.cpp b/backends/cloud/storage.cpp
index 4cccacf6d6..3a9ae53a43 100644
--- a/backends/cloud/storage.cpp
+++ b/backends/cloud/storage.cpp
@@ -28,6 +28,7 @@
#include "common/debug.h"
#include "common/file.h"
#include <common/translation.h>
+#include "common/osd_message_queue.h"
namespace Cloud {
@@ -207,7 +208,7 @@ void Storage::savesSyncDefaultCallback(BoolResponse response) {
if (!response.value)
warning("SavesSyncRequest called success callback with `false` argument");
- g_system->displayMessageOnOSD(_("Saved games sync complete."));
+ Common::OSDMessageQueue::instance().addMessage(_("Saved games sync complete."));
}
void Storage::savesSyncDefaultErrorCallback(Networking::ErrorResponse error) {
@@ -218,9 +219,9 @@ void Storage::savesSyncDefaultErrorCallback(Networking::ErrorResponse error) {
printErrorResponse(error);
if (error.interrupted)
- g_system->displayMessageOnOSD(_("Saved games sync was cancelled."));
+ Common::OSDMessageQueue::instance().addMessage(_("Saved games sync was cancelled."));
else
- g_system->displayMessageOnOSD(_("Saved games sync failed.\nCheck your Internet connection."));
+ Common::OSDMessageQueue::instance().addMessage(_("Saved games sync failed.\nCheck your Internet connection."));
}
///// DownloadFolderRequest-related /////
@@ -328,7 +329,7 @@ void Storage::directoryDownloadedCallback(FileArrayResponse response) {
} else {
message = _("Download complete.");
}
- g_system->displayMessageOnOSD(message.c_str());
+ Common::OSDMessageQueue::instance().addMessage(message.c_str());
}
void Storage::directoryDownloadedErrorCallback(Networking::ErrorResponse error) {
@@ -336,7 +337,7 @@ void Storage::directoryDownloadedErrorCallback(Networking::ErrorResponse error)
_downloadFolderRequest = nullptr;
_runningRequestsMutex.unlock();
- g_system->displayMessageOnOSD(_("Download failed."));
+ Common::OSDMessageQueue::instance().addMessage(_("Download failed."));
}
} // End of namespace Cloud
diff --git a/backends/events/androidsdl/androidsdl-events.cpp b/backends/events/androidsdl/androidsdl-events.cpp
index c8a730aa8e..0adcff817e 100644
--- a/backends/events/androidsdl/androidsdl-events.cpp
+++ b/backends/events/androidsdl/androidsdl-events.cpp
@@ -66,9 +66,8 @@ bool AndroidSdlEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &
bool AndroidSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
if (false) {}
- if (ev.key.keysym.sym == SDLK_LCTRL) {
- event.type = Common::EVENT_KEYDOWN;
- event.kbd.keycode = Common::KEYCODE_F5;
+ if (ev.key.keysym.sym == SDLK_F13) {
+ event.type = Common::EVENT_MAINMENU;
return true;
} else {
// Let the events fall through if we didn't change them, this may not be the best way to
diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp
index 7caa177819..5fb66a7ec4 100644
--- a/backends/events/sdl/sdl-events.cpp
+++ b/backends/events/sdl/sdl-events.cpp
@@ -110,13 +110,51 @@ SdlEventSource::~SdlEventSource() {
int SdlEventSource::mapKey(SDLKey sdlKey, SDLMod mod, Uint16 unicode) {
Common::KeyCode key = SDLToOSystemKeycode(sdlKey);
+ // Keep unicode in case it's regular ASCII text or in case we didn't get a valid keycode
+ //
+ // We need to use unicode in those cases, simply because SDL1.x passes us non-layout-adjusted keycodes.
+ // So unicode is the only way to get layout-adjusted keys.
+ if (unicode < 0x20) {
+ // don't use unicode, in case it's control characters
+ unicode = 0;
+ } else {
+ // Use unicode, in case keycode is invalid.
+ // Umlauts and others will set KEYCODE_INVALID on SDL2, so in such a case always keep unicode.
+ if (key != Common::KEYCODE_INVALID) {
+ // keycode is valid, check further also depending on modifiers
+ if (mod & (KMOD_CTRL | KMOD_ALT)) {
+ // Ctrl and/or Alt is active
+ //
+ // We need to restrict unicode to only up to 0x7E, because on macOS the option/alt key will switch to
+ // an alternate keyboard, which will cause us to receive Unicode characters for some keys, which are outside
+ // of the ASCII range (e.g. alt-x will get us U+2248). We need to return 'x' for alt-x, so using unicode
+ // in that case would break alt-shortcuts.
+ if (unicode > 0x7E)
+ unicode = 0; // do not allow any characters above 0x7E
+ } else {
+ // We must not restrict as much as when Ctrl/Alt-modifiers are active, otherwise
+ // we wouldn't let umlauts through for SDL1. For SDL1 umlauts may set for example KEYCODE_QUOTE, KEYCODE_MINUS, etc.
+ if (unicode > 0xFF)
+ unicode = 0; // do not allow any characters above 0xFF
+ }
+ }
+ }
+
+ // Attention:
+ // When using SDL1.x, we will get scancodes via sdlKey, that are raw scancodes, so NOT adjusted to keyboard layout/
+ // mapping. So for example for certain locales, we will get KEYCODE_y, when 'z' is pressed and so on.
+ // When using SDL2.x however, we will get scancodes based on the keyboard layout.
+
if (key >= Common::KEYCODE_F1 && key <= Common::KEYCODE_F9) {
return key - Common::KEYCODE_F1 + Common::ASCII_F1;
} else if (key >= Common::KEYCODE_KP0 && key <= Common::KEYCODE_KP9) {
+ if ((mod & KMOD_NUM) == 0)
+ return 0; // In case Num-Lock is NOT enabled, return 0 for ascii, so that directional keys on numpad work
return key - Common::KEYCODE_KP0 + '0';
} else if (key >= Common::KEYCODE_UP && key <= Common::KEYCODE_PAGEDOWN) {
return key;
} else if (unicode) {
+ // Return unicode in case it's stil set and wasn't filtered.
return unicode;
} else if (key >= 'a' && key <= 'z' && (mod & KMOD_SHIFT)) {
return key & ~0x20;
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index a0882347b5..7b41699e80 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -377,7 +377,6 @@ void OpenGLGraphicsManager::updateScreen() {
#ifdef USE_OSD
{
- Common::StackLock lock(_osdMutex);
if (_osdMessageChangeRequest) {
osdMessageUpdateSurface();
}
@@ -741,11 +740,6 @@ void OpenGLGraphicsManager::setCursorPalette(const byte *colors, uint start, uin
void OpenGLGraphicsManager::displayMessageOnOSD(const char *msg) {
#ifdef USE_OSD
- // HACK: Actually no client code should use graphics functions from
- // another thread. But the MT-32 emulator and network synchronization still do,
- // thus we need to make sure this doesn't happen while a updateScreen call is done.
- Common::StackLock lock(_osdMutex);
-
_osdMessageChangeRequest = true;
_osdMessageNextData = msg;
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index 01672f4f5c..d3f8d792ba 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -596,14 +596,6 @@ private:
kOSDIconTopMargin = 10,
kOSDIconRightMargin = 10
};
-
- /**
- * Mutex for the OSD draw calls.
- *
- * Mutex to allow displayMessageOnOSD and displayActivityIconOnOSD
- * to be used from the audio and network threads.
- */
- Common::Mutex _osdMutex;
#endif
};
diff --git a/backends/platform/androidsdl/androidsdl-sdl.cpp b/backends/platform/androidsdl/androidsdl-sdl.cpp
index 3d0429e098..d04512475a 100644
--- a/backends/platform/androidsdl/androidsdl-sdl.cpp
+++ b/backends/platform/androidsdl/androidsdl-sdl.cpp
@@ -20,6 +20,8 @@
*
*/
+#define FORBIDDEN_SYMBOL_EXCEPTION_getenv(a)
+
#include "common/config-manager.h"
#include "backends/platform/androidsdl/androidsdl-sdl.h"
@@ -36,7 +38,7 @@ void OSystem_ANDROIDSDL::initBackend() {
_graphicsManager = new AndroidSdlGraphicsManager(_eventSource, _window);
if (!ConfMan.hasKey("browser_lastpath"))
- ConfMan.set("browser_lastpath", "/storage");
+ ConfMan.set("browser_lastpath", getenv("SDCARD"));
if (!ConfMan.hasKey("gfx_mode"))
ConfMan.set("gfx_mode", "2x");