How can I read spacenavigator data in C#

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

Moderator: Moderators

Post Reply
lrozenbe
Posts: 5
Joined: Wed Jan 19, 2011 2:29 am

How can I read spacenavigator data in C#

Post by lrozenbe »

Hello to all
I am working on windows7 64bit and I have a C# application that needs to read data from the spacenavigator.
Does any one have sample of C# code that reads the raw data?

Thank u in advance

Liora Rozenberg
ngomes
Moderator
Moderator
Posts: 3334
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Post by ngomes »

Please refer to the Raw Input API in C# topic.
lrozenbe
Posts: 5
Joined: Wed Jan 19, 2011 2:29 am

c# example for reading the spacenavigator raw data

Post by lrozenbe »

thank u for your reply.
I have already seen this article and even run the example on my comuter and when I touch the spacenavigator i succeeded to stop with breakpoint but how can i retrive the data?
I undestand that the data will come in the RAWHID struct but it contain only dwSizHid and dwCount
what structure should I add to the RAWHID struct so i could see the data ?

thank u for your replay
Liora
ngomes
Moderator
Moderator
Posts: 3334
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Post by ngomes »

You can find the code in the S3DM SDK sample used to decode the Raw Input packets. Refer to method CRawInputImplT::TranslateRawInputData() in the rawinput.hpp file.

You can download the SDK from the Software Developer page.
lrozenbe
Posts: 5
Joined: Wed Jan 19, 2011 2:29 am

Success

Post by lrozenbe »

Thank u very much :lol:
bamshad
Posts: 1
Joined: Fri Nov 23, 2012 2:50 pm

Re: How can I read spacenavigator data in C#

Post by bamshad »

Hi

I have the same problem in c#. Now I can read the raw data which is like "Data: 001 000 000 000 000 249 255 ". How can I translate that in C#? I couldn't find it in SDK. would you please give me more detail about it?

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

Re: How can I read spacenavigator data in C#

Post by jwick »

bamshad wrote:Hi

I have the same problem in c#. Now I can read the raw data which is like "Data: 001 000 000 000 000 249 255 ". How can I translate that in C#? I couldn't find it in SDK. would you please give me more detail about it?

Regards
Bamshad
001 indicates a translation vector. The next 6 bytes are the components in little-endian order. Combine them as such:

Code: Select all

public TranslationVector(byte xl, byte xh, byte yl, byte yh, byte zl, byte zh)
{
        this.x = (int)(xl + (System.Int16)((System.Int16)xh << 8));
        this.y = (int)(yl + (System.Int16)((System.Int16)yh << 8));
        this.z = (int)(zl + (System.Int16)((System.Int16)zh << 8));
}
002 indicates a rotation vector.

There is a WPF sample on our ftp site that shows how to do this: see this thread
devdev
Posts: 4
Joined: Mon Oct 15, 2012 7:27 am

Re: How can I read spacenavigator data in C#

Post by devdev »

Am I right with the assumption that the Data Above is a translation with 7 units against the Z-Axis?
jwick
Moderator
Moderator
Posts: 3340
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: How can I read spacenavigator data in C#

Post by jwick »

devdev wrote:Am I right with the assumption that the Data Above is a translation with 7 units against the Z-Axis?
That looks right to me. It is a signed two's complement number.
Post Reply