COMless interfacing

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

Moderator: Moderators

aprice2704
Posts: 5
Joined: Fri May 18, 2007 10:23 pm

COMless interfacing

Post by aprice2704 »

Hi there!

I am new to the 3DConnection products. My company is developing and industrial simulation and control system and we wish to use the Space Nav.

We are using Ogre 3D for graphics, gcc & code::blocks -- which all gives us the platform indepedence we require. Obviously COM is not very useful in this environment (I think).

Can anyone offer suggestions? After all, all we need to do is read some numbers from the device regularly and provide a callback for button events.

I saw that Zekaric asked about a COM-less SDK a couple of weeks ago and that jwick described where to find a plain C SDK, but I have been unable to locate it for Windows/USB.

Just need to call a DLL/so directly really.

Can anyone help?

Many thanks in advance

Andy :)
Andrew Price
R&D Coordinator
Skyder Research Ltd.
www.skyder.com
jwick
Moderator
Moderator
Posts: 3340
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

Hi Andy,

I can give you some code that shows you how to use DirectInput or HID directly. It is simple to use HID w/o creating windows. It is probably possible to use DI w/o creating windows.

These both bypass the 3DxWare driver, so nothing an end-user will do in the 3DxWare GUI will have any impact. You will also have to handle any difference between 3Dx devices individually (in particular introduction of new devices). Those are the tradeoffs.

Jim
3Dx Software Development
aprice2704
Posts: 5
Joined: Fri May 18, 2007 10:23 pm

Yes please!

Post by aprice2704 »

That would be great!! I'm quite content with the trade-offs.

Many thanks

Andy :) :)
Andrew Price
R&D Coordinator
Skyder Research Ltd.
www.skyder.com
jwick
Moderator
Moderator
Posts: 3340
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

Hi Andy,

You can get a HID example from the following ftp site:

ftp:/ *** ***
login: ***
password: ***

This is the contents of the txt file in the HIDTest directory:

HIDTest shows how to use the HID client API to access 3Dx devices.

It enumerates and lists the properties of all HID devices. It then
picks out 3Dx devices and lists the data from them. It currently
will only list axis and button data from one of the devices it
finds because WaitForMultipleObjects only wakes on events from one.
I'm not sure why.

The project is a VS2005 project. You will have to direct the
project properties to your HID include files and libraries
to build it.

Using HID circumvents the 3DxWare driver. No modifications
users make in the 3DxWare GUI will effect the data from HID.

The axis orientation from HID is very different from the axis
orientation documented in the 3Dx documentation. You should
still make sure things work "correctly" as far as the direction
of pan/zoom/rotations. The names and directions may be different
but the functionality should be the same as in the 3Dx demos.

If you change that orientation, users will be very confused when
transfering from one application to another.

Jim
3Dx Software Development


Moderator Edit: the sample code is no longer available from the FTP service. Please contact 3Dconnexion API Support if you need further assistance.
aprice2704
Posts: 5
Joined: Fri May 18, 2007 10:23 pm

Cool, thanks so much Jim!

Post by aprice2704 »

I'll let you know how it goes and post any good results.

:)
Andrew Price
R&D Coordinator
Skyder Research Ltd.
www.skyder.com
jwick
Moderator
Moderator
Posts: 3340
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

I've also created an example of how to use WM_INPUT (RawInput). It is on the same ftp site. It takes about the same amount of code, but does handle disconnection and reconnection of new devices quite transparently.

All the same caveats about bypassing the 3DxWare driver...

Jim
3Dx Software Development
aprice2704
Posts: 5
Joined: Fri May 18, 2007 10:23 pm

Excellent -- thanks again

Post by aprice2704 »

More options are always good! :)
Andrew Price
R&D Coordinator
Skyder Research Ltd.
www.skyder.com
aprice2704
Posts: 5
Joined: Fri May 18, 2007 10:23 pm

Post by aprice2704 »

jwick wrote:I've also created an example of how to use WM_INPUT (RawInput). It is on the same ftp site. It takes about the same amount of code, but does handle disconnection and reconnection of new devices quite transparently.

All the same caveats about bypassing the 3DxWare driver...

Jim
3Dx Software Development
The WM_INPUT example looks even better for our purposes! Again, thanks so much. :)
Andrew Price
R&D Coordinator
Skyder Research Ltd.
www.skyder.com
dgilbert
Posts: 2
Joined: Thu Aug 09, 2007 10:05 am

