diff options
| author | 2020-11-17 22:55:09 -0600 | |
|---|---|---|
| committer | 2020-11-25 23:59:30 -0600 | |
| commit | e46f0e084c73420f8c76c514079952ca0acf1ebe (patch) | |
| tree | 9d17776f73ffee5a42e20a7d4b12409e830cce26 /src/input_common/main.cpp | |
| parent | Merge pull request #4308 from ReinUsesLisp/maxwell-3d-funcs (diff) | |
| download | yuzu-e46f0e084c73420f8c76c514079952ca0acf1ebe.tar.gz yuzu-e46f0e084c73420f8c76c514079952ca0acf1ebe.tar.xz yuzu-e46f0e084c73420f8c76c514079952ca0acf1ebe.zip | |
Implement full mouse support
Diffstat (limited to 'src/input_common/main.cpp')
| -rw-r--r-- | src/input_common/main.cpp | 73 |
1 files changed, 63 insertions, 10 deletions
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index e59ad4ff5..880ea73b8 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp | |||
| @@ -10,8 +10,9 @@ | |||
| 10 | #include "input_common/gcadapter/gc_poller.h" | 10 | #include "input_common/gcadapter/gc_poller.h" |
| 11 | #include "input_common/keyboard.h" | 11 | #include "input_common/keyboard.h" |
| 12 | #include "input_common/main.h" | 12 | #include "input_common/main.h" |
| 13 | #include "input_common/motion_emu.h" | ||
| 14 | #include "input_common/motion_from_button.h" | 13 | #include "input_common/motion_from_button.h" |
| 14 | #include "input_common/mouse/mouse_input.h" | ||
| 15 | #include "input_common/mouse/mouse_poller.h" | ||
| 15 | #include "input_common/touch_from_button.h" | 16 | #include "input_common/touch_from_button.h" |
| 16 | #include "input_common/udp/client.h" | 17 | #include "input_common/udp/client.h" |
| 17 | #include "input_common/udp/udp.h" | 18 | #include "input_common/udp/udp.h" |
| @@ -37,8 +38,6 @@ struct InputSubsystem::Impl { | |||
| 37 | std::make_shared<AnalogFromButton>()); | 38 | std::make_shared<AnalogFromButton>()); |
| 38 | Input::RegisterFactory<Input::MotionDevice>("keyboard", | 39 | Input::RegisterFactory<Input::MotionDevice>("keyboard", |
| 39 | std::make_shared<MotionFromButton>()); | 40 | std::make_shared<MotionFromButton>()); |
| 40 | motion_emu = std::make_shared<MotionEmu>(); | ||
| 41 | Input::RegisterFactory<Input::MotionDevice>("motion_emu", motion_emu); | ||
| 42 | Input::RegisterFactory<Input::TouchDevice>("touch_from_button", | 41 | Input::RegisterFactory<Input::TouchDevice>("touch_from_button", |
| 43 | std::make_shared<TouchFromButtonFactory>()); | 42 | std::make_shared<TouchFromButtonFactory>()); |
| 44 | 43 | ||
| @@ -51,6 +50,16 @@ struct InputSubsystem::Impl { | |||
| 51 | Input::RegisterFactory<Input::MotionDevice>("cemuhookudp", udpmotion); | 50 | Input::RegisterFactory<Input::MotionDevice>("cemuhookudp", udpmotion); |
| 52 | udptouch = std::make_shared<UDPTouchFactory>(udp); | 51 | udptouch = std::make_shared<UDPTouchFactory>(udp); |
| 53 | Input::RegisterFactory<Input::TouchDevice>("cemuhookudp", udptouch); | 52 | Input::RegisterFactory<Input::TouchDevice>("cemuhookudp", udptouch); |
| 53 | |||
| 54 | mouse = std::make_shared<MouseInput::Mouse>(); | ||
| 55 | mousebuttons = std::make_shared<MouseButtonFactory>(mouse); | ||
| 56 | Input::RegisterFactory<Input::ButtonDevice>("mouse", mousebuttons); | ||
| 57 | mouseanalog = std::make_shared<MouseAnalogFactory>(mouse); | ||
| 58 | Input::RegisterFactory<Input::AnalogDevice>("mouse", mouseanalog); | ||
| 59 | mousemotion = std::make_shared<MouseMotionFactory>(mouse); | ||
| 60 | Input::RegisterFactory<Input::MotionDevice>("mouse", mousemotion); | ||
| 61 | mousetouch = std::make_shared<MouseTouchFactory>(mouse); | ||
| 62 | Input::RegisterFactory<Input::TouchDevice>("mouse", mousetouch); | ||
| 54 | } | 63 | } |
| 55 | 64 | ||
| 56 | void Shutdown() { | 65 | void Shutdown() { |
| @@ -58,8 +67,6 @@ struct InputSubsystem::Impl { | |||
| 58 | Input::UnregisterFactory<Input::MotionDevice>("keyboard"); | 67 | Input::UnregisterFactory<Input::MotionDevice>("keyboard"); |
| 59 | keyboard.reset(); | 68 | keyboard.reset(); |
| 60 | Input::UnregisterFactory<Input::AnalogDevice>("analog_from_button"); | 69 | Input::UnregisterFactory<Input::AnalogDevice>("analog_from_button"); |
| 61 | Input::UnregisterFactory<Input::MotionDevice>("motion_emu"); | ||
| 62 | motion_emu.reset(); | ||
| 63 | Input::UnregisterFactory<Input::TouchDevice>("touch_from_button"); | 70 | Input::UnregisterFactory<Input::TouchDevice>("touch_from_button"); |
| 64 | #ifdef HAVE_SDL2 | 71 | #ifdef HAVE_SDL2 |
| 65 | sdl.reset(); | 72 | sdl.reset(); |
| @@ -77,6 +84,16 @@ struct InputSubsystem::Impl { | |||
| 77 | 84 | ||
| 78 | udpmotion.reset(); | 85 | udpmotion.reset(); |
| 79 | udptouch.reset(); | 86 | udptouch.reset(); |
| 87 | |||
| 88 | Input::UnregisterFactory<Input::ButtonDevice>("mouse"); | ||
| 89 | Input::UnregisterFactory<Input::AnalogDevice>("mouse"); | ||
| 90 | Input::UnregisterFactory<Input::MotionDevice>("mouse"); | ||
| 91 | Input::UnregisterFactory<Input::TouchDevice>("mouse"); | ||
| 92 | |||
| 93 | mousebuttons.reset(); | ||
| 94 | mouseanalog.reset(); | ||
| 95 | mousemotion.reset(); | ||
| 96 | mousetouch.reset(); | ||
| 80 | } | 97 | } |
| 81 | 98 | ||
| 82 | [[nodiscard]] std::vector<Common::ParamPackage> GetInputDevices() const { | 99 | [[nodiscard]] std::vector<Common::ParamPackage> GetInputDevices() const { |
| @@ -140,7 +157,6 @@ struct InputSubsystem::Impl { | |||
| 140 | } | 157 | } |
| 141 | 158 | ||
| 142 | std::shared_ptr<Keyboard> keyboard; | 159 | std::shared_ptr<Keyboard> keyboard; |
| 143 | std::shared_ptr<MotionEmu> motion_emu; | ||
| 144 | #ifdef HAVE_SDL2 | 160 | #ifdef HAVE_SDL2 |
| 145 | std::unique_ptr<SDL::State> sdl; | 161 | std::unique_ptr<SDL::State> sdl; |
| 146 | #endif | 162 | #endif |
| @@ -149,8 +165,13 @@ struct InputSubsystem::Impl { | |||
| 149 | std::shared_ptr<GCVibrationFactory> gcvibration; | 165 | std::shared_ptr<GCVibrationFactory> gcvibration; |
| 150 | std::shared_ptr<UDPMotionFactory> udpmotion; | 166 | std::shared_ptr<UDPMotionFactory> udpmotion; |
| 151 | std::shared_ptr<UDPTouchFactory> udptouch; | 167 | std::shared_ptr<UDPTouchFactory> udptouch; |
| 168 | std::shared_ptr<MouseButtonFactory> mousebuttons; | ||
| 169 | std::shared_ptr<MouseAnalogFactory> mouseanalog; | ||
| 170 | std::shared_ptr<MouseMotionFactory> mousemotion; | ||
| 171 | std::shared_ptr<MouseTouchFactory> mousetouch; | ||
| 152 | std::shared_ptr<CemuhookUDP::Client> udp; | 172 | std::shared_ptr<CemuhookUDP::Client> udp; |
| 153 | std::shared_ptr<GCAdapter::Adapter> gcadapter; | 173 | std::shared_ptr<GCAdapter::Adapter> gcadapter; |
| 174 | std::shared_ptr<MouseInput::Mouse> mouse; | ||
| 154 | }; | 175 | }; |
| 155 | 176 | ||
| 156 | InputSubsystem::InputSubsystem() : impl{std::make_unique<Impl>()} {} | 177 | InputSubsystem::InputSubsystem() : impl{std::make_unique<Impl>()} {} |
| @@ -173,12 +194,12 @@ const Keyboard* InputSubsystem::GetKeyboard() const { | |||
| 173 | return impl->keyboard.get(); | 194 | return impl->keyboard.get(); |
| 174 | } | 195 | } |
| 175 | 196 | ||
| 176 | MotionEmu* InputSubsystem::GetMotionEmu() { | 197 | MouseInput::Mouse* InputSubsystem::GetMouse() { |
| 177 | return impl->motion_emu.get(); | 198 | return impl->mouse.get(); |
| 178 | } | 199 | } |
| 179 | 200 | ||
| 180 | const MotionEmu* InputSubsystem::GetMotionEmu() const { | 201 | const MouseInput::Mouse* InputSubsystem::GetMouse() const { |
| 181 | return impl->motion_emu.get(); | 202 | return impl->mouse.get(); |
| 182 | } | 203 | } |
| 183 | 204 | ||
| 184 | std::vector<Common::ParamPackage> InputSubsystem::GetInputDevices() const { | 205 | std::vector<Common::ParamPackage> InputSubsystem::GetInputDevices() const { |
| @@ -229,6 +250,38 @@ const UDPTouchFactory* InputSubsystem::GetUDPTouch() const { | |||
| 229 | return impl->udptouch.get(); | 250 | return impl->udptouch.get(); |
| 230 | } | 251 | } |
| 231 | 252 | ||
| 253 | MouseButtonFactory* InputSubsystem::GetMouseButtons() { | ||
| 254 | return impl->mousebuttons.get(); | ||
| 255 | } | ||
| 256 | |||
| 257 | const MouseButtonFactory* InputSubsystem::GetMouseButtons() const { | ||
| 258 | return impl->mousebuttons.get(); | ||
| 259 | } | ||
| 260 | |||
| 261 | MouseAnalogFactory* InputSubsystem::GetMouseAnalogs() { | ||
| 262 | return impl->mouseanalog.get(); | ||
| 263 | } | ||
| 264 | |||
| 265 | const MouseAnalogFactory* InputSubsystem::GetMouseAnalogs() const { | ||
| 266 | return impl->mouseanalog.get(); | ||
| 267 | } | ||
| 268 | |||
| 269 | MouseMotionFactory* InputSubsystem::GetMouseMotions() { | ||
| 270 | return impl->mousemotion.get(); | ||
| 271 | } | ||
| 272 | |||
| 273 | const MouseMotionFactory* InputSubsystem::GetMouseMotions() const { | ||
| 274 | return impl->mousemotion.get(); | ||
| 275 | } | ||
| 276 | |||
| 277 | MouseTouchFactory* InputSubsystem::GetMouseTouch() { | ||
| 278 | return impl->mousetouch.get(); | ||
| 279 | } | ||
| 280 | |||
| 281 | const MouseTouchFactory* InputSubsystem::GetMouseTouch() const { | ||
| 282 | return impl->mousetouch.get(); | ||
| 283 | } | ||
| 284 | |||
| 232 | void InputSubsystem::ReloadInputDevices() { | 285 | void InputSubsystem::ReloadInputDevices() { |
| 233 | if (!impl->udp) { | 286 | if (!impl->udp) { |
| 234 | return; | 287 | return; |