summaryrefslogtreecommitdiffstats
path: root/src/input_common/main.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2022-12-18 02:16:13 +0100
committerGitHub <noreply@github.com>2022-12-18 02:16:13 +0100
commit48108a8c9b28e08f86aab5c2ad41414e455f4706 (patch)
tree2dc3ff390a17ebdee32958eac619632cef424fe4 /src/input_common/main.cpp
parentMerge pull request #7450 from FernandoS27/ndc-vulkan (diff)
parentinput_common: Add virtual gamepad (diff)
downloadyuzu-48108a8c9b28e08f86aab5c2ad41414e455f4706.tar
yuzu-48108a8c9b28e08f86aab5c2ad41414e455f4706.tar.gz
yuzu-48108a8c9b28e08f86aab5c2ad41414e455f4706.tar.bz2
yuzu-48108a8c9b28e08f86aab5c2ad41414e455f4706.tar.lz
yuzu-48108a8c9b28e08f86aab5c2ad41414e455f4706.tar.xz
yuzu-48108a8c9b28e08f86aab5c2ad41414e455f4706.tar.zst
yuzu-48108a8c9b28e08f86aab5c2ad41414e455f4706.zip
Diffstat (limited to 'src/input_common/main.cpp')
-rw-r--r--src/input_common/main.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp
index 942a13535..75b856c95 100644
--- a/src/input_common/main.cpp
+++ b/src/input_common/main.cpp
@@ -12,6 +12,7 @@
#include "input_common/drivers/touch_screen.h"
#include "input_common/drivers/udp_client.h"
#include "input_common/drivers/virtual_amiibo.h"
+#include "input_common/drivers/virtual_gamepad.h"
#include "input_common/helpers/stick_from_buttons.h"
#include "input_common/helpers/touch_from_buttons.h"
#include "input_common/input_engine.h"
@@ -85,6 +86,12 @@ struct InputSubsystem::Impl {
Common::Input::RegisterOutputFactory(virtual_amiibo->GetEngineName(),
virtual_amiibo_output_factory);
+ virtual_gamepad = std::make_shared<VirtualGamepad>("virtual_gamepad");
+ virtual_gamepad->SetMappingCallback(mapping_callback);
+ virtual_gamepad_input_factory = std::make_shared<InputFactory>(virtual_gamepad);
+ Common::Input::RegisterInputFactory(virtual_gamepad->GetEngineName(),
+ virtual_gamepad_input_factory);
+
#ifdef HAVE_SDL2
sdl = std::make_shared<SDLDriver>("sdl");
sdl->SetMappingCallback(mapping_callback);
@@ -132,6 +139,9 @@ struct InputSubsystem::Impl {
Common::Input::UnregisterOutputFactory(virtual_amiibo->GetEngineName());
virtual_amiibo.reset();
+ Common::Input::UnregisterInputFactory(virtual_gamepad->GetEngineName());
+ virtual_gamepad.reset();
+
#ifdef HAVE_SDL2
Common::Input::UnregisterInputFactory(sdl->GetEngineName());
Common::Input::UnregisterOutputFactory(sdl->GetEngineName());
@@ -290,6 +300,9 @@ struct InputSubsystem::Impl {
if (engine == tas_input->GetEngineName()) {
return true;
}
+ if (engine == virtual_gamepad->GetEngineName()) {
+ return true;
+ }
#ifdef HAVE_SDL2
if (engine == sdl->GetEngineName()) {
return true;
@@ -338,6 +351,7 @@ struct InputSubsystem::Impl {
std::shared_ptr<CemuhookUDP::UDPClient> udp_client;
std::shared_ptr<Camera> camera;
std::shared_ptr<VirtualAmiibo> virtual_amiibo;
+ std::shared_ptr<VirtualGamepad> virtual_gamepad;
std::shared_ptr<InputFactory> keyboard_factory;
std::shared_ptr<InputFactory> mouse_factory;
@@ -347,6 +361,7 @@ struct InputSubsystem::Impl {
std::shared_ptr<InputFactory> tas_input_factory;
std::shared_ptr<InputFactory> camera_input_factory;
std::shared_ptr<InputFactory> virtual_amiibo_input_factory;
+ std::shared_ptr<InputFactory> virtual_gamepad_input_factory;
std::shared_ptr<OutputFactory> keyboard_output_factory;
std::shared_ptr<OutputFactory> mouse_output_factory;
@@ -423,6 +438,14 @@ const VirtualAmiibo* InputSubsystem::GetVirtualAmiibo() const {
return impl->virtual_amiibo.get();
}
+VirtualGamepad* InputSubsystem::GetVirtualGamepad() {
+ return impl->virtual_gamepad.get();
+}
+
+const VirtualGamepad* InputSubsystem::GetVirtualGamepad() const {
+ return impl->virtual_gamepad.get();
+}
+
std::vector<Common::ParamPackage> InputSubsystem::GetInputDevices() const {
return impl->GetInputDevices();
}