How to process SDL events with Qt?
I have a Qt application and want to use SDL to control parts of it with a gamepad/joystick.
I already integrated SDL and had some rudimentary event processing in the works, but I think I am doing things the wrong way. How do you approach processing SDL events within a Qt application? Would a separate thread be a good idea?
Since I am completely new to SDL and spoiled by Qts great documentation, I feel somewhat lost at the moment.
I hope somebody knows something to help me out - thanks in advance.
As a start I settled with putting the SDL-stuff into a new QThread and run a simple while-loop in there. I am still not sure how to "integrate" the SDL-events into my application, though.
while(SDL_WaitEventTimeout(&event, 1000))//false only if there was an error
//do things with the received event
I read about "QAbstractEventDispatcher":http://qt-project.org/doc/qt-5/qabstracteventdispatcher.html and it seems like it would offer an elegant solution. But subclassing it also seems like a real piece of work and I just wouldn't know where to start.
Did you have some progress? I'm looking for a similar solution
"Some progress", yes. It has been a while and I sadly didn't finish the whole project due to being unable to make the control scheme configurable (I will return to that). But I managed to pipe the input commands through a state machine which translated the digital ones into unique, user-readable strings (e.g. a short version of "button 25 released while buttons 7 and 9 were held down") while the analogue ones consisted of numbers and a string. That data was then mapped to some method and things started working. I don't remember all the coding details and am not yet sure if there isn't a better way to achieve what I need the program to do.