Frequency of Xevents in Qt

Post questions, comments and feedback to our 3Dconnexion UNIX and Linux Development Team.

Moderator: Moderators

Post Reply
stage
Posts: 3
Joined: Tue Aug 19, 2008 7:07 am

Frequency of Xevents in Qt

Post by stage »

hi,

i am developing an application that uses a 3D mouse for navigation. It is written in C++, linux x64 on fedora core 8, Qt 4.3.4

in some situations, the openGL renderer is slower than the the 3D mouse sending events. Resulting in a long history of 3D mouse movements even when you have released the button. Since you can have only one thread sending commands to X, threading is not an option. Is there a way to perhaps change the frequency of X events ? Or ( better ) perhaps not queue unprocessed events, but just store the last X event ?
Using QCoreApplication::removePostedEvents( this, 0 ); does not seem to help...

Any suggestions ?

Cheers
crobl
Moderator
Moderator
Posts: 138
Joined: Mon Feb 26, 2007 8:34 am
Location: Freiham, Germany

Post by crobl »

Hi stage,

there is an undocumented/hidden command line option in 3dxwareunix:
"-slowUSB <n>", where <n> is the amount of motion events that should be dropped (valid values: 0...20). Example n=1: one event dropped, one event used.
But this is surely not what you want, because it makes the device and your application feel slow and kind of imprecise.

My suggestion would be - although you say its not an option - to have two threads:
Thread 1 handles the X part, which would be the connection/receiving window to 3dxwareunix. This thread consumes all events, stores the last motion event received and queues button events (otherwise you'll lose button presses).

Thread 2 draws the OpenGL object and reads the events from the thread 1 when its finished drawing.

If button events are present at thread 1 those will get priority over motion events. Of course you can add some time stamp info to this events and process them chronological. If a button event is read, it has to be cleared from the button event queue of thread 1.

Hope I could help - somehow. ;)

If you still have questions, feel free to ask!


Regards,

Christian Robl
3Dconnexion
stage
Posts: 3
Joined: Tue Aug 19, 2008 7:07 am

Post by stage »

I thought this wasn't possible since X is single threaded, but some more extensive searching gave me some examples. :)

I have not solved all problems with multi-threaded OpenGL yet, but am sure I will get there in the end and have a smooth 3D mouse input :)

Cheers !
Post Reply