mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-22 14:24:33 +01:00
Merge pull request #2711 from marijnvdwerf/add-cmd-modifier
Allow using CMD as shortcut modifier
This commit is contained in:
12
src/config.c
12
src/config.c
@@ -894,6 +894,12 @@ void config_apply_to_old_addresses()
|
||||
#define SHIFT 0x100
|
||||
#define CTRL 0x200
|
||||
#define ALT 0x400
|
||||
#define CMD 0x800
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
#define PLATFORM_MODIFIER CMD
|
||||
#else
|
||||
#define PLATFORM_MODIFIER CTRL
|
||||
#endif
|
||||
|
||||
// Current keyboard shortcuts
|
||||
uint16 gShortcutKeys[SHORTCUT_COUNT];
|
||||
@@ -932,19 +938,19 @@ static const uint16 _defaultShortcutKeys[SHORTCUT_COUNT] = {
|
||||
SDL_SCANCODE_S, // SHORTCUT_SHOW_STAFF_LIST
|
||||
SDL_SCANCODE_M, // SHORTCUT_SHOW_RECENT_MESSAGES
|
||||
SDL_SCANCODE_TAB, // SHORTCUT_SHOW_MAP
|
||||
CTRL | SDL_SCANCODE_S, // SHORTCUT_SCREENSHOT
|
||||
PLATFORM_MODIFIER | SDL_SCANCODE_S, // SHORTCUT_SCREENSHOT
|
||||
|
||||
// New
|
||||
SDL_SCANCODE_MINUS, // SHORTCUT_REDUCE_GAME_SPEED,
|
||||
SDL_SCANCODE_EQUALS, // SHORTCUT_INCREASE_GAME_SPEED,
|
||||
CTRL | ALT | SDL_SCANCODE_C, // SHORTCUT_OPEN_CHEAT_WINDOW,
|
||||
PLATFORM_MODIFIER | ALT | SDL_SCANCODE_C, // SHORTCUT_OPEN_CHEAT_WINDOW,
|
||||
SDL_SCANCODE_T, // SHORTCUT_REMOVE_TOP_BOTTOM_TOOLBAR_TOGGLE,
|
||||
SDL_SCANCODE_UP, // SHORTCUT_SCROLL_MAP_UP
|
||||
SDL_SCANCODE_LEFT, // SHORTCUT_SCROLL_MAP_LEFT
|
||||
SDL_SCANCODE_DOWN, // SHORTCUT_SCROLL_MAP_DOWN
|
||||
SDL_SCANCODE_RIGHT, // SHORTCUT_SCROLL_MAP_RIGHT
|
||||
SDL_SCANCODE_C, // SHORTCUT_OPEN_CHAT_WINDOW
|
||||
CTRL | SDL_SCANCODE_F10, // SHORTCUT_QUICK_SAVE_GAME
|
||||
PLATFORM_MODIFIER | SDL_SCANCODE_F10, // SHORTCUT_QUICK_SAVE_GAME
|
||||
};
|
||||
|
||||
#define SHORTCUT_FILE_VERSION 1
|
||||
|
||||
16
src/input.c
16
src/input.c
@@ -1391,6 +1391,11 @@ void title_handle_keyboard_input()
|
||||
gInputPlaceObjectModifier |= PLACE_OBJECT_MODIFIER_COPY_Z;
|
||||
if (gKeysState[SDL_SCANCODE_LALT] || gKeysState[SDL_SCANCODE_RALT])
|
||||
gInputPlaceObjectModifier |= 4;
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
if (gKeysState[SDL_SCANCODE_LGUI] || gKeysState[SDL_SCANCODE_RGUI]) {
|
||||
gInputPlaceObjectModifier |= 8;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1451,6 +1456,11 @@ void game_handle_keyboard_input()
|
||||
if (gKeysState[SDL_SCANCODE_LALT] || gKeysState[SDL_SCANCODE_RALT]) {
|
||||
gInputPlaceObjectModifier |= 4;
|
||||
}
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
if (gKeysState[SDL_SCANCODE_LGUI] || gKeysState[SDL_SCANCODE_RGUI]) {
|
||||
gInputPlaceObjectModifier |= 8;
|
||||
}
|
||||
#endif
|
||||
game_handle_key_scroll();
|
||||
}
|
||||
}
|
||||
@@ -1634,6 +1644,7 @@ void game_handle_key_scroll()
|
||||
const int SHIFT = 0x100;
|
||||
const int CTRL = 0x200;
|
||||
const int ALT = 0x400;
|
||||
const int CMD = 0x800;
|
||||
|
||||
uint16 shortcutKey = gShortcutKeys[shortcutId];
|
||||
uint8 scancode = shortcutKey & 0xFF;
|
||||
@@ -1650,6 +1661,11 @@ void game_handle_key_scroll()
|
||||
if (shortcutKey & ALT) {
|
||||
if (!gKeysState[SDL_SCANCODE_LALT] && !gKeysState[SDL_SCANCODE_RALT]) continue;
|
||||
}
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
if (shortcutKey & CMD) {
|
||||
if (!gKeysState[SDL_SCANCODE_LGUI] && !gKeysState[SDL_SCANCODE_RGUI]) continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (shortcutId) {
|
||||
case SHORTCUT_SCROLL_MAP_UP:
|
||||
|
||||
@@ -97,7 +97,15 @@ void keyboard_shortcut_format_string(char *buffer, uint16 shortcutKey)
|
||||
strcat(buffer, formatBuffer);
|
||||
}
|
||||
if (shortcutKey & 0x400) {
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
format_string(formatBuffer, STR_OPTION_PLUS, NULL);
|
||||
#else
|
||||
format_string(formatBuffer, STR_ALT_PLUS, NULL);
|
||||
#endif
|
||||
strcat(buffer, formatBuffer);
|
||||
}
|
||||
if (shortcutKey & 0x800) {
|
||||
format_string(formatBuffer, STR_CMD_PLUS, NULL);
|
||||
strcat(buffer, formatBuffer);
|
||||
}
|
||||
strcat(buffer, SDL_GetScancodeName(shortcutKey & 0xFF));
|
||||
|
||||
@@ -2256,6 +2256,9 @@ enum {
|
||||
|
||||
STR_DLC_PARKS = 5631,
|
||||
STR_BUILD_YOUR_OWN_PARKS = 5632,
|
||||
|
||||
STR_CMD_PLUS = 5633,
|
||||
STR_OPTION_PLUS = 5634,
|
||||
|
||||
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
|
||||
STR_COUNT = 32768
|
||||
|
||||
Reference in New Issue
Block a user