summaryrefslogtreecommitdiff
path: root/src/input_common/main.cpp
diff options
context:
space:
mode:
authorGravatar german2020-09-04 21:35:42 -0500
committerGravatar german2020-09-04 21:48:13 -0500
commit6ee8eab670acfed494ade355d77a32c57f7c9585 (patch)
treeca91a7ca7ac7861ae48c5456870eee425fc8c209 /src/input_common/main.cpp
parentRemove RealMotionDevice (diff)
downloadyuzu-6ee8eab670acfed494ade355d77a32c57f7c9585.tar.gz
yuzu-6ee8eab670acfed494ade355d77a32c57f7c9585.tar.xz
yuzu-6ee8eab670acfed494ade355d77a32c57f7c9585.zip
Add cemu hook changes related to PR #4609
Diffstat (limited to 'src/input_common/main.cpp')
-rw-r--r--src/input_common/main.cpp46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp
index ea1a1cee6..062ec66b5 100644
--- a/src/input_common/main.cpp
+++ b/src/input_common/main.cpp
@@ -12,6 +12,7 @@
12#include "input_common/main.h" 12#include "input_common/main.h"
13#include "input_common/motion_emu.h" 13#include "input_common/motion_emu.h"
14#include "input_common/touch_from_button.h" 14#include "input_common/touch_from_button.h"
15#include "input_common/udp/client.h"
15#include "input_common/udp/udp.h" 16#include "input_common/udp/udp.h"
16#ifdef HAVE_SDL2 17#ifdef HAVE_SDL2
17#include "input_common/sdl/sdl.h" 18#include "input_common/sdl/sdl.h"
@@ -40,7 +41,11 @@ struct InputSubsystem::Impl {
40 sdl = SDL::Init(); 41 sdl = SDL::Init();
41#endif 42#endif
42 43
43 udp = CemuhookUDP::Init(); 44 udp = std::make_shared<InputCommon::CemuhookUDP::Client>();
45 udpmotion = std::make_shared<UDPMotionFactory>(udp);
46 Input::RegisterFactory<Input::MotionDevice>("cemuhookudp", udpmotion);
47 udptouch = std::make_shared<UDPTouchFactory>(udp);
48 Input::RegisterFactory<Input::TouchDevice>("cemuhookudp", udptouch);
44 } 49 }
45 50
46 void Shutdown() { 51 void Shutdown() {
@@ -53,12 +58,17 @@ struct InputSubsystem::Impl {
53#ifdef HAVE_SDL2 58#ifdef HAVE_SDL2
54 sdl.reset(); 59 sdl.reset();
55#endif 60#endif
56 udp.reset();
57 Input::UnregisterFactory<Input::ButtonDevice>("gcpad"); 61 Input::UnregisterFactory<Input::ButtonDevice>("gcpad");
58 Input::UnregisterFactory<Input::AnalogDevice>("gcpad"); 62 Input::UnregisterFactory<Input::AnalogDevice>("gcpad");
59 63
60 gcbuttons.reset(); 64 gcbuttons.reset();
61 gcanalog.reset(); 65 gcanalog.reset();
66
67 Input::UnregisterFactory<Input::MotionDevice>("cemuhookudp");
68 Input::UnregisterFactory<Input::TouchDevice>("cemuhookudp");
69
70 udpmotion.reset();
71 udptouch.reset();
62 } 72 }
63 73
64 [[nodiscard]] std::vector<Common::ParamPackage> GetInputDevices() const { 74 [[nodiscard]] std::vector<Common::ParamPackage> GetInputDevices() const {
@@ -109,14 +119,28 @@ struct InputSubsystem::Impl {
109 return {}; 119 return {};
110 } 120 }
111 121
122 [[nodiscard]] MotionMapping GetMotionMappingForDevice(
123 const Common::ParamPackage& params) const {
124 if (!params.Has("class") || params.Get("class", "") == "any") {
125 return {};
126 }
127 if (params.Get("class", "") == "cemuhookudp") {
128 // TODO return the correct motion device
129 return {};
130 }
131 return {};
132 }
133
112 std::shared_ptr<Keyboard> keyboard; 134 std::shared_ptr<Keyboard> keyboard;
113 std::shared_ptr<MotionEmu> motion_emu; 135 std::shared_ptr<MotionEmu> motion_emu;
114#ifdef HAVE_SDL2 136#ifdef HAVE_SDL2
115 std::unique_ptr<SDL::State> sdl; 137 std::unique_ptr<SDL::State> sdl;
116#endif 138#endif
117 std::unique_ptr<CemuhookUDP::State> udp;
118 std::shared_ptr<GCButtonFactory> gcbuttons; 139 std::shared_ptr<GCButtonFactory> gcbuttons;
119 std::shared_ptr<GCAnalogFactory> gcanalog; 140 std::shared_ptr<GCAnalogFactory> gcanalog;
141 std::shared_ptr<UDPMotionFactory> udpmotion;
142 std::shared_ptr<UDPTouchFactory> udptouch;
143 std::shared_ptr<CemuhookUDP::Client> udp;
120}; 144};
121 145
122InputSubsystem::InputSubsystem() : impl{std::make_unique<Impl>()} {} 146InputSubsystem::InputSubsystem() : impl{std::make_unique<Impl>()} {}
@@ -175,6 +199,22 @@ const GCButtonFactory* InputSubsystem::GetGCButtons() const {
175 return impl->gcbuttons.get(); 199 return impl->gcbuttons.get();
176} 200}
177 201
202UDPMotionFactory* InputSubsystem::GetUDPMotions() {
203 return impl->udpmotion.get();
204}
205
206const UDPMotionFactory* InputSubsystem::GetUDPMotions() const {
207 return impl->udpmotion.get();
208}
209
210UDPTouchFactory* InputSubsystem::GetUDPTouch() {
211 return impl->udptouch.get();
212}
213
214const UDPTouchFactory* InputSubsystem::GetUDPTouch() const {
215 return impl->udptouch.get();
216}
217
178void InputSubsystem::ReloadInputDevices() { 218void InputSubsystem::ReloadInputDevices() {
179 if (!impl->udp) { 219 if (!impl->udp) {
180 return; 220 return;