Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. How to process SDL events with Qt?

How to process SDL events with Qt?

Scheduled Pinned Locked Moved 3rd Party Software
3 Posts 2 Posters 2.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thEClaw
    wrote on 8 Mar 2014, 18:56 last edited by
    #1

    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.

    EDIT:
    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.
    @SDL_Event event;
    while(!stop)
    {
    while(SDL_WaitEventTimeout(&event, 1000))//false only if there was an error
    {
    switch(event.type)
    {
    //do things with the received event
    }
    if(stop)
    {
    return;
    }
    }
    }@

    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.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      karlox
      wrote on 24 Sept 2014, 11:41 last edited by
      #2

      Did you have some progress? I'm looking for a similar solution

      1 Reply Last reply
      0
      • T Offline
        T Offline
        thEClaw
        wrote on 24 Sept 2014, 18:36 last edited by
        #3

        "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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved