Direct Input Example

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

Moderator: Moderators

Post Reply
Seabra
Posts: 13
Joined: Thu Feb 28, 2008 10:32 am

Direct Input Example

Post by Seabra »

Hi,

Anyone have any example of Direct Input with Space Navigator without windows???

I would like to use the Direct Input Example from a prompt, and only read the coordinates of Space Navigator, without showing them in a GUI. I need of their coordinates to use in the other application.

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

Post by jwick »

If you don't want to use Windows at all, you are probably best using the HID example.
Seabra
Posts: 13
Joined: Thu Feb 28, 2008 10:32 am

Post by Seabra »

Ok. But, where I find the library "hidsdi.h"?
I need it to compile the example HIDTest.

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

Post by jwick »

hidsdi.h is in the Microsoft Device Driver Kit.
Seabra
Posts: 13
Joined: Thu Feb 28, 2008 10:32 am

Post by Seabra »

Thanks!
rodrigo.seabra
Posts: 44
Joined: Fri Apr 04, 2008 7:03 am

Post by rodrigo.seabra »

Hi,

I'm trying to addapt the HIDtest code to continuously get the rotation and translation parameters that are generated by the SpaceNavigator.
In the function call:
waitResult = WaitForMultipleObjects(_waitListIndex, _waitListHandles, FALSE, INFINITE);

from the example we're discussing, how can I change the parameter INFINITE so that it doesn't wait infinite time for a response from the device?

Or do I have to do any other modification to get what I want?

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

Post by jwick »

Read the documentation on WaitForMultipleObjects. If you wait, you will get woken whenever some data is available on the device. If you don't wait you will get woken when the timeout is exceeded, if nothing happens on the handles you are waiting on.
rodrigo.seabra
Posts: 44
Joined: Fri Apr 04, 2008 7:03 am

Post by rodrigo.seabra »

jwick,

I've changed the parameter INFINITE to 0, but I still have to wait for an interaction to occur. I'm kind of lost here... I don't know which part of the following code makes my application wait for a sign of life from the device:

Code: Select all

if (bRun) {
		float vettranslacao[3], vetrotacao[3];
		waitResult = WaitForMultipleObjects(_waitListIndex, _waitListHandles, FALSE, 0);
		if (waitResult <WAIT_OBJECT_0> handle, pDev -> buf, pDev -> capabilities.InputReportByteLength, &nread, FALSE))
...
}
Please, help me out... All I wanted was to get the translation and rotation vectors, even if the device is not activated.

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

Post by jwick »

The way you've changed the code, you should return immediately but you won't have any data most of the time.
All I wanted was to get the translation and rotation vectors, even if the device is not activated
You can't get the data if there isn't anything there to be got. If you want to get new data at any time and not be blocked in your main thread, you should run a separate thread that just reads the device and provides the data to the main loop of your app any time you need it.
rodrigo.seabra
Posts: 44
Joined: Fri Apr 04, 2008 7:03 am

Post by rodrigo.seabra »

Oh, so there is a way of just reading the device? Simpler than the example in question? Sorry to be so straightforward, but how can I do it?

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

Post by jwick »

HIDTest is just about as simple as it gets. There is very little going on there. I'm suggesting that you put that code into a separate thread so it doesn't block your main thread.
Post Reply