From e098370249382e9ccc3c4e9d4fe73a295fc5de74 Mon Sep 17 00:00:00 2001 From: Phil Marell Date: Sat, 24 Jul 2021 16:27:34 +1000 Subject: [PATCH] Use Command key instead of Control as modifier on macOS This provides an experience closer to the original classic Mac version. This is supported by the earlier changes to gracefully quit the game. --- AerofoilSDL/GpDisplayDriver_SDL_GL2.cpp | 8 ++++++++ GpCommon/GpVOSEvent.h | 4 ++-- PortabilityLayer/MenuManager.cpp | 10 +++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/AerofoilSDL/GpDisplayDriver_SDL_GL2.cpp b/AerofoilSDL/GpDisplayDriver_SDL_GL2.cpp index f323d86..01da78b 100644 --- a/AerofoilSDL/GpDisplayDriver_SDL_GL2.cpp +++ b/AerofoilSDL/GpDisplayDriver_SDL_GL2.cpp @@ -1637,11 +1637,19 @@ static bool IdentifyVKey(const SDL_KeyboardEvent *keyEvt, GpKeyIDSubset_t &outSu return false; } break; +#ifdef __MACOS__ + case SDLK_LGUI: +#else case SDLK_LCTRL: +#endif outSubset = GpKeyIDSubsets::kSpecial; outKey.m_specialKey = GpKeySpecials::kLeftCtrl; break; +#ifdef __MACOS__ + case SDLK_RGUI: +#else case SDLK_RCTRL: +#endif outSubset = GpKeyIDSubsets::kSpecial; outKey.m_specialKey = GpKeySpecials::kRightCtrl; break; diff --git a/GpCommon/GpVOSEvent.h b/GpCommon/GpVOSEvent.h index 4389d32..08c8305 100644 --- a/GpCommon/GpVOSEvent.h +++ b/GpCommon/GpVOSEvent.h @@ -97,8 +97,8 @@ namespace GpKeySpecials kEnter, kLeftShift, kRightShift, - kLeftCtrl, - kRightCtrl, + kLeftCtrl, // Maps to Command modifier on macOS. + kRightCtrl, // kLeftAlt, kRightAlt, kNumLock, diff --git a/PortabilityLayer/MenuManager.cpp b/PortabilityLayer/MenuManager.cpp index e55e6f7..f73b8ff 100644 --- a/PortabilityLayer/MenuManager.cpp +++ b/PortabilityLayer/MenuManager.cpp @@ -1405,14 +1405,22 @@ namespace PortabilityLayer size_t MenuManagerImpl::FormatHintText(uint8_t *buffer, uint8_t key) { +#ifdef __MACOS__ + buffer[0] = 'C'; + buffer[1] = 'm'; + buffer[2] = 'd'; + buffer[3] = '+'; + buffer[4] = key; + return 5; +#else buffer[0] = 'C'; buffer[1] = 't'; buffer[2] = 'r'; buffer[3] = 'l'; buffer[4] = '+'; buffer[5] = key; - return 6; +#endif } MenuManagerImpl *MenuManagerImpl::GetInstance()