Is ISimpleDevice::GetIsConnected() working?

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

Moderator: Moderators

Post Reply
calques3d
Posts: 4
Joined: Sat Nov 10, 2007 11:33 am
Location: London
Contact:

Is ISimpleDevice::GetIsConnected() working?

Post by calques3d »

Hi all,

I'm trying to determine if a 3d device is connected to the computer (mine is a SpaceNavigator PE) but it looks like that the GetIsConnected() method always return TRUE, even if you remove the USB or even stop the driver.

Here is the code I'm using:

Code: Select all

  ISimpleDevicePtr _p3DxDevice;
  HRESULT   hr = m_g3DKeyboard->get_Device((IDispatch**)&_p3DxDevice);
  if (SUCCEEDED(hr))
  {
      BOOL b = _p3DxDevice->GetIsConnected();
      _p3DxDevice.Release();
  }
I'm using VC++ 6 and the COM SDK.

Thanks
jwick
Moderator
Moderator
Posts: 3341
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

Hi calques3d,

IsConnected() is only associated with the calls to Connect() and Disconnect() methods, not with a physical bit of hardware, nor with 3dxware.

The best method to find out if you do not have a device attached is to check what type of device is being serviced by using _p3DxDevice.get_Type(&type). (0 == UNKNOWN == None)

When a new device is attached i.e. 3dxware startsup again, the devices DeviceChange event is fired
calques3d
Posts: 4
Joined: Sat Nov 10, 2007 11:33 am
Location: London
Contact:

Post by calques3d »

jwick wrote:Hi calques3d,

IsConnected() is only associated with the calls to Connect() and Disconnect() methods, not with a physical bit of hardware, nor with 3dxware.

The best method to find out if you do not have a device attached is to check what type of device is being serviced by using _p3DxDevice.get_Type(&type). (0 == UNKNOWN == None)

When a new device is attached i.e. 3dxware startsup again, the devices DeviceChange event is fired
Thanks for the hint, jwick.
I tried your idea but same effect: if I unplug the USB cable or if I manually stop the driver, I still get type==6. I even tried to start my application with the USB unplugged, same result.

It seems to me that the hardware detection is not working or at least not signaled to my app. I don't know if it is a problem with the SpaceNavigator installation, with WinXP witself or ith the VC++ I'm using.

BTW, I cannot use the DeviceChange event because I am still using VC++6 and __hook/__unhook are only available in VC++2005. I am looking for a compatible alternative. In the mean time, I am using the Timer event and check the previous code every time (not very efficient but will do for the time being).

Any other idea I could try?
ngomes
Moderator
Moderator
Posts: 3344
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Post by ngomes »

Hi calques3d,
BTW, I cannot use the DeviceChange event because I am still using VC++6 and __hook/__unhook are only available in VC++2005.
You can use COM event notification in code generated by VC6. Attribute programming isn't there but you should be able to use the IConnectionPoint interfaces directly.

If you can try building a C++ sample with /Fx compiler option in VC8 (perhaps VS2005 Express?). This will generate replace the attributes with source which you should be able to use on your VC6 project.
Nuno Gomes
jwick
Moderator
Moderator
Posts: 3341
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

Hi calques3d,

I guess I don't understand what you are trying to do here. I assumed you were trying to determine if a device was attached when you started your program. It seems as if you are trying to disconnect the device while your program is running and detect that. I think we've told you how to detect the former situation. There is no support for the latter via the COM interface. You'd have to use O/S functions for that.

Jim
3Dx Software Development
calques3d
Posts: 4
Joined: Sat Nov 10, 2007 11:33 am
Location: London
Contact:

Post by calques3d »

jwick,

sorry, I should have been more explicit. Yes, you are right, I was trying to find out if an existing device has been disconnected or not (not a fundamental issue, just a high-level check for stopping/suspending the timer and avoiding propagating unnecessary messages - I can do that other ways, by verifying 0 values on Vector3D::Length and AngleAxis:Angle).

I now understand why what you told me didn't work, because I was not looking at the right situation. I will have a look for the O/S solution.

And thanks for the hints on COM event in VC6, I am looking at that issue (I never worked with COM/ATL before, lots of stuff to catch up :-)).

Regards
Post Reply