From 297823239026d1b5487f9b07f63646ca4a2e3a79 Mon Sep 17 00:00:00 2001 From: german Date: Fri, 25 Sep 2020 17:58:27 -0500 Subject: Add random motion input to keyboard --- src/input_common/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/input_common/main.cpp') diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index 8da829132..3d97d95f7 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp @@ -11,6 +11,7 @@ #include "input_common/keyboard.h" #include "input_common/main.h" #include "input_common/motion_emu.h" +#include "input_common/motion_from_button.h" #include "input_common/touch_from_button.h" #include "input_common/udp/client.h" #include "input_common/udp/udp.h" @@ -32,6 +33,8 @@ struct InputSubsystem::Impl { Input::RegisterFactory("keyboard", keyboard); Input::RegisterFactory("analog_from_button", std::make_shared()); + Input::RegisterFactory("keyboard", + std::make_shared()); motion_emu = std::make_shared(); Input::RegisterFactory("motion_emu", motion_emu); Input::RegisterFactory("touch_from_button", @@ -50,6 +53,7 @@ struct InputSubsystem::Impl { void Shutdown() { Input::UnregisterFactory("keyboard"); + Input::UnregisterFactory("keyboard"); keyboard.reset(); Input::UnregisterFactory("analog_from_button"); Input::UnregisterFactory("motion_emu"); -- cgit v1.2.3 From 046c0c91a3ed665531f20955e7cfb86fe5b73213 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 14 Oct 2020 02:51:14 -0400 Subject: input_common/CMakeLists: Make some warnings errors Makes the input_common code warnings consistent with the rest of the codebase. --- src/input_common/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/input_common/main.cpp') diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index 3d97d95f7..d32fd8b81 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp @@ -196,6 +196,10 @@ ButtonMapping InputSubsystem::GetButtonMappingForDevice(const Common::ParamPacka return impl->GetButtonMappingForDevice(device); } +MotionMapping InputSubsystem::GetMotionMappingForDevice(const Common::ParamPackage& device) const { + return impl->GetMotionMappingForDevice(device); +} + GCAnalogFactory* InputSubsystem::GetGCAnalogs() { return impl->gcanalog.get(); } -- cgit v1.2.3 From 75eaab2e0f48eb588c1bfb85f96630e199fbc1da Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Thu, 17 Sep 2020 12:00:29 -0400 Subject: configure_input_player: Implement input exclusivity and persistence With this, the "Input Devices" combobox should accurately reflect the input device being used and disallows inputs from other input devices unless the input device is set to "Any". --- src/input_common/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/input_common/main.cpp') diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index d32fd8b81..354c734fe 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp @@ -78,7 +78,7 @@ struct InputSubsystem::Impl { [[nodiscard]] std::vector GetInputDevices() const { std::vector devices = { Common::ParamPackage{{"display", "Any"}, {"class", "any"}}, - Common::ParamPackage{{"display", "Keyboard/Mouse"}, {"class", "key"}}, + Common::ParamPackage{{"display", "Keyboard/Mouse"}, {"class", "keyboard"}}, }; #ifdef HAVE_SDL2 auto sdl_devices = sdl->GetInputDevices(); @@ -96,7 +96,7 @@ struct InputSubsystem::Impl { if (!params.Has("class") || params.Get("class", "") == "any") { return {}; } - if (params.Get("class", "") == "key") { + if (params.Get("class", "") == "keyboard") { // TODO consider returning the SDL key codes for the default keybindings return {}; } @@ -116,7 +116,7 @@ struct InputSubsystem::Impl { if (!params.Has("class") || params.Get("class", "") == "any") { return {}; } - if (params.Get("class", "") == "key") { + if (params.Get("class", "") == "keyboard") { // TODO consider returning the SDL key codes for the default keybindings return {}; } -- cgit v1.2.3 From ceb7b11f166a4e59945a6296d364980c37ca681e Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Mon, 28 Sep 2020 10:27:29 -0400 Subject: configure_input_player: Change "Defaults" button behavior RestoreDefaults() now restores the selected devices' mappings using UpdateMappingWithDefaults(). This allows us to move the keyboard mapping from RestoreDefaults() to UpdateMappingWithDefaults(). --- src/input_common/main.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src/input_common/main.cpp') diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index 354c734fe..b438482cc 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp @@ -96,10 +96,6 @@ struct InputSubsystem::Impl { if (!params.Has("class") || params.Get("class", "") == "any") { return {}; } - if (params.Get("class", "") == "keyboard") { - // TODO consider returning the SDL key codes for the default keybindings - return {}; - } if (params.Get("class", "") == "gcpad") { return gcadapter->GetAnalogMappingForDevice(params); } @@ -116,10 +112,6 @@ struct InputSubsystem::Impl { if (!params.Has("class") || params.Get("class", "") == "any") { return {}; } - if (params.Get("class", "") == "keyboard") { - // TODO consider returning the SDL key codes for the default keybindings - return {}; - } if (params.Get("class", "") == "gcpad") { return gcadapter->GetButtonMappingForDevice(params); } -- cgit v1.2.3 From e9e1876e821b8bd1bb5c8254ec93e2cc479e16dd Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Tue, 20 Oct 2020 13:55:25 -0400 Subject: input_common: Add VibrationDevice and VibrationDeviceFactory A vibration device is an input device that returns an unsigned byte as status. It represents whether the vibration device supports vibration or not. If the status returns 1, it supports vibration. Otherwise, it does not support vibration. --- src/input_common/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/input_common/main.cpp') diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index b438482cc..e59ad4ff5 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp @@ -28,6 +28,8 @@ struct InputSubsystem::Impl { Input::RegisterFactory("gcpad", gcbuttons); gcanalog = std::make_shared(gcadapter); Input::RegisterFactory("gcpad", gcanalog); + gcvibration = std::make_shared(gcadapter); + Input::RegisterFactory("gcpad", gcvibration); keyboard = std::make_shared(); Input::RegisterFactory("keyboard", keyboard); @@ -64,9 +66,11 @@ struct InputSubsystem::Impl { #endif Input::UnregisterFactory("gcpad"); Input::UnregisterFactory("gcpad"); + Input::UnregisterFactory("gcpad"); gcbuttons.reset(); gcanalog.reset(); + gcvibration.reset(); Input::UnregisterFactory("cemuhookudp"); Input::UnregisterFactory("cemuhookudp"); @@ -142,6 +146,7 @@ struct InputSubsystem::Impl { #endif std::shared_ptr gcbuttons; std::shared_ptr gcanalog; + std::shared_ptr gcvibration; std::shared_ptr udpmotion; std::shared_ptr udptouch; std::shared_ptr udp; -- cgit v1.2.3 From 2c2b586d86d71bd6c134c32d27b155615230222e Mon Sep 17 00:00:00 2001 From: german Date: Tue, 17 Nov 2020 22:16:29 -0600 Subject: Add multiple udp server support --- src/input_common/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/input_common/main.cpp') diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index e59ad4ff5..5299549db 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp @@ -233,7 +233,7 @@ void InputSubsystem::ReloadInputDevices() { if (!impl->udp) { return; } - impl->udp->ReloadUDPClient(); + impl->udp->ReloadSockets(); } std::vector> InputSubsystem::GetPollers( -- cgit v1.2.3 From e46f0e084c73420f8c76c514079952ca0acf1ebe Mon Sep 17 00:00:00 2001 From: german Date: Tue, 17 Nov 2020 22:55:09 -0600 Subject: Implement full mouse support --- src/input_common/main.cpp | 73 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 63 insertions(+), 10 deletions(-) (limited to 'src/input_common/main.cpp') 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 @@ #include "input_common/gcadapter/gc_poller.h" #include "input_common/keyboard.h" #include "input_common/main.h" -#include "input_common/motion_emu.h" #include "input_common/motion_from_button.h" +#include "input_common/mouse/mouse_input.h" +#include "input_common/mouse/mouse_poller.h" #include "input_common/touch_from_button.h" #include "input_common/udp/client.h" #include "input_common/udp/udp.h" @@ -37,8 +38,6 @@ struct InputSubsystem::Impl { std::make_shared()); Input::RegisterFactory("keyboard", std::make_shared()); - motion_emu = std::make_shared(); - Input::RegisterFactory("motion_emu", motion_emu); Input::RegisterFactory("touch_from_button", std::make_shared()); @@ -51,6 +50,16 @@ struct InputSubsystem::Impl { Input::RegisterFactory("cemuhookudp", udpmotion); udptouch = std::make_shared(udp); Input::RegisterFactory("cemuhookudp", udptouch); + + mouse = std::make_shared(); + mousebuttons = std::make_shared(mouse); + Input::RegisterFactory("mouse", mousebuttons); + mouseanalog = std::make_shared(mouse); + Input::RegisterFactory("mouse", mouseanalog); + mousemotion = std::make_shared(mouse); + Input::RegisterFactory("mouse", mousemotion); + mousetouch = std::make_shared(mouse); + Input::RegisterFactory("mouse", mousetouch); } void Shutdown() { @@ -58,8 +67,6 @@ struct InputSubsystem::Impl { Input::UnregisterFactory("keyboard"); keyboard.reset(); Input::UnregisterFactory("analog_from_button"); - Input::UnregisterFactory("motion_emu"); - motion_emu.reset(); Input::UnregisterFactory("touch_from_button"); #ifdef HAVE_SDL2 sdl.reset(); @@ -77,6 +84,16 @@ struct InputSubsystem::Impl { udpmotion.reset(); udptouch.reset(); + + Input::UnregisterFactory("mouse"); + Input::UnregisterFactory("mouse"); + Input::UnregisterFactory("mouse"); + Input::UnregisterFactory("mouse"); + + mousebuttons.reset(); + mouseanalog.reset(); + mousemotion.reset(); + mousetouch.reset(); } [[nodiscard]] std::vector GetInputDevices() const { @@ -140,7 +157,6 @@ struct InputSubsystem::Impl { } std::shared_ptr keyboard; - std::shared_ptr motion_emu; #ifdef HAVE_SDL2 std::unique_ptr sdl; #endif @@ -149,8 +165,13 @@ struct InputSubsystem::Impl { std::shared_ptr gcvibration; std::shared_ptr udpmotion; std::shared_ptr udptouch; + std::shared_ptr mousebuttons; + std::shared_ptr mouseanalog; + std::shared_ptr mousemotion; + std::shared_ptr mousetouch; std::shared_ptr udp; std::shared_ptr gcadapter; + std::shared_ptr mouse; }; InputSubsystem::InputSubsystem() : impl{std::make_unique()} {} @@ -173,12 +194,12 @@ const Keyboard* InputSubsystem::GetKeyboard() const { return impl->keyboard.get(); } -MotionEmu* InputSubsystem::GetMotionEmu() { - return impl->motion_emu.get(); +MouseInput::Mouse* InputSubsystem::GetMouse() { + return impl->mouse.get(); } -const MotionEmu* InputSubsystem::GetMotionEmu() const { - return impl->motion_emu.get(); +const MouseInput::Mouse* InputSubsystem::GetMouse() const { + return impl->mouse.get(); } std::vector InputSubsystem::GetInputDevices() const { @@ -229,6 +250,38 @@ const UDPTouchFactory* InputSubsystem::GetUDPTouch() const { return impl->udptouch.get(); } +MouseButtonFactory* InputSubsystem::GetMouseButtons() { + return impl->mousebuttons.get(); +} + +const MouseButtonFactory* InputSubsystem::GetMouseButtons() const { + return impl->mousebuttons.get(); +} + +MouseAnalogFactory* InputSubsystem::GetMouseAnalogs() { + return impl->mouseanalog.get(); +} + +const MouseAnalogFactory* InputSubsystem::GetMouseAnalogs() const { + return impl->mouseanalog.get(); +} + +MouseMotionFactory* InputSubsystem::GetMouseMotions() { + return impl->mousemotion.get(); +} + +const MouseMotionFactory* InputSubsystem::GetMouseMotions() const { + return impl->mousemotion.get(); +} + +MouseTouchFactory* InputSubsystem::GetMouseTouch() { + return impl->mousetouch.get(); +} + +const MouseTouchFactory* InputSubsystem::GetMouseTouch() const { + return impl->mousetouch.get(); +} + void InputSubsystem::ReloadInputDevices() { if (!impl->udp) { return; -- cgit v1.2.3