Direct Input Example

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

Moderator: Moderators

Direct Input Example

Postby Seabra » Thu Apr 03, 2008 6:22 am

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.
Seabra
 
Posts: 13
Joined: Thu Feb 28, 2008 10:32 am

Postby jwick » Thu Apr 03, 2008 7:17 am

If you don't want to use Windows at all, you are probably best using the HID example.
jwick
Moderator
Moderator
 
Posts: 1769
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA

Postby Seabra » Thu Apr 03, 2008 7:31 am

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

Thanks.
Seabra
 
Posts: 13
Joined: Thu Feb 28, 2008 10:32 am

Postby jwick » Thu Apr 03, 2008 7:41 am

hidsdi.h is in the Microsoft Device Driver Kit.
jwick
Moderator
Moderator
 
Posts: 1769
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA

Postby Seabra » Thu Apr 03, 2008 9:55 am

Thanks!
Seabra
 
Posts: 13
Joined: Thu Feb 28, 2008 10:32 am

Postby rodrigo.seabra » Wed Apr 09, 2008 5:54 am

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.
rodrigo.seabra
 
Posts: 44
Joined: Fri Apr 04, 2008 7:03 am

Postby jwick » Wed Apr 09, 2008 6:06 am

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.
jwick
Moderator
Moderator
 
Posts: 1769
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA

Postby rodrigo.seabra » Wed Apr 09, 2008 7:14 am

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.
rodrigo.seabra
 
Posts: 44
Joined: Fri Apr 04, 2008 7:03 am

Postby jwick » Wed Apr 09, 2008 7:26 am

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.
jwick
Moderator
Moderator
 
Posts: 1769
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA

Postby rodrigo.seabra » Wed Apr 09, 2008 7:49 am

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.
rodrigo.seabra
 
Posts: 44
Joined: Fri Apr 04, 2008 7:03 am

Postby jwick » Wed Apr 09, 2008 7:55 am

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.
jwick
Moderator
Moderator
 
Posts: 1769
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA


Return to Developer's Forum for Windows

Who is online

Users browsing this forum: No registered users and 0 guests