Wrapper over Space Mouse data chunk within WM_INPUT event (known also as Raw Input in WinAPI). This class predefines specific list of supported devices, which does not depend on 3rdparty library provided by mouse vendor. Supported input chunks:
More...
Wrapper over Space Mouse data chunk within WM_INPUT event (known also as Raw Input in WinAPI). This class predefines specific list of supported devices, which does not depend on 3rdparty library provided by mouse vendor. Supported input chunks:
- Rotation (3 directions);
- Translation (3 directions);
- Pressed buttons.
To use the class, register Raw Input device:
RAWINPUTDEVICE aRawInDevList[1];
RAWINPUTDEVICE& aRawSpace = aRawInDevList[0];
aRawSpace.usUsagePage = HID_USAGE_PAGE_GENERIC;
aRawSpace.usUsage = HID_USAGE_GENERIC_MULTI_AXIS_CONTROLLER;
aRawSpace.dwFlags = 0;
aRawSpace.hwndTarget = (HWND )theWindow->NativeHandle();
if (!::RegisterRawInputDevices (aRawInDevList, 1, sizeof(aRawInDevList[0]))) { Error; }
Then handle WM_INPUT events within window message loop.
case WM_INPUT:
{
UINT aSize = 0;
::GetRawInputData ((HRAWINPUT )theLParam, RID_INPUT, NULL, &aSize, sizeof(RAWINPUTHEADER));
if (aSize == 0 || ::GetRawInputData ((HRAWINPUT )theLParam, RID_INPUT, aRawData, &aSize, sizeof(RAWINPUTHEADER)) != aSize)
{
break;
}
const RAWINPUT* aRawInput = (RAWINPUT* )(BYTE* )aRawData;
if (aRawInput->header.dwType != RIM_TYPEHID)
{
break;
}
RID_DEVICE_INFO aDevInfo; aDevInfo.cbSize = sizeof(RID_DEVICE_INFO);
UINT aDevInfoSize = sizeof(RID_DEVICE_INFO);
if (::GetRawInputDeviceInfoW (aRawInput->header.hDevice, RIDI_DEVICEINFO, &aDevInfo, &aDevInfoSize) != sizeof(RID_DEVICE_INFO)
{
break;
}
const double aTimeStamp = theViewCtrl.
EventTime();
WNT_HIDSpaceMouse aSpaceData (aDevInfo.hid.dwProductId, aRawInput->data.hid.bRawData, aRawInput->data.hid.dwSizeHid);
if (aSpaceData.IsTranslation())
{
bool isIdle = true, isQuadric = true;
}
if (aSpaceData.IsRotation()) {}
if (aSpaceData.IsKeyState()) {}
break;
}