diff options
| author | 2021-12-18 13:57:14 +0800 | |
|---|---|---|
| committer | 2021-12-18 13:57:14 +0800 | |
| commit | e49184e6069a9d791d2df3c1958f5c4b1187e124 (patch) | |
| tree | b776caf722e0be0e680f67b0ad0842628162ef1c /src/input_common/input_mapping.h | |
| parent | Implement convert legacy to generic (diff) | |
| parent | Merge pull request #7570 from ameerj/favorites-expanded (diff) | |
| download | yuzu-e49184e6069a9d791d2df3c1958f5c4b1187e124.tar.gz yuzu-e49184e6069a9d791d2df3c1958f5c4b1187e124.tar.xz yuzu-e49184e6069a9d791d2df3c1958f5c4b1187e124.zip | |
Merge branch 'yuzu-emu:master' into convert_legacy
Diffstat (limited to 'src/input_common/input_mapping.h')
| -rw-r--r-- | src/input_common/input_mapping.h | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/input_common/input_mapping.h b/src/input_common/input_mapping.h new file mode 100644 index 000000000..93564b5f8 --- /dev/null +++ b/src/input_common/input_mapping.h | |||
| @@ -0,0 +1,83 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | #include "common/threadsafe_queue.h" | ||
| 7 | |||
| 8 | namespace InputCommon { | ||
| 9 | class InputEngine; | ||
| 10 | struct MappingData; | ||
| 11 | |||
| 12 | class MappingFactory { | ||
| 13 | public: | ||
| 14 | MappingFactory(); | ||
| 15 | |||
| 16 | /** | ||
| 17 | * Resets all variables to begin the mapping process | ||
| 18 | * @param type type of input desired to be returned | ||
| 19 | */ | ||
| 20 | void BeginMapping(Polling::InputType type); | ||
| 21 | |||
| 22 | /// Returns an input event with mapping information from the input_queue | ||
| 23 | [[nodiscard]] const Common::ParamPackage GetNextInput(); | ||
| 24 | |||
| 25 | /** | ||
| 26 | * Registers mapping input data from the driver | ||
| 27 | * @param data A struct containing all the information needed to create a proper | ||
| 28 | * ParamPackage | ||
| 29 | */ | ||
| 30 | void RegisterInput(const MappingData& data); | ||
| 31 | |||
| 32 | /// Stop polling from all backends | ||
| 33 | void StopMapping(); | ||
| 34 | |||
| 35 | private: | ||
| 36 | /** | ||
| 37 | * If provided data satisfies the requirements it will push an element to the input_queue | ||
| 38 | * Supported input: | ||
| 39 | * - Button: Creates a basic button ParamPackage | ||
| 40 | * - HatButton: Creates a basic hat button ParamPackage | ||
| 41 | * - Analog: Creates a basic analog ParamPackage | ||
| 42 | * @param data A struct containing all the information needed to create a proper | ||
| 43 | * ParamPackage | ||
| 44 | */ | ||
| 45 | void RegisterButton(const MappingData& data); | ||
| 46 | |||
| 47 | /** | ||
| 48 | * If provided data satisfies the requirements it will push an element to the input_queue | ||
| 49 | * Supported input: | ||
| 50 | * - Button, HatButton: Pass the data to RegisterButton | ||
| 51 | * - Analog: Stores the first axis and on the second axis creates a basic stick ParamPackage | ||
| 52 | * @param data A struct containing all the information needed to create a proper | ||
| 53 | * ParamPackage | ||
| 54 | */ | ||
| 55 | void RegisterStick(const MappingData& data); | ||
| 56 | |||
| 57 | /** | ||
| 58 | * If provided data satisfies the requirements it will push an element to the input_queue | ||
| 59 | * Supported input: | ||
| 60 | * - Button, HatButton: Pass the data to RegisterButton | ||
| 61 | * - Analog: Stores the first two axis and on the third axis creates a basic Motion | ||
| 62 | * ParamPackage | ||
| 63 | * - Motion: Creates a basic Motion ParamPackage | ||
| 64 | * @param data A struct containing all the information needed to create a proper | ||
| 65 | * ParamPackage | ||
| 66 | */ | ||
| 67 | void RegisterMotion(const MappingData& data); | ||
| 68 | |||
| 69 | /** | ||
| 70 | * Returns true if driver can be mapped | ||
| 71 | * @param data A struct containing all the information needed to create a proper | ||
| 72 | * ParamPackage | ||
| 73 | */ | ||
| 74 | bool IsDriverValid(const MappingData& data) const; | ||
| 75 | |||
| 76 | Common::SPSCQueue<Common::ParamPackage> input_queue; | ||
| 77 | Polling::InputType input_type{Polling::InputType::None}; | ||
| 78 | bool is_enabled{}; | ||
| 79 | int first_axis = -1; | ||
| 80 | int second_axis = -1; | ||
| 81 | }; | ||
| 82 | |||
| 83 | } // namespace InputCommon | ||