2021-09-20 17:41:15 -04:00
|
|
|
// 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();
|
|
|
|
|
|
|
|
/**
|
2021-12-13 20:31:57 -05:00
|
|
|
* Resets all variables to begin the mapping process
|
|
|
|
* @param type type of input desired to be returned
|
2021-09-20 17:41:15 -04:00
|
|
|
*/
|
|
|
|
void BeginMapping(Polling::InputType type);
|
|
|
|
|
|
|
|
/// Returns an input event with mapping information from the input_queue
|
2022-01-24 11:39:17 -05:00
|
|
|
[[nodiscard]] Common::ParamPackage GetNextInput();
|
2021-09-20 17:41:15 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers mapping input data from the driver
|
2021-12-13 20:31:57 -05:00
|
|
|
* @param data A struct containing all the information needed to create a proper
|
|
|
|
* ParamPackage
|
2021-09-20 17:41:15 -04:00
|
|
|
*/
|
|
|
|
void RegisterInput(const MappingData& data);
|
|
|
|
|
|
|
|
/// Stop polling from all backends
|
|
|
|
void StopMapping();
|
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
2021-12-13 20:31:57 -05:00
|
|
|
* If provided data satisfies the requirements it will push an element to the input_queue
|
2021-09-20 17:41:15 -04:00
|
|
|
* Supported input:
|
|
|
|
* - Button: Creates a basic button ParamPackage
|
|
|
|
* - HatButton: Creates a basic hat button ParamPackage
|
|
|
|
* - Analog: Creates a basic analog ParamPackage
|
2021-12-13 20:31:57 -05:00
|
|
|
* @param data A struct containing all the information needed to create a proper
|
2021-09-20 17:41:15 -04:00
|
|
|
* ParamPackage
|
|
|
|
*/
|
|
|
|
void RegisterButton(const MappingData& data);
|
|
|
|
|
|
|
|
/**
|
2021-12-13 20:31:57 -05:00
|
|
|
* If provided data satisfies the requirements it will push an element to the input_queue
|
2021-09-20 17:41:15 -04:00
|
|
|
* Supported input:
|
|
|
|
* - Button, HatButton: Pass the data to RegisterButton
|
|
|
|
* - Analog: Stores the first axis and on the second axis creates a basic stick ParamPackage
|
2021-12-13 20:31:57 -05:00
|
|
|
* @param data A struct containing all the information needed to create a proper
|
|
|
|
* ParamPackage
|
2021-09-20 17:41:15 -04:00
|
|
|
*/
|
|
|
|
void RegisterStick(const MappingData& data);
|
|
|
|
|
|
|
|
/**
|
2021-12-13 20:31:57 -05:00
|
|
|
* If provided data satisfies the requirements it will push an element to the input_queue
|
2021-09-20 17:41:15 -04:00
|
|
|
* 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
|
2021-12-13 20:31:57 -05:00
|
|
|
* @param data A struct containing all the information needed to create a proper
|
|
|
|
* ParamPackage
|
2021-09-20 17:41:15 -04:00
|
|
|
*/
|
|
|
|
void RegisterMotion(const MappingData& data);
|
|
|
|
|
2021-11-14 11:45:07 -05:00
|
|
|
/**
|
|
|
|
* Returns true if driver can be mapped
|
2021-12-13 20:31:57 -05:00
|
|
|
* @param data A struct containing all the information needed to create a proper
|
|
|
|
* ParamPackage
|
2021-11-14 11:45:07 -05:00
|
|
|
*/
|
|
|
|
bool IsDriverValid(const MappingData& data) const;
|
|
|
|
|
2021-09-20 17:41:15 -04:00
|
|
|
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
|