Direct Input axis format

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

Moderator: Moderators

Augie
Posts: 18
Joined: Wed Oct 22, 2014 2:04 pm

Direct Input axis format

Post by Augie »

Hi,

I'm currently trying to add support for the 3Dconnexion Space Navigator to my Rewired input plugin for Unity. I've got it working using Raw Input, but when I use Direct Input, the axis values accumulate over time ultimately overflowing the min/max values set through Direct Input. When reading the HID data in Raw Input, the axes behave like absolute joystick axes returning only the current value. Nothing seems to make DI work like RI. I found some very old messages (2008ish) on this forum talking about DI examples on the FTP site, but the URL, username, and password are just asterisks. Any help will be appreciated.

I may add support through the SDK at a later date, but currently I just wanted to get it working with Raw & Direct Input.
ngomes
Moderator
Moderator
Posts: 3321
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Direct Input axis format

Post by ngomes »

Hi Augie,

Have you reviewed Patrick "Hightree"'s project?

If Patrick's solution will not cut it from you, how are you configuring the DirectInput? If I remember correctly, there was something off with the configuration flags. Something along the lines of what's defined to "relative" is in fact "absolute" and vice-versa.
Nuno Gomes
Augie
Posts: 18
Joined: Wed Oct 22, 2014 2:04 pm

Re: Direct Input axis format

Post by Augie »

ngomes wrote: Mon Jun 25, 2018 7:04 am Hi Augie,

Have you reviewed Patrick "Hightree"'s project?

If Patrick's solution will not cut it from you, how are you configuring the DirectInput? If I remember correctly, there was something off with the configuration flags. Something along the lines of what's defined to "relative" is in fact "absolute" and vice-versa.
Thanks for the response!

I hadn't seen that project before, but looking at it, I can see it's using the Space Navigator SDK, which isn't what I'm going for at this point. I want to get the data through standard HID means. I've been able to do it successfully on Windows using Raw Input, but Direct Input is still not working right. I also have it working on OSX, but Linux doesn't work in much the same way Direct Input doesn't.

I've tried setting the flag to both Absolute and Relative in DI and it doesn't make any difference. The axes always report accumulated relative values.

On Linux, udev reports the axes to be relative axes as well and therefore they do not send events when the value is zero. There is also no way to query the range for the axis in udev being a relative axis. There appears to be no way to reliably convert this to an absolute axis. Reading old posts, I see messages from as far back as 2008 complaining of this issue with no resolution.

It appears I will be unable to support the device on Direct Input or Linux without using the SDK.
ngomes
Moderator
Moderator
Posts: 3321
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Direct Input axis format

Post by ngomes »

Hi Augie,

How are you configuring the device? Can you perhaps share a small code snippet?

As far as I can tell, using IDirectInputDevice8::EnumObjects with the DIDFT_AXIS flag ought to ensure the data is absolute.

That still leaves with problem of detecting when the user has released the device sensor cap. What we normally do (in the cases where the "all zero" data packet is filtered out) is to set a timer. The timer can be set for about 2x to 4x the normal time interval between device data (about 17ms for USB device types). The timer must be reset whenever a data packet is received. The delay introduce (normally well under 100ms) is not perceived by the end-user.
Augie
Posts: 18
Joined: Wed Oct 22, 2014 2:04 pm

Re: Direct Input axis format

Post by Augie »

ngomes wrote: Tue Jun 26, 2018 7:28 am Hi Augie,

How are you configuring the device? Can you perhaps share a small code snippet?

