mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-11-30 09:43:02 +00:00
(Windows) Fix uxnemu freezing on exit.
This commit is contained in:
parent
219cfee472
commit
4c59498f14
1 changed files with 10 additions and 1 deletions
11
src/uxnemu.c
11
src/uxnemu.c
|
@ -16,6 +16,9 @@
|
||||||
#include "devices/controller.h"
|
#include "devices/controller.h"
|
||||||
#include "devices/mouse.h"
|
#include "devices/mouse.h"
|
||||||
#include "devices/datetime.h"
|
#include "devices/datetime.h"
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <processthreadsapi.h>
|
||||||
|
#endif
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
|
|
||||||
|
@ -40,6 +43,7 @@ static SDL_Texture *gTexture;
|
||||||
static SDL_Renderer *gRenderer;
|
static SDL_Renderer *gRenderer;
|
||||||
static SDL_AudioDeviceID audio_id;
|
static SDL_AudioDeviceID audio_id;
|
||||||
static SDL_Rect gRect;
|
static SDL_Rect gRect;
|
||||||
|
static SDL_Thread *stdin_thread;
|
||||||
|
|
||||||
/* devices */
|
/* devices */
|
||||||
|
|
||||||
|
@ -179,7 +183,7 @@ init(void)
|
||||||
audio0_event = SDL_RegisterEvents(POLYPHONY);
|
audio0_event = SDL_RegisterEvents(POLYPHONY);
|
||||||
redraw_event = SDL_RegisterEvents(1);
|
redraw_event = SDL_RegisterEvents(1);
|
||||||
interrupt_event = SDL_RegisterEvents(1);
|
interrupt_event = SDL_RegisterEvents(1);
|
||||||
SDL_DetachThread(SDL_CreateThread(stdin_handler, "stdin", NULL));
|
SDL_DetachThread(stdin_thread = SDL_CreateThread(stdin_handler, "stdin", NULL));
|
||||||
SDL_DetachThread(SDL_CreateThread(redraw_handler, "redraw", NULL));
|
SDL_DetachThread(SDL_CreateThread(redraw_handler, "redraw", NULL));
|
||||||
SDL_StartTextInput();
|
SDL_StartTextInput();
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
|
@ -507,7 +511,12 @@ main(int argc, char **argv)
|
||||||
if(!loaded && !start(&u, "launcher.rom"))
|
if(!loaded && !start(&u, "launcher.rom"))
|
||||||
return error("usage", "uxnemu [-s scale] file.rom");
|
return error("usage", "uxnemu [-s scale] file.rom");
|
||||||
run(&u);
|
run(&u);
|
||||||
|
#ifdef _WIN32
|
||||||
|
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
|
||||||
|
TerminateThread((HANDLE)SDL_GetThreadID(stdin_thread), 0);
|
||||||
|
#else
|
||||||
close(0); /* make stdin thread exit */
|
close(0); /* make stdin thread exit */
|
||||||
|
#endif
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue