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.h26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/input_common/main.h b/src/input_common/main.h
index 0e32856f6..ebc7f9533 100644
--- a/src/input_common/main.h
+++ b/src/input_common/main.h
@@ -6,8 +6,10 @@
6 6
7#include <memory> 7#include <memory>
8#include <string> 8#include <string>
9#include <unordered_map>
9#include <vector> 10#include <vector>
10#include "input_common/gcadapter/gc_poller.h" 11#include "input_common/gcadapter/gc_poller.h"
12#include "input_common/settings.h"
11 13
12namespace Common { 14namespace Common {
13class ParamPackage; 15class ParamPackage;
@@ -42,9 +44,27 @@ std::string GenerateKeyboardParam(int key_code);
42std::string GenerateAnalogParamFromKeys(int key_up, int key_down, int key_left, int key_right, 44std::string GenerateAnalogParamFromKeys(int key_up, int key_down, int key_left, int key_right,
43 int key_modifier, float modifier_scale); 45 int key_modifier, float modifier_scale);
44 46
47/**
48 * Return a list of available input devices that this Factory can create a new device with.
49 * Each returned Parampackage should have a `display` field used for display, a class field for
50 * backends to determine if this backend is meant to service the request and any other information
51 * needed to identify this in the backend later.
52 */
53std::vector<Common::ParamPackage> GetInputDevices();
54
55/**
56 * Given a ParamPackage for a Device returned from `GetInputDevices`, attempt to get the default
57 * mapping for the device. This is currently only implemented for the sdl backend devices.
58 */
59using ButtonMapping = std::unordered_map<Settings::NativeButton::Values, Common::ParamPackage>;
60using AnalogMapping = std::unordered_map<Settings::NativeAnalog::Values, Common::ParamPackage>;
61
62ButtonMapping GetButtonMappingForDevice(const Common::ParamPackage&);
63AnalogMapping GetAnalogMappingForDevice(const Common::ParamPackage&);
64
45namespace Polling { 65namespace Polling {
46 66
47enum class DeviceType { Button, Analog }; 67enum class DeviceType { Button, AnalogPreferred };
48 68
49/** 69/**
50 * A class that can be used to get inputs from an input device like controllers without having to 70 * A class that can be used to get inputs from an input device like controllers without having to
@@ -54,7 +74,9 @@ class DevicePoller {
54public: 74public:
55 virtual ~DevicePoller() = default; 75 virtual ~DevicePoller() = default;
56 /// Setup and start polling for inputs, should be called before GetNextInput 76 /// Setup and start polling for inputs, should be called before GetNextInput
57 virtual void Start() = 0; 77 /// If a device_id is provided, events should be filtered to only include events from this
78 /// device id
79 virtual void Start(std::string device_id = "") = 0;
58 /// Stop polling 80 /// Stop polling
59 virtual void Stop() = 0; 81 virtual void Stop() = 0;
60 /** 82 /**