summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/input/input_xinput.h
blob: fa36b7a2622b48200e404aa74727867d2f2a38e1 (plain) (blame)
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
// license:BSD-3-Clause
// copyright-holders:Brad Hughes, Vas Crabb
#ifndef MAME_OSD_INPUT_INPUT_XINPUT_H
#define MAME_OSD_INPUT_INPUT_XINPUT_H

#pragma once

#include "input_common.h"

#include "modules/lib/osdlib.h"

#include <memory>

#include <windows.h>
#include <xinput.h>


namespace osd {

class xinput_api_helper
{
public:
	xinput_api_helper() { }

	int initialize();

	std::unique_ptr<device_info> create_xinput_device(UINT index, input_module_base &module);

	DWORD xinput_get_state(DWORD dwUserindex, XINPUT_STATE *pState) const
	{
		return (*XInputGetState)(dwUserindex, pState);
	}

	DWORD xinput_get_capabilities(DWORD dwUserindex, DWORD dwFlags, XINPUT_CAPABILITIES* pCapabilities) const
	{
		return (*XInputGetCapabilities)(dwUserindex, dwFlags, pCapabilities);
	}

private:
	// Typedefs for dynamically loaded functions
	typedef DWORD (WINAPI *xinput_get_state_fn)(DWORD, XINPUT_STATE *);
	typedef DWORD (WINAPI *xinput_get_caps_fn)(DWORD, DWORD, XINPUT_CAPABILITIES *);

	dynamic_module::ptr m_xinput_dll = nullptr;
	xinput_get_state_fn XInputGetState = nullptr;
	xinput_get_caps_fn  XInputGetCapabilities = nullptr;
};

} // namespace osd

#endif // MAME_OSD_INPUT_INPUT_XINPUT_H