|
@@ -629,12 +629,34 @@ bool VideoDriver_Cocoa::PollEvent()
|
|
|
|
|
|
[ NSApp sendEvent:event ];
|
|
|
|
|
|
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()
|
|
|
{
|
|
|
auto cur_ticks = std::chrono::steady_clock::now();
|
|
|
auto last_realtime_tick = cur_ticks;
|
|
|
auto next_game_tick = cur_ticks;
|
|
@@ -650,23 +672,12 @@ void VideoDriver_Cocoa::GameLoop()
|
|
|
if (_exit_game) {
|
|
|
/* Restore saved resolution if in fullscreen mode. */
|
|
|
if (this->IsFullscreen()) _cur_resolution = this->orig_res;
|
|
|
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();
|
|
|
|
|
|
/* If more than a millisecond has passed, increase the _realtime_tick. */
|
|
|
if (cur_ticks - last_realtime_tick > std::chrono::milliseconds(1)) {
|
|
|
auto delta = std::chrono::duration_cast<std::chrono::milliseconds>(cur_ticks - last_realtime_tick);
|
|
@@ -689,20 +700,14 @@ void VideoDriver_Cocoa::GameLoop()
|
|
|
/* Prevent drawing when switching mode, as windows can be removed when they should still appear. */
|
|
|
if (cur_ticks >= next_draw_tick && (_switch_mode == SM_NONE || HasModalProgress())) {
|
|
|
next_draw_tick += this->GetDrawInterval();
|
|
|
/* 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();
|
|
|
|
|
|
this->Draw();
|
|
|
}
|
|
|
|