pineapple-src/src/input_common/input_mapping.h

89 lines
2.8 KiB
C
Raw Normal View History

2022-04-23 14:49:07 -04:00
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
2021-11-02 00:02:57 -04:00
#pragma once
2022-01-25 17:21:18 -05:00
#include "common/param_package.h"
2021-11-02 00:02:57 -04:00
#include "common/threadsafe_queue.h"
2022-01-25 17:21:18 -05:00
namespace InputCommon::Polling {
enum class InputType;
}
2021-11-02 00:02:57 -04:00
namespace InputCommon {
class InputEngine;
struct MappingData;
class MappingFactory {
public:
MappingFactory();
/**
2021-12-14 23:46:01 -05:00
* Resets all variables to begin the mapping process
* @param type type of input desired to be returned
2021-11-02 00:02:57 -04:00
*/
void BeginMapping(Polling::InputType type);
/// Returns an input event with mapping information from the input_queue
2022-01-25 17:21:18 -05:00
[[nodiscard]] Common::ParamPackage GetNextInput();
2021-11-02 00:02:57 -04:00
/**
* Registers mapping input data from the driver
2021-12-14 23:46:01 -05:00
* @param data A struct containing all the information needed to create a proper
* ParamPackage
2021-11-02 00:02:57 -04:00
*/
void RegisterInput(const MappingData& data);
/// Stop polling from all backends
void StopMapping();
private:
/**
2021-12-14 23:46:01 -05:00
* If provided data satisfies the requirements it will push an element to the input_queue
2021-11-02 00:02:57 -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-14 23:46:01 -05:00
* @param data A struct containing all the information needed to create a proper
2021-11-02 00:02:57 -04:00
* ParamPackage
*/
void RegisterButton(const MappingData& data);
/**
2021-12-14 23:46:01 -05:00
* If provided data satisfies the requirements it will push an element to the input_queue
2021-11-02 00:02:57 -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-14 23:46:01 -05:00
* @param data A struct containing all the information needed to create a proper
* ParamPackage
2021-11-02 00:02:57 -04:00
*/
void RegisterStick(const MappingData& data);
/**
2021-12-14 23:46:01 -05:00
* If provided data satisfies the requirements it will push an element to the input_queue
2021-11-02 00:02:57 -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-14 23:46:01 -05:00
* @param data A struct containing all the information needed to create a proper
* ParamPackage
2021-11-02 00:02:57 -04:00
*/
void RegisterMotion(const MappingData& data);
2021-11-14 20:13:48 -05:00
/**
* Returns true if driver can be mapped
2021-12-14 23:46:01 -05:00
* @param data A struct containing all the information needed to create a proper
* ParamPackage
2021-11-14 20:13:48 -05:00
*/
bool IsDriverValid(const MappingData& data) const;
2021-11-02 00:02:57 -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