1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-24 07:14:31 +01:00

Fix emscripten support

This commit is contained in:
Ethan O'Brien
2024-12-31 09:31:33 -06:00
parent 752f169acf
commit 63b0106de8
28 changed files with 769 additions and 25 deletions

View File

@@ -19,6 +19,10 @@
#include <openrct2/core/String.hpp>
#include <openrct2/core/UTF8.h>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
#ifdef __MACOSX__
// macOS uses COMMAND rather than CTRL for many keyboard shortcuts
#define KEYBOARD_PRIMARY_MODIFIER KMOD_GUI
@@ -170,7 +174,21 @@ void TextComposition::HandleMessage(const SDL_Event* e)
case SDLK_c:
if ((modifier & KEYBOARD_PRIMARY_MODIFIER) && _session.Length)
{
#ifndef __EMSCRIPTEN__
SDL_SetClipboardText(_session.Buffer->c_str());
#else
MAIN_THREAD_EM_ASM(
{
try
{
navigator.clipboard.writeText(UTF8ToString($0));
}
catch (e)
{
};
},
_session.Buffer->c_str());
#endif
ContextShowError(STR_COPY_INPUT_TO_CLIPBOARD, STR_NONE, {});
}
break;