As far as I can tell, using IDirectInputDevice8::EnumObjects with the DIDFT_AXIS flag ought to ensure the data is absolute.
I'm using a C# DirectInput wrapper, so the code isn't making direct calls to the DI API. The end result is however the same. IDirectInputDevice8::SetProperty is called on the device with DIPROP_AXISMODE set to absolute. The values returned are always relative values.
ngomes wrote: Tue Jun 26, 2018 7:28 amThat still leaves with problem of detecting when the user has released the device sensor cap. What we normally do (in the cases where the "all zero" data packet is filtered out) is to set a timer. The timer can be set for about 2x to 4x the normal time interval between device data (about 17ms for USB device types). The timer must be reset whenever a data packet is received. The delay introduce (normally well under 100ms) is not perceived by the end-user.
I had considered using a timer to do this when I was working on the Linux implementation, but didn't know if there was any reliable way to know the timeout required. I tried hardcoding a 34ms timeout and it seems to be working fine on Linux. I will use this same technique along with a comparison of previous to current values to convert the Direct Input results to absolute values as well. Thanks for the help!
Hypersonic
Posts: 265
Joined: Mon Jul 12, 2010 5:58 pm

Re: Direct Input axis format

Post by Hypersonic »

Space Navigator is supported on Windows, OSX, and Linux according to the chart here
http://guavaman.com/projects/rewired/do ... llers.html

Overload uses Rewired in Unity, and it works well with a Space Navigator
https://playoverload.com/overload-versi ... now-steam/

I have encountered one app (Aquanox 2) that seemed to accumulate values over time for 5 axis, but it uses an engine called Krass from the 1990s which probably uses an older version of DI (likely v5, a version that mapped well to the SpaceOrb.)

I've read on
https://docs.microsoft.com/en-us/previo ... 9(v=vs.85)

DIDFT_ABSAXIS An absolute axis.
DIDFT_AXIS An axis, either absolute or relative.

Perhaps ABSAXIS might help?
Augie
Posts: 18
Joined: Wed Oct 22, 2014 2:04 pm

Re: Direct Input axis format

Post by Augie »

Hypersonic wrote: Wed Jun 27, 2018 4:31 pm Space Navigator is supported on Windows, OSX, and Linux according to the chart here
http://guavaman.com/projects/rewired/do ... llers.html

Overload uses Rewired in Unity, and it works well with a Space Navigator
https://playoverload.com/overload-versi ... now-steam/

I have encountered one app (Aquanox 2) that seemed to accumulate values over time for 5 axis, but it uses an engine called Krass from the 1990s which probably uses an older version of DI (likely v5, a version that mapped well to the SpaceOrb.)

I've read on
https://docs.microsoft.com/en-us/previo ... 9(v=vs.85)

DIDFT_ABSAXIS An absolute axis.
DIDFT_AXIS An axis, either absolute or relative.

Perhaps ABSAXIS might help?
Not sure if you read my first message, but I am the author of Rewired. I just updated Rewired to include support for the Space Navigator yesterday because I was able to rework these relative axis values to absolute based on the information in this thread.

Overload uses Rewired, but they are obviously using other means to support the Space Navigator because it did not work with Rewired prior to yesterday. They've probably integrated SDK support.

Nothing worked in Direct Input to get the axes to report absolute values. I had to use the same technique I used on Linux with the exception that I have to detect changes in value since the axis reports a total accumulated value.

I also posted a reply to this thread yesterday but it never showed up. I'm guessing it's still in the moderation queue.
Hypersonic
Posts: 265
Joined: Mon Jul 12, 2010 5:58 pm

Re: Direct Input axis format

Post by Hypersonic »

Sorry, I must have missed the 'my' in front of 'rewired input plugin for unity' link!

I just figured that Overload solely relied on Rewired by looking at the version update, I see now that I was mistaken. I'm surprised that the 3DMouse worked in the first release version, maybe via Direct Input.

I've read that early 3DMice (perhaps some Space Navigators) reported in USB HID as relative instead of absolute and perhaps that carries over to Direct Input?
Hypersonic
Posts: 265
Joined: Mon Jul 12, 2010 5:58 pm

Re: Direct Input axis format

Post by Hypersonic »

