diff options
| author | german77 <juangerman-13@hotmail.com> | 2021-09-20 16:41:15 -0500 |
|---|---|---|
| committer | Narr the Reg <juangerman-13@hotmail.com> | 2021-11-24 20:30:22 -0600 |
| commit | 783c01771ac830cb05af4f9399475954fed14b1e (patch) | |
| tree | 229ada777d889243bdfcb6c240ad615c246cd8c6 /src/input_common/input_mapping.h | |
| parent | 312dd2fb89e23f48a4e132460913082acbcc655f (diff) | |
input_common: Create input poller and mapping
Diffstat (limited to 'src/input_common/input_mapping.h')
| -rw-r--r-- | src/input_common/input_mapping.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/input_common/input_mapping.h b/src/input_common/input_mapping.h new file mode 100644 index 0000000000..2622dba70c --- /dev/null +++ b/src/input_common/input_mapping.h @@ -0,0 +1,76 @@ +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included + +#pragma once +#include "common/threadsafe_queue.h" + +namespace InputCommon { +class InputEngine; +struct MappingData; + +class MappingFactory { +public: + MappingFactory(); + + /** + * Resets all varables to beggin the mapping process + * @param "type": type of input desired to be returned + */ + void BeginMapping(Polling::InputType type); + + /// Returns an input event with mapping information from the input_queue + [[nodiscard]] const Common::ParamPackage GetNextInput(); + + /** + * Registers mapping input data from the driver + * @param "data": An struct containing all the information needed to create a proper + * ParamPackage + */ + void RegisterInput(const MappingData& data); + + /// Stop polling from all backends + void StopMapping(); + +private: + /** + * If provided data satisfies the requeriments it will push an element to the input_queue + * Supported input: + * - Button: Creates a basic button ParamPackage + * - HatButton: Creates a basic hat button ParamPackage + * - Analog: Creates a basic analog ParamPackage + * @param "data": An struct containing all the information needed to create a proper + * ParamPackage + */ + void RegisterButton(const MappingData& data); + + /** + * If provided data satisfies the requeriments it will push an element to the input_queue + * Supported input: + * - Button, HatButton: Pass the data to RegisterButton + * - Analog: Stores the first axis and on the second axis creates a basic stick ParamPackage + * @param "data": An struct containing all the information needed to create a proper + * ParamPackage + */ + void RegisterStick(const MappingData& data); + + /** + * If provided data satisfies the requeriments it will push an element to the input_queue + * Supported input: + * - Button, HatButton: Pass the data to RegisterButton + * - Analog: Stores the first two axis and on the third axis creates a basic Motion + * ParamPackage + * - Motion: Creates a basic Motion ParamPackage + * @param "data": An struct containing all the information needed to create a proper + * ParamPackage + */ + void RegisterMotion(const MappingData& data); + + Common::SPSCQueue<Common::ParamPackage> input_queue; + Polling::InputType input_type{Polling::InputType::None}; + bool is_enabled{}; + int first_axis = -1; + int second_axis = -1; +}; + +} // namespace InputCommon |
