Skip to content

Commit 9b01ac4

Browse files
committed
Use command rather than control on mac for shortcuts
1 parent 74297ee commit 9b01ac4

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/crab/common/frontend/sdl_opengl_imgui_frontend.cr

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ require "./controllers/*"
77
require "./widgets/*"
88
require "./shaders/*"
99

10+
MOD_KEY = {% if flag?(:darwin) %} LibSDL::Keymod::LGUI {% else %} LibSDL::Keymod::LCTRL {% end %}
11+
MOD_KEY_STR = {% if flag?(:darwin) %} "Cmd" {% else %} "Ctrl" {% end %}
12+
1013
class SDLOpenGLImGuiFrontend < Frontend
1114
CONTROLLERS = [StubbedController, GBController, GBAController]
1215
ROM_EXTENSIONS = CONTROLLERS.reduce([] of String) { |acc, controller| acc + controller.extensions }
@@ -133,7 +136,7 @@ class SDLOpenGLImGuiFrontend < Frontend
133136
next if @io.want_capture_keyboard # let ImGui handle keyboard input when focused
134137
if @config_editor.keybindings.wants_input?
135138
@config_editor.keybindings.key_released(event.sym) unless event.pressed? # pass on key release
136-
elsif event.mod.includes?(LibSDL::Keymod::LCTRL)
139+
elsif event.mod.includes?(MOD_KEY)
137140
case event.sym
138141
when LibSDL::Keycode::R then reset
139142
when LibSDL::Keycode::P then pause(!@pause) unless event.pressed?
@@ -220,15 +223,15 @@ class SDLOpenGLImGuiFrontend < Frontend
220223
ImGui.separator
221224
@config_editor.open = true if ImGui.menu_item "Settings"
222225
ImGui.separator
223-
exit if ImGui.menu_item "Exit", "Ctrl+Q"
226+
exit if ImGui.menu_item "Exit", MOD_KEY_STR + "+Q"
224227
end
225228

226229
ImGui.menu "Emulation" do
227230
should_reset = false
228231
pause = @pause
229232

230-
ImGui.menu_item "Reset", "Ctrl+R", pointerof(should_reset)
231-
ImGui.menu_item "Pause", "Ctrl+P", pointerof(pause)
233+
ImGui.menu_item "Reset", MOD_KEY_STR + "+R", pointerof(should_reset)
234+
ImGui.menu_item "Pause", MOD_KEY_STR + "+P", pointerof(pause)
232235
@controller.toggle_sync if ImGui.menu_item "Audio Sync", "Tab", @controller.sync?, !stubbed?
233236

234237
reset if should_reset
@@ -244,7 +247,7 @@ class SDLOpenGLImGuiFrontend < Frontend
244247
end
245248
end
246249
ImGui.separator
247-
@window.fullscreen = @fullscreen if ImGui.menu_item "Fullscreen", "Ctrl+F", pointerof(@fullscreen)
250+
@window.fullscreen = @fullscreen if ImGui.menu_item "Fullscreen", MOD_KEY_STR + "+F", pointerof(@fullscreen)
248251
end
249252
end
250253

0 commit comments

Comments
 (0)