I have 2 different Space Navigators (different firmwares.) Do you have a test program for rewired I could try, that shows direct input readings you get from the controllers? I remember in Chrome before they fixed it, I'd get different value ranges from each of the Space Navigators. Perhaps also one reports relative and the other reports absolute?

I could also test it on a few other 3DMouse models, it would be nice to have more 3DConnexion devices on the list.
http://guavaman.com/projects/rewired/do ... llers.html

I suppose 'report' means how to interpret the data. So while the raw data might be absolute, Direct Input might see the relative flag report and interpret those as relative?

https://www.3dconnexion.com/forum/viewtopic.php?t=3307
"(2) it DOES not report its axis to be absolute
It does not and that's unfortunate. When the first 3D mice with USB were developed, not all platforms (Windows, Mac, Linux) had the same support for the HID standard. The "mis-reporting" of relative/absolute is a legacy of that time."
Augie
Posts: 18
Joined: Wed Oct 22, 2014 2:04 pm

Re: Direct Input axis format

Post by Augie »

Hypersonic wrote: Wed Jun 27, 2018 11:08 pm Sorry, I must have missed the 'my' in front of 'rewired input plugin for unity' link!

I just figured that Overload solely relied on Rewired by looking at the version update, I see now that I was mistaken. I'm surprised that the 3DMouse worked in the first release version, maybe via Direct Input.

I've read that early 3DMice (perhaps some Space Navigators) reported in USB HID as relative instead of absolute and perhaps that carries over to Direct Input?
:D

I think that's correct. Linux reports them relative and Direct Input seems to also.
Augie
Posts: 18
Joined: Wed Oct 22, 2014 2:04 pm

Re: Direct Input axis format

Post by Augie »

Hypersonic wrote: Thu Jun 28, 2018 10:08 am I have 2 different Space Navigators (different firmwares.) Do you have a test program for rewired I could try, that shows direct input readings you get from the controllers? I remember in Chrome before they fixed it, I'd get different value ranges from each of the Space Navigators. Perhaps also one reports relative and the other reports absolute?

I could also test it on a few other 3DMouse models, it would be nice to have more 3DConnexion devices on the list.
http://guavaman.com/projects/rewired/do ... llers.html

I suppose 'report' means how to interpret the data. So while the raw data might be absolute, Direct Input might see the relative flag report and interpret those as relative?

https://www.3dconnexion.com/forum/viewtopic.php?t=3307
"(2) it DOES not report its axis to be absolute
It does not and that's unfortunate. When the first 3D mice with USB were developed, not all platforms (Windows, Mac, Linux) had the same support for the HID standard. The "mis-reporting" of relative/absolute is a legacy of that time."
That would be great to add support for more 3Dconnexion devices.

Do you use Unity? If so, it would be a little easier. If not, I can make a build for you that you can run. If you do use Unity, you can get the free trial of Rewired here.

Just open the Rewired/DevTools/JoystickElementIdentifier scene.
To test Raw Input, press Play.
To test Direct Input, click the Rewired Input Manager in the hierarchy and press the big button on the inspector.
Go to Settings -> Windows and change Primary Input Source to Direct Input.
Then press Play.

You will see information displayed on the left side of the screen about the devices Rewired sees. Axis values will change as you manipulate them. If multiple devices are connected (the KJM emulated device on raw input will), press +/- on the keyboard to cycle through the active device.
Augie
Posts: 18
Joined: Wed Oct 22, 2014 2:04 pm

Re: Direct Input axis format

Post by Augie »

If Direct Input is showing you values that accumulate over time and do not reset to zero when the control knob is released, then the axes are returning relative values.

I thought it would make it easier for you if I just made you builds:
https://www.dropbox.com/s/8z3xt85x99k6g ... 4.zip?dl=0
https://www.dropbox.com/s/xuqp9u9q8lgx6 ... 4.zip?dl=0

I can do Linux and OSX too if you want those.
Hypersonic
Posts: 265
Joined: Mon Jul 12, 2010 5:58 pm

