summaryrefslogtreecommitdiff
path: root/src/video/cocoa/cocoa_v.mm
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-02-19 11:01:49 +0100
committerPatric Stout <github@truebrain.nl>2021-02-20 17:08:44 +0100
commit661eb39ecc3a128c24dbbc4f53d1c075fe89bc93 (patch)
treec579f44c8186f43169138cafce3ed02d38baf2ef /src/video/cocoa/cocoa_v.mm
parent38b4ae1c0ea05944cda66a499454a5b08a7a4462 (diff)
downloadopenttd-661eb39ecc3a128c24dbbc4f53d1c075fe89bc93.tar.xz
Codechange: move all input-handling of video-drivers into InputLoop
Diffstat (limited to 'src/video/cocoa/cocoa_v.mm')
-rw-r--r--src/video/cocoa/cocoa_v.mm43
1 files changed, 24 insertions, 19 deletions
diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm
index cf2512b04..5e8c82b2a 100644
--- a/src/video/cocoa/cocoa_v.mm
+++ b/src/video/cocoa/cocoa_v.mm
@@ -632,6 +632,28 @@ bool VideoDriver_Cocoa::PollEvent()
return true;
}
+void VideoDriver_Cocoa::InputLoop()
+{
+ NSUInteger cur_mods = [ NSEvent modifierFlags ];
+
+ bool old_ctrl_pressed = _ctrl_pressed;
+
+ _ctrl_pressed = (cur_mods & ( _settings_client.gui.right_mouse_btn_emulation != RMBE_CONTROL ? NSControlKeyMask : NSCommandKeyMask)) != 0;
+ _shift_pressed = (cur_mods & NSShiftKeyMask) != 0;
+
+#if defined(_DEBUG)
+ if (_shift_pressed) {
+#else
+ if (_tab_is_down) {
+#endif
+ if (!_networking && _game_mode != GM_MENU) _fast_forward |= 2;
+ } else if (_fast_forward & 2) {
+ _fast_forward = 0;
+ }
+
+ if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged();
+}
+
/** Main game loop. */
void VideoDriver_Cocoa::GameLoop()
{
@@ -653,17 +675,6 @@ void VideoDriver_Cocoa::GameLoop()
break;
}
- NSUInteger cur_mods = [ NSEvent modifierFlags ];
-
-#if defined(_DEBUG)
- if (cur_mods & NSShiftKeyMask) {
-#else
- if (_tab_is_down) {
-#endif
- if (!_networking && _game_mode != GM_MENU) _fast_forward |= 2;
- } else if (_fast_forward & 2) {
- _fast_forward = 0;
- }
cur_ticks = std::chrono::steady_clock::now();
@@ -692,14 +703,8 @@ void VideoDriver_Cocoa::GameLoop()
/* Avoid next_draw_tick getting behind more and more if it cannot keep up. */
if (next_draw_tick < cur_ticks - ALLOWED_DRIFT * this->GetDrawInterval()) next_draw_tick = cur_ticks;
- bool old_ctrl_pressed = _ctrl_pressed;
-
- _ctrl_pressed = (cur_mods & ( _settings_client.gui.right_mouse_btn_emulation != RMBE_CONTROL ? NSControlKeyMask : NSCommandKeyMask)) != 0;
- _shift_pressed = (cur_mods & NSShiftKeyMask) != 0;
-
- if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged();
-
- InputLoop();
+ this->InputLoop();
+ ::InputLoop();
UpdateWindows();
this->CheckPaletteAnim();