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);
}
}
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!