2021-09-20 14:41:15 -07:00
|
|
|
// Copyright 2021 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included
|
|
|
|
|
|
|
|
#pragma once
|
2022-01-24 08:42:05 -08:00
|
|
|
|
|
|
|
#include "common/param_package.h"
|
2021-09-20 14:41:15 -07:00
|
|
|
#include "common/threadsafe_queue.h"
|
|
|
|
|
2022-01-24 08:42:05 -08:00
|
|
|
namespace InputCommon::Polling {
|
|
|
|
enum class InputType;
|
|
|
|
}
|
|
|
|
|
2021-09-20 14:41:15 -07:00
|
|
|
namespace InputCommon {
|
|
|
|
class InputEngine;
|
|
|
|
struct MappingData;
|
|
|
|
|
|
|
|
class MappingFactory {
|
|
|
|
public:
|
|
|
|
MappingFactory();
|
|
|
|
|
|
|
|
/**
|
2021-12-13 17:31:57 -08:00
|
|
|
* Resets all variables to begin the mapping process
|
|
|
|
* @param type type of input desired to be returned
|
2021-09-20 14:41:15 -07:00
|
|
|
*/
|
|
|
|
void BeginMapping(Polling::InputType type);
|
|
|
|
|
|
|
|
/// Returns an input event with mapping information from the input_queue
|
2022-01-24 08:39:17 -08:00
|
|
|
[[nodiscard]] Common::ParamPackage GetNextInput();
|
2021-09-20 14:41:15 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers mapping input data from the driver
|
2021-12-13 17:31:57 -08:00
|
|
|
* @param data A struct containing all the information needed to create a proper
|
|
|
|
* ParamPackage
|
2021-09-20 14:41:15 -07:00
|
|
|
*/
|
|
|
|
void RegisterInput(const MappingData& data);
|
|
|
|
|
|
|
|
/// Stop polling from all backends
|
|
|
|
void StopMapping();
|
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
2021-12-13 17:31:57 -08:00
|
|
|
* If provided data satisfies the requirements it will push an element to the input_queue
|
2021-09-20 14:41:15 -07: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 17:31:57 -08:00
|
|
|
* @param data A struct containing all the information needed to create a proper
|
2021-09-20 14:41:15 -07:00
|
|
|
* ParamPackage
|
|
|
|
*/
|
|
|
|
void RegisterButton(const MappingData& data);
|
|
|
|
|
|
|
|
/**
|
2021-12-13 17:31:57 -08:00
|
|
|
* If provided data satisfies the requirements it will push an element to the input_queue
|
2021-09-20 14:41:15 -07: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 17:31:57 -08:00
|
|
|
* @param data A struct containing all the information needed to create a proper
|
|
|
|
* ParamPackage
|
2021-09-20 14:41:15 -07:00
|
|
|
*/
|
|
|
|
void RegisterStick(const MappingData& data);
|
|
|
|
|
|
|
|
/**
|
2021-12-13 17:31:57 -08:00
|
|
|
* If provided data satisfies the requirements it will push an element to the input_queue
|
2021-09-20 14:41:15 -07: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 17:31:57 -08:00
|
|
|
* @param data A struct containing all the information needed to create a proper
|
|
|
|
* ParamPackage
|
2021-09-20 14:41:15 -07:00
|
|
|
*/
|
|
|
|
void RegisterMotion(const MappingData& data);
|
|
|
|
|
2021-11-14 08:45:07 -08:00
|
|
|
/**
|
|
|
|
* Returns true if driver can be mapped
|
2021-12-13 17:31:57 -08:00
|
|
|
* @param data A struct containing all the information needed to create a proper
|
|
|
|
* ParamPackage
|
2021-11-14 08:45:07 -08:00
|
|
|
*/
|
|
|
|
bool IsDriverValid(const MappingData& data) const;
|
|
|
|
|
2021-09-20 14:41:15 -07: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
|