2021-09-20 23:41:15 +02: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-14 02:31:57 +01:00
|
|
|
* Resets all variables to begin the mapping process
|
|
|
|
* @param type type of input desired to be returned
|
2021-09-20 23:41:15 +02:00
|
|
|
*/
|
|
|
|
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
|
2021-12-14 02:31:57 +01:00
|
|
|
* @param data A struct containing all the information needed to create a proper
|
|
|
|
* ParamPackage
|
2021-09-20 23:41:15 +02:00
|
|
|
*/
|
|
|
|
void RegisterInput(const MappingData& data);
|
|
|
|
|
|
|
|
/// Stop polling from all backends
|
|
|
|
void StopMapping();
|
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
2021-12-14 02:31:57 +01:00
|
|
|
* If provided data satisfies the requirements it will push an element to the input_queue
|
2021-09-20 23:41:15 +02:00
|
|
|
* Supported input:
|
|
|
|
* - Button: Creates a basic button ParamPackage
|
|
|
|
* - HatButton: Creates a basic hat button ParamPackage
|
|
|
|
* - Analog: Creates a basic analog ParamPackage
|
2021-12-14 02:31:57 +01:00
|
|
|
* @param data A struct containing all the information needed to create a proper
|
2021-09-20 23:41:15 +02:00
|
|
|
* ParamPackage
|
|
|
|
*/
|
|
|
|
void RegisterButton(const MappingData& data);
|
|
|
|
|
|
|
|
/**
|
2021-12-14 02:31:57 +01:00
|
|
|
* If provided data satisfies the requirements it will push an element to the input_queue
|
2021-09-20 23:41:15 +02: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-14 02:31:57 +01:00
|
|
|
* @param data A struct containing all the information needed to create a proper
|
|
|
|
* ParamPackage
|
2021-09-20 23:41:15 +02:00
|
|
|
*/
|
|
|
|
void RegisterStick(const MappingData& data);
|
|
|
|
|
|
|
|
/**
|
2021-12-14 02:31:57 +01:00
|
|
|
* If provided data satisfies the requirements it will push an element to the input_queue
|
2021-09-20 23:41:15 +02: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-14 02:31:57 +01:00
|
|
|
* @param data A struct containing all the information needed to create a proper
|
|
|
|
* ParamPackage
|
2021-09-20 23:41:15 +02:00
|
|
|
*/
|
|
|
|
void RegisterMotion(const MappingData& data);
|
|
|
|
|
2021-11-14 17:45:07 +01:00
|
|
|
/**
|
|
|
|
* Returns true if driver can be mapped
|
2021-12-14 02:31:57 +01:00
|
|
|
* @param data A struct containing all the information needed to create a proper
|
|
|
|
* ParamPackage
|
2021-11-14 17:45:07 +01:00
|
|
|
*/
|
|
|
|
bool IsDriverValid(const MappingData& data) const;
|
|
|
|
|
2021-09-20 23:41:15 +02: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
|