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 01:06:02 +01:00
|
|
|
// SPDX-FileCopyrightText: 2017 Citra Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-01-21 09:53:03 +00:00
|
|
|
|
|
|
|
#include <memory>
|
2021-09-20 23:43:13 +01:00
|
|
|
#include "common/input.h"
|
2017-01-21 09:53:03 +00:00
|
|
|
#include "common/param_package.h"
|
2022-06-19 05:32:07 +01:00
|
|
|
#include "input_common/drivers/camera.h"
|
2021-09-20 23:43:13 +01:00
|
|
|
#include "input_common/drivers/gc_adapter.h"
|
|
|
|
#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 02:28:27 +01:00
|
|
|
#include "input_common/drivers/virtual_amiibo.h"
|
2021-09-20 23:43:13 +01: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 09:53:03 +00:00
|
|
|
#include "input_common/main.h"
|
2017-01-21 15:33:48 +00:00
|
|
|
#ifdef HAVE_SDL2
|
2021-09-20 23:43:13 +01:00
|
|
|
#include "input_common/drivers/sdl_driver.h"
|
2017-01-21 15:33:48 +00:00
|
|
|
#endif
|
2017-01-21 09:53:03 +00:00
|
|
|
|
|
|
|
namespace InputCommon {
|
|
|
|
|
2020-08-27 20:16:47 +01:00
|
|
|
struct InputSubsystem::Impl {
|
|
|
|
void Initialize() {
|
2021-09-20 23:43:13 +01:00
|
|
|
mapping_factory = std::make_shared<MappingFactory>();
|
2022-01-24 16:31:40 +00:00
|
|
|
MappingCallback mapping_callback{[this](const MappingData& data) { RegisterInput(data); }};
|
2021-09-20 23:43:13 +01:00
|
|
|
|
|
|
|
keyboard = std::make_shared<Keyboard>("keyboard");
|
|
|
|
keyboard->SetMappingCallback(mapping_callback);
|
|
|
|
keyboard_factory = std::make_shared<InputFactory>(keyboard);
|
2021-10-20 23:53:14 +01:00
|
|
|
keyboard_output_factory = std::make_shared<OutputFactory>(keyboard);
|
2021-10-31 03:23:10 +00:00
|
|
|
Common::Input::RegisterFactory<Common::Input::InputDevice>(keyboard->GetEngineName(),
|
|
|
|
keyboard_factory);
|
|
|
|
Common::Input::RegisterFactory<Common::Input::OutputDevice>(keyboard->GetEngineName(),
|
|
|
|
keyboard_output_factory);
|
2021-09-20 23:43:13 +01:00
|
|
|
|
|
|
|
mouse = std::make_shared<Mouse>("mouse");
|
|
|
|
mouse->SetMappingCallback(mapping_callback);
|
|
|
|
mouse_factory = std::make_shared<InputFactory>(mouse);
|
2021-10-20 23:53:14 +01:00
|
|
|
mouse_output_factory = std::make_shared<OutputFactory>(mouse);
|
2021-10-31 03:23:10 +00:00
|
|
|
Common::Input::RegisterFactory<Common::Input::InputDevice>(mouse->GetEngineName(),
|
|
|
|
mouse_factory);
|
|
|
|
Common::Input::RegisterFactory<Common::Input::OutputDevice>(mouse->GetEngineName(),
|
|
|
|
mouse_output_factory);
|
2021-09-20 23:43:13 +01:00
|
|
|
|
|
|
|
touch_screen = std::make_shared<TouchScreen>("touch");
|
|
|
|
touch_screen_factory = std::make_shared<InputFactory>(touch_screen);
|
2021-10-31 03:23:10 +00:00
|
|
|
Common::Input::RegisterFactory<Common::Input::InputDevice>(touch_screen->GetEngineName(),
|
|
|
|
touch_screen_factory);
|
2021-09-20 23:43:13 +01:00
|
|
|
|
|
|
|
gcadapter = std::make_shared<GCAdapter>("gcpad");
|
|
|
|
gcadapter->SetMappingCallback(mapping_callback);
|
2021-10-11 06:43:11 +01:00
|
|
|
gcadapter_input_factory = std::make_shared<InputFactory>(gcadapter);
|
|
|
|
gcadapter_output_factory = std::make_shared<OutputFactory>(gcadapter);
|
2021-10-31 03:23:10 +00:00
|
|
|
Common::Input::RegisterFactory<Common::Input::InputDevice>(gcadapter->GetEngineName(),
|
|
|
|
gcadapter_input_factory);
|
|
|
|
Common::Input::RegisterFactory<Common::Input::OutputDevice>(gcadapter->GetEngineName(),
|
|
|
|
gcadapter_output_factory);
|
2021-09-20 23:43:13 +01:00
|
|
|
|
|
|
|
udp_client = std::make_shared<CemuhookUDP::UDPClient>("cemuhookudp");
|
|
|
|
udp_client->SetMappingCallback(mapping_callback);
|
2021-11-26 21:45:37 +00:00
|
|
|
udp_client_input_factory = std::make_shared<InputFactory>(udp_client);
|
|
|
|
udp_client_output_factory = std::make_shared<OutputFactory>(udp_client);
|
2021-10-31 03:23:10 +00:00
|
|
|
Common::Input::RegisterFactory<Common::Input::InputDevice>(udp_client->GetEngineName(),
|
2021-11-26 21:45:37 +00:00
|
|
|
udp_client_input_factory);
|
|
|
|
Common::Input::RegisterFactory<Common::Input::OutputDevice>(udp_client->GetEngineName(),
|
|
|
|
udp_client_output_factory);
|
2021-09-20 23:43:13 +01:00
|
|
|
|
|
|
|
tas_input = std::make_shared<TasInput::Tas>("tas");
|
|
|
|
tas_input->SetMappingCallback(mapping_callback);
|
|
|
|
tas_input_factory = std::make_shared<InputFactory>(tas_input);
|
2021-10-20 23:53:14 +01:00
|
|
|
tas_output_factory = std::make_shared<OutputFactory>(tas_input);
|
2021-10-31 03:23:10 +00:00
|
|
|
Common::Input::RegisterFactory<Common::Input::InputDevice>(tas_input->GetEngineName(),
|
|
|
|
tas_input_factory);
|
|
|
|
Common::Input::RegisterFactory<Common::Input::OutputDevice>(tas_input->GetEngineName(),
|
|
|
|
tas_output_factory);
|
2021-09-20 23:43:13 +01:00
|
|
|
|
2022-06-19 05:32:07 +01:00
|
|
|
camera = std::make_shared<Camera>("camera");
|
|
|
|
camera->SetMappingCallback(mapping_callback);
|
|
|
|
camera_input_factory = std::make_shared<InputFactory>(camera);
|
|
|
|
camera_output_factory = std::make_shared<OutputFactory>(camera);
|
|
|
|
Common::Input::RegisterFactory<Common::Input::InputDevice>(camera->GetEngineName(),
|
|
|
|
camera_input_factory);
|
|
|
|
Common::Input::RegisterFactory<Common::Input::OutputDevice>(camera->GetEngineName(),
|
|
|
|
camera_output_factory);
|
|
|
|
|
2022-09-25 02:28:27 +01:00
|
|
|
virtual_amiibo = std::make_shared<VirtualAmiibo>("virtual_amiibo");
|
|
|
|
virtual_amiibo->SetMappingCallback(mapping_callback);
|
|
|
|
virtual_amiibo_input_factory = std::make_shared<InputFactory>(virtual_amiibo);
|
|
|
|
virtual_amiibo_output_factory = std::make_shared<OutputFactory>(virtual_amiibo);
|
|
|
|
Common::Input::RegisterFactory<Common::Input::InputDevice>(virtual_amiibo->GetEngineName(),
|
|
|
|
virtual_amiibo_input_factory);
|
|
|
|
Common::Input::RegisterFactory<Common::Input::OutputDevice>(virtual_amiibo->GetEngineName(),
|
|
|
|
virtual_amiibo_output_factory);
|
|
|
|
|
2021-09-20 23:43:13 +01:00
|
|
|
#ifdef HAVE_SDL2
|
|
|
|
sdl = std::make_shared<SDLDriver>("sdl");
|
|
|
|
sdl->SetMappingCallback(mapping_callback);
|
2021-10-11 06:43:11 +01:00
|
|
|
sdl_input_factory = std::make_shared<InputFactory>(sdl);
|
|
|
|
sdl_output_factory = std::make_shared<OutputFactory>(sdl);
|
2021-10-31 03:23:10 +00:00
|
|
|
Common::Input::RegisterFactory<Common::Input::InputDevice>(sdl->GetEngineName(),
|
|
|
|
sdl_input_factory);
|
|
|
|
Common::Input::RegisterFactory<Common::Input::OutputDevice>(sdl->GetEngineName(),
|
|
|
|
sdl_output_factory);
|
2021-09-20 23:43:13 +01:00
|
|
|
#endif
|
|
|
|
|
2021-10-31 03:23:10 +00:00
|
|
|
Common::Input::RegisterFactory<Common::Input::InputDevice>(
|
|
|
|
"touch_from_button", std::make_shared<TouchFromButton>());
|
|
|
|
Common::Input::RegisterFactory<Common::Input::InputDevice>(
|
|
|
|
"analog_from_button", std::make_shared<StickFromButton>());
|
2020-08-27 20:16:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Shutdown() {
|
2021-10-31 03:23:10 +00:00
|
|
|
Common::Input::UnregisterFactory<Common::Input::InputDevice>(keyboard->GetEngineName());
|
|
|
|
Common::Input::UnregisterFactory<Common::Input::OutputDevice>(keyboard->GetEngineName());
|
2021-09-20 23:43:13 +01:00
|
|
|
keyboard.reset();
|
|
|
|
|
2021-10-31 03:23:10 +00:00
|
|
|
Common::Input::UnregisterFactory<Common::Input::InputDevice>(mouse->GetEngineName());
|
|
|
|
Common::Input::UnregisterFactory<Common::Input::OutputDevice>(mouse->GetEngineName());
|
2021-09-20 23:43:13 +01:00
|
|
|
mouse.reset();
|
|
|
|
|
2021-10-31 03:23:10 +00:00
|
|
|
Common::Input::UnregisterFactory<Common::Input::InputDevice>(touch_screen->GetEngineName());
|
2021-09-20 23:43:13 +01:00
|
|
|
touch_screen.reset();
|
|
|
|
|
2021-10-31 03:23:10 +00:00
|
|
|
Common::Input::UnregisterFactory<Common::Input::InputDevice>(gcadapter->GetEngineName());
|
|
|
|
Common::Input::UnregisterFactory<Common::Input::OutputDevice>(gcadapter->GetEngineName());
|
2021-09-20 23:43:13 +01:00
|
|
|
gcadapter.reset();
|
|
|
|
|
2021-10-31 03:23:10 +00:00
|
|
|
Common::Input::UnregisterFactory<Common::Input::InputDevice>(udp_client->GetEngineName());
|
2021-11-26 21:45:37 +00:00
|
|
|
Common::Input::UnregisterFactory<Common::Input::OutputDevice>(udp_client->GetEngineName());
|
2021-09-20 23:43:13 +01:00
|
|
|
udp_client.reset();
|
|
|
|
|
2021-10-31 03:23:10 +00:00
|
|
|
Common::Input::UnregisterFactory<Common::Input::InputDevice>(tas_input->GetEngineName());
|
|
|
|
Common::Input::UnregisterFactory<Common::Input::OutputDevice>(tas_input->GetEngineName());
|
2021-09-20 23:43:13 +01:00
|
|
|
tas_input.reset();
|
|
|
|
|
|
|
|
#ifdef HAVE_SDL2
|
2021-10-31 03:23:10 +00:00
|
|
|
Common::Input::UnregisterFactory<Common::Input::InputDevice>(sdl->GetEngineName());
|
|
|
|
Common::Input::UnregisterFactory<Common::Input::OutputDevice>(sdl->GetEngineName());
|
2021-09-20 23:43:13 +01:00
|
|
|
sdl.reset();
|
|
|
|
#endif
|
|
|
|
|
2021-10-31 03:23:10 +00:00
|
|
|
Common::Input::UnregisterFactory<Common::Input::InputDevice>("touch_from_button");
|
|
|
|
Common::Input::UnregisterFactory<Common::Input::InputDevice>("analog_from_button");
|
2020-08-27 20:16:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] std::vector<Common::ParamPackage> GetInputDevices() const {
|
|
|
|
std::vector<Common::ParamPackage> devices = {
|
2021-09-20 23:43:13 +01:00
|
|
|
Common::ParamPackage{{"display", "Any"}, {"engine", "any"}},
|
2020-08-27 20:16:47 +01:00
|
|
|
};
|
2021-09-20 23:43:13 +01: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());
|
|
|
|
auto gcadapter_devices = gcadapter->GetInputDevices();
|
|
|
|
devices.insert(devices.end(), gcadapter_devices.begin(), gcadapter_devices.end());
|
2021-11-26 21:45:37 +00:00
|
|
|
auto udp_devices = udp_client->GetInputDevices();
|
|
|
|
devices.insert(devices.end(), udp_devices.begin(), udp_devices.end());
|
2021-09-20 23:43:13 +01:00
|
|
|
#ifdef HAVE_SDL2
|
|
|
|
auto sdl_devices = sdl->GetInputDevices();
|
|
|
|
devices.insert(devices.end(), sdl_devices.begin(), sdl_devices.end());
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return devices;
|
2020-08-27 20:16:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] AnalogMapping GetAnalogMappingForDevice(
|
|
|
|
const Common::ParamPackage& params) const {
|
2021-09-20 23:43:13 +01:00
|
|
|
if (!params.Has("engine") || params.Get("engine", "") == "any") {
|
2020-08-27 20:16:47 +01:00
|
|
|
return {};
|
|
|
|
}
|
2021-09-20 23:43:13 +01:00
|
|
|
const std::string engine = params.Get("engine", "");
|
2021-10-24 17:22:20 +01:00
|
|
|
if (engine == mouse->GetEngineName()) {
|
|
|
|
return mouse->GetAnalogMappingForDevice(params);
|
|
|
|
}
|
2021-09-20 23:43:13 +01:00
|
|
|
if (engine == gcadapter->GetEngineName()) {
|
|
|
|
return gcadapter->GetAnalogMappingForDevice(params);
|
|
|
|
}
|
2021-11-26 21:45:37 +00:00
|
|
|
if (engine == udp_client->GetEngineName()) {
|
|
|
|
return udp_client->GetAnalogMappingForDevice(params);
|
|
|
|
}
|
2021-09-20 23:43:13 +01:00
|
|
|
if (engine == tas_input->GetEngineName()) {
|
|
|
|
return tas_input->GetAnalogMappingForDevice(params);
|
|
|
|
}
|
|
|
|
#ifdef HAVE_SDL2
|
|
|
|
if (engine == sdl->GetEngineName()) {
|
|
|
|
return sdl->GetAnalogMappingForDevice(params);
|
|
|
|
}
|
|
|
|
#endif
|
2020-08-27 20:16:47 +01:00
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] ButtonMapping GetButtonMappingForDevice(
|
|
|
|
const Common::ParamPackage& params) const {
|
2021-09-20 23:43:13 +01:00
|
|
|
if (!params.Has("engine") || params.Get("engine", "") == "any") {
|
2020-08-27 20:16:47 +01:00
|
|
|
return {};
|
|
|
|
}
|
2021-09-20 23:43:13 +01:00
|
|
|
const std::string engine = params.Get("engine", "");
|
|
|
|
if (engine == gcadapter->GetEngineName()) {
|
|
|
|
return gcadapter->GetButtonMappingForDevice(params);
|
|
|
|
}
|
2021-11-26 21:45:37 +00:00
|
|
|
if (engine == udp_client->GetEngineName()) {
|
|
|
|
return udp_client->GetButtonMappingForDevice(params);
|
|
|
|
}
|
2021-09-20 23:43:13 +01:00
|
|
|
if (engine == tas_input->GetEngineName()) {
|
|
|
|
return tas_input->GetButtonMappingForDevice(params);
|
|
|
|
}
|
|
|
|
#ifdef HAVE_SDL2
|
|
|
|
if (engine == sdl->GetEngineName()) {
|
|
|
|
return sdl->GetButtonMappingForDevice(params);
|
|
|
|
}
|
|
|
|
#endif
|
2020-08-27 20:16:47 +01:00
|
|
|
return {};
|
|
|
|
}
|
2018-09-11 02:29:59 +01:00
|
|
|
|
2020-09-05 03:35:42 +01:00
|
|
|
[[nodiscard]] MotionMapping GetMotionMappingForDevice(
|
|
|
|
const Common::ParamPackage& params) const {
|
2021-09-20 23:43:13 +01:00
|
|
|
if (!params.Has("engine") || params.Get("engine", "") == "any") {
|
2020-09-05 03:35:42 +01:00
|
|
|
return {};
|
|
|
|
}
|
2021-09-20 23:43:13 +01:00
|
|
|
const std::string engine = params.Get("engine", "");
|
2021-11-26 21:45:37 +00:00
|
|
|
if (engine == udp_client->GetEngineName()) {
|
|
|
|
return udp_client->GetMotionMappingForDevice(params);
|
2021-09-20 23:43:13 +01:00
|
|
|
}
|
|
|
|
#ifdef HAVE_SDL2
|
|
|
|
if (engine == sdl->GetEngineName()) {
|
|
|
|
return sdl->GetMotionMappingForDevice(params);
|
|
|
|
}
|
|
|
|
#endif
|
2020-09-05 03:35:42 +01:00
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2021-11-21 20:12:01 +00:00
|
|
|
Common::Input::ButtonNames GetButtonName(const Common::ParamPackage& params) const {
|
2021-09-20 23:43:13 +01:00
|
|
|
if (!params.Has("engine") || params.Get("engine", "") == "any") {
|
2021-11-21 20:12:01 +00:00
|
|
|
return Common::Input::ButtonNames::Undefined;
|
2021-09-20 23:43:13 +01:00
|
|
|
}
|
|
|
|
const std::string engine = params.Get("engine", "");
|
|
|
|
if (engine == mouse->GetEngineName()) {
|
|
|
|
return mouse->GetUIName(params);
|
|
|
|
}
|
|
|
|
if (engine == gcadapter->GetEngineName()) {
|
|
|
|
return gcadapter->GetUIName(params);
|
|
|
|
}
|
|
|
|
if (engine == udp_client->GetEngineName()) {
|
|
|
|
return udp_client->GetUIName(params);
|
|
|
|
}
|
|
|
|
if (engine == tas_input->GetEngineName()) {
|
|
|
|
return tas_input->GetUIName(params);
|
|
|
|
}
|
|
|
|
#ifdef HAVE_SDL2
|
|
|
|
if (engine == sdl->GetEngineName()) {
|
|
|
|
return sdl->GetUIName(params);
|
|
|
|
}
|
|
|
|
#endif
|
2021-11-21 20:12:01 +00:00
|
|
|
return Common::Input::ButtonNames::Invalid;
|
2021-09-20 23:43:13 +01:00
|
|
|
}
|
|
|
|
|
2022-03-04 17:47:13 +00:00
|
|
|
bool IsStickInverted(const Common::ParamPackage& params) {
|
|
|
|
const std::string engine = params.Get("engine", "");
|
|
|
|
if (engine == mouse->GetEngineName()) {
|
|
|
|
return mouse->IsStickInverted(params);
|
|
|
|
}
|
|
|
|
if (engine == gcadapter->GetEngineName()) {
|
|
|
|
return gcadapter->IsStickInverted(params);
|
|
|
|
}
|
|
|
|
if (engine == udp_client->GetEngineName()) {
|
|
|
|
return udp_client->IsStickInverted(params);
|
|
|
|
}
|
|
|
|
if (engine == tas_input->GetEngineName()) {
|
|
|
|
return tas_input->IsStickInverted(params);
|
|
|
|
}
|
|
|
|
#ifdef HAVE_SDL2
|
|
|
|
if (engine == sdl->GetEngineName()) {
|
|
|
|
return sdl->IsStickInverted(params);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-09-20 23:43:13 +01:00
|
|
|
bool IsController(const Common::ParamPackage& params) {
|
|
|
|
const std::string engine = params.Get("engine", "");
|
|
|
|
if (engine == mouse->GetEngineName()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (engine == gcadapter->GetEngineName()) {
|
|
|
|
return true;
|
|
|
|
}
|
2021-11-26 21:45:37 +00:00
|
|
|
if (engine == udp_client->GetEngineName()) {
|
|
|
|
return true;
|
|
|
|
}
|
2021-09-20 23:43:13 +01:00
|
|
|
if (engine == tas_input->GetEngineName()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#ifdef HAVE_SDL2
|
|
|
|
if (engine == sdl->GetEngineName()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BeginConfiguration() {
|
|
|
|
keyboard->BeginConfiguration();
|
|
|
|
mouse->BeginConfiguration();
|
|
|
|
gcadapter->BeginConfiguration();
|
|
|
|
udp_client->BeginConfiguration();
|
|
|
|
#ifdef HAVE_SDL2
|
|
|
|
sdl->BeginConfiguration();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void EndConfiguration() {
|
|
|
|
keyboard->EndConfiguration();
|
|
|
|
mouse->EndConfiguration();
|
|
|
|
gcadapter->EndConfiguration();
|
|
|
|
udp_client->EndConfiguration();
|
|
|
|
#ifdef HAVE_SDL2
|
|
|
|
sdl->EndConfiguration();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-01-24 16:31:40 +00:00
|
|
|
void RegisterInput(const MappingData& data) {
|
2021-09-20 23:43:13 +01:00
|
|
|
mapping_factory->RegisterInput(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<MappingFactory> mapping_factory;
|
2021-10-11 06:43:11 +01:00
|
|
|
|
2021-09-20 23:43:13 +01:00
|
|
|
std::shared_ptr<Keyboard> keyboard;
|
|
|
|
std::shared_ptr<Mouse> mouse;
|
|
|
|
std::shared_ptr<GCAdapter> gcadapter;
|
|
|
|
std::shared_ptr<TouchScreen> touch_screen;
|
2021-10-11 06:43:11 +01:00
|
|
|
std::shared_ptr<TasInput::Tas> tas_input;
|
2021-09-20 23:43:13 +01:00
|
|
|
std::shared_ptr<CemuhookUDP::UDPClient> udp_client;
|
2022-06-19 05:32:07 +01:00
|
|
|
std::shared_ptr<Camera> camera;
|
2022-09-25 02:28:27 +01:00
|
|
|
std::shared_ptr<VirtualAmiibo> virtual_amiibo;
|
2021-10-11 06:43:11 +01:00
|
|
|
|
|
|
|
std::shared_ptr<InputFactory> keyboard_factory;
|
|
|
|
std::shared_ptr<InputFactory> mouse_factory;
|
|
|
|
std::shared_ptr<InputFactory> gcadapter_input_factory;
|
|
|
|
std::shared_ptr<InputFactory> touch_screen_factory;
|
2021-11-26 21:45:37 +00:00
|
|
|
std::shared_ptr<InputFactory> udp_client_input_factory;
|
2021-09-20 23:43:13 +01:00
|
|
|
std::shared_ptr<InputFactory> tas_input_factory;
|
2022-06-19 05:32:07 +01:00
|
|
|
std::shared_ptr<InputFactory> camera_input_factory;
|
2022-09-25 02:28:27 +01:00
|
|
|
std::shared_ptr<InputFactory> virtual_amiibo_input_factory;
|
2021-10-11 06:43:11 +01:00
|
|
|
|
2021-10-20 23:53:14 +01:00
|
|
|
std::shared_ptr<OutputFactory> keyboard_output_factory;
|
|
|
|
std::shared_ptr<OutputFactory> mouse_output_factory;
|
2021-10-11 06:43:11 +01:00
|
|
|
std::shared_ptr<OutputFactory> gcadapter_output_factory;
|
2021-11-26 21:45:37 +00:00
|
|
|
std::shared_ptr<OutputFactory> udp_client_output_factory;
|
2021-10-20 23:53:14 +01:00
|
|
|
std::shared_ptr<OutputFactory> tas_output_factory;
|
2022-06-19 05:32:07 +01:00
|
|
|
std::shared_ptr<OutputFactory> camera_output_factory;
|
2022-09-25 02:28:27 +01:00
|
|
|
std::shared_ptr<OutputFactory> virtual_amiibo_output_factory;
|
2021-10-11 06:43:11 +01:00
|
|
|
|
2021-09-20 23:43:13 +01:00
|
|
|
#ifdef HAVE_SDL2
|
|
|
|
std::shared_ptr<SDLDriver> sdl;
|
2021-10-11 06:43:11 +01:00
|
|
|
std::shared_ptr<InputFactory> sdl_input_factory;
|
|
|
|
std::shared_ptr<OutputFactory> sdl_output_factory;
|
2021-09-20 23:43:13 +01:00
|
|
|
#endif
|
2020-08-27 20:16:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
InputSubsystem::InputSubsystem() : impl{std::make_unique<Impl>()} {}
|
|
|
|
|
|
|
|
InputSubsystem::~InputSubsystem() = default;
|
|
|
|
|
|
|
|
void InputSubsystem::Initialize() {
|
|
|
|
impl->Initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InputSubsystem::Shutdown() {
|
|
|
|
impl->Shutdown();
|
|
|
|
}
|
|
|
|
|
2021-09-20 23:43:13 +01: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 05:32:07 +01:00
|
|
|
Camera* InputSubsystem::GetCamera() {
|
|
|
|
return impl->camera.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
const Camera* InputSubsystem::GetCamera() const {
|
|
|
|
return impl->camera.get();
|
|
|
|
}
|
|
|
|
|
2022-09-25 02:28:27 +01:00
|
|
|
VirtualAmiibo* InputSubsystem::GetVirtualAmiibo() {
|
|
|
|
return impl->virtual_amiibo.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
const VirtualAmiibo* InputSubsystem::GetVirtualAmiibo() const {
|
|
|
|
return impl->virtual_amiibo.get();
|
|
|
|
}
|
|
|
|
|
2020-08-27 20:16:47 +01: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 17:47:58 +01:00
|
|
|
|
2020-08-27 20:16:47 +01:00
|
|
|
ButtonMapping InputSubsystem::GetButtonMappingForDevice(const Common::ParamPackage& device) const {
|
|
|
|
return impl->GetButtonMappingForDevice(device);
|
2017-01-21 09:53:03 +00:00
|
|
|
}
|
|
|
|
|
2020-10-14 07:51:14 +01:00
|
|
|
MotionMapping InputSubsystem::GetMotionMappingForDevice(const Common::ParamPackage& device) const {
|
|
|
|
return impl->GetMotionMappingForDevice(device);
|
|
|
|
}
|
|
|
|
|
2021-11-21 20:12:01 +00:00
|
|
|
Common::Input::ButtonNames InputSubsystem::GetButtonName(const Common::ParamPackage& params) const {
|
|
|
|
return impl->GetButtonName(params);
|
2021-09-20 23:43:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool InputSubsystem::IsController(const Common::ParamPackage& params) const {
|
|
|
|
return impl->IsController(params);
|
|
|
|
}
|
|
|
|
|
2022-03-04 17:47:13 +00: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 19:56:51 +01:00
|
|
|
void InputSubsystem::ReloadInputDevices() {
|
2021-09-20 23:43:13 +01:00
|
|
|
impl->udp_client.get()->ReloadSockets();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InputSubsystem::BeginMapping(Polling::InputType type) {
|
|
|
|
impl->BeginConfiguration();
|
|
|
|
impl->mapping_factory->BeginMapping(type);
|
|
|
|
}
|
|
|
|
|
2022-01-24 16:39:17 +00:00
|
|
|
Common::ParamPackage InputSubsystem::GetNextInput() const {
|
2021-09-20 23:43:13 +01:00
|
|
|
return impl->mapping_factory->GetNextInput();
|
2020-07-14 18:01:36 +01:00
|
|
|
}
|
|
|
|
|
2021-09-20 23:43:13 +01:00
|
|
|
void InputSubsystem::StopMapping() const {
|
|
|
|
impl->EndConfiguration();
|
|
|
|
impl->mapping_factory->StopMapping();
|
2020-06-21 17:36:28 +01:00
|
|
|
}
|
|
|
|
|
2017-01-21 09:53:03 +00:00
|
|
|
std::string GenerateKeyboardParam(int key_code) {
|
2021-07-23 01:59:26 +01:00
|
|
|
Common::ParamPackage param;
|
|
|
|
param.Set("engine", "keyboard");
|
|
|
|
param.Set("code", key_code);
|
|
|
|
param.Set("toggle", false);
|
2017-01-21 09:53:03 +00:00
|
|
|
return param.Serialize();
|
|
|
|
}
|
|
|
|
|
2017-01-21 11:04:00 +00: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 09:53:03 +00:00
|
|
|
} // namespace InputCommon
|