Not receiving rotation data

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

Moderator: Moderators

Post Reply
LeifB
Posts: 8
Joined: Fri Jan 16, 2015 8:53 am

Not receiving rotation data

Post by LeifB » Fri Jan 16, 2015 9:32 am

Hi all,

First post with hopefully a simple question.

I'm resurrecting an internal application with 3DConnexion support that my company wrote ~2010, and adapting it to work with a SpaceMouse Wireless (previously it was a SpaceNavigator, I think).

It's working fine except that I never receive any rotation data, and I occasionally get a weird response (see below). Here's the code, basically straight from the SDK examples:

Code: Select all

          
            if (sRidDeviceInfo.hid.dwVendorId == LOGITECH_VENDOR_ID)    // I changed this from 0x046D to 0x256F, as found here on the forums 
            {
                // Motion data comes in two packages
                // Orientation is a right handed coordinate system with Z down;
                // this is the standard HID orientation
                if (pRawInput->data.hid.bRawData[0] == 0x01)     // This works fine
                {
                    // Translation vector
                    short* pnData = reinterpret_cast<short*>(&pRawInput->data.hid.bRawData[1]);    
                    m_x = pnData[0];
                    m_y = pnData[1];
                    m_z = pnData[2];
                }
                else if (pRawInput->data.hid.bRawData[0] == 0x02)   // I never get this!
                {
                    // Directed rotation vector (NOT Euler)
                    short* pnData = reinterpret_cast<short*>(&pRawInput->data.hid.bRawData[1]);
                    m_rx = pnData[0];
                    m_ry = pnData[1];
                    m_rz = pnData[2];
                }
                else if (pRawInput->data.hid.bRawData[0] == 0x03)   // This also works fine.
                {
                    // State of the keys
                    unsigned long dwKeystate = *reinterpret_cast<unsigned long *>(&pRawInput->data.hid.bRawData[1]);
                    m_key1 = (dwKeystate & 1) == 1;
                    m_key2 = (dwKeystate & 2) == 1;
                }
		           else
				{
					char msg[100];
					sprintf(msg, "Unknown value in data.hid.bRawData received: %d", pRawInput->data.hid.bRawData[0]);
					MessageBoxA(NULL, msg, "Error!", MB_ICONERROR | MB_TASKMODAL);			
				}
            }
So I get Translation and Button events just fine, but no Rotation. I did check in the 3DConnexion profile for my app under Advanced Settings that Rotation was selected (it wwasn't at first), but it doesn't seem to have made a difference. What else should I check/change?

Also, note my error case at the end. I occasionally get a single byte in bRawData, the value 0x17 (23 decimal). I can filter it out, but what causes it?

Thanks!

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

Re: Not receiving rotation data

Post by jwick » Fri Jan 16, 2015 9:46 am

The new devices send all 6 axes in the translation packet (Tx, Ty, Tz, Rx, Ry, Rz). Check the length of the event data. I can send you a new code sample if you want.

LeifB
Posts: 8
Joined: Fri Jan 16, 2015 8:53 am

Re: Not receiving rotation data

Post by LeifB » Fri Jan 16, 2015 9:56 am

Oh, indeed it does. That was easy, thanks. Thanks for the super quick reply. Any thoughts on the random 0x17s?

Code: Select all

       if (pRawInput->data.hid.bRawData[0] == 0x01)
                {
                    // Translation vector
                    short* pnData = reinterpret_cast<short*>(&pRawInput->data.hid.bRawData[1]);
                    m_x = pnData[0];
                    m_y = pnData[1];
                    m_z = pnData[2];

                    // Rotation vector
                    m_rx = pnData[3];
                    m_ry = pnData[4];
                    m_rz = pnData[5];
                }

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

Re: Not receiving rotation data

Post by jwick » Mon Jan 19, 2015 1:13 am

That code probably won't work on an older device that sends T and R separately.
You can check (HIDP_CAPS).InputReportByteLength >= 13 to find the long packet.

You can ignore all packets you don't use.
0x17 happens to be the battery level packet.

LeifB
Posts: 8
Joined: Fri Jan 16, 2015 8:53 am

Re: Not receiving rotation data

Post by LeifB » Mon Jan 19, 2015 8:27 am

Noted. We're only using this in-house anyway, but that's a good tip re. the length, thanks.

Are the packets defined anywhere? I filled out the form on your site regarding the updated SDK, but have received nada so far.

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

Re: Not receiving rotation data

Post by jwick » Wed Jan 21, 2015 1:17 am

LeifB, your developer account should have been approved. I don't know if we send out any sort of notice.

LeifB
Posts: 8
Joined: Fri Jan 16, 2015 8:53 am

Re: Not receiving rotation data

Post by LeifB » Wed Jan 21, 2015 11:02 am

Yes, I got a notification email soon after posting my message. Someone here must have been reading :wink:

I am up and running with our application now, by the way. Thanks again.

Post Reply