Need to use 4 devices via Windows SDK at a time. Help!

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

Moderator: Moderators

Post Reply
Lyosha
Posts: 5
Joined: Thu Jun 29, 2017 4:27 pm

Need to use 4 devices via Windows SDK at a time. Help!

Post by Lyosha »

Hello there!

For an installation project I need to distinguish between 4 different SpaceNavigators plugged in. So far in SDK I've found no way of figuring out from which device does the SiSpwEvent come from. How can I figure that out?

Thanks a bunch in advance!
Lyosha
Posts: 5
Joined: Thu Jun 29, 2017 4:27 pm

Re: Need to use 4 devices via Windows SDK at a time. Help!

Post by Lyosha »

I have tried modifying 3DxTest this way:

Code: Select all

int num = SiGetNumDevices();
  SiDevID devIndex1 = SiDeviceIndex(1);
  SiDevID devIndex2 = SiDeviceIndex(2);
  if ( (devHdl = SiOpen ("3DxTest32", /*SI_ANY_DEVICE*/devIndex2, SI_NO_MASK, SI_EVENT, &oData)) == NULL)
(in accordance with the info frome here: https://www.3dconnexion.com/forum/viewt ... 8&start=15)

but I still get events from both devices.
UtaSH
Moderator
Moderator
Posts: 3754
Joined: Mon Nov 27, 2006 10:34 am
Location: Munich, Germany
Contact:

Re: Need to use 4 devices via Windows SDK at a time. Help!

Post by UtaSH »

Moving post to Developer Forum.
jwick
Moderator
Moderator
Posts: 3331
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: Need to use 4 devices via Windows SDK at a time. Help!

Post by jwick »

This is how you open multiple devices (from our puzzle demo):

Code: Select all

...
  SiInitialize ();
  numDevices = SiGetNumDevices();
  for(int devID = 0; devID <= numDevices; devID++)
  {
         SiOpenWinInit (&oData, Spw_hWndMain);
         devHdls[devID] = SiOpen ("puzzle", devID, SI_NO_MASK, SI_EVENT, &oData);
         SiGetDeviceInfo(devHdls[devID], &devInfos[devID]);
...
Then when you get a windows message, you have to figure out which device generated it.
You use each hdl to communicate with each device.
The events from each device arrive separately:
(again from puzzle)

Code: Select all

         // Loop through all the devices.
         // Use the first for view control.
         // The others for object control.
      SiGetEventWinInit (&eData, msg.message, msg.wParam, msg.lParam);
      for(int devID=0; devID <= MAX_DEVICE_INDEX; devID++)
         {
                if (devHdls[devID] != SI_NO_HANDLE)
                {
                       if (SiGetEvent (devHdls[devID], 0, &eData, &event) == SI_IS_EVENT)
                       {
...
If the driver is installed, you will always have at least one "device". Even if there are no actual physical 3D mice attached to the user's machine, you will have a device that will send you notifications if a user plugs a device in while your application is running.
Lyosha
Posts: 5
Joined: Thu Jun 29, 2017 4:27 pm

Re: Need to use 4 devices via Windows SDK at a time. Help!

Post by Lyosha »

Thanks for reply!

Where do I get the puzzle demo? Current SDK doesn't seem to have it anymore.
Lyosha
Posts: 5
Joined: Thu Jun 29, 2017 4:27 pm

Re: Need to use 4 devices via Windows SDK at a time. Help!

Post by Lyosha »

Ok, I have tried what you suggested and I still have both controllers' messages on the handle that I've used the last.

I've read through this thread: https://www.3dconnexion.com/forum/viewt ... 19&t=15981

Heisters had the same problem as me, but in my case it wasn't fixed by calling

Code: Select all

SiGrabDevice( device.handle, SPW_TRUE )
on the both handles.

What do I do next?
jwick
Moderator
Moderator
Posts: 3331
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: Need to use 4 devices via Windows SDK at a time. Help!

Post by jwick »

Sign up as a developer, then you can send me your sample code.

That other thread was about applications which have a window that is hidden (it never gets focus).
You need to have one SiHdl for every device you want to get input from.

Sorry, we don't normally distribute the puzzle src code. It was never cleaned for outside consumption. And I don't want to embarrass myself :)
I may modify the 3DxTest sample code.
jwick
Moderator
Moderator
Posts: 3331
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: Need to use 4 devices via Windows SDK at a time. Help!

Post by jwick »

I believe you have found a bug in the driver illuminated by the structure of 3DxTest.
To work around it, don't display the application's window until after opening the devices.

It should be fixed in the next release.

Thanks for finding it.
Post Reply