summaryrefslogtreecommitdiffhomepage
path: root/dinput/dinput.hpp
blob: 09c9a30b13cc126ba7bf503138a80e68c5aee19d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* Copyright (c) 2016, Stanislaw Halik <sthalik@misaki.pl>

 * Permission to use, copy, modify, and/or distribute this
 * software for any purpose with or without fee is hereby granted,
 * provided that the above copyright notice and this permission
 * notice appear in all copies.
 */

#pragma once

#include <QMutex>

#include "export.hpp"

#undef DIRECTINPUT_VERSION
#define DIRECTINPUT_VERSION 0x800

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:
    di_t();
    di_t(const di_t&) : di_t() {}
    di_t& operator=(const di_t&) = default;

    diptr operator->() const;
    operator bool() const;
    operator diptr() const;

    static bool poll_device(IDirectInputDevice8A* dev);
};