SDL Input in its own thread

Hi guys,

Basically what I’m trying to do is use SDL Input event processing in its
own thread. The application I’m writing is plugin based, so the display
plugin runs in its own thread, and the input plugin runs in its own
thread. One of the available display plugins uses SDL, but regardless of
the display plugin, I still want to be able to use SDL for input (so long
as the display plugin has a valid window handle).

I’ve tried setting the environment variable SDL_WINDOWID in the input
thread, but it doesn’t seem to work. If I take the same code and put it
in the display thread it works fine, so it seems like the problem lies in
the initialization of SDL in the input thread.

Can anyone offer some advice in how to get event processing to work in the
input thread?

Thanks,

  • Jon

Jonathan Apostoles wrote:

Can anyone offer some advice in how to get event processing to work in
the input thread?

SDL_INIT_EVENTTHREAD

it is an undocumented feature and only works on
linux.

but, SDL only requires SDL_WaitEvent or SDL_PollEvent to be called from
the same thread as SDL_InitVideo has been called. you could wrap both
functions (InitVideo and PollEvent) into your plugin interface and call
it from the same thread. also the possibility to call InitVideo more
often then once, might come in handy here.

clemens