Reputation: 31
I am using SDL libarary for capturing touch and mouse event on screen. But if i disconnect touch screen and reconnect it, Sometime i stop getting finger touch events i.e SDL_FINGERMOTION, SDL_FINGERDOWN, SDL_FINGERUP.
Below is the code i am using:
while(SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_QUIT:{
//Some Code
}
case SDL_MOUSEBUTTONDOWN:{
//Some Code
}
case SDL_MOUSEBUTTONUP:{
//Some Code
}
case SDL_MOUSEMOTION:{
//Some Code
}
case SDL_FINGERMOTION:
case SDL_FINGERDOWN:
case SDL_FINGERUP: {
//Some Code
}
}
}
return true;
}
Any suggestion would be helpful.
P.S using opensuse 42.2 and SDL2
Upvotes: 1
Views: 1118
Reputation: 7983
On Linux, SDL opens each available input event device the moment you call SDL_Init(... | SDL_INIT_EVENTS)
. If an input device is removed from the system, SDL will get an error whenever it tries to poll it. However, SDL does not get a notification when a new input device is added, and so it will never open new input event devices.
A workaround might be to periodically check /dev/input/event*
yourself, see if anything has changed, and if so, do SDL_QuitSubSystem(SDL_INIT_EVENTS); SDL_Init(SDL_INIT_EVENTS)
. However, that is a hack, and might not work reliably.
Upvotes: 2