chore: make yuzu REUSE compliant
[REUSE] is a specification that aims at making file copyright
information consistent, so that it can be both human and machine
readable. It basically requires that all files have a header containing
copyright and licensing information. When this isn't possible, like
when dealing with binary assets, generated files or embedded third-party
dependencies, it is permitted to insert copyright information in the
`.reuse/dep5` file.
Oh, and it also requires that all the licenses used in the project are
present in the `LICENSES` folder, that's why the diff is so huge.
This can be done automatically with `reuse download --all`.
The `reuse` tool also contains a handy subcommand that analyzes the
project and tells whether or not the project is (still) compliant,
`reuse lint`.
Following REUSE has a few advantages over the current approach:
- Copyright information is easy to access for users / downstream
- Files like `dist/license.md` do not need to exist anymore, as
`.reuse/dep5` is used instead
- `reuse lint` makes it easy to ensure that copyright information of
files like binary assets / images is always accurate and up to date
To add copyright information of files that didn't have it I looked up
who committed what and when, for each file. As yuzu contributors do not
have to sign a CLA or similar I couldn't assume that copyright ownership
was of the "yuzu Emulator Project", so I used the name and/or email of
the commit author instead.
[REUSE]: https://reuse.software
Follow-up to 01cf05bc75b1e47beb08937439f3ed9339e7b254
2022-05-15 02:06:02 +02:00
|
|
|
// SPDX-FileCopyrightText: 2017 Citra Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-01-21 10:53:03 +01:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2017-12-06 05:26:29 +01:00
|
|
|
#include <memory>
|
2017-01-21 10:53:03 +01:00
|
|
|
#include <string>
|
2020-07-22 16:39:53 +02:00
|
|
|
#include <unordered_map>
|
2017-12-06 05:26:29 +01:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace Common {
|
|
|
|
class ParamPackage;
|
|
|
|
}
|
2017-01-21 10:53:03 +01:00
|
|
|
|
2021-11-21 21:12:01 +01:00
|
|
|
namespace Common::Input {
|
|
|
|
enum class ButtonNames;
|
|
|
|
}
|
|
|
|
|
2020-08-29 01:15:06 +02:00
|
|
|
namespace Settings::NativeAnalog {
|
|
|
|
enum Values : int;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Settings::NativeButton {
|
|
|
|
enum Values : int;
|
|
|
|
}
|
|
|
|
|
2020-09-05 04:48:03 +02:00
|
|
|
namespace Settings::NativeMotion {
|
|
|
|
enum Values : int;
|
|
|
|
}
|
|
|
|
|
2021-09-21 00:43:13 +02:00
|
|
|
namespace InputCommon {
|
2022-06-19 06:32:07 +02:00
|
|
|
class Camera;
|
2021-09-21 00:43:13 +02:00
|
|
|
class Keyboard;
|
2020-11-18 05:55:09 +01:00
|
|
|
class Mouse;
|
2021-09-21 00:43:13 +02:00
|
|
|
class TouchScreen;
|
2022-09-25 03:28:27 +02:00
|
|
|
class VirtualAmiibo;
|
2022-12-16 23:16:54 +01:00
|
|
|
class VirtualGamepad;
|
2021-09-21 00:43:13 +02:00
|
|
|
struct MappingData;
|
|
|
|
} // namespace InputCommon
|
2020-11-18 05:55:09 +01:00
|
|
|
|
2021-09-21 00:43:13 +02:00
|
|
|
namespace InputCommon::TasInput {
|
2021-06-18 16:15:42 +02:00
|
|
|
class Tas;
|
2021-09-21 00:43:13 +02:00
|
|
|
} // namespace InputCommon::TasInput
|
2021-06-18 16:15:42 +02:00
|
|
|
|
2017-01-21 10:53:03 +01:00
|
|
|
namespace InputCommon {
|
2017-12-06 05:26:29 +01:00
|
|
|
namespace Polling {
|
2021-09-20 23:41:15 +02:00
|
|
|
/// Type of input desired for mapping purposes
|
|
|
|
enum class InputType { None, Button, Stick, Motion, Touch };
|
2017-12-06 05:26:29 +01:00
|
|
|
} // namespace Polling
|
2020-08-27 21:16:47 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Given a ParamPackage for a Device returned from `GetInputDevices`, attempt to get the default
|
2021-09-21 00:43:13 +02:00
|
|
|
* mapping for the device.
|
2020-08-27 21:16:47 +02:00
|
|
|
*/
|
|
|
|
using AnalogMapping = std::unordered_map<Settings::NativeAnalog::Values, Common::ParamPackage>;
|
|
|
|
using ButtonMapping = std::unordered_map<Settings::NativeButton::Values, Common::ParamPackage>;
|
2020-09-05 04:48:03 +02:00
|
|
|
using MotionMapping = std::unordered_map<Settings::NativeMotion::Values, Common::ParamPackage>;
|
2020-08-27 21:16:47 +02:00
|
|
|
|
|
|
|
class InputSubsystem {
|
|
|
|
public:
|
|
|
|
explicit InputSubsystem();
|
|
|
|
~InputSubsystem();
|
|
|
|
|
|
|
|
InputSubsystem(const InputSubsystem&) = delete;
|
|
|
|
InputSubsystem& operator=(const InputSubsystem&) = delete;
|
|
|
|
|
|
|
|
InputSubsystem(InputSubsystem&&) = delete;
|
|
|
|
InputSubsystem& operator=(InputSubsystem&&) = delete;
|
|
|
|
|
|
|
|
/// Initializes and registers all built-in input device factories.
|
|
|
|
void Initialize();
|
|
|
|
|
|
|
|
/// Unregisters all built-in input device factories and shuts them down.
|
|
|
|
void Shutdown();
|
|
|
|
|
2021-09-21 00:43:13 +02:00
|
|
|
/// Retrieves the underlying keyboard device.
|
|
|
|
[[nodiscard]] Keyboard* GetKeyboard();
|
|
|
|
|
|
|
|
/// Retrieves the underlying keyboard device.
|
|
|
|
[[nodiscard]] const Keyboard* GetKeyboard() const;
|
|
|
|
|
|
|
|
/// Retrieves the underlying mouse device.
|
|
|
|
[[nodiscard]] Mouse* GetMouse();
|
|
|
|
|
|
|
|
/// Retrieves the underlying mouse device.
|
|
|
|
[[nodiscard]] const Mouse* GetMouse() const;
|
|
|
|
|
|
|
|
/// Retrieves the underlying touch screen device.
|
|
|
|
[[nodiscard]] TouchScreen* GetTouchScreen();
|
|
|
|
|
|
|
|
/// Retrieves the underlying touch screen device.
|
|
|
|
[[nodiscard]] const TouchScreen* GetTouchScreen() const;
|
|
|
|
|
|
|
|
/// Retrieves the underlying tas input device.
|
|
|
|
[[nodiscard]] TasInput::Tas* GetTas();
|
|
|
|
|
2022-06-19 06:32:07 +02:00
|
|
|
/// Retrieves the underlying tas input device.
|
2021-09-21 00:43:13 +02:00
|
|
|
[[nodiscard]] const TasInput::Tas* GetTas() const;
|
|
|
|
|
2022-06-19 06:32:07 +02:00
|
|
|
/// Retrieves the underlying camera input device.
|
|
|
|
[[nodiscard]] Camera* GetCamera();
|
|
|
|
|
|
|
|
/// Retrieves the underlying camera input device.
|
|
|
|
[[nodiscard]] const Camera* GetCamera() const;
|
|
|
|
|
2022-09-25 03:28:27 +02:00
|
|
|
/// Retrieves the underlying virtual amiibo input device.
|
|
|
|
[[nodiscard]] VirtualAmiibo* GetVirtualAmiibo();
|
|
|
|
|
|
|
|
/// Retrieves the underlying virtual amiibo input device.
|
|
|
|
[[nodiscard]] const VirtualAmiibo* GetVirtualAmiibo() const;
|
|
|
|
|
2022-12-16 23:16:54 +01:00
|
|
|
/// Retrieves the underlying virtual gamepad input device.
|
|
|
|
[[nodiscard]] VirtualGamepad* GetVirtualGamepad();
|
|
|
|
|
|
|
|
/// Retrieves the underlying virtual gamepad input device.
|
|
|
|
[[nodiscard]] const VirtualGamepad* GetVirtualGamepad() const;
|
|
|
|
|
2020-08-27 21:16:47 +02:00
|
|
|
/**
|
|
|
|
* Returns all available input devices that this Factory can create a new device with.
|
2021-09-21 00:43:13 +02:00
|
|
|
* Each returned ParamPackage should have a `display` field used for display, a `engine` field
|
|
|
|
* for backends to determine if this backend is meant to service the request and any other
|
2020-08-27 21:16:47 +02:00
|
|
|
* information needed to identify this in the backend later.
|
|
|
|
*/
|
|
|
|
[[nodiscard]] std::vector<Common::ParamPackage> GetInputDevices() const;
|
|
|
|
|
|
|
|
/// Retrieves the analog mappings for the given device.
|
|
|
|
[[nodiscard]] AnalogMapping GetAnalogMappingForDevice(const Common::ParamPackage& device) const;
|
|
|
|
|
|
|
|
/// Retrieves the button mappings for the given device.
|
|
|
|
[[nodiscard]] ButtonMapping GetButtonMappingForDevice(const Common::ParamPackage& device) const;
|
|
|
|
|
2020-09-05 04:48:03 +02:00
|
|
|
/// Retrieves the motion mappings for the given device.
|
|
|
|
[[nodiscard]] MotionMapping GetMotionMappingForDevice(const Common::ParamPackage& device) const;
|
|
|
|
|
2021-11-21 21:12:01 +01:00
|
|
|
/// Returns an enum contaning the name to be displayed from the input engine.
|
|
|
|
[[nodiscard]] Common::Input::ButtonNames GetButtonName(
|
|
|
|
const Common::ParamPackage& params) const;
|
2021-09-21 00:43:13 +02:00
|
|
|
|
|
|
|
/// Returns true if device is a controller.
|
|
|
|
[[nodiscard]] bool IsController(const Common::ParamPackage& params) const;
|
|
|
|
|
2022-03-04 18:47:13 +01:00
|
|
|
/// Returns true if axis of a stick aren't mapped in the correct direction
|
|
|
|
[[nodiscard]] bool IsStickInverted(const Common::ParamPackage& device) const;
|
|
|
|
|
2021-09-21 00:43:13 +02:00
|
|
|
/// Reloads the input devices.
|
2020-08-29 20:56:51 +02:00
|
|
|
void ReloadInputDevices();
|
|
|
|
|
2021-09-21 00:43:13 +02:00
|
|
|
/// Start polling from all backends for a desired input type.
|
|
|
|
void BeginMapping(Polling::InputType type);
|
|
|
|
|
|
|
|
/// Returns an input event with mapping information.
|
2022-01-24 17:39:17 +01:00
|
|
|
[[nodiscard]] Common::ParamPackage GetNextInput() const;
|
2021-09-21 00:43:13 +02:00
|
|
|
|
|
|
|
/// Stop polling from all backends.
|
|
|
|
void StopMapping() const;
|
2020-08-27 21:16:47 +02:00
|
|
|
|
2022-11-27 02:08:44 +01:00
|
|
|
/// Signals SDL driver for new input events
|
|
|
|
void PumpEvents() const;
|
|
|
|
|
2020-08-27 21:16:47 +02:00
|
|
|
private:
|
|
|
|
struct Impl;
|
|
|
|
std::unique_ptr<Impl> impl;
|
|
|
|
};
|
|
|
|
|
2021-09-21 00:43:13 +02:00
|
|
|
/// Generates a serialized param package for creating a keyboard button device.
|
2020-08-27 21:16:47 +02:00
|
|
|
std::string GenerateKeyboardParam(int key_code);
|
|
|
|
|
2021-09-21 00:43:13 +02:00
|
|
|
/// Generates a serialized param package for creating an analog device taking input from keyboard.
|
2020-08-27 21:16:47 +02:00
|
|
|
std::string GenerateAnalogParamFromKeys(int key_up, int key_down, int key_left, int key_right,
|
|
|
|
int key_modifier, float modifier_scale);
|
2017-01-21 10:53:03 +01:00
|
|
|
} // namespace InputCommon
|