diff --git a/src/port/Game.cpp b/src/port/Game.cpp index 74666296d..598b31100 100644 --- a/src/port/Game.cpp +++ b/src/port/Game.cpp @@ -943,6 +943,10 @@ void CM_ThrowRuntimeError(const char* fmt, ...) { exit(EXIT_FAILURE); } +#ifdef __APPLE__ +#include +#endif + #ifdef _WIN32 int SDL_main(int argc, char** argv) { #else @@ -955,6 +959,14 @@ extern "C" #ifdef _WIN32 // Allow non-ascii characters for Windows setlocale(LC_ALL, ".UTF8"); +#endif +#if defined(__APPLE__) + // Disable the macOS "press and hold" accent/diacritic popup for this app. SDL keeps a Cocoa text + // input context active, so holding a movement key is interpreted as holding a letter key in a text + // field, and macOS shows the accent picker instead of repeating it. Per-app equivalent of + // `defaults write -app ApplePressAndHoldEnabled -bool false`; key repeat still works. + CFPreferencesSetAppValue(CFSTR("ApplePressAndHoldEnabled"), kCFBooleanFalse, kCFPreferencesCurrentApplication); + CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication); #endif // load_wasm(); GameEngine::Create();