Index: binaries/data/mods/public/gui/credits/texts/programming.json =================================================================== --- binaries/data/mods/public/gui/credits/texts/programming.json +++ binaries/data/mods/public/gui/credits/texts/programming.json @@ -231,6 +231,7 @@ { "nick": "sathyam", "name": "Sathyam Vellal" }, { "nick": "sbirmi", "name": "Sharad Birmiwal" }, { "nick": "sbte", "name": "Sven Baars" }, + { "nick": "Schweini", "name": "Laurenz Reinthaler"}, { "nick": "scroogie", "name": "André Gemünd" }, { "nick": "scythetwirler", "name": "Casey X." }, { "nick": "serveurix" }, Index: binaries/data/mods/public/gui/options/options.js =================================================================== --- binaries/data/mods/public/gui/options/options.js +++ binaries/data/mods/public/gui/options/options.js @@ -363,6 +363,8 @@ { Engine.ConfigDB_WriteFile("user", "config/user.cfg"); Engine.ConfigDB_SetChanges("user", false); + // Reload hotkeys for the "Mac Mouse" option + Engine.ReloadHotkeys(); enableButtons(); } Index: binaries/data/mods/public/gui/options/options.json =================================================================== --- binaries/data/mods/public/gui/options/options.json +++ binaries/data/mods/public/gui/options/options.json @@ -84,6 +84,12 @@ "tooltip": "Show only generic names for units." } ] + }, + { + "type": "boolean", + "label": "Mac Mouse", + "tooltip": "Enables the emulation of a right-click with Ctrl+Click on Mac. Hotkeys that used 'Ctrl' before will be changed to 'Cmd'.", + "config": "macmouse" } ] }, Index: source/ps/GameSetup/GameSetup.cpp =================================================================== --- source/ps/GameSetup/GameSetup.cpp +++ source/ps/GameSetup/GameSetup.cpp @@ -638,14 +638,6 @@ // SDL2 >= 2.0.9 defaults to 32 pixels (to support touch screens) but that can break our double-clicking. SDL_SetHint(SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS, "1"); #endif - -#if OS_MACOSX - // Some Mac mice only have one button, so they can't right-click - // but SDL2 can emulate that with Ctrl+Click - bool macMouse = false; - CFG_GET_VAL("macmouse", macMouse); - SDL_SetHint(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, macMouse ? "1" : "0"); -#endif } static void ShutdownSDL() Index: source/ps/Hotkey.cpp =================================================================== --- source/ps/Hotkey.cpp +++ source/ps/Hotkey.cpp @@ -77,6 +77,14 @@ // all key combinations that trigger it. static void LoadConfigBindings(CConfigDB& configDB) { + // when the "Mac Mouse" option is enabled change all Ctrl only hotkeys to Super + bool macMouse = false; + #if OS_MACOSX + configDB.GetValue(CFG_COMMAND, "macmouse", macMouse); + + SDL_SetHint(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, macMouse ? "1" : "0"); + #endif + for (const std::pair& configPair : configDB.GetValuesWithPrefix(CFG_COMMAND, "hotkey.")) { std::string hotkeyName = configPair.first.substr(7); // strip the "hotkey." prefix @@ -111,6 +119,16 @@ } SKey key = { scancode }; + + if (macMouse && hotkey == "Ctrl") + { + key = {UNIFIED_SUPER}; + } + else if (!macMouse && hotkey == "Super") + { + key = {UNIFIED_CTRL}; + } + keyCombination.push_back(key); } @@ -145,6 +163,12 @@ g_HotkeyStatus.clear(); } +void ReloadHotkeys() +{ + UnloadHotkeys(); + LoadHotkeys(g_ConfigDB); +} + bool isPressed(const SKey& key) { // Normal keycodes are below EXTRA_KEYS_BASE