From 01a883e6693e11dc635e36b1f04dfb4eaa605f7f Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 16 Feb 2020 19:07:13 -0500 Subject: [PATCH] Corrects fullscreen switch. --- .../xcschemes/Clock Signal.xcscheme | 2 +- OSBindings/SDL/main.cpp | 33 +++++++++---------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme b/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme index 63be2c037..a99eb0a5d 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme +++ b/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme @@ -67,7 +67,7 @@ &buffer) final { std::lock_guard lock_guard(audio_buffer_mutex_); - const auto buffer_size = buffered_samples * (is_stereo ? 2 : 1); + const size_t buffer_size = buffered_samples * (is_stereo ? 2 : 1); if(audio_buffer_.size() > buffer_size) { audio_buffer_.erase(audio_buffer_.begin(), audio_buffer_.end() - buffer_size); } @@ -664,7 +664,7 @@ int main(int argc, char *argv[]) { desired_audio_spec.freq = 48000; // TODO: how can I get SDL to reveal the output rate of this machine? desired_audio_spec.format = AUDIO_S16; desired_audio_spec.channels = 1 + int(speaker->get_is_stereo()); - desired_audio_spec.samples = SpeakerDelegate::buffered_samples; + desired_audio_spec.samples = Uint16(SpeakerDelegate::buffered_samples); desired_audio_spec.callback = SpeakerDelegate::SDL_audio_callback; desired_audio_spec.userdata = &speaker_delegate; @@ -869,23 +869,22 @@ int main(int argc, char *argv[]) { SDL_FreeSurface(surface); break; } + } + // Syphon off alt+enter (toggle full-screen) upon key up only; this was previously a key down action, + // but the SDL_KEYDOWN announcement was found to be reposted after changing graphics mode on some + // systems, causing a loop of changes, so key up is safer. + if(event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_RETURN && (SDL_GetModState()&KMOD_ALT)) { + fullscreen_mode ^= SDL_WINDOW_FULLSCREEN_DESKTOP; + SDL_SetWindowFullscreen(window, fullscreen_mode); + SDL_ShowCursor((fullscreen_mode&SDL_WINDOW_FULLSCREEN_DESKTOP) ? SDL_DISABLE : SDL_ENABLE); - // Syphon off alt+enter (toggle full-screen) upon key up only; this was previously a key down action, - // but the SDL_KEYDOWN announcement was found to be reposted after changing graphics mode on some - // systems so key up is safer. - if(event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_RETURN && (SDL_GetModState()&KMOD_ALT)) { - fullscreen_mode ^= SDL_WINDOW_FULLSCREEN_DESKTOP; - SDL_SetWindowFullscreen(window, fullscreen_mode); - SDL_ShowCursor((fullscreen_mode&SDL_WINDOW_FULLSCREEN_DESKTOP) ? SDL_DISABLE : SDL_ENABLE); - - // Announce a potential discontinuity in keyboard input. - const auto keyboard_machine = machine->keyboard_machine(); - if(keyboard_machine) { - keyboard_machine->get_keyboard().reset_all_keys(); - } - break; + // Announce a potential discontinuity in keyboard input. + const auto keyboard_machine = machine->keyboard_machine(); + if(keyboard_machine) { + keyboard_machine->get_keyboard().reset_all_keys(); } + break; } const bool is_pressed = event.type == SDL_KEYDOWN;