4 #ifndef SWIFT_INPUT_JOYSTICKWINDOWS_H
5 #define SWIFT_INPUT_JOYSTICKWINDOWS_H
24 namespace swift::input
44 QObject *parent =
nullptr);
47 bool init(HWND helperWindow);
64 virtual void timerEvent(QTimerEvent *event)
override;
69 struct DirectInputDevice8Deleter
71 void operator()(IDirectInputDevice8 *obj)
81 using DirectInputDevice8Ptr = std::unique_ptr<IDirectInputDevice8, DirectInputDevice8Deleter>;
84 HRESULT pollDeviceState();
87 static QString hrString(HRESULT hr);
90 static BOOL CALLBACK enumObjectsCallback(
const DIDEVICEOBJECTINSTANCE *dev, LPVOID pvRef);
95 QString m_productName;
96 DirectInput8Ptr m_directInput;
97 DirectInputDevice8Ptr m_directInputDevice;
98 QVector<CJoystickDeviceInput> m_joystickDeviceInputs;
102 bool operator==(CJoystickDevice
const &lhs, CJoystickDevice
const &rhs);
129 HRESULT initDirectInput();
132 HRESULT enumJoystickDevices();
135 int createHelperWindow();
139 void requestDeviceNotification();
142 void destroyHelperWindow();
145 void addJoystickDevice(
const DIDEVICEINSTANCE *pdidInstance);
148 void removeJoystickDevice(
const GUID &guid);
151 bool isJoystickAlreadyAdded(
const DIDEVICEINSTANCE *pdidInstance)
const;
155 static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
158 static BOOL CALLBACK enumJoysticksCallback(
const DIDEVICEINSTANCE *pdidInstance, VOID *pContext);
160 HWND helperWindow =
nullptr;
161 HDEVNOTIFY hDevNotify =
nullptr;
163 const TCHAR *helperWindowClassName = TEXT(
"HelperWindow");
164 const TCHAR *helperWindowName = TEXT(
"JoystickCatcherWindow");
166 bool m_coInitializeSucceeded =
false;
168 QVector<CJoystickDevice *> m_joystickDevices;
std::shared_ptr< IDirectInput8 > DirectInput8Ptr
Shared IDirectInput8 ptr.