summaryrefslogtreecommitdiffhomepage
path: root/dinput/dinput.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-06-26 22:26:07 +0200
committerStanislaw Halik <sthalik@misaki.pl>2018-06-26 23:05:21 +0200
commit1cfafd9df6e334ac436cc4ffd78de6341b9caa42 (patch)
tree7a7ba14607c9a9df2f4626afa6fda90bf1988f57 /dinput/dinput.hpp
parentd65936200a2756e6619a109fa6fa673b91df802e (diff)
dinput: simplify di_t
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;
+ }
};
+