How to detect whether the devices are plugged/unplugged?

Questions and answers about 3Dconnexion devices on Windows.

Moderator: Moderators

Post Reply
Cheney
Posts: 13
Joined: Mon May 10, 2010 7:41 pm

How to detect whether the devices are plugged/unplugged?

Post by Cheney »

Thanks!
Fred
Moderator
Moderator
Posts: 997
Joined: Wed Dec 06, 2006 7:15 am
Location: Rochester, NY
Contact:

Post by Fred »

Simple way is to follow the cord to the end if you see the end of the usb its not plugged in. :lol:

Otherwise go to system and check if windows detects the device under human interface if not its either not plugged in or windows isnt detecting the device.
If you go task manager, processes you can see if the 3DXsrv.exe is running if so the device is plugged in otherwise the driver wont launch at bootup if its not plugged in.
Cheney
Posts: 13
Joined: Mon May 10, 2010 7:41 pm

Post by Cheney »

Sorry I did not make myself clear.

I want to support 3DConnexion device in our product, and want to detect whether the device is plugged or unplugged in codes. I cannot find any API to do this.
jwick
Moderator
Moderator
Posts: 3418
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

What API are you using to access the 3Dx device? We recommend Raw Input.
Cheney
Posts: 13
Joined: Mon May 10, 2010 7:41 pm

Post by Cheney »

We have a button for 3dconnexion related function, and want to show the button when the device is plugged and hide it when device is unplugged. So we need detect the status in codes.
jwick
Moderator
Moderator
Posts: 3418
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

???

What API are you using to access the 3Dx device? We recommend Raw Input.
Cheney
Posts: 13
Joined: Mon May 10, 2010 7:41 pm

Post by Cheney »

We are not using Raw Input currently. We register the message SpaceWareMessage00 and handle it.

As I understand it, the Raw Input is about how to handle the message. Dose connecting/disconnecting the device send any message that can only be handled by Raw Input.

My requirement is that open our product, show/hide the button for 3dconnexion if the device is connected/disconnected, and some time after that, if the device is disconnected/conntected, hide/show that button immediately. My original thought is that there may be a API to return that status. As you mentioned Raw Input here, I wonder whether it send some message when connecting/disconnecting the device, and i can read the status in the message handler.

Thank you for your help.
jwick
Moderator
Moderator
Posts: 3418
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

You can register for device notification messages. These will tell you when devices connect and disconnect (WM_DEVICECHANGE events).

The next version of 3DxWare (version 7) will also forward these events to your SpaceWareMessage00 window.

You only need to initialized Raw Input once though. If there are ever any devices attached and something happens on one of them you will just get the data. No reason not to set it up. No harm. No foul.
Cheney
Posts: 13
Joined: Mon May 10, 2010 7:41 pm

Post by Cheney »

Registering for device notification needs the GUID of the device, and i cannot find the GUID in the Device Manager, Registry and etc. Do you know where i can find the GUID? Tnank you!
jwick
Moderator
Moderator
Posts: 3418
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

You need the HID GUID:

GUID hidGuid;
HidD_GetHidGuid (&hidGuid);

DEV_BROADCAST_DEVICEINTERFACE filterData;
ZeroMemory(&filterData, sizeof(DEV_BROADCAST_DEVICEINTERFACE));

filterData.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
filterData.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
filterData.dbcc_classguid = hidGuid;

ghDevNotify = RegisterDeviceNotification( (HANDLE)ghwndDevNotify,
&filterData, DEVICE_NOTIFY_WINDOW_HANDLE );
Cheney
Posts: 13
Joined: Mon May 10, 2010 7:41 pm

Post by Cheney »

Calling the function HidD_GetHidGuid() requires installing the DDK. So i think it costs too much to implement the functionality in this way that asks all developers to install DDk and makes the application independ on the library.

Is this the only way to get the status? And When will the versin 7 been released?
jwick
Moderator
Moderator
Posts: 3418
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

I'd be willing to make a small wager that the GUID is a constant. You could run it once in a test program and save it. It might even be found in inf files.

OTOH, the DDK is the "Microsoft Way". Not installing it may be the same as not installing the 3Dx SDK. I don't know what else you are missing.

If you have a lot of existing 3DxWare SDK code (Si* functions), it might be simpler to wait for 3Dx7 (in internal beta now, external beta soon). OTOH, 3DxInput (COM server) is deprecated and there are not plans to add any 3Dx7 functionality to it. We are highly recommending that ISV convert to Raw Input.
Cheney
Posts: 13
Joined: Mon May 10, 2010 7:41 pm

Post by Cheney »

Where are the inf files? I cannot find them in \program files\3DConnexion\3Dconnexion 3DxSoftWare and \WINDOWS\inf.

I need to get all the devices we want to support if i run a test program and save the GUIDs. And unfortunately i only have three of them now.
jwick
Moderator
Moderator
Posts: 3418
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

Sorry. There aren't any inf files in the version you have. You don't need GUIDs for individual devices, you need the HID GUID. Your notifications don't come from devices.

Install the DDK.

OTOH, it looks like the HID GUID is: {4D1E55B2-F16F-11CF-88CB-001111000030}. This was from W7, x86. I have no idea if it is the same on all platforms. We always look it up with the code I gave you.

Install the DDK. Anything else is unsupported.

Install the DDK.
Post Reply