Space Navigator for Notebooks working in a background app

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

Moderator: Moderators

Post Reply
superbigio
Posts: 18
Joined: Thu Jan 25, 2007 1:11 pm
Location: Los Angeles

Space Navigator for Notebooks working in a background app

Post by superbigio » Mon May 16, 2011 7:48 am

Hi there,

I recently bought a Space Navigator for Notebooks and I want to integrate its functionality in an application.
The idea is to get something that supports multiple devices as well. I see that is possible with the Max OS X API.

I am writing some driver code to capture the data sent by the SN and I run into a problem.
When the app in question is not the frontmost app I stop receiving data from the SN.

If I initialize the device with the following code:

clientID = RegisterConnexionClient('max2', NULL, kConnexionClientModeTakeOver, kConnexionMaskAll);

I receive data normally, but only if the app is frontmost.

This is the code that - according to the docs - should allow me to receive data no matter if the app is frontmost or in the background:

clientID = RegisterConnexionClient(kConnexionClientWildcard, NULL, kConnexionClientModeTakeOver, kConnexionMaskAll);

However, in this case I don't receive anything at all.

What am I doing wrong ?

Thanks.

- Luigi Castelli

superbigio
Posts: 18
Joined: Thu Jan 25, 2007 1:11 pm
Location: Los Angeles

Post by superbigio » Mon May 16, 2011 7:49 am

ok, nevermind... my bad.
I was doing something silly and figured out the mistake.

Now, just to clarify:

if I register my client as follows:
clientID = RegisterConnexionClient('max2', NULL, kConnexionClientModeTakeOver, kConnexionMaskAll);

then I only receive events when my application ('max2') is in focus,

whereas, if I use:
clientID = RegisterConnexionClient(kConnexionClientWildcard, NULL, kConnexionClientModeTakeOver, kConnexionMaskAll);

then I receive events whether we are in focus or not. Correct ?
In this mode why would I need a client ID ? Can I safely disregard it ?

Thanks.

- Luigi Castelli

flomotan
Moderator
Moderator
Posts: 287
Joined: Mon Jan 08, 2007 3:37 pm

Post by flomotan » Wed May 18, 2011 5:21 pm

Hi,

The returned clientID is needed to properly close down the connection and release any callback handlers you've installed. You'd need it in the call to UnregisterConnexionClient(fConnexionClientID);

Also be sure to call CleanupConnexionHandlers(); after you unregister.

superbigio
Posts: 18
Joined: Thu Jan 25, 2007 1:11 pm
Location: Los Angeles

Post by superbigio » Thu May 19, 2011 1:30 pm

That's right, of course...

Thanks for your help.

- Luigi

Post Reply