diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2021-02-01 22:12:13 +0200 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2021-02-01 22:28:15 +0200 |
commit | 609a26b59a82bb8dfa5722b5f8ea6c42014360d2 (patch) | |
tree | 6a362b94a06ced7a8b063d7e5c86ce751800c2b3 /indra/llwindow | |
parent | eac0f1857c6e8e89be649b60dcd8dca7573933df (diff) | |
parent | 21565a1f3fe1ae737e2f91c58be2c3cb0b5a2fec (diff) |
Merge branch 'master' of https://bitbucket.org/lindenlab/viewer/src/master into DRTVWR-515-maint
# Conflicts:
# autobuild.xml (llca)
# indra/llwindow/llwindow.h (SL-13507 vs SL-5894)
# indra/newview/llscenemonitor.cpp (SL-14422)
# indra/newview/llvovolume.cpp (SL-12069)
Diffstat (limited to 'indra/llwindow')
-rw-r--r-- | indra/llwindow/llwindow.h | 3 | ||||
-rw-r--r-- | indra/llwindow/llwindowwin32.cpp | 41 | ||||
-rw-r--r-- | indra/llwindow/llwindowwin32.h | 3 |
3 files changed, 47 insertions, 0 deletions
diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index bb4e534b60..d4d5b76937 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -171,6 +171,9 @@ public: static std::vector<std::string> getDisplaysResolutionList(); + // windows only DirectInput8 for joysticks + virtual void* getDirectInput8() { return NULL; }; + virtual bool getInputDevices(U32 device_type_filter, void * devices_callback, void* userdata) { return false; }; protected: LLWindow(LLWindowCallbacks* callbacks, BOOL fullscreen, U32 flags); virtual ~LLWindow(); diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 36148190fa..f774cd0d31 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -60,6 +60,9 @@ #include <dinput.h> #include <Dbt.h.> +#include <InitGuid.h> // needed for llurlentry test to build on some systems +#pragma comment(lib, "dxguid.lib") // needed for llurlentry test to build on some systems +#pragma comment(lib, "dinput8") const S32 MAX_MESSAGE_PER_UPDATE = 20; const S32 BITS_PER_PIXEL = 32; @@ -77,6 +80,7 @@ const F32 ICON_FLASH_TIME = 0.5f; extern BOOL gDebugWindowProc; LPWSTR gIconResource = IDI_APPLICATION; +LPDIRECTINPUT8 gDirectInput8; LLW32MsgCallback gAsyncMsgCallback = NULL; @@ -533,6 +537,21 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks, mhInstance = GetModuleHandle(NULL); mWndProc = NULL; + // Init Direct Input - needed for joystick / Spacemouse + + LPDIRECTINPUT8 di8_interface; + HRESULT status = DirectInput8Create( + mhInstance, // HINSTANCE hinst, + DIRECTINPUT_VERSION, // DWORD dwVersion, + IID_IDirectInput8, // REFIID riidltf, + (LPVOID*)&di8_interface, // LPVOID * ppvOut, + NULL // LPUNKNOWN punkOuter + ); + if (status == DI_OK) + { + gDirectInput8 = di8_interface; + } + mSwapMethod = SWAP_METHOD_UNDEFINED; // No WPARAM yet. @@ -4249,6 +4268,28 @@ void LLWindowWin32::setDPIAwareness() } } +void* LLWindowWin32::getDirectInput8() +{ + return &gDirectInput8; +} + +bool LLWindowWin32::getInputDevices(U32 device_type_filter, void * di8_devices_callback, void* userdata) +{ + if (gDirectInput8 != NULL) + { + // Enumerate devices + HRESULT status = gDirectInput8->EnumDevices( + (DWORD) device_type_filter, // DWORD dwDevType, + (LPDIENUMDEVICESCALLBACK)di8_devices_callback, // LPDIENUMDEVICESCALLBACK lpCallback, // BOOL DIEnumDevicesCallback( LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef ) // BOOL CALLBACK DinputDevice::DevicesCallback + (LPVOID*)userdata, // LPVOID pvRef + DIEDFL_ATTACHEDONLY // DWORD dwFlags + ); + + return status == DI_OK; + } + return false; +} + F32 LLWindowWin32::getSystemUISize() { F32 scale_value = 1.f; diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index b1e8350a78..0b3d14fb16 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -117,6 +117,9 @@ public: static std::vector<std::string> getDisplaysResolutionList(); static std::vector<std::string> getDynamicFallbackFontList(); static void setDPIAwareness(); + + /*virtual*/ void* getDirectInput8(); + /*virtual*/ bool getInputDevices(U32 device_type_filter, void * di8_devices_callback, void* userdata); protected: LLWindowWin32(LLWindowCallbacks* callbacks, const std::string& title, const std::string& name, int x, int y, int width, int height, U32 flags, |