Help!

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

Moderator: Moderators

Post Reply
Julian
Posts: 11
Joined: Thu Dec 18, 2008 5:20 am

Help!

Post by Julian »

Hello everyone, I am trying to integrate 3d spacemouse to simulate a joystick. I have the code for joystick mapping, and it was written as a console application.(including a main.app in which there is a main() function). What I need to do is only get the data of spacemouse translation & rotation, then map the data to joystick movement. I have download the "old SDK" and I can successfully complied the testcode, but it was written as a Win32 application(there is no main.app, the Winmain fuction is in a file named 3DxTest32.c), and it will run a window loop to detect the change of motion event.

So how can i combine my joystick mapping code with this Win32 test application? ANY good ideas?

I am a newbie of C++ programming. Maybe it is such a stupid question, but anyway, I hope I can get help from the forum.
jwick
Moderator
Moderator
Posts: 3341
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

If you don't want a windows main loop, you should use the HID API. There are examples posted in the forum.
Julian
Posts: 11
Joined: Thu Dec 18, 2008 5:20 am

Post by Julian »

jwick wrote:If you don't want a windows main loop, you should use the HID API. There are examples posted in the forum.
Thank you jwick, for this reply!

I have tried HID example, I downloaded the Winddk and complied HIDTest code successfully. But when I run that code, there only showed some figures in the console. I didnt find spacemouse Translation&Rotation data printed out. I guess the HIDTest.exe found a HID device on my computer which is my virtual joystick instead of the spacemouse, because I saw "NumberInputButtonCaps" and "NumberInputValueCaps" were exactly the number in my virtual joystick configration.

Under this situation, what should I do?
jwick
Moderator
Moderator
Posts: 3341
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

Yes of course the HIDTest code lists the information for all your devices, but only, I think, prints out the values for the first device in the list. Since your USB bus can constantly have a different arrangement of devices, you need to look at each device descriptor to figure out which one you want to list the motion and button data for.
Julian
Posts: 11
Joined: Thu Dec 18, 2008 5:20 am

Post by Julian »

jwick wrote:Yes of course the HIDTest code lists the information for all your devices, but only, I think, prints out the values for the first device in the list. Since your USB bus can constantly have a different arrangement of devices, you need to look at each device descriptor to figure out which one you want to list the motion and button data for.
Where is the device descriptor? and for example, how can i modify the code to see all values for the second device in the list? and how do i know how many devices detected by HIDTest.exe? The most important thing for me is to access my spacemouse and get motion data from it.
jwick
Moderator
Moderator
Posts: 3341
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

You may have to read up on the HID API. The code is long but fairly easy to understand (IMO).

The code reads all the descriptive data from each device into an array. The array is loaded in the order the devices are discovered. The code then attempts to wait on all devices with usage page 1, usage 4 (joystick) or 8 (multi-axis controller--your SpaceNavigator). Do to some restriction in Windows, it only gets woken per thread on the first handle. Therefore you may want to remove your virtual joystick from the list of handles given to WaitForMultipleObjects.
Julian
Posts: 11
Joined: Thu Dec 18, 2008 5:20 am

Post by Julian »

jwick wrote:You may have to read up on the HID API. The code is long but fairly easy to understand (IMO).

The code reads all the descriptive data from each device into an array. The array is loaded in the order the devices are discovered. The code then attempts to wait on all devices with usage page 1, usage 4 (joystick) or 8 (multi-axis controller--your SpaceNavigator). Do to some restriction in Windows, it only gets woken per thread on the first handle. Therefore you may want to remove your virtual joystick from the list of handles given to WaitForMultipleObjects.
THANKS FOR THE CLUE! I will read through the code and keep working on it. You are a nice person!

Best wishes
Julian
Post Reply