DirectInput Programming Examples

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

Moderator: Moderators

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

Re: DirectInput Programming Examples

Post by jwick » Fri Mar 22, 2013 8:00 am

Of course, you use the DIJOYSTATE structure to get the data because that is the structure defined by the API. That doesn't make it the same data as comes out of joysticks. DirectInput is just a transport mechanism. Once you get the data you have to interpret it properly. You want to be able to do that consistently for all devices.

For example, 3Dconnexion devices stream signed data indicating the displacement from the rest (centered) position with negative numbers in one direction and positive numbers in the other direction (zero means the axis is at rest). They do this for 6 axes simultaneously. DirectInput uses the HID descriptor to format that data for you.

Unfortunately some of our older HID descriptors are incorrect and this causes DirectInput to misinterpret the data. As a result, you don't get the correct data from the device--you get mangled data. With some configuration parameters, DirectInput produces data that is really bad; with other parameter values it is useful. The task is to find the specific parameters that will unmangle the data back to the original values. There may also be differences in the way this mangling is done with different versions of DI.

You are trying to get the raw data from the device, but through DirectInput, with its particular quirks. Or, of course, you could use the 3DxWare API instead of Direct Input. It works much better. Most developers use the 3DxWare API. Very few developers manage to get DirectInput working. We only recommend DI if you already have a lot of code invested in it...and then you see it is not straightforward.

DeeMAGE
Posts: 20
Joined: Fri Nov 05, 2010 5:35 am
Location: UKRAINE

Re: DirectInput Programming Examples

Post by DeeMAGE » Fri Mar 22, 2013 8:22 am

The only one that we need is an official (tested, 100% functional) information for IDirectInput8 about NAME-PID-DIPROPAXISMODE for all range of your products.
Is that possible to get or no?
Thank you.

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

Re: DirectInput Programming Examples

Post by jwick » Thu Apr 04, 2013 6:29 am