Post by dgilbert »

I just started looking into integrating SpaceNavigator with our application, and the WM_INPUT example seems like a good approach for me as well. Going off your example code is enough to get me started, but I'd like a better understanding of the data in order to make my implementation as flexible as possible.

Is there any documentation describing the format of the raw data and a list of the associated RID_DEVICE_INFO_HID for each of the 3Dconnexion products?

Thanks in advance for any additional info you can provide.

-- Dan
jwick
Moderator
Moderator
Posts: 3340
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

The best way to find a 3Dx device is to check the Vendor ID and the UsagePage and Usage.

The VendorID for all Logitech/3Dx products is: 0x046d.

The ProductID is different for each individual product so don't use it or you will not recognize any future devices.
That having been said, the current list of Product IDs is:
0xc603 SpaceMousePlus
0xc621 SpaceBall 5000
0xc623 SpaceTraveler
0xc625 SpacePilot
0xc626 SpaceNavigator
0xc627 SpaceExplorer

The UsagePage for all 3Dx devices is: HID_USAGE_PAGE_GENERIC (use the constants, not the numbers.)

The Usage for all 3Dx devices is: 8. This is the multiaxis controller usage.

These are all HID standards. The best source for information is the HID site (http://www.usb.org/developers/hidpage/).

Jim
3Dx Software Development
dgilbert
Posts: 2
Joined: Thu Aug 09, 2007 10:05 am

Post by dgilbert »

Thanks for the quick reply, Jim.

The link to the HID site is perfect. I'm new to this HID stuff, so knowing where to look is always the first hurdle. :)
Paul
Posts: 2
Joined: Tue Aug 28, 2007 5:51 am

two devices, HID, WaitForMultipleObjects problem

Post by Paul »

So both the WM and HID examples work nicely with one device, but I'd like to use two, and use them both from Java, so in this sense the HID example looks more attractive to me as a starting point.

I'm wondering if anyone might have figure out the problem with WaitForMultipleObjects. On my machine it certianly never waits at all, but instead the function ReadFile blocks.

I'm going to keep poking to see if I can convince this to work, and I'll post if I have any success. But I'd also be happy to hear any advice.

cheers,

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

Post by jwick »

Hi Paul,

In my experiments with multiple devices via HID, WaitForMultipleObjects waits, but it only wakes when one of the devices fires. The other device(s) can't wake up WaitForMultipleObjects.

My next attempt was going to put each device into it's own thread.

OTOH, WM_INPUT works flawlessly with multiple devices (but you need a message pump).

Jim
3Dx Software Development
Paul
Posts: 2
Joined: Tue Aug 28, 2007 5:51 am

two devices, HID, two threads

Post by Paul »

Hello Jim,

Thanks for the fast response!

My java bindings are working now. I decided to make two threads on the java side and let them block in the native code on the read call. This is perhaps not the cleanest solution since I can't do a proper shut down of the HID stuff while there is a blocked read call (just the same, I haven't noticed any negative effects yet). I suppose the proper solution would be to use the WaitForMultipleObjects call, but it never blocks for me (and I'm not going to worry about it too much).

cheers,

Paul
Faraz
Posts: 2
Joined: Sat Sep 08, 2007 12:10 am

Post by Faraz »

Hi

I'm trying to use the WM_INPUT method, but my WM_INPUT messages are received in bursts by WndProc. This is how my underlying gui library works (fltk), there is no messagepump/loop that uses GetMessage. The WndProc is in a dll, I don't know if that matters.

If I PeekMessage for WM_INPUT on any message I see there are a lot more there and I can get a smooth motion. The trouble is this builds up a queue of messages - I have to check the timestamp of each message and discard if its too old. So after the navigation is finished there is a surge of CPU activity to clear up the queue that can last a while. This is all very messy and I'd much rather leave the message queue alone.

If the mouse movement is generating messages this seems to make the WM_INPUT messages get through. So if you move the mouse around whilst using the Spacenavigator you can get a smooth motion?

Maybe I should look for a more transparent way of handling the input.

My app does not use COM, its mostly ansi c++ and it's not easy to get the ATL example code to compile in there (using vs2003). Is it possible to write a ATL dll that handles the input via ATL and passes these in as events to my app? I'm not that familiar with ATL, could you tell me does the ATL example rely on having a window?

Any help really appreciated
Post Reply