Results 1 to 3 of 3

Thread: Use of SDL within QT, joystick application

  1. #1
    Join Date
    Sep 2008
    Location
    Falmouth, MA, USA
    Posts
    34
    Thanks
    4
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Use of SDL within QT, joystick application

    I have an application that communicates (using primarily UDP sockets) with a variety of sensors, and with the user via button pushes, etc. It has been working fine. Now the users want to add a USB joystick to it.

    I did the requisite Google searches, and found joypick. https://code.google.com/p/joypick/. I copied much of the code from joypick into my application, making changes as necessary to fit my windowing approach, etc.

    Although joypick compiles and executes just fine, when I use its qjoystick.cpp (without changes) in my code, it hangs up at a line

    Qt Code:
    1. SDL_Event event;
    2.  
    3. SDL_PollEvent(&event);
    To copy to clipboard, switch view to plain text mode 

    joypick doesn't do this. My suspicion is that the SDL event loop is somehow getting robbed of events by the qt event loop, but I dont know how to prevent it. joypick doesn't seem do anything special along these lines. Any ideas? I detect and initialize the joystick just fine, can count its buttons and axes, etc, but the event poll never returns

    Thanks in advance

    I guess I should have indicated that I am using Windows 7, QT 4.7.4 with mingw, and SDL 1.2.15

  2. #2
    Join Date
    Sep 2008
    Location
    Falmouth, MA, USA
    Posts
    34
    Thanks
    4
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Use of SDL within QT, joystick application

    Another piece of information to add:

    I use multiple QTimers in my program. joypick (the QT/SDL application that works) only uses one, and the SDL_PollEvent is within its timeout slot.

    When I disable all of my timers, leaving only the joystick timer, the joystick part of my code works as intended.

    Unfortunately, I really need several timers in my application. I could of course use just one at the highest rate I need and "multiplex" but I dont really want that complexity. So I'm still looking for a solution.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Use of SDL within QT, joystick application

    Integrating event loops is not an easy task. usually it requires a specialized event dispatcher class.

    Have you tried running the SDL event loop in a thread?

    Cheers,
    _

Similar Threads

  1. Control Joystick with QT
    By Mien89 in forum Qt Programming
    Replies: 0
    Last Post: 23rd November 2012, 12:21
  2. QGraphicsScene illustrating the position of a joystick
    By Texton in forum Qt Programming
    Replies: 1
    Last Post: 21st August 2012, 22:40
  3. Emulating Joystick Input in Linux ( C++ )
    By invisible_uli in forum General Programming
    Replies: 6
    Last Post: 5th January 2012, 07:01
  4. Another Qt Joystick Question
    By chriskon149 in forum Qt Programming
    Replies: 2
    Last Post: 14th November 2011, 03:50
  5. Joystick Reader
    By Arpitgarg in forum Newbie
    Replies: 3
    Last Post: 6th March 2011, 15:43

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.