1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0031632: Draw Harness - handle 3d mouse Raw HID input on Windows

WNT_HIDSpaceMouse - added auxiliary class for processing 3d mouse Raw HID input.
AIS_ViewController::Update3dMouse() - added default processor for 3d mouse input event.
ViewerTest now redirects WM_INPUT to AIS_ViewController::Update3dMouse().
Aspect_VKey enumeration has been extended by 3D view buttons.
WNT_Window::RegisterRawInputDevices() has beend added as a small wrapper
over WinAPI RegisterRawInputDevices() for common HID input devices.

AIS_ViewCube now stores animation duration within AIS_AnimationCamera instead of dedicated duplicating class property.
This commit is contained in:
kgv
2020-06-26 09:58:50 +03:00
committed by bugmaster
parent 79e9ba31d2
commit d6fbb2aba4
15 changed files with 1054 additions and 143 deletions

View File

@@ -35,6 +35,7 @@ IMPLEMENT_STANDARD_RTTIEXT(ViewerTest_EventManager,Standard_Transient)
const Handle(AIS_AnimationCamera)& ViewerTest_EventManager::GlobalViewAnimation()
{
static Handle(AIS_AnimationCamera) THE_CAMERA_ANIM = new AIS_AnimationCamera ("ViewerTest_EventManager_ViewAnimation", Handle(V3d_View)());
THE_CAMERA_ANIM->SetOwnDuration (0.5);
return THE_CAMERA_ANIM;
}

View File

@@ -55,6 +55,7 @@
#include <Message_ProgressSentry.hxx>
#include <NCollection_DataMap.hxx>
#include <NCollection_List.hxx>
#include <NCollection_LocalArray.hxx>
#include <NCollection_Vector.hxx>
#include <OSD.hxx>
#include <OSD_Timer.hxx>
@@ -89,6 +90,7 @@
#if defined(_WIN32)
#include <WNT_WClass.hxx>
#include <WNT_Window.hxx>
#include <WNT_HIDSpaceMouse.hxx>
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
#include <Cocoa_Window.hxx>
#else
@@ -1831,6 +1833,7 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
aPxLeft, aPxTop,
aPxWidth, aPxHeight,
Quantity_NOC_BLACK);
VT_GetWindow()->RegisterRawInputDevices (WNT_Window::RawInputMask_SpaceMouse);
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
VT_GetWindow() = new Cocoa_Window (aTitle.ToCString(),
aPxLeft, aPxTop,
@@ -3258,6 +3261,40 @@ static LRESULT WINAPI ViewerWindowProc (HWND theWinHandle,
ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), aView, true);
break;
}
case WM_INPUT:
{
UINT aSize = 0;
::GetRawInputData ((HRAWINPUT )lParam, RID_INPUT, NULL, &aSize, sizeof(RAWINPUTHEADER));
NCollection_LocalArray<BYTE> aRawData (aSize);
if (aSize == 0 || ::GetRawInputData ((HRAWINPUT )lParam, 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)
|| (aDevInfo.hid.dwVendorId != WNT_HIDSpaceMouse::VENDOR_ID_LOGITECH
&& aDevInfo.hid.dwVendorId != WNT_HIDSpaceMouse::VENDOR_ID_3DCONNEXION))
{
break;
}
WNT_HIDSpaceMouse aSpaceData (aDevInfo.hid.dwProductId, aRawInput->data.hid.bRawData, aRawInput->data.hid.dwSizeHid);
if (ViewerTest::CurrentEventManager()->Update3dMouse (aSpaceData)
&& !VT_GetWindow().IsNull())
{
VT_GetWindow()->InvalidateContent();
}
break;
}
default:
{
return DefWindowProcW (theWinHandle, theMsg, wParam, lParam);