summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/interface/inputman.h
blob: 223c9a6926d892cc175bcab5ca424f9f96345d5c (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
/***************************************************************************

    inputman.h

    OSD interface to the input manager.

***************************************************************************/
#ifndef MAME_OSD_INTERFACE_INPUTMAN_H
#define MAME_OSD_INTERFACE_INPUTMAN_H

#pragma once

#include "inputcode.h"

#include <string_view>


namespace osd {

//**************************************************************************
//  CONSTANTS
//**************************************************************************

// relative devices return ~512 units per on-screen pixel
constexpr s32 INPUT_RELATIVE_PER_PIXEL = 512;

// absolute devices return values between -65536 and +65536
constexpr s32 INPUT_ABSOLUTE_MIN = -65'536;
constexpr s32 INPUT_ABSOLUTE_MAX = 65'536;

// invalid memory value for axis polling
constexpr s32 INVALID_AXIS_VALUE = 0x7fff'ffff;



//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************

// base for application representation of host input device

class input_device
{
public:
	// callback for getting the value of an individual input on a device
	typedef s32 (*item_get_state_func)(void *device_internal, void *item_internal);

	virtual ~input_device() = default;

	virtual input_item_id add_item(
			std::string_view name,
			input_item_id itemid,
			item_get_state_func getstate,
			void *internal = nullptr) = 0;
};


// base for application input manager

class input_manager
{
public:
	virtual ~input_manager() = default;

	virtual input_device &add_device(
			input_device_class devclass,
			std::string_view name,
			std::string_view id,
			void *internal = nullptr) = 0;
};


} // namespace osd

#endif // MAME_OSD_INTERFACE_INPUTMAN_H