Filter by RegisterConnexionClient ID?

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

Moderator: Moderators

Post Reply
mcc
Posts: 6
Joined: Sun Dec 03, 2017 10:30 pm

Filter by RegisterConnexionClient ID?

Post by mcc »

The documentation says

"RegisterConnexionClient() returns a unique ID to identify your application to the driver. You will need to save this ID and pass it back to driver when calling certain SDK functions.
You would also use this ID to filter events coming in. The driver will broadcast device events to all registered applications. Each event will have a client field that identifies the intended target for the event. The value of client is normally the ID of the front-most active application."

I would like to filter by ID so that I do not receive messages when I am not the frontmost app. However, the API is not working as advertised. The ID returned by RegisterConnexionClient is (for example) 4099 and the value I am passed back as the "connection" variable is (for example) 50734. When I am in the background the connection id is "32767", so it's doing SOMETHING with that connection value, but I don't know what value I'm supposed to compare to to know that the message is meant for me.

I am using SetConnexionHandlers with RegisterConnexionClient. I am running inside a dylib which is being loaded by another application.

Has 3dConnexion abandoned this forum?
crobl
Moderator
Moderator
Posts: 138
Joined: Mon Feb 26, 2007 8:34 am
Location: Freiham, Germany

Re: Filter by RegisterConnexionClient ID?

Post by crobl »

Hello mcc,

you're correct, RegisterConnexionClient() returns a unique ID/handle for the connection to 3DxWareMac.
It's also correct to use this handle to "filter" for the incoming events, to lower the processing needs for incoming events.

Unfortunately you didn't provide any code, so I can only guess / point at the working solution:

Code: Select all

void TestMessageHandler(io_connect_t connection, natural_t messageType, void *messageArgument)
{
	static ConnexionDeviceState	lastState;
	ConnexionDeviceState		*state;
	
	switch(messageType)
	{
		case kConnexionMsgDeviceState:
			state = (ConnexionDeviceState*)messageArgument;
			if(state->client == gConnexionTest->fConnexionClientID)
			{
			...
If you have a look at the code of "3DxValuesCocoa" from our SDK (excerpt above), the value in state->client will match the handle you got via RegisterConnexionClient() as soon as your application is in focus again.
I don't know, what field you're accessing in ConnexionDeviceState, but the "50734" you get is the device's ID (0xC62E), which is a SpaceMouse Wireless.
Are you querying deviceID of ConnexionDevicePrefs, *ConnexionDevicePrefsPtr?

Please have another look at the supplied SDK samples and/or please provide your code, which fails.

Thank you!


Regards,

Christian Robl
Post Reply