Use DIPROPAXISMODE_REL for:
SpaceExplorer
SpacePilot
SpaceNavigator
SpaceMouse Pro
SpacePilot Pro (but it doesn't work well)
Future devices

All in all, having reviewed the performance of DirectInput with our devices, I can't recommend using it. It is inconsistent. It might work ok with some devices, but not with others. It has its own quirks in the way it seems to accumulate and deliver events. I'd say it is ok to use it to prototype 3Dx support if you already are heavily invested in DirectInput code, but I'd schedule time to implement a better mechanism before delivering your product.

We highly recommend that you use the 3DxWare SDK.

DeeMAGE
Posts: 20
Joined: Fri Nov 05, 2010 5:35 am
Location: UKRAINE

Re: DirectInput Programming Examples

Post by DeeMAGE » Thu Apr 04, 2013 6:42 am

Thank you.
The only changes that SpacePilot Pro works fine in _ABS mode, we have many users on it.

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

Re: DirectInput Programming Examples

Post by jwick » Thu Apr 04, 2013 7:23 am

DeeMAGE wrote:Thank you.
The only changes that SpacePilot Pro works fine in _ABS mode, we have many users on it.
Are you using it in the mode where DI does not give you the displacement from 0 but some large number and constant small changes to it? E.g., maybe it starts at 32767, then gives you 32766, 32765, etc. Then you are calculating the deltas yourself?
Are you using all the devices that way?

DeeMAGE
Posts: 20
Joined: Fri Nov 05, 2010 5:35 am
Location: UKRAINE

Re: DirectInput Programming Examples

Post by DeeMAGE » Thu Apr 04, 2013 7:31 am

jwick wrote:Are you using it in the mode where DI does not give you the displacement from 0 but some large number and constant small changes to it?
No, it gives us correct numbers from 0 in usual DIJOYSTATE structure. All devices.

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

Re: DirectInput Programming Examples

Post by jwick » Thu Apr 04, 2013 7:44 am

DeeMAGE wrote:
jwick wrote:Are you using it in the mode where DI does not give you the displacement from 0 but some large number and constant small changes to it?
No, it gives us correct numbers from 0 in usual DIJOYSTATE structure. All devices.
0,1,2,3,4, then 4,3,2,1,0 when you release the cap?
Can you tell me what firmware version your SpacePilot Pro has?

DeeMAGE
Posts: 20
Joined: Fri Nov 05, 2010 5:35 am
Location: UKRAINE

Re: DirectInput Programming Examples

Post by DeeMAGE » Thu Apr 04, 2013 7:56 am

jwick wrote:0,1,2,3,4, then 4,3,2,1,0 when you release the cap?
Yes, but it scaled up with 512.
I have no idea about firmware but we have thousands of users and all your devices does fine except SpaceMousePro, which expected to be fixed when we will switch it to _REL.

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

Re: DirectInput Programming Examples

Post by jwick » Thu Apr 04, 2013 8:00 am

DeeMAGE wrote:
jwick wrote:0,1,2,3,4, then 4,3,2,1,0 when you release the cap?
Yes, but it scaled up with 512.
I have no idea about firmware but we have thousands of users and all your devices does fine except SpaceMousePro, which expected to be fixed when we will switch it to _REL.
Scaled by 512??
You get: 0, 512, 1024, 1536, 2048 ..., 2048, 1536, 1024, 512, 0 ??

DeeMAGE
Posts: 20
Joined: Fri Nov 05, 2010 5:35 am
Location: UKRAINE

Re: DirectInput Programming Examples

Post by DeeMAGE » Thu Apr 04, 2013 8:08 am

It is in range about -1400..+1400.
The values 1,2,3,4 is fairly hard to get.

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

Re: DirectInput Programming Examples

Post by jwick » Thu Apr 04, 2013 8:15 am

I don't understand what you meant by scaled up with 512.

DeeMAGE
Posts: 20
Joined: Fri Nov 05, 2010 5:35 am
Location: UKRAINE

Re: DirectInput Programming Examples

Post by DeeMAGE » Thu Apr 04, 2013 8:21 am

jwick wrote:I don't understand what you meant by scaled up with 512.
From your own code:

Code: Select all

	// Set the range for the axis
    DIPROPRANGE diprg; 
    diprg.diph.dwSize       = sizeof(DIPROPRANGE); 
    diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER); 
    diprg.diph.dwHow        = DIPH_BYID; 
    diprg.diph.dwObj        = pdidoi->dwType; // Specify the enumerated axis
    diprg.lMin              = -512; // +/- 512 matches the hardware 1:1 
    diprg.lMax              =  511; 
Nevermind.

hi_sidd
Posts: 3
Joined: Fri Jul 25, 2014 1:21 pm

Re: DirectInput Programming Examples

Post by hi_sidd » Fri Jul 25, 2014 1:26 pm

A bit late here, but I cannot access the zip file on the ftp site. I am trying to use the DirectInput API, so looking at the example will be quite helpful.

hi_sidd
Posts: 3
Joined: Fri Jul 25, 2014 1:21 pm

Re: DirectInput Programming Examples

Post by hi_sidd » Fri Jul 25, 2014 1:37 pm

In some detail here, I am trying to use the SpacePilot PRO. However, the orientation data is reset to 0 once the cap is released. This isn't the case with SpaceExplorer, where the orientation values were accumulated. I have tried changing the property DIPROP_AXISMODE to both DIPROPAXISMODE_ABS and DIPROPAXISMODE_REL. Regardless, the data is reset.

Since I didn't had access to the example on the ftp site, I used the sample from the following MS site,

http://code.msdn.microsoft.com/windowsa ... s-8ac6f5e3

Any help here would be useful.

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

Re: DirectInput Programming Examples

Post by jwick » Mon Jul 28, 2014 2:17 am

The USB descriptors are different on some of the devices. Apparently DirectInput is not handling the devices the same.

The best thing to do is use the one setting that works consistently and do the accumulation yourself.

Post Reply