summaryrefslogtreecommitdiffhomepage
path: root/dinput/dinput.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'dinput/dinput.hpp')
-rw-r--r--dinput/dinput.hpp54
1 files changed, 27 insertions, 27 deletions
diff --git a/dinput/dinput.hpp b/dinput/dinput.hpp
index fc73a90a..4806a992 100644
--- a/dinput/dinput.hpp
+++ b/dinput/dinput.hpp
@@ -10,42 +10,42 @@
#include "export.hpp"
+#include <atomic>
+
#undef DIRECTINPUT_VERSION
#define DIRECTINPUT_VERSION 0x800
+
#include <dinput.h>
-#include <atomic>
-class OTR_DINPUT_EXPORT dinput_handle final
+using diptr = IDirectInput8A*;
+
+class OTR_DINPUT_EXPORT di_t final
{
-public:
- class di_t;
+ static void unref_di();
+ static void ref_di();
-private:
+ static diptr handle;
static std::atomic<int> refcnt;
static std::atomic_flag init_lock;
+ static diptr init_di_();
- static LPDIRECTINPUT8& init_di();
public:
- class di_t final
+ di_t();
+ ~di_t();
+ di_t(const di_t&) : di_t() {}
+ di_t& operator=(const di_t&) { return *this; }
+
+ diptr operator->() const { return handle; }
+ operator bool() { return handle; }
+
+ // for debugging bad usages
+ template<typename t = void>
+ operator void*() const
{
- 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_assert(sizeof(t) == -1);
+ static_assert(sizeof(t) == 0);
+
+ return nullptr;
+ }
};
+