bool ConnexionClient::RawInputEventFilter(void* msg, long* result) { ConnexionData& connexiondata = ConnexionData::getInstance(); auto userInputMapper = DependencyManager::get<UserInputMapper>(); if (Is3dmouseAttached() && connexiondata.getDeviceID() == 0) { connexiondata.registerToUserInputMapper(*userInputMapper); connexiondata.assignDefaultInputMapping(*userInputMapper); UserActivityLogger::getInstance().connectedDevice("controller", "3Dconnexion"); } else if (!Is3dmouseAttached() && connexiondata.getDeviceID() != 0) { int deviceid = connexiondata.getDeviceID(); connexiondata.setDeviceID(0); userInputMapper->removeDevice(deviceid); } if (!Is3dmouseAttached()) { return false; } MSG* message = (MSG*)(msg); if (message->message == WM_INPUT) { HRAWINPUT hRawInput = reinterpret_cast<HRAWINPUT>(message->lParam); OnRawInput(RIM_INPUT, hRawInput); if (result != 0) { result = 0; } return true; } return false; }
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INPUT: OnRawInput( GET_RAWINPUT_CODE_WPARAM(wParam) == RIM_INPUT, (HRAWINPUT)lParam ); return(DefWindowProc(hWnd, msg, wParam, lParam)); case WM_MOUSEWHEEL: OutputDebugString(_T("WM_MOUSEWHEEL\n")); TCHAR buffer[1024]; memset(buffer, NULL, 1024); _stprintf_s(buffer, 1024, _T(" wheel delta=%d\n"), GET_WHEEL_DELTA_WPARAM(wParam)); OutputDebugString(buffer); break; // Windows XP までは tilt は専用ドライバによってWM_HSCROLLを発行している場合が多いらしい case WM_HSCROLL: OutputDebugString(_T("WM_HSCROLL\n")); break; // Windows Vista からは tilt は WM_MOUSEHWHEEL で検出できるらしい case WM_MOUSEHWHEEL: OutputDebugString(_T("WM_MOUSEHWHEEL\n")); break; case WM_CREATE: device.usUsagePage = 0x01; device.usUsage = 0x02; device.dwFlags = 0; device.hwndTarget = 0; RegisterRawInputDevices(&device, 1, sizeof device); break; case WM_DESTROY: device.usUsagePage = 0x01; device.usUsage = 0x02; device.dwFlags = RIDEV_REMOVE; device.hwndTarget = 0; RegisterRawInputDevices(&device, 1, sizeof device); PostQuitMessage(0); break; default: return(DefWindowProc(hWnd, msg, wParam, lParam)); } return (0L); }