Re: Direct Input axis format

Post by Hypersonic »

I should use Unity, it appears to be a popular engine for games these days, along with the Unreal engine. Are these Unity downloads on a trial period?
https://unity3d.com/get-unity/download/archive

Thanks, I'll try out the builds on the various 3DMice I have and see if I get different results.

I got raw from the old Space Navigator, but not DI.
I got raw from the new Space Navigator, and DI (the accumulative slider type, like in Aquanox2.)
I got raw from the Space Explorer, but not DI. (However the SpaceExplorer worked fine in Overload.)
I think I got raw from SpacePilotPro, but I couldn't even get that to work in Overload. (maybe wrong vendor/product id in my XML?)
Augie
Posts: 18
Joined: Wed Oct 22, 2014 2:04 pm

Re: Direct Input axis format

Post by Augie »

Hypersonic wrote: Thu Jun 28, 2018 11:23 pm I should use Unity, it appears to be a popular engine for games these days, along with the Unreal engine. Are these Unity downloads on a trial period?
https://unity3d.com/get-unity/download/archive
You can use Unity totally free if you earn less than $100,000/yr.
Hypersonic wrote: Thu Jun 28, 2018 11:23 pmI got raw from the old Space Navigator, but not DI.
Did the device not appear or did it just return no value?
Hypersonic wrote: Thu Jun 28, 2018 11:23 pmI got raw from the new Space Navigator, and DI (the accumulative slider type, like in Aquanox2.)
This is the Space Navigator I have and the one I added support for in Rewired. I had to convert the relative values in DI to absolute.
Hypersonic wrote: Thu Jun 28, 2018 11:23 pmI got raw from the Space Explorer, but not DI. (However the SpaceExplorer worked fine in Overload.)
That confirms what I thought. Overload implemented 3Dconnexion support using the SDK, not Raw/Direct Input. That would be a possible next step for me if I ever get time.
Hypersonic wrote: Thu Jun 28, 2018 11:23 pmI think I got raw from SpacePilotPro, but I couldn't even get that to work in Overload. (maybe wrong vendor/product id in my XML?)
Interesting... I would think the Space Pilot Pro would work with the SDK.

If you're interested in me adding these devices to Rewired, I'll need to get certain information from you about each device in each mode. It would probably be best handled via email and not here. If you want to do it, you can contact me here: http://guavaman.com/rewired#support. Just use the Pre-Sales option because it has way fewer questions. Thanks!
Augie
Posts: 18
Joined: Wed Oct 22, 2014 2:04 pm

Re: Direct Input axis format

Post by Augie »

ngomes wrote: Tue Jun 26, 2018 7:28 am Hi Augie,

How are you configuring the device? Can you perhaps share a small code snippet?

As far as I can tell, using IDirectInputDevice8::EnumObjects with the DIDFT_AXIS flag ought to ensure the data is absolute.

That still leaves with problem of detecting when the user has released the device sensor cap. What we normally do (in the cases where the "all zero" data packet is filtered out) is to set a timer. The timer can be set for about 2x to 4x the normal time interval between device data (about 17ms for USB device types). The timer must be reset whenever a data packet is received. The delay introduce (normally well under 100ms) is not perceived by the end-user.
Since it appears my previous response got lost in the moderator queue ether, I'll re-respond to this just for the sake of the thread.

EnumObjects is called with DIDFT_ALL. All objects are returned. IDirectInputDevice8::SetProperty is used to set the device to absolute axis mode using DIPROP_AXISMODE and setting the value to DIPROPAXISMODE_ABS.

I came to the conclusion that using a timer would be the only way possible to handle this while I was puzzling out how to convert these values, but I didn't know whether the required timing would be fixed or if it could vary system to system or based on some other OS settings. I tried out a 34ms timer and it seems to work perfectly well on both Linux and Direct Input. Thanks for that, it really helped!
Post Reply