From 49905f3babf4940d5171cb4ee9295cf433b3fe62 Mon Sep 17 00:00:00 2001 From: Tomochika Hara Date: Sat, 13 Jan 2024 23:13:13 +0900 Subject: [PATCH] :bug: Fix SDL event handling --- Sources/SwiftNESMain/Emulator.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/SwiftNESMain/Emulator.swift b/Sources/SwiftNESMain/Emulator.swift index 5eb80bf..1283172 100644 --- a/Sources/SwiftNESMain/Emulator.swift +++ b/Sources/SwiftNESMain/Emulator.swift @@ -87,18 +87,18 @@ final class Emulator { } while isRunning { + SDL_PollEvent(&event) + let startTicks = SDL_GetTicks() let startPerf = SDL_GetPerformanceCounter() let eventType = SDL_EventType(rawValue: event.type) - while SDL_PollEvent(&event) != 0 { - switch eventType { - case SDL_QUIT, SDL_APP_TERMINATING: - isRunning = false - default: - break - } + switch eventType { + case SDL_QUIT, SDL_APP_TERMINATING: + isRunning = false + default: + break } controller.update(keys: currentKeys)