From c4c7069a8a0b4ffc5de8758c2aa154118449aa62 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Mon, 17 May 2010 17:19:31 +0000 Subject: Fix FS#11280 SDL docs say SDL_PumpEvent (implicitely called by SDL_Poll/WaitEvent) may only be called from the thread that initializes the video subsystem, apparently because Windows requires that. So create an (or bring it back) SDL thread (with preemtive behavior) to read the event queue for buttons and initialize the video subsystem. I'd probably would have done that anyway because it enables an interrupt-like method to read them (no polling). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26113 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/hosted/sdl/button-sdl.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'firmware/target/hosted/sdl/button-sdl.c') diff --git a/firmware/target/hosted/sdl/button-sdl.c b/firmware/target/hosted/sdl/button-sdl.c index cfe08de1d2..e9fc03792c 100644 --- a/firmware/target/hosted/sdl/button-sdl.c +++ b/firmware/target/hosted/sdl/button-sdl.c @@ -85,20 +85,21 @@ bool remote_button_hold(void) { static void button_event(int key, bool pressed); extern bool debug_wps; extern bool mapping; -static void gui_message_loop(void) + +void gui_message_loop(void) { SDL_Event event; static int x,y,xybutton = 0; - if (SDL_PollEvent(&event)) + while (SDL_WaitEvent(&event)) { + sim_enter_irq_handler(); switch(event.type) { case SDL_KEYDOWN: - button_event(event.key.keysym.sym, true); - break; case SDL_KEYUP: - button_event(event.key.keysym.sym, false); + button_event(event.key.keysym.sym, event.type == SDL_KEYDOWN); + break; case SDL_MOUSEBUTTONDOWN: switch ( event.button.button ) { #ifdef HAVE_SCROLLWHEEL @@ -174,6 +175,7 @@ static void gui_message_loop(void) case SDL_QUIT: { + sim_exit_irq_handler(); exit(EXIT_SUCCESS); break; } @@ -181,6 +183,7 @@ static void gui_message_loop(void) /*printf("Unhandled event\n"); */ break; } + sim_exit_irq_handler(); } } @@ -1502,7 +1505,6 @@ int button_read_device(void) return BUTTON_NONE; else #endif - gui_message_loop(); return btn; } -- cgit v1.2.3