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
|
|
|
|
|
|
|
#include <memory>
|
2021-09-21 00:43:13 +02:00
|
|
|
#include "common/input.h"
|
2017-01-21 10:53:03 +01:00
|
|
|
#include "common/param_package.h"
|
2022-06-19 06:32:07 +02:00
|
|
|
#include "input_common/drivers/camera.h"
|
2021-09-21 00:43:13 +02:00
|
|
|
#include "input_common/drivers/keyboard.h"
|
|
|
|
#include "input_common/drivers/mouse.h"
|
|
|
|
#include "input_common/drivers/tas_input.h"
|
|
|
|
#include "input_common/drivers/touch_screen.h"
|
|
|
|
#include "input_common/drivers/udp_client.h"
|
2022-09-25 03:28:27 +02:00
|
|
|
#include "input_common/drivers/virtual_amiibo.h"
|
2022-12-16 23:16:54 +01:00
|
|
|
#include "input_common/drivers/virtual_gamepad.h"
|
2021-09-21 00:43:13 +02:00
|
|
|
#include "input_common/helpers/stick_from_buttons.h"
|
|
|
|
#include "input_common/helpers/touch_from_buttons.h"
|
|
|
|
#include "input_common/input_engine.h"
|
|
|
|
#include "input_common/input_mapping.h"
|
|
|
|
#include "input_common/input_poller.h"
|
2017-01-21 10:53:03 +01:00
|
|
|
#include "input_common/main.h"
|
2022-12-28 23:26:46 +01:00
|
|
|
|
|
|
|
#ifdef HAVE_LIBUSB
|
|
|
|
#include "input_common/drivers/gc_adapter.h"
|
|
|
|
#endif
|
2017-01-21 16:33:48 +01:00
|
|
|
#ifdef HAVE_SDL2
|
2022-12-20 18:34:33 +01:00
|
|
|
#include "input_common/drivers/joycon.h"
|
2021-09-21 00:43:13 +02:00
|
|
|
#include "input_common/drivers/sdl_driver.h"
|
2017-01-21 16:33:48 +01:00
|
|
|
#endif
|
2017-01-21 10:53:03 +01:00
|
|
|
|
2024-02-17 03:19:17 +01:00
|
|
|
#ifdef ANDROID
|
|
|
|
#include "input_common/drivers/android.h"
|
|
|
|
#endif
|
|
|
|
|
2017-01-21 10:53:03 +01:00
|
|
|
namespace InputCommon {
|
|
|
|
|
2023-01-06 02:16:55 +01:00
|
|
|
/// Dummy engine to get periodic updates
|
|
|
|
class UpdateEngine final : public InputEngine {
|
|
|
|
public:
|
|
|
|
explicit UpdateEngine(std::string input_engine_) : InputEngine(std::move(input_engine_)) {
|
|
|
|
PreSetController(identifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PumpEvents() {
|
|
|
|
SetButton(identifier, 0, last_state);
|
|
|
|
last_state = !last_state;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static constexpr PadIdentifier identifier = {
|
|
|
|
.guid = Common::UUID{},
|
|
|
|
.port = 0,
|
|
|
|
.pad = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
bool last_state{};
|
|
|
|
};
|
|
|
|
|
2020-08-27 21:16:47 +02:00
|
|
|
struct InputSubsystem::Impl {
|
2022-12-18 20:24:02 +01:00
|
|
|
template <typename Engine>
|
|
|
|
void RegisterEngine(std::string name, std::shared_ptr<Engine>& engine) {
|
2022-01-24 17:31:40 +01:00
|
|
|
MappingCallback mapping_callback{[this](const MappingData& data) { RegisterInput(data); }};
|
2021-09-21 00:43:13 +02:00
|
|
|
|
2022-12-18 20:24:02 +01:00
|
|
|
engine = std::make_shared<Engine>(name);
|
|
|
|
engine->SetMappingCallback(mapping_callback);
|
|
|
|
|
|
|
|
std::shared_ptr<InputFactory> input_factory = std::make_shared<InputFactory>(engine);
|
|
|
|
std::shared_ptr<OutputFactory> output_factory = std::make_shared<OutputFactory>(engine);
|
|
|
|
Common::Input::RegisterInputFactory(engine->GetEngineName(), std::move(input_factory));
|
|
|
|
Common::Input::RegisterOutputFactory(engine->GetEngineName(), std::move(output_factory));
|
|
|
|
}
|
2022-12-16 23:16:54 +01:00
|
|
|
|
2022-12-18 20:24:02 +01:00
|
|
|
void Initialize() {
|
|
|
|
mapping_factory = std::make_shared<MappingFactory>();
|
|
|
|
|
2023-01-06 02:16:55 +01:00
|
|
|
RegisterEngine("updater", update_engine);
|
2022-12-18 20:24:02 +01:00
|
|
|
RegisterEngine("keyboard", keyboard);
|
|
|
|
RegisterEngine("mouse", mouse);
|
|
|
|
RegisterEngine("touch", touch_screen);
|
2022-12-28 23:26:46 +01:00
|
|
|
#ifdef HAVE_LIBUSB
|
2022-12-18 20:24:02 +01:00
|
|
|
RegisterEngine("gcpad", gcadapter);
|
2022-12-28 23:26:46 +01:00
|
|
|
#endif
|
2022-12-18 20:24:02 +01:00
|
|
|
RegisterEngine("cemuhookudp", udp_client);
|
|
|
|
RegisterEngine("tas", tas_input);
|
|
|
|
RegisterEngine("camera", camera);
|
2024-02-17 03:19:17 +01:00
|
|
|
#ifdef ANDROID
|
2024-01-18 05:01:33 +01:00
|
|
|
RegisterEngine("android", android);
|
2024-02-17 03:19:17 +01:00
|
|
|
#endif
|
2022-12-18 20:24:02 +01:00
|
|
|
RegisterEngine("virtual_amiibo", virtual_amiibo);
|
|
|
|
RegisterEngine("virtual_gamepad", virtual_gamepad);
|
2021-09-21 00:43:13 +02:00
|
|
|
#ifdef HAVE_SDL2
|
2022-12-18 20:24:02 +01:00
|
|
|
RegisterEngine("sdl", sdl);
|
2022-12-20 18:34:33 +01:00
|
|
|
RegisterEngine("joycon", joycon);
|
2021-09-21 00:43:13 +02:00
|
|
|
#endif
|
|
|
|
|
2022-11-28 15:19:01 +01:00
|
|
|
Common::Input::RegisterInputFactory("touch_from_button",
|
|
|
|
std::make_shared<TouchFromButton>());
|
|
|
|
Common::Input::RegisterInputFactory("analog_from_button",
|
|
|
|
std::make_shared<StickFromButton>());
|
2020-08-27 21:16:47 +02:00
|
|
|
}
|
|
|
|
|
2022-12-18 20:24:02 +01:00
|
|
|
template <typename Engine>
|
|
|
|
void UnregisterEngine(std::shared_ptr<Engine>& engine) {
|
|
|
|
Common::Input::UnregisterInputFactory(engine->GetEngineName());
|
|
|
|
Common::Input::UnregisterOutputFactory(engine->GetEngineName());
|
|
|
|
engine.reset();
|
|
|
|
}
|
2022-12-16 23:16:54 +01:00
|
|
|
|
2022-12-18 20:24:02 +01:00
|
|
|
void Shutdown() {
|
2023-01-06 02:16:55 +01:00
|
|
|
UnregisterEngine(update_engine);
|
2022-12-18 20:24:02 +01:00
|
|
|
UnregisterEngine(keyboard);
|
|
|
|
UnregisterEngine(mouse);
|
|
|
|
UnregisterEngine(touch_screen);
|
2022-12-28 23:26:46 +01:00
|
|
|
#ifdef HAVE_LIBUSB
|
2022-12-18 20:24:02 +01:00
|
|
|
UnregisterEngine(gcadapter);
|
2022-12-28 23:26:46 +01:00
|
|
|
#endif
|
2022-12-18 20:24:02 +01:00
|
|
|
UnregisterEngine(udp_client);
|
|
|
|
UnregisterEngine(tas_input);
|
|
|
|
UnregisterEngine(camera);
|
2024-02-17 03:19:17 +01:00
|
|
|
#ifdef ANDROID
|
2024-01-18 05:01:33 +01:00
|
|
|
UnregisterEngine(android);
|
2024-02-17 03:19:17 +01:00
|
|
|
#endif
|
2022-12-18 20:24:02 +01:00
|
|
|
UnregisterEngine(virtual_amiibo);
|
|
|
|
UnregisterEngine(virtual_gamepad);
|
2021-09-21 00:43:13 +02:00
|
|
|
#ifdef HAVE_SDL2
|
2022-12-18 20:24:02 +01:00
|
|
|
UnregisterEngine(sdl);
|
2022-12-20 18:34:33 +01:00
|
|
|
UnregisterEngine(joycon);
|
2021-09-21 00:43:13 +02:00
|
|
|
#endif
|
|
|
|
|
2022-11-28 15:19:01 +01:00
|
|
|
Common::Input::UnregisterInputFactory("touch_from_button");
|
|
|
|
Common::Input::UnregisterInputFactory("analog_from_button");
|
2020-08-27 21:16:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] std::vector<Common::ParamPackage> GetInputDevices() const {
|
|
|
|
std::vector<Common::ParamPackage> devices = {
|
2021-09-21 00:43:13 +02:00
|
|
|
Common::ParamPackage{{"display", "Any"}, {"engine", "any"}},
|
2020-08-27 21:16:47 +02:00
|
|
|
};
|
2021-09-21 00:43:13 +02:00
|
|
|
|
2024-02-17 03:19:17 +01:00
|
|
|
#ifndef ANDROID
|
2021-09-21 00:43:13 +02:00
|
|
|
auto keyboard_devices = keyboard->GetInputDevices();
|
|
|
|
devices.insert(devices.end(), keyboard_devices.begin(), keyboard_devices.end());
|
|
|
|
auto mouse_devices = mouse->GetInputDevices();
|
|
|
|
devices.insert(devices.end(), mouse_devices.begin(), mouse_devices.end());
|
2024-02-17 03:19:17 +01:00
|
|
|
#endif
|
|
|
|
#ifdef ANDROID
|
2024-01-18 05:01:33 +01:00
|
|
|
auto android_devices = android->GetInputDevices();
|
|
|
|
devices.insert(devices.end(), android_devices.begin(), android_devices.end());
|
2024-02-17 03:19:17 +01:00
|
|
|
#endif
|
2022-12-28 23:26:46 +01:00
|
|
|
#ifdef HAVE_LIBUSB
|
2021-09-21 00:43:13 +02:00
|
|
|
auto gcadapter_devices = gcadapter->GetInputDevices();
|
|
|
|
devices.insert(devices.end(), gcadapter_devices.begin(), gcadapter_devices.end());
|
2022-12-28 23:26:46 +01:00
|
|
|
#endif
|
2021-11-26 22:45:37 +01:00
|
|
|
auto udp_devices = udp_client->GetInputDevices();
|
|
|
|
devices.insert(devices.end(), udp_devices.begin(), udp_devices.end());
|
2021-09-21 00:43:13 +02:00
|
|
|
#ifdef HAVE_SDL2
|
2022-12-20 18:34:33 +01:00
|
|
|
auto joycon_devices = joycon->GetInputDevices();
|
|
|
|
devices.insert(devices.end(), joycon_devices.begin(), joycon_devices.end());
|
2021-09-21 00:43:13 +02:00
|
|
|
auto sdl_devices = sdl->GetInputDevices();
|
|
|
|
devices.insert(devices.end(), sdl_devices.begin(), sdl_devices.end());
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return devices;
|
2020-08-27 21:16:47 +02:00
|
|
|
}
|
|
|
|
|
2022-12-18 20:24:02 +01:00
|
|
|
[[nodiscard]] std::shared_ptr<InputEngine> GetInputEngine(
|
2020-08-27 21:16:47 +02:00
|
|
|
const Common::ParamPackage& params) const {
|
2021-09-21 00:43:13 +02:00
|
|
|
if (!params.Has("engine") || params.Get("engine", "") == "any") {
|
2022-12-18 20:24:02 +01:00
|
|
|
return nullptr;
|
2020-08-27 21:16:47 +02:00
|
|
|
}
|
2021-09-21 00:43:13 +02:00
|
|
|
const std::string engine = params.Get("engine", "");
|
2022-12-18 20:24:02 +01:00
|
|
|
if (engine == keyboard->GetEngineName()) {
|
|
|
|
return keyboard;
|
|
|
|
}
|
2021-10-24 18:22:20 +02:00
|
|
|
if (engine == mouse->GetEngineName()) {
|
2022-12-18 20:24:02 +01:00
|
|
|
return mouse;
|
2021-10-24 18:22:20 +02:00
|
|
|
}
|
2024-02-17 03:19:17 +01:00
|
|
|
#ifdef ANDROID
|
2024-01-18 05:01:33 +01:00
|
|
|
if (engine == android->GetEngineName()) {
|
|
|
|
return android;
|
|
|
|
}
|
2024-02-17 03:19:17 +01:00
|
|
|
#endif
|
2022-12-28 23:26:46 +01:00
|
|
|
#ifdef HAVE_LIBUSB
|
2021-09-21 00:43:13 +02:00
|
|
|
if (engine == gcadapter->GetEngineName()) {
|
2022-12-18 20:24:02 +01:00
|
|
|
return gcadapter;
|
2021-09-21 00:43:13 +02:00
|
|
|
}
|
2022-12-28 23:26:46 +01:00
|
|
|
#endif
|
2021-11-26 22:45:37 +01:00
|
|
|
if (engine == udp_client->GetEngineName()) {
|
2022-12-18 20:24:02 +01:00
|
|
|
return udp_client;
|
2021-09-21 00:43:13 +02:00
|
|
|
}
|
|
|
|
#ifdef HAVE_SDL2
|
|
|
|
if (engine == sdl->GetEngineName()) {
|
2022-12-18 20:24:02 +01:00
|
|
|
return sdl;
|
2021-09-21 00:43:13 +02:00
|
|
|
}
|
2022-12-20 18:34:33 +01:00
|
|
|
if (engine == joycon->GetEngineName()) {
|
|
|
|
return joycon;
|
|
|
|
}
|
2021-09-21 00:43:13 +02:00
|
|
|
#endif
|
2022-12-18 20:24:02 +01:00
|
|
|
return nullptr;
|
2020-08-27 21:16:47 +02:00
|
|
|
}
|
|
|
|
|
2022-12-18 20:24:02 +01:00
|
|
|
[[nodiscard]] AnalogMapping GetAnalogMappingForDevice(
|
2020-08-27 21:16:47 +02:00
|
|
|
const Common::ParamPackage& params) const {
|
2022-12-18 20:24:02 +01:00
|
|
|
const auto input_engine = GetInputEngine(params);
|
|
|
|
|
|
|
|
if (input_engine == nullptr) {
|
2020-08-27 21:16:47 +02:00
|
|
|
return {};
|
|
|
|
}
|
2022-12-18 20:24:02 +01:00
|
|
|
|
|
|
|
return input_engine->GetAnalogMappingForDevice(params);
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] ButtonMapping GetButtonMappingForDevice(
|
|
|
|
const Common::ParamPackage& params) const {
|
|
|
|
const auto input_engine = GetInputEngine(params);
|
|
|
|
|
|
|
|
if (input_engine == nullptr) {
|
|
|
|
return {};
|
2021-09-21 00:43:13 +02:00
|
|
|
}
|
2022-12-18 20:24:02 +01:00
|
|
|
|
|
|
|
return input_engine->GetButtonMappingForDevice(params);
|
2020-08-27 21:16:47 +02:00
|
|
|
}
|
2018-09-11 03:29:59 +02:00
|
|
|
|
2020-09-05 04:35:42 +02:00
|
|
|
[[nodiscard]] MotionMapping GetMotionMappingForDevice(
|
|
|
|
const Common::ParamPackage& params) const {
|
2022-12-18 20:24:02 +01:00
|
|
|
const auto input_engine = GetInputEngine(params);
|
|
|
|
|
|
|
|
if (input_engine == nullptr) {
|
2020-09-05 04:35:42 +02:00
|
|
|
return {};
|
|
|
|
}
|
2022-12-18 20:24:02 +01:00
|
|
|
|
|
|
|
return input_engine->GetMotionMappingForDevice(params);
|
2020-09-05 04:35:42 +02:00
|
|
|
}
|
|
|
|
|
2021-11-21 21:12:01 +01:00
|
|
|
Common::Input::ButtonNames GetButtonName(const Common::ParamPackage& params) const {
|
2021-09-21 00:43:13 +02:00
|
|
|
if (!params.Has("engine") || params.Get("engine", "") == "any") {
|
2021-11-21 21:12:01 +01:00
|
|
|
return Common::Input::ButtonNames::Undefined;
|
2021-09-21 00:43:13 +02:00
|
|
|
}
|
2022-12-18 20:24:02 +01:00
|
|
|
const auto input_engine = GetInputEngine(params);
|
|
|
|
|
|
|
|
if (input_engine == nullptr) {
|
|
|
|
return Common::Input::ButtonNames::Invalid;
|
2021-09-21 00:43:13 +02:00
|
|
|
}
|
2022-12-18 20:24:02 +01:00
|
|
|
|
|
|
|
return input_engine->GetUIName(params);
|
2021-09-21 00:43:13 +02:00
|
|
|
}
|
|
|
|
|
2022-03-04 18:47:13 +01:00
|
|
|
bool IsStickInverted(const Common::ParamPackage& params) {
|
2022-12-18 20:24:02 +01:00
|
|
|
const auto input_engine = GetInputEngine(params);
|
|
|
|
|
|
|
|
if (input_engine == nullptr) {
|
|
|
|
return false;
|
2022-03-04 18:47:13 +01:00
|
|
|
}
|
2022-12-18 20:24:02 +01:00
|
|
|
|
|
|
|
return input_engine->IsStickInverted(params);
|
2022-03-04 18:47:13 +01:00
|
|
|
}
|
|
|
|
|
2021-09-21 00:43:13 +02:00
|
|
|
bool IsController(const Common::ParamPackage& params) {
|
|
|
|
const std::string engine = params.Get("engine", "");
|
|
|
|
if (engine == mouse->GetEngineName()) {
|
|
|
|
return true;
|
|
|
|
}
|
2024-02-17 03:19:17 +01:00
|
|
|
#ifdef ANDROID
|
2024-01-18 05:01:33 +01:00
|
|
|
if (engine == android->GetEngineName()) {
|
|
|
|
return true;
|
|
|
|
}
|
2024-02-17 03:19:17 +01:00
|
|
|
#endif
|
2022-12-28 23:26:46 +01:00
|
|
|
#ifdef HAVE_LIBUSB
|
2021-09-21 00:43:13 +02:00
|
|
|
if (engine == gcadapter->GetEngineName()) {
|
|
|
|
return true;
|
|
|
|
}
|
2022-12-28 23:26:46 +01:00
|
|
|
#endif
|
2021-11-26 22:45:37 +01:00
|
|
|
if (engine == udp_client->GetEngineName()) {
|
|
|
|
return true;
|
|
|
|
}
|
2021-09-21 00:43:13 +02:00
|
|
|
if (engine == tas_input->GetEngineName()) {
|
|
|
|
return true;
|
|
|
|
}
|
2022-12-16 23:16:54 +01:00
|
|
|
if (engine == virtual_gamepad->GetEngineName()) {
|
|
|
|
return true;
|
|
|
|
}
|
2021-09-21 00:43:13 +02:00
|
|
|
#ifdef HAVE_SDL2
|
|
|
|
if (engine == sdl->GetEngineName()) {
|
|
|
|
return true;
|
|
|
|
}
|
2022-12-20 18:34:33 +01:00
|
|
|
if (engine == joycon->GetEngineName()) {
|
|
|
|
return true;
|
|
|
|
}
|
2021-09-21 00:43:13 +02:00
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BeginConfiguration() {
|
|
|
|
keyboard->BeginConfiguration();
|
|
|
|
mouse->BeginConfiguration();
|
2024-02-17 03:19:17 +01:00
|
|
|
#ifdef ANDROID
|
2024-01-18 05:01:33 +01:00
|
|
|
android->BeginConfiguration();
|
2024-02-17 03:19:17 +01:00
|
|
|
#endif
|
2022-12-28 23:26:46 +01:00
|
|
|
#ifdef HAVE_LIBUSB
|
2021-09-21 00:43:13 +02:00
|
|
|
gcadapter->BeginConfiguration();
|
2022-12-28 23:26:46 +01:00
|
|
|
#endif
|
2021-09-21 00:43:13 +02:00
|
|
|
udp_client->BeginConfiguration();
|
|
|
|
#ifdef HAVE_SDL2
|
|
|
|
sdl->BeginConfiguration();
|
2022-12-20 18:34:33 +01:00
|
|
|
joycon->BeginConfiguration();
|
2021-09-21 00:43:13 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void EndConfiguration() {
|
|
|
|
keyboard->EndConfiguration();
|
|
|
|
mouse->EndConfiguration();
|
2024-02-17 03:19:17 +01:00
|
|
|
#ifdef ANDROID
|
2024-01-18 05:01:33 +01:00
|
|
|
android->EndConfiguration();
|
2024-02-17 03:19:17 +01:00
|
|
|
#endif
|
2022-12-28 23:26:46 +01:00
|
|
|
#ifdef HAVE_LIBUSB
|
2021-09-21 00:43:13 +02:00
|
|
|
gcadapter->EndConfiguration();
|
2022-12-28 23:26:46 +01:00
|
|
|
#endif
|
2021-09-21 00:43:13 +02:00
|
|
|
udp_client->EndConfiguration();
|
|
|
|
#ifdef HAVE_SDL2
|
|
|
|
sdl->EndConfiguration();
|
2022-12-20 18:34:33 +01:00
|
|
|
joycon->EndConfiguration();
|
2021-09-21 00:43:13 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-11-27 02:08:44 +01:00
|
|
|
void PumpEvents() const {
|
2023-01-06 02:16:55 +01:00
|
|
|
update_engine->PumpEvents();
|
2022-11-27 02:08:44 +01:00
|
|
|
#ifdef HAVE_SDL2
|
|
|
|
sdl->PumpEvents();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-01-24 17:31:40 +01:00
|
|
|
void RegisterInput(const MappingData& data) {
|
2021-09-21 00:43:13 +02:00
|
|
|
mapping_factory->RegisterInput(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<MappingFactory> mapping_factory;
|
2021-10-11 07:43:11 +02:00
|
|
|
|
2023-01-06 02:16:55 +01:00
|
|
|
std::shared_ptr<UpdateEngine> update_engine;
|
2021-09-21 00:43:13 +02:00
|
|
|
std::shared_ptr<Keyboard> keyboard;
|
|
|
|
std::shared_ptr<Mouse> mouse;
|
|
|
|
std::shared_ptr<TouchScreen> touch_screen;
|
2021-10-11 07:43:11 +02:00
|
|
|
std::shared_ptr<TasInput::Tas> tas_input;
|
2021-09-21 00:43:13 +02:00
|
|
|
std::shared_ptr<CemuhookUDP::UDPClient> udp_client;
|
2022-06-19 06:32:07 +02:00
|
|
|
std::shared_ptr<Camera> camera;
|
2022-09-25 03:28:27 +02:00
|
|
|
std::shared_ptr<VirtualAmiibo> virtual_amiibo;
|
2022-12-16 23:16:54 +01:00
|
|
|
std::shared_ptr<VirtualGamepad> virtual_gamepad;
|
2021-10-11 07:43:11 +02:00
|
|
|
|
2022-12-28 23:26:46 +01:00
|
|
|
#ifdef HAVE_LIBUSB
|
|
|
|
std::shared_ptr<GCAdapter> gcadapter;
|
|
|
|
#endif
|
|
|
|
|
2021-09-21 00:43:13 +02:00
|
|
|
#ifdef HAVE_SDL2
|
|
|
|
std::shared_ptr<SDLDriver> sdl;
|
2022-12-20 18:34:33 +01:00
|
|
|
std::shared_ptr<Joycons> joycon;
|
2021-09-21 00:43:13 +02:00
|
|
|
#endif
|
2024-02-17 03:19:17 +01:00
|
|
|
|
|
|
|
#ifdef ANDROID
|
|
|
|
std::shared_ptr<Android> android;
|
|
|
|
#endif
|
2020-08-27 21:16:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
InputSubsystem::InputSubsystem() : impl{std::make_unique<Impl>()} {}
|
|
|
|
|
|
|
|
InputSubsystem::~InputSubsystem() = default;
|
|
|
|
|
|
|
|
void InputSubsystem::Initialize() {
|
|
|
|
impl->Initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InputSubsystem::Shutdown() {
|
|
|
|
impl->Shutdown();
|
|
|
|
}
|
|
|
|
|
2021-09-21 00:43:13 +02:00
|
|
|
Keyboard* InputSubsystem::GetKeyboard() {
|
|
|
|
return impl->keyboard.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
const Keyboard* InputSubsystem::GetKeyboard() const {
|
|
|
|
return impl->keyboard.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
Mouse* InputSubsystem::GetMouse() {
|
|
|
|
return impl->mouse.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
const Mouse* InputSubsystem::GetMouse() const {
|
|
|
|
return impl->mouse.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
TouchScreen* InputSubsystem::GetTouchScreen() {
|
|
|
|
return impl->touch_screen.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
const TouchScreen* InputSubsystem::GetTouchScreen() const {
|
|
|
|
return impl->touch_screen.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
TasInput::Tas* InputSubsystem::GetTas() {
|
|
|
|
return impl->tas_input.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
const TasInput::Tas* InputSubsystem::GetTas() const {
|
|
|
|
return impl->tas_input.get();
|
|
|
|
}
|
|
|
|
|
2022-06-19 06:32:07 +02:00
|
|
|
Camera* InputSubsystem::GetCamera() {
|
|
|
|
return impl->camera.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
const Camera* InputSubsystem::GetCamera() const {
|
|
|
|
return impl->camera.get();
|
|
|
|
}
|
|
|
|
|
2024-02-17 03:19:17 +01:00
|
|
|
#ifdef ANDROID
|
2024-01-18 05:01:33 +01:00
|
|
|
Android* InputSubsystem::GetAndroid() {
|
|
|
|
return impl->android.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
const Android* InputSubsystem::GetAndroid() const {
|
|
|
|
return impl->android.get();
|
|
|
|
}
|
2024-02-17 03:19:17 +01:00
|
|
|
#endif
|
2024-01-18 05:01:33 +01:00
|
|
|
|
2022-09-25 03:28:27 +02:00
|
|
|
VirtualAmiibo* InputSubsystem::GetVirtualAmiibo() {
|
|
|
|
return impl->virtual_amiibo.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
const VirtualAmiibo* InputSubsystem::GetVirtualAmiibo() const {
|
|
|
|
return impl->virtual_amiibo.get();
|
|
|
|
}
|
|
|
|
|
2022-12-16 23:16:54 +01:00
|
|
|
VirtualGamepad* InputSubsystem::GetVirtualGamepad() {
|
|
|
|
return impl->virtual_gamepad.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
const VirtualGamepad* InputSubsystem::GetVirtualGamepad() const {
|
|
|
|
return impl->virtual_gamepad.get();
|
|
|
|
}
|
|
|
|
|
2020-08-27 21:16:47 +02:00
|
|
|
std::vector<Common::ParamPackage> InputSubsystem::GetInputDevices() const {
|
|
|
|
return impl->GetInputDevices();
|
|
|
|
}
|
|
|
|
|
|
|
|
AnalogMapping InputSubsystem::GetAnalogMappingForDevice(const Common::ParamPackage& device) const {
|
|
|
|
return impl->GetAnalogMappingForDevice(device);
|
|
|
|
}
|
2020-06-23 18:47:58 +02:00
|
|
|
|
2020-08-27 21:16:47 +02:00
|
|
|
ButtonMapping InputSubsystem::GetButtonMappingForDevice(const Common::ParamPackage& device) const {
|
|
|
|
return impl->GetButtonMappingForDevice(device);
|
2017-01-21 10:53:03 +01:00
|
|
|
}
|
|
|
|
|
2020-10-14 08:51:14 +02:00
|
|
|
MotionMapping InputSubsystem::GetMotionMappingForDevice(const Common::ParamPackage& device) const {
|
|
|
|
return impl->GetMotionMappingForDevice(device);
|
|
|
|
}
|
|
|
|
|
2021-11-21 21:12:01 +01:00
|
|
|
Common::Input::ButtonNames InputSubsystem::GetButtonName(const Common::ParamPackage& params) const {
|
|
|
|
return impl->GetButtonName(params);
|
2021-09-21 00:43:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool InputSubsystem::IsController(const Common::ParamPackage& params) const {
|
|
|
|
return impl->IsController(params);
|
|
|
|
}
|
|
|
|
|
2022-03-04 18:47:13 +01:00
|
|
|
bool InputSubsystem::IsStickInverted(const Common::ParamPackage& params) const {
|
|
|
|
if (params.Has("axis_x") && params.Has("axis_y")) {
|
|
|
|
return impl->IsStickInverted(params);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-08-29 20:56:51 +02:00
|
|
|
void InputSubsystem::ReloadInputDevices() {
|
2021-09-21 00:43:13 +02:00
|
|
|
impl->udp_client.get()->ReloadSockets();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InputSubsystem::BeginMapping(Polling::InputType type) {
|
|
|
|
impl->BeginConfiguration();
|
|
|
|
impl->mapping_factory->BeginMapping(type);
|
|
|
|
}
|
|
|
|
|
2022-01-24 17:39:17 +01:00
|
|
|
Common::ParamPackage InputSubsystem::GetNextInput() const {
|
2021-09-21 00:43:13 +02:00
|
|
|
return impl->mapping_factory->GetNextInput();
|
2020-07-14 19:01:36 +02:00
|
|
|
}
|
|
|
|
|
2021-09-21 00:43:13 +02:00
|
|
|
void InputSubsystem::StopMapping() const {
|
|
|
|
impl->EndConfiguration();
|
|
|
|
impl->mapping_factory->StopMapping();
|
2020-06-21 18:36:28 +02:00
|
|
|
}
|
|
|
|
|
2022-11-27 02:08:44 +01:00
|
|
|
void InputSubsystem::PumpEvents() const {
|
|
|
|
impl->PumpEvents();
|
|
|
|
}
|
|
|
|
|
2017-01-21 10:53:03 +01:00
|
|
|
std::string GenerateKeyboardParam(int key_code) {
|
2021-07-23 02:59:26 +02:00
|
|
|
Common::ParamPackage param;
|
|
|
|
param.Set("engine", "keyboard");
|
|
|
|
param.Set("code", key_code);
|
|
|
|
param.Set("toggle", false);
|
2017-01-21 10:53:03 +01:00
|
|
|
return param.Serialize();
|
|
|
|
}
|
|
|
|
|
2017-01-21 12:04:00 +01:00
|
|
|
std::string GenerateAnalogParamFromKeys(int key_up, int key_down, int key_left, int key_right,
|
|
|
|
int key_modifier, float modifier_scale) {
|
|
|
|
Common::ParamPackage circle_pad_param{
|
|
|
|
{"engine", "analog_from_button"},
|
|
|
|
{"up", GenerateKeyboardParam(key_up)},
|
|
|
|
{"down", GenerateKeyboardParam(key_down)},
|
|
|
|
{"left", GenerateKeyboardParam(key_left)},
|
|
|
|
{"right", GenerateKeyboardParam(key_right)},
|
|
|
|
{"modifier", GenerateKeyboardParam(key_modifier)},
|
|
|
|
{"modifier_scale", std::to_string(modifier_scale)},
|
|
|
|
};
|
|
|
|
return circle_pad_param.Serialize();
|
|
|
|
}
|
2017-01-21 10:53:03 +01:00
|
|
|
} // namespace InputCommon
|