Not receiving SpaceNavigator events in custom 3D app

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

Moderator: Moderators

Post Reply
dbramsen
Posts: 13
Joined: Wed Feb 11, 2009 9:44 am

Not receiving SpaceNavigator events in custom 3D app

Post by dbramsen »

I am trying to integrate the SpaceNavigator in my custom 3D app. I have been able to run xapp with no problems, so I used xapp.c as a guide, the biggest difference being I have an existing Window. The two major methods I call are MagellanInit() andXSelectInput() before starting the loop to receive events. The debug statements that get printed to the console look the same as when I run xapp (with a few changes in numbers):

Code: Select all

Magellan: xdrvlib.c 
MagellanMotionEvent = 1070 
MagellanButtonPressEvent = 1071 
MagellanButtonReleaseEvent = 1072 
MagellanCommandEvent = 1073 

Magellan: xdrvlib.c 
Magellan Root Window Number: 00000163 

Magellan Window Number: 04000148 

Magellan Window Name: Magellan Window 

Magellan Send Command Message: 03E00003 

Magellan: xdrvlib.c 
Magellan Display = :0.0 
Magellan Driver Window = 04000148 
Magellan Application Window = 03E00003 
I do receive keyboard inputs since I followed xapp.c's example of calling XSelectInput with the KeyPressMask | KeyReleaseMask argument. However, I am not getting any SpaceNavigator events. Does anyone know what I am missing?

Thanks.
UtaSH
Moderator
Moderator
Posts: 3754
Joined: Mon Nov 27, 2006 10:34 am
Location: Munich, Germany
Contact:

Re: Not receiving SpaceNavigator events in custom 3D app

Post by UtaSH »

Hi dbramsen,

you have to select the ClientMessages and check with MagellanTranslateEvent() if this is a MagellanMotionEvent, a MagellanInputButtonPressEvent or a MagellanInputButtonReleaseEvent. In the example xapp.c this is done right after the case ClientMessage:

Code: Select all

case ClientMessage:
  switch( MagellanTranslateEvent( display, &report, &MagellanEvent, 1.0, 1.0 ) )
    {
      ...
Uta Ludwig
3Dconnexion
dbramsen
Posts: 13
Joined: Wed Feb 11, 2009 9:44 am

Post by dbramsen »

I do have the 'case ClientMessage' statement in there, but my problem is that it never gets called.

I forgot to mention that in my application, I don't want XNextEvent() to block, so I call XCheckWindowEvent() to see if there are any events in the queue first. The mask argument I am passing into XCheckWindowEvent() is 'KeyPressMask | KeyReleaseMask'. Should I be passing in something for it to check for SpaceNavigator events?

So my real problem is that XCheckWindowEvent() does not return true when I move the SpaceNavigator, which means XNextEvent() is not called, which means the 'case ClientMessage' is never reached. Sorry for not being more clear the first time.
dbramsen
Posts: 13
Joined: Wed Feb 11, 2009 9:44 am

Post by dbramsen »

The fix for XCheckWindowEvent() is to use XPending(), but that didn't fix the problem that my window isn't getting the SpaceNavigator events, even though it receives keyboard events (and mouse events too, with the proper masks set). I can get SpaceNavigator events when I create a brand new window using XCreateSimpleWindow(), followed by XSetWMProperties(), but I don't know how to register a window that I didn't create via XCreateSimpleWindow(). Do I need to set classhints->res_class to something other than "BasicWindow"? Do I call XSetWMProperties() on that window?
UtaSH
Moderator
Moderator
Posts: 3754
Joined: Mon Nov 27, 2006 10:34 am
Location: Munich, Germany
Contact:

Post by UtaSH »

I am sorry for the delay. :oops: The problem is that I am not quite sure if the XSetWMProperties() sets something that is necessary to receive the XClientMessages. As far as I know there is nothing specific to prepare (set a mask or similar) to receive the ClientMessages.

When you invoke the XSetWMProperties() do you use the same properties as in the source code of xapp.c?

How did you create your window?
dbramsen
Posts: 13
Joined: Wed Feb 11, 2009 9:44 am

Post by dbramsen »

I'm still not certain what the problem is (it could be that this window, which is part of an app developed by many people, already has an xevent listener that is usurping all the xevents), but I created a workaround by using an invisible window as the event receiver so that the callbacks are made, and then I proceed to modify my app window as expected.
Post Reply