diff options
Diffstat (limited to 'dinput/dinput.hpp')
-rw-r--r-- | dinput/dinput.hpp | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/dinput/dinput.hpp b/dinput/dinput.hpp index fc73a90a..09c9a30b 100644 --- a/dinput/dinput.hpp +++ b/dinput/dinput.hpp @@ -8,44 +8,48 @@ #pragma once +#include <QMutex> + #include "export.hpp" #undef DIRECTINPUT_VERSION #define DIRECTINPUT_VERSION 0x800 -#include <dinput.h> -#include <atomic> -class OTR_DINPUT_EXPORT dinput_handle final +struct IDirectInputDevice8A; +typedef struct IDirectInputDevice8A IDirectInputDevice8A; +struct IDirectInput8A; +typedef struct IDirectInput8A IDirectInput8A; +struct _GUID; +typedef struct _GUID GUID; +struct _DIDATAFORMAT; +typedef struct _DIDATAFORMAT DIDATAFORMAT; +typedef int BOOL; +struct DIDEVICEINSTANCEA; +typedef struct DIDEVICEINSTANCEA DIDEVICEINSTANCEA; +struct DIDEVICEOBJECTINSTANCEA; +typedef struct DIDEVICEOBJECTINSTANCEA DIDEVICEOBJECTINSTANCEA; + +// XXX TODO -sh 20190209 +// keybinding_worker and joystick context are badly named +// add namespaces and rename, including inner joystick device struct + +using diptr = IDirectInput8A*; + +class OTR_DINPUT_EXPORT di_t final { + static diptr handle; + static QMutex lock; + static diptr init_di_(); + static diptr init_di(); + public: - class di_t; + di_t(); + di_t(const di_t&) : di_t() {} + di_t& operator=(const di_t&) = default; -private: - static std::atomic<int> refcnt; - static std::atomic_flag init_lock; + diptr operator->() const; + operator bool() const; + operator diptr() const; - static LPDIRECTINPUT8& init_di(); -public: - class di_t final - { - friend class dinput_handle; - - LPDIRECTINPUT8* handle; - - di_t(LPDIRECTINPUT8& handle); - void free_di(); - void unref_di(); - void ref_di(); - - public: - LPDIRECTINPUT8 operator->() { return *handle; } - operator LPDIRECTINPUT8() { return *handle; } - LPDIRECTINPUT8 di() { return *handle; } - di_t& operator=(const di_t& new_di); - di_t(); - ~di_t(); - }; - - static di_t make_di(); - dinput_handle() = delete; + static bool poll_device(IDirectInputDevice8A* dev); }; |