DirectInput Programming Examples
Moderator: Moderators
Re: DirectInput Programming Examples
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.
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.
Re: DirectInput Programming Examples
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.
Is that possible to get or no?
Thank you.
Re: DirectInput Programming Examples
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.
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.
Re: DirectInput Programming Examples
Thank you.
The only changes that SpacePilot Pro works fine in _ABS mode, we have many users on it.
The only changes that SpacePilot Pro works fine in _ABS mode, we have many users on it.
Re: DirectInput Programming Examples
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?DeeMAGE wrote:Thank you.
The only changes that SpacePilot Pro works fine in _ABS mode, we have many users on it.
Are you using all the devices that way?
Re: DirectInput Programming Examples
No, it gives us correct numbers from 0 in usual DIJOYSTATE structure. All devices.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?
Re: DirectInput Programming Examples
0,1,2,3,4, then 4,3,2,1,0 when you release the cap?DeeMAGE wrote:No, it gives us correct numbers from 0 in usual DIJOYSTATE structure. All devices.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?
Can you tell me what firmware version your SpacePilot Pro has?
Re: DirectInput Programming Examples
Yes, but it scaled up with 512.jwick wrote:0,1,2,3,4, then 4,3,2,1,0 when you release the cap?
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.
Re: DirectInput Programming Examples
Scaled by 512??DeeMAGE wrote:Yes, but it scaled up with 512.jwick wrote:0,1,2,3,4, then 4,3,2,1,0 when you release the cap?
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.
You get: 0, 512, 1024, 1536, 2048 ..., 2048, 1536, 1024, 512, 0 ??
Re: DirectInput Programming Examples
It is in range about -1400..+1400.
The values 1,2,3,4 is fairly hard to get.
The values 1,2,3,4 is fairly hard to get.
Re: DirectInput Programming Examples
I don't understand what you meant by scaled up with 512.
Re: DirectInput Programming Examples
From your own code:jwick wrote:I don't understand what you meant by scaled up with 512.
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;
Re: DirectInput Programming Examples
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.
Re: DirectInput Programming Examples
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.
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.
Re: DirectInput Programming Examples
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.
The best thing to do is use the one setting that works consistently and do the accumulation yourself.