diff options
Diffstat (limited to '')
-rw-r--r-- | src/input_common/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/input_common/drivers/keyboard.cpp | 35 | ||||
-rw-r--r-- | src/input_common/drivers/keyboard.h (renamed from src/input_common/keyboard.h) | 29 | ||||
-rw-r--r-- | src/input_common/keyboard.cpp | 121 | ||||
-rw-r--r-- | src/input_common/main.cpp | 263 | ||||
-rw-r--r-- | src/input_common/main.h | 89 | ||||
-rw-r--r-- | src/yuzu/bootmanager.cpp | 62 | ||||
-rw-r--r-- | src/yuzu/bootmanager.h | 2 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 83 | ||||
-rw-r--r-- | src/yuzu/debugger/controller.cpp | 3 | ||||
-rw-r--r-- | src/yuzu/main.cpp | 18 |
11 files changed, 95 insertions, 614 deletions
diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt index 90e7618ce..0fcf7a9d7 100644 --- a/src/input_common/CMakeLists.txt +++ b/src/input_common/CMakeLists.txt @@ -1,6 +1,6 @@ add_library(input_common STATIC - keyboard.cpp - keyboard.h + drivers/keyboard.cpp + drivers/keyboard.h helpers/stick_from_buttons.cpp helpers/stick_from_buttons.h helpers/touch_from_buttons.cpp diff --git a/src/input_common/drivers/keyboard.cpp b/src/input_common/drivers/keyboard.cpp new file mode 100644 index 000000000..b00a4b8d9 --- /dev/null +++ b/src/input_common/drivers/keyboard.cpp @@ -0,0 +1,35 @@ +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included + +#include "common/param_package.h" +#include "input_common/drivers/keyboard.h" + +namespace InputCommon { + +Keyboard::Keyboard(const std::string& input_engine_) : InputEngine(input_engine_) { + PreSetController(identifier); +} + +void Keyboard::PressKey(int key_code) { + SetButton(identifier, key_code, true); +} + +void Keyboard::ReleaseKey(int key_code) { + SetButton(identifier, key_code, false); +} + +void Keyboard::ReleaseAllKeys() { + ResetButtonState(); +} + +std::vector<Common::ParamPackage> Keyboard::GetInputDevices() const { + std::vector<Common::ParamPackage> devices; + devices.emplace_back(Common::ParamPackage{ + {"engine", "keyboard"}, + {"display", "Keyboard Only"}, + }); + return devices; +} + +} // namespace InputCommon diff --git a/src/input_common/keyboard.h b/src/input_common/drivers/keyboard.h index 861950472..a3e0d8a61 100644 --- a/src/input_common/keyboard.h +++ b/src/input_common/drivers/keyboard.h @@ -1,30 +1,20 @@ -// Copyright 2017 Citra Emulator Project +// Copyright 2021 yuzu Emulator Project // Licensed under GPLv2 or any later version -// Refer to the license.txt file included. +// Refer to the license.txt file included #pragma once -#include <memory> -#include "core/frontend/input.h" +#include "input_common/input_engine.h" namespace InputCommon { -class KeyButtonList; - /** * A button device factory representing a keyboard. It receives keyboard events and forward them * to all button devices it created. */ -class Keyboard final : public Input::Factory<Input::ButtonDevice> { +class Keyboard final : public InputCommon::InputEngine { public: - Keyboard(); - - /** - * Creates a button device from a keyboard key - * @param params contains parameters for creating the device: - * - "code": the code of the key to bind with the button - */ - std::unique_ptr<Input::ButtonDevice> Create(const Common::ParamPackage& params) override; + explicit Keyboard(const std::string& input_engine_); /** * Sets the status of all buttons bound with the key to pressed @@ -40,8 +30,15 @@ public: void ReleaseAllKeys(); + /// Used for automapping features + std::vector<Common::ParamPackage> GetInputDevices() const override; + private: - std::shared_ptr<KeyButtonList> key_button_list; + const PadIdentifier identifier = { + .guid = Common::UUID{""}, + .port = 0, + .pad = 0, + }; }; } // namespace InputCommon diff --git a/src/input_common/keyboard.cpp b/src/input_common/keyboard.cpp deleted file mode 100644 index 8261e76fd..000000000 --- a/src/input_common/keyboard.cpp +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2017 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include <atomic> -#include <list> -#include <mutex> -#include <utility> -#include "input_common/keyboard.h" - -namespace InputCommon { - -class KeyButton final : public Input::ButtonDevice { -public: - explicit KeyButton(std::shared_ptr<KeyButtonList> key_button_list_, bool toggle_) - : key_button_list(std::move(key_button_list_)), toggle(toggle_) {} - - ~KeyButton() override; - - bool GetStatus() const override { - if (toggle) { - return toggled_status.load(std::memory_order_relaxed); - } - return status.load(); - } - - void ToggleButton() { - if (lock) { - return; - } - lock = true; - const bool old_toggle_status = toggled_status.load(); - toggled_status.store(!old_toggle_status); - } - - void UnlockButton() { - lock = false; - } - - friend class KeyButtonList; - -private: - std::shared_ptr<KeyButtonList> key_button_list; - std::atomic<bool> status{false}; - std::atomic<bool> toggled_status{false}; - bool lock{false}; - const bool toggle; -}; - -struct KeyButtonPair { - int key_code; - KeyButton* key_button; -}; - -class KeyButtonList { -public: - void AddKeyButton(int key_code, KeyButton* key_button) { - std::lock_guard guard{mutex}; - list.push_back(KeyButtonPair{key_code, key_button}); - } - - void RemoveKeyButton(const KeyButton* key_button) { - std::lock_guard guard{mutex}; - list.remove_if( - [key_button](const KeyButtonPair& pair) { return pair.key_button == key_button; }); - } - - void ChangeKeyStatus(int key_code, bool pressed) { - std::lock_guard guard{mutex}; - for (const KeyButtonPair& pair : list) { - if (pair.key_code == key_code) { - pair.key_button->status.store(pressed); - if (pressed) { - pair.key_button->ToggleButton(); - } else { - pair.key_button->UnlockButton(); - } - pair.key_button->TriggerOnChange(); - } - } - } - - void ChangeAllKeyStatus(bool pressed) { - std::lock_guard guard{mutex}; - for (const KeyButtonPair& pair : list) { - pair.key_button->status.store(pressed); - } - } - -private: - std::mutex mutex; - std::list<KeyButtonPair> list; -}; - -Keyboard::Keyboard() : key_button_list{std::make_shared<KeyButtonList>()} {} - -KeyButton::~KeyButton() { - key_button_list->RemoveKeyButton(this); -} - -std::unique_ptr<Input::ButtonDevice> Keyboard::Create(const Common::ParamPackage& params) { - const int key_code = params.Get("code", 0); - const bool toggle = params.Get("toggle", false); - std::unique_ptr<KeyButton> button = std::make_unique<KeyButton>(key_button_list, toggle); - key_button_list->AddKeyButton(key_code, button.get()); - return button; -} - -void Keyboard::PressKey(int key_code) { - key_button_list->ChangeKeyStatus(key_code, true); -} - -void Keyboard::ReleaseKey(int key_code) { - key_button_list->ChangeKeyStatus(key_code, false); -} - -void Keyboard::ReleaseAllKeys() { - key_button_list->ChangeAllKeyStatus(false); -} - -} // namespace InputCommon diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index 7a5c29b40..da501b6cc 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp @@ -6,17 +6,7 @@ #include <thread> #include "common/param_package.h" #include "common/settings.h" -#include "input_common/gcadapter/gc_adapter.h" -#include "input_common/gcadapter/gc_poller.h" -#include "input_common/keyboard.h" #include "input_common/main.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/tas/tas_input.h" -#include "input_common/tas/tas_poller.h" -#include "input_common/udp/client.h" -#include "input_common/udp/udp.h" #ifdef HAVE_SDL2 #include "input_common/sdl/sdl.h" #endif @@ -25,82 +15,9 @@ namespace InputCommon { struct InputSubsystem::Impl { void Initialize() { - gcadapter = std::make_shared<GCAdapter::Adapter>(); - gcbuttons = std::make_shared<GCButtonFactory>(gcadapter); - Input::RegisterFactory<Input::ButtonDevice>("gcpad", gcbuttons); - gcanalog = std::make_shared<GCAnalogFactory>(gcadapter); - Input::RegisterFactory<Input::AnalogDevice>("gcpad", gcanalog); - gcvibration = std::make_shared<GCVibrationFactory>(gcadapter); - Input::RegisterFactory<Input::VibrationDevice>("gcpad", gcvibration); - - keyboard = std::make_shared<Keyboard>(); - Input::RegisterFactory<Input::ButtonDevice>("keyboard", keyboard); - Input::RegisterFactory<Input::MotionDevice>("keyboard", - std::make_shared<MotionFromButton>()); - -#ifdef HAVE_SDL2 - sdl = SDL::Init(); -#endif - - udp = std::make_shared<InputCommon::CemuhookUDP::Client>(); - udpmotion = std::make_shared<UDPMotionFactory>(udp); - Input::RegisterFactory<Input::MotionDevice>("cemuhookudp", udpmotion); - udptouch = std::make_shared<UDPTouchFactory>(udp); - Input::RegisterFactory<Input::TouchDevice>("cemuhookudp", udptouch); - - mouse = std::make_shared<MouseInput::Mouse>(); - mousebuttons = std::make_shared<MouseButtonFactory>(mouse); - Input::RegisterFactory<Input::ButtonDevice>("mouse", mousebuttons); - mouseanalog = std::make_shared<MouseAnalogFactory>(mouse); - Input::RegisterFactory<Input::AnalogDevice>("mouse", mouseanalog); - mousemotion = std::make_shared<MouseMotionFactory>(mouse); - Input::RegisterFactory<Input::MotionDevice>("mouse", mousemotion); - mousetouch = std::make_shared<MouseTouchFactory>(mouse); - Input::RegisterFactory<Input::TouchDevice>("mouse", mousetouch); - - tas = std::make_shared<TasInput::Tas>(); - tasbuttons = std::make_shared<TasButtonFactory>(tas); - Input::RegisterFactory<Input::ButtonDevice>("tas", tasbuttons); - tasanalog = std::make_shared<TasAnalogFactory>(tas); - Input::RegisterFactory<Input::AnalogDevice>("tas", tasanalog); } void Shutdown() { - Input::UnregisterFactory<Input::ButtonDevice>("keyboard"); - Input::UnregisterFactory<Input::MotionDevice>("keyboard"); - keyboard.reset(); -#ifdef HAVE_SDL2 - sdl.reset(); -#endif - Input::UnregisterFactory<Input::ButtonDevice>("gcpad"); - Input::UnregisterFactory<Input::AnalogDevice>("gcpad"); - Input::UnregisterFactory<Input::VibrationDevice>("gcpad"); - - gcbuttons.reset(); - gcanalog.reset(); - gcvibration.reset(); - - Input::UnregisterFactory<Input::MotionDevice>("cemuhookudp"); - Input::UnregisterFactory<Input::TouchDevice>("cemuhookudp"); - - udpmotion.reset(); - udptouch.reset(); - - Input::UnregisterFactory<Input::ButtonDevice>("mouse"); - Input::UnregisterFactory<Input::AnalogDevice>("mouse"); - Input::UnregisterFactory<Input::MotionDevice>("mouse"); - Input::UnregisterFactory<Input::TouchDevice>("mouse"); - - mousebuttons.reset(); - mouseanalog.reset(); - mousemotion.reset(); - mousetouch.reset(); - - Input::UnregisterFactory<Input::ButtonDevice>("tas"); - Input::UnregisterFactory<Input::AnalogDevice>("tas"); - - tasbuttons.reset(); - tasanalog.reset(); } [[nodiscard]] std::vector<Common::ParamPackage> GetInputDevices() const { @@ -108,19 +25,7 @@ struct InputSubsystem::Impl { Common::ParamPackage{{"display", "Any"}, {"class", "any"}}, Common::ParamPackage{{"display", "Keyboard/Mouse"}, {"class", "keyboard"}}, }; - if (Settings::values.tas_enable) { - devices.emplace_back( - Common::ParamPackage{{"display", "TAS Controller"}, {"class", "tas"}}); - } -#ifdef HAVE_SDL2 - auto sdl_devices = sdl->GetInputDevices(); - devices.insert(devices.end(), sdl_devices.begin(), sdl_devices.end()); -#endif - auto udp_devices = udp->GetInputDevices(); - devices.insert(devices.end(), udp_devices.begin(), udp_devices.end()); - auto gcpad_devices = gcadapter->GetInputDevices(); - devices.insert(devices.end(), gcpad_devices.begin(), gcpad_devices.end()); - return devices; + return {}; } [[nodiscard]] AnalogMapping GetAnalogMappingForDevice( @@ -128,17 +33,6 @@ struct InputSubsystem::Impl { if (!params.Has("class") || params.Get("class", "") == "any") { return {}; } - if (params.Get("class", "") == "gcpad") { - return gcadapter->GetAnalogMappingForDevice(params); - } - if (params.Get("class", "") == "tas") { - return tas->GetAnalogMappingForDevice(params); - } -#ifdef HAVE_SDL2 - if (params.Get("class", "") == "sdl") { - return sdl->GetAnalogMappingForDevice(params); - } -#endif return {}; } @@ -147,17 +41,6 @@ struct InputSubsystem::Impl { if (!params.Has("class") || params.Get("class", "") == "any") { return {}; } - if (params.Get("class", "") == "gcpad") { - return gcadapter->GetButtonMappingForDevice(params); - } - if (params.Get("class", "") == "tas") { - return tas->GetButtonMappingForDevice(params); - } -#ifdef HAVE_SDL2 - if (params.Get("class", "") == "sdl") { - return sdl->GetButtonMappingForDevice(params); - } -#endif return {}; } @@ -166,37 +49,9 @@ struct InputSubsystem::Impl { if (!params.Has("class") || params.Get("class", "") == "any") { return {}; } - if (params.Get("class", "") == "cemuhookudp") { - // TODO return the correct motion device - return {}; - } -#ifdef HAVE_SDL2 - if (params.Get("class", "") == "sdl") { - return sdl->GetMotionMappingForDevice(params); - } -#endif return {}; } - std::shared_ptr<Keyboard> keyboard; -#ifdef HAVE_SDL2 - std::unique_ptr<SDL::State> sdl; -#endif - std::shared_ptr<GCButtonFactory> gcbuttons; - std::shared_ptr<GCAnalogFactory> gcanalog; - std::shared_ptr<GCVibrationFactory> gcvibration; - std::shared_ptr<UDPMotionFactory> udpmotion; - std::shared_ptr<UDPTouchFactory> udptouch; - std::shared_ptr<MouseButtonFactory> mousebuttons; - std::shared_ptr<MouseAnalogFactory> mouseanalog; - std::shared_ptr<MouseMotionFactory> mousemotion; - std::shared_ptr<MouseTouchFactory> mousetouch; - std::shared_ptr<TasButtonFactory> tasbuttons; - std::shared_ptr<TasAnalogFactory> tasanalog; - std::shared_ptr<CemuhookUDP::Client> udp; - std::shared_ptr<GCAdapter::Adapter> gcadapter; - std::shared_ptr<MouseInput::Mouse> mouse; - std::shared_ptr<TasInput::Tas> tas; }; InputSubsystem::InputSubsystem() : impl{std::make_unique<Impl>()} {} @@ -211,30 +66,6 @@ void InputSubsystem::Shutdown() { impl->Shutdown(); } -Keyboard* InputSubsystem::GetKeyboard() { - return impl->keyboard.get(); -} - -const Keyboard* InputSubsystem::GetKeyboard() const { - return impl->keyboard.get(); -} - -MouseInput::Mouse* InputSubsystem::GetMouse() { - return impl->mouse.get(); -} - -const MouseInput::Mouse* InputSubsystem::GetMouse() const { - return impl->mouse.get(); -} - -TasInput::Tas* InputSubsystem::GetTas() { - return impl->tas.get(); -} - -const TasInput::Tas* InputSubsystem::GetTas() const { - return impl->tas.get(); -} - std::vector<Common::ParamPackage> InputSubsystem::GetInputDevices() const { return impl->GetInputDevices(); } @@ -251,100 +82,12 @@ MotionMapping InputSubsystem::GetMotionMappingForDevice(const Common::ParamPacka return impl->GetMotionMappingForDevice(device); } -GCAnalogFactory* InputSubsystem::GetGCAnalogs() { - return impl->gcanalog.get(); -} - -const GCAnalogFactory* InputSubsystem::GetGCAnalogs() const { - return impl->gcanalog.get(); -} - -GCButtonFactory* InputSubsystem::GetGCButtons() { - return impl->gcbuttons.get(); -} - -const GCButtonFactory* InputSubsystem::GetGCButtons() const { - return impl->gcbuttons.get(); -} - -UDPMotionFactory* InputSubsystem::GetUDPMotions() { - return impl->udpmotion.get(); -} - -const UDPMotionFactory* InputSubsystem::GetUDPMotions() const { - return impl->udpmotion.get(); -} - -UDPTouchFactory* InputSubsystem::GetUDPTouch() { - return impl->udptouch.get(); -} - -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(); -} - -TasButtonFactory* InputSubsystem::GetTasButtons() { - return impl->tasbuttons.get(); -} - -const TasButtonFactory* InputSubsystem::GetTasButtons() const { - return impl->tasbuttons.get(); -} - -TasAnalogFactory* InputSubsystem::GetTasAnalogs() { - return impl->tasanalog.get(); -} - -const TasAnalogFactory* InputSubsystem::GetTasAnalogs() const { - return impl->tasanalog.get(); -} - void InputSubsystem::ReloadInputDevices() { - if (!impl->udp) { - return; - } - impl->udp->ReloadSockets(); } -std::vector<std::unique_ptr<Polling::DevicePoller>> InputSubsystem::GetPollers( - [[maybe_unused]] Polling::DeviceType type) const { -#ifdef HAVE_SDL2 - return impl->sdl->GetPollers(type); -#else +std::vector<std::unique_ptr<Polling::DevicePoller>> InputSubsystem::GetPollers([ + [maybe_unused]] Polling::DeviceType type) const { return {}; -#endif } std::string GenerateKeyboardParam(int key_code) { diff --git a/src/input_common/main.h b/src/input_common/main.h index eb247e164..b504ebe54 100644 --- a/src/input_common/main.h +++ b/src/input_common/main.h @@ -63,18 +63,6 @@ public: }; } // namespace Polling -class GCAnalogFactory; -class GCButtonFactory; -class UDPMotionFactory; -class UDPTouchFactory; -class MouseButtonFactory; -class MouseAnalogFactory; -class MouseMotionFactory; -class MouseTouchFactory; -class TasButtonFactory; -class TasAnalogFactory; -class Keyboard; - /** * Given a ParamPackage for a Device returned from `GetInputDevices`, attempt to get the default * mapping for the device. This is currently only implemented for the SDL backend devices. @@ -100,23 +88,6 @@ public: /// Unregisters all built-in input device factories and shuts them down. void Shutdown(); - /// Retrieves the underlying keyboard device. - [[nodiscard]] Keyboard* GetKeyboard(); - - /// Retrieves the underlying keyboard device. - [[nodiscard]] const Keyboard* GetKeyboard() const; - - /// Retrieves the underlying mouse device. - [[nodiscard]] MouseInput::Mouse* GetMouse(); - - /// Retrieves the underlying mouse device. - [[nodiscard]] const MouseInput::Mouse* GetMouse() const; - - /// Retrieves the underlying tas device. - [[nodiscard]] TasInput::Tas* GetTas(); - - /// Retrieves the underlying tas device. - [[nodiscard]] const TasInput::Tas* GetTas() const; /** * Returns all available input devices that this Factory can create a new device with. * Each returned ParamPackage should have a `display` field used for display, a class field for @@ -134,66 +105,6 @@ public: /// Retrieves the motion mappings for the given device. [[nodiscard]] MotionMapping GetMotionMappingForDevice(const Common::ParamPackage& device) const; - /// Retrieves the underlying GameCube analog handler. - [[nodiscard]] GCAnalogFactory* GetGCAnalogs(); - - /// Retrieves the underlying GameCube analog handler. - [[nodiscard]] const GCAnalogFactory* GetGCAnalogs() const; - - /// Retrieves the underlying GameCube button handler. - [[nodiscard]] GCButtonFactory* GetGCButtons(); - - /// Retrieves the underlying GameCube button handler. - [[nodiscard]] const GCButtonFactory* GetGCButtons() const; - - /// Retrieves the underlying udp motion handler. - [[nodiscard]] UDPMotionFactory* GetUDPMotions(); - - /// Retrieves the underlying udp motion handler. - [[nodiscard]] const UDPMotionFactory* GetUDPMotions() const; - - /// Retrieves the underlying udp touch handler. - [[nodiscard]] UDPTouchFactory* GetUDPTouch(); - - /// Retrieves the underlying udp touch handler. - [[nodiscard]] const UDPTouchFactory* GetUDPTouch() const; - - /// Retrieves the underlying mouse button handler. - [[nodiscard]] MouseButtonFactory* GetMouseButtons(); - - /// Retrieves the underlying mouse button handler. - [[nodiscard]] const MouseButtonFactory* GetMouseButtons() const; - - /// Retrieves the underlying mouse analog handler. - [[nodiscard]] MouseAnalogFactory* GetMouseAnalogs(); - - /// Retrieves the underlying mouse analog handler. - [[nodiscard]] const MouseAnalogFactory* GetMouseAnalogs() const; - - /// Retrieves the underlying mouse motion handler. - [[nodiscard]] MouseMotionFactory* GetMouseMotions(); - - /// Retrieves the underlying mouse motion handler. - [[nodiscard]] const MouseMotionFactory* GetMouseMotions() const; - - /// Retrieves the underlying mouse touch handler. - [[nodiscard]] MouseTouchFactory* GetMouseTouch(); - - /// Retrieves the underlying mouse touch handler. - [[nodiscard]] const MouseTouchFactory* GetMouseTouch() const; - - /// Retrieves the underlying tas button handler. - [[nodiscard]] TasButtonFactory* GetTasButtons(); - - /// Retrieves the underlying tas button handler. - [[nodiscard]] const TasButtonFactory* GetTasButtons() const; - - /// Retrieves the underlying tas analogs handler. - [[nodiscard]] TasAnalogFactory* GetTasAnalogs(); - - /// Retrieves the underlying tas analogs handler. - [[nodiscard]] const TasAnalogFactory* GetTasAnalogs() const; - /// Reloads the input devices void ReloadInputDevices(); diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index fd0a130a3..8a0ea90f9 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -34,8 +34,6 @@ #include "core/frontend/framebuffer_layout.h" #include "input_common/keyboard.h" #include "input_common/main.h" -#include "input_common/mouse/mouse_input.h" -#include "input_common/tas/tas_input.h" #include "video_core/renderer_base.h" #include "video_core/video_core.h" #include "yuzu/bootmanager.h" @@ -394,34 +392,34 @@ void GRenderWindow::closeEvent(QCloseEvent* event) { void GRenderWindow::keyPressEvent(QKeyEvent* event) { if (!event->isAutoRepeat()) { - input_subsystem->GetKeyboard()->PressKey(event->key()); + // input_subsystem->GetKeyboard()->PressKey(event->key()); } } void GRenderWindow::keyReleaseEvent(QKeyEvent* event) { if (!event->isAutoRepeat()) { - input_subsystem->GetKeyboard()->ReleaseKey(event->key()); - } -} - -MouseInput::MouseButton GRenderWindow::QtButtonToMouseButton(Qt::MouseButton button) { - switch (button) { - case Qt::LeftButton: - return MouseInput::MouseButton::Left; - case Qt::RightButton: - return MouseInput::MouseButton::Right; - case Qt::MiddleButton: - return MouseInput::MouseButton::Wheel; - case Qt::BackButton: - return MouseInput::MouseButton::Backward; - case Qt::ForwardButton: - return MouseInput::MouseButton::Forward; - case Qt::TaskButton: - return MouseInput::MouseButton::Task; - default: - return MouseInput::MouseButton::Extra; - } -} + // input_subsystem->GetKeyboard()->ReleaseKey(event->key()); + } +} + +//MouseInput::MouseButton GRenderWindow::QtButtonToMouseButton(Qt::MouseButton button) { +// switch (button) { +// case Qt::LeftButton: +// return MouseInput::MouseButton::Left; +// case Qt::RightButton: +// return MouseInput::MouseButton::Right; +// case Qt::MiddleButton: +// return MouseInput::MouseButton::Wheel; +// case Qt::BackButton: +// return MouseInput::MouseButton::Backward; +// case Qt::ForwardButton: +// return MouseInput::MouseButton::Forward; +// case Qt::TaskButton: +// return MouseInput::MouseButton::Task; +// default: +// return MouseInput::MouseButton::Extra; +// } +//} void GRenderWindow::mousePressEvent(QMouseEvent* event) { // Touch input is handled in TouchBeginEvent @@ -432,8 +430,8 @@ void GRenderWindow::mousePressEvent(QMouseEvent* event) { // coordinates and map them to the current render area const auto pos = mapFromGlobal(QCursor::pos()); const auto [x, y] = ScaleTouch(pos); - const auto button = QtButtonToMouseButton(event->button()); - input_subsystem->GetMouse()->PressButton(x, y, button); + //const auto button = QtButtonToMouseButton(event->button()); + //input_subsystem->GetMouse()->PressButton(x, y, button); if (event->button() == Qt::LeftButton) { this->TouchPressed(x, y, 0); @@ -453,7 +451,7 @@ void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { const auto [x, y] = ScaleTouch(pos); const int center_x = width() / 2; const int center_y = height() / 2; - input_subsystem->GetMouse()->MouseMove(x, y, center_x, center_y); + //input_subsystem->GetMouse()->MouseMove(x, y, center_x, center_y); this->TouchMoved(x, y, 0); if (Settings::values.mouse_panning) { @@ -469,8 +467,8 @@ void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) { return; } - const auto button = QtButtonToMouseButton(event->button()); - input_subsystem->GetMouse()->ReleaseButton(button); + //const auto button = QtButtonToMouseButton(event->button()); + //input_subsystem->GetMouse()->ReleaseButton(button); if (event->button() == Qt::LeftButton) { this->TouchReleased(0); @@ -558,8 +556,8 @@ bool GRenderWindow::event(QEvent* event) { void GRenderWindow::focusOutEvent(QFocusEvent* event) { QWidget::focusOutEvent(event); - input_subsystem->GetKeyboard()->ReleaseAllKeys(); - input_subsystem->GetMouse()->ReleaseAllButtons(); + //input_subsystem->GetKeyboard()->ReleaseAllKeys(); + //input_subsystem->GetMouse()->ReleaseAllButtons(); this->TouchReleased(0); } diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index 061e3605f..f0784046b 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h @@ -165,7 +165,7 @@ public: void keyReleaseEvent(QKeyEvent* event) override; /// Converts a Qt mouse button into MouseInput mouse button - static MouseInput::MouseButton QtButtonToMouseButton(Qt::MouseButton button); + // static MouseInput::MouseButton QtButtonToMouseButton(Qt::MouseButton button); void mousePressEvent(QMouseEvent* event) override; void mouseMoveEvent(QMouseEvent* event) override; diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 3aab5d5f8..09f0b219b 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -16,10 +16,7 @@ #include "core/hle/service/hid/controllers/npad.h" #include "core/hle/service/hid/hid.h" #include "core/hle/service/sm/sm.h" -#include "input_common/gcadapter/gc_poller.h" #include "input_common/main.h" -#include "input_common/mouse/mouse_poller.h" -#include "input_common/udp/udp.h" #include "ui_configure_input_player.h" #include "yuzu/bootmanager.h" #include "yuzu/configuration/config.h" @@ -564,55 +561,6 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i connect(poll_timer.get(), &QTimer::timeout, [this] { Common::ParamPackage params; - if (input_subsystem->GetGCButtons()->IsPolling()) { - params = input_subsystem->GetGCButtons()->GetNextInput(); - if (params.Has("engine") && IsInputAcceptable(params)) { - SetPollingResult(params, false); - return; - } - } - if (input_subsystem->GetGCAnalogs()->IsPolling()) { - params = input_subsystem->GetGCAnalogs()->GetNextInput(); - if (params.Has("engine") && IsInputAcceptable(params)) { - SetPollingResult(params, false); - return; - } - } - if (input_subsystem->GetUDPMotions()->IsPolling()) { - params = input_subsystem->GetUDPMotions()->GetNextInput(); - if (params.Has("engine")) { - SetPollingResult(params, false); - return; - } - } - if (input_subsystem->GetMouseButtons()->IsPolling()) { - params = input_subsystem->GetMouseButtons()->GetNextInput(); - if (params.Has("engine") && IsInputAcceptable(params)) { - SetPollingResult(params, false); - return; - } - } - if (input_subsystem->GetMouseAnalogs()->IsPolling()) { - params = input_subsystem->GetMouseAnalogs()->GetNextInput(); - if (params.Has("engine") && IsInputAcceptable(params)) { - SetPollingResult(params, false); - return; - } - } - if (input_subsystem->GetMouseMotions()->IsPolling()) { - params = input_subsystem->GetMouseMotions()->GetNextInput(); - if (params.Has("engine") && IsInputAcceptable(params)) { - SetPollingResult(params, false); - return; - } - } - if (input_subsystem->GetMouseTouch()->IsPolling()) { - params = input_subsystem->GetMouseTouch()->GetNextInput(); - if (params.Has("engine") && IsInputAcceptable(params)) { - SetPollingResult(params, false); - return; - } - } for (auto& poller : device_pollers) { params = poller->GetNextInput(); if (params.Has("engine") && IsInputAcceptable(params)) { @@ -1353,25 +1301,6 @@ void ConfigureInputPlayer::HandleClick( QWidget::grabMouse(); QWidget::grabKeyboard(); - if (type == InputCommon::Polling::DeviceType::Button) { - input_subsystem->GetGCButtons()->BeginConfiguration(); - } else { - input_subsystem->GetGCAnalogs()->BeginConfiguration(); - } - - if (type == InputCommon::Polling::DeviceType::Motion) { - input_subsystem->GetUDPMotions()->BeginConfiguration(); - } - - if (type == InputCommon::Polling::DeviceType::Button) { - input_subsystem->GetMouseButtons()->BeginConfiguration(); - } else if (type == InputCommon::Polling::DeviceType::AnalogPreferred) { - input_subsystem->GetMouseAnalogs()->BeginConfiguration(); - } else if (type == InputCommon::Polling::DeviceType::Motion) { - input_subsystem->GetMouseMotions()->BeginConfiguration(); - } else { - input_subsystem->GetMouseTouch()->BeginConfiguration(); - } if (type == InputCommon::Polling::DeviceType::Button) { ui->controllerFrame->BeginMappingButton(button_id); @@ -1393,15 +1322,6 @@ void ConfigureInputPlayer::SetPollingResult(const Common::ParamPackage& params, QWidget::releaseMouse(); QWidget::releaseKeyboard(); - input_subsystem->GetGCButtons()->EndConfiguration(); - input_subsystem->GetGCAnalogs()->EndConfiguration(); - - input_subsystem->GetUDPMotions()->EndConfiguration(); - - input_subsystem->GetMouseButtons()->EndConfiguration(); - input_subsystem->GetMouseAnalogs()->EndConfiguration(); - input_subsystem->GetMouseMotions()->EndConfiguration(); - input_subsystem->GetMouseTouch()->EndConfiguration(); if (!abort) { (*input_setter)(params); @@ -1435,8 +1355,7 @@ void ConfigureInputPlayer::mousePressEvent(QMouseEvent* event) { return; } - const auto button = GRenderWindow::QtButtonToMouseButton(event->button()); - input_subsystem->GetMouse()->PressButton(0, 0, button); + //const auto button = GRenderWindow::QtButtonToMouseButton(event->button()); } void ConfigureInputPlayer::keyPressEvent(QKeyEvent* event) { diff --git a/src/yuzu/debugger/controller.cpp b/src/yuzu/debugger/controller.cpp index 5a844409b..0e190a3d5 100644 --- a/src/yuzu/debugger/controller.cpp +++ b/src/yuzu/debugger/controller.cpp @@ -7,7 +7,6 @@ #include <QString> #include "common/settings.h" #include "input_common/main.h" -#include "input_common/tas/tas_input.h" #include "yuzu/configuration/configure_input_player_widget.h" #include "yuzu/debugger/controller.h" @@ -81,5 +80,5 @@ void ControllerDialog::InputController(ControllerInput input) { buttons |= (btn ? 1U : 0U) << index; index++; } - input_subsystem->GetTas()->RecordInput(buttons, input.axis_values); + //input_subsystem->GetTas()->RecordInput(buttons, input.axis_values); } diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 88e84e8f7..663760a1e 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -2969,15 +2969,15 @@ void GMainWindow::UpdateWindowTitle(std::string_view title_name, std::string_vie } QString GMainWindow::GetTasStateDescription() const { - auto [tas_status, current_tas_frame, total_tas_frames] = input_subsystem->GetTas()->GetStatus(); - switch (tas_status) { - case TasInput::TasState::Running: - return tr("TAS state: Running %1/%2").arg(current_tas_frame).arg(total_tas_frames); - case TasInput::TasState::Recording: - return tr("TAS state: Recording %1").arg(total_tas_frames); - case TasInput::TasState::Stopped: - return tr("TAS state: Idle %1/%2").arg(current_tas_frame).arg(total_tas_frames); - default: + //auto [tas_status, current_tas_frame, total_tas_frames] = input_subsystem->GetTas()->GetStatus(); + //switch (tas_status) { + //case TasInput::TasState::Running: + // return tr("TAS state: Running %1/%2").arg(current_tas_frame).arg(total_tas_frames); + //case TasInput::TasState::Recording: + // return tr("TAS state: Recording %1").arg(total_tas_frames); + //case TasInput::TasState::Stopped: + // return tr("TAS state: Idle %1/%2").arg(current_tas_frame).arg(total_tas_frames); + //default: return tr("TAS State: Invalid"); } } |