summaryrefslogtreecommitdiff
path: root/src/input_common/main.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/main.h')
-rw-r--r--src/input_common/main.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/input_common/main.h b/src/input_common/main.h
index 5604f0fa8..77a0ce90b 100644
--- a/src/input_common/main.h
+++ b/src/input_common/main.h
@@ -4,7 +4,13 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <memory>
7#include <string> 8#include <string>
9#include <vector>
10
11namespace Common {
12class ParamPackage;
13}
8 14
9namespace InputCommon { 15namespace InputCommon {
10 16
@@ -31,4 +37,30 @@ std::string GenerateKeyboardParam(int key_code);
31std::string GenerateAnalogParamFromKeys(int key_up, int key_down, int key_left, int key_right, 37std::string GenerateAnalogParamFromKeys(int key_up, int key_down, int key_left, int key_right,
32 int key_modifier, float modifier_scale); 38 int key_modifier, float modifier_scale);
33 39
40namespace Polling {
41
42enum class DeviceType { Button, Analog };
43
44/**
45 * A class that can be used to get inputs from an input device like controllers without having to
46 * poll the device's status yourself
47 */
48class DevicePoller {
49public:
50 virtual ~DevicePoller() = default;
51 /// Setup and start polling for inputs, should be called before GetNextInput
52 virtual void Start() = 0;
53 /// Stop polling
54 virtual void Stop() = 0;
55 /**
56 * Every call to this function returns the next input recorded since calling Start
57 * @return A ParamPackage of the recorded input, which can be used to create an InputDevice.
58 * If there has been no input, the package is empty
59 */
60 virtual Common::ParamPackage GetNextInput() = 0;
61};
62
63// Get all DevicePoller from all backends for a specific device type
64std::vector<std::unique_ptr<DevicePoller>> GetPollers(DeviceType type);
65} // namespace Polling
34} // namespace InputCommon 66} // namespace InputCommon