diff options
Diffstat (limited to '')
-rw-r--r-- | src/input_common/CMakeLists.txt | 11 | ||||
-rw-r--r-- | src/input_common/drivers/gc_adapter.h | 2 | ||||
-rw-r--r-- | src/input_common/drivers/mouse.cpp | 1 | ||||
-rw-r--r-- | src/input_common/drivers/mouse.h | 2 | ||||
-rw-r--r-- | src/input_common/drivers/sdl_driver.cpp | 15 | ||||
-rw-r--r-- | src/input_common/drivers/sdl_driver.h | 3 | ||||
-rw-r--r-- | src/input_common/drivers/tas_input.cpp | 1 | ||||
-rw-r--r-- | src/input_common/drivers/virtual_amiibo.cpp | 15 | ||||
-rw-r--r-- | src/input_common/drivers/virtual_amiibo.h | 3 | ||||
-rw-r--r-- | src/input_common/helpers/stick_from_buttons.cpp | 25 | ||||
-rw-r--r-- | src/input_common/helpers/touch_from_buttons.cpp | 22 | ||||
-rw-r--r-- | src/input_common/input_engine.h | 2 | ||||
-rw-r--r-- | src/input_common/input_poller.cpp | 18 | ||||
-rw-r--r-- | src/input_common/main.cpp | 110 | ||||
-rw-r--r-- | src/input_common/main.h | 3 | ||||
-rw-r--r-- | src/input_common/precompiled_headers.h | 6 |
16 files changed, 140 insertions, 99 deletions
diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt index cc6f0ffc0..e41da2726 100644 --- a/src/input_common/CMakeLists.txt +++ b/src/input_common/CMakeLists.txt @@ -34,6 +34,7 @@ add_library(input_common STATIC input_poller.h main.cpp main.h + precompiled_headers.h ) if (MSVC) @@ -55,7 +56,11 @@ if (ENABLE_SDL2) drivers/sdl_driver.cpp drivers/sdl_driver.h ) - target_link_libraries(input_common PRIVATE SDL2) + if (YUZU_USE_EXTERNAL_SDL2) + target_link_libraries(input_common PRIVATE SDL2-static) + else() + target_link_libraries(input_common PRIVATE SDL2) + endif() target_compile_definitions(input_common PRIVATE HAVE_SDL2) endif() @@ -63,3 +68,7 @@ target_link_libraries(input_common PRIVATE usb) create_target_directory_groups(input_common) target_link_libraries(input_common PUBLIC core PRIVATE common Boost::boost) + +if (YUZU_USE_PRECOMPILED_HEADERS) + target_precompile_headers(input_common PRIVATE precompiled_headers.h) +endif() diff --git a/src/input_common/drivers/gc_adapter.h b/src/input_common/drivers/gc_adapter.h index 7f81767f7..b5270fd0b 100644 --- a/src/input_common/drivers/gc_adapter.h +++ b/src/input_common/drivers/gc_adapter.h @@ -5,10 +5,10 @@ #include <array> #include <memory> -#include <stop_token> #include <string> #include <thread> +#include "common/polyfill_thread.h" #include "input_common/input_engine.h" struct libusb_context; diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index 98c3157a8..faf9cbdc3 100644 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp @@ -1,7 +1,6 @@ // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include <stop_token> #include <thread> #include <fmt/format.h> diff --git a/src/input_common/drivers/mouse.h b/src/input_common/drivers/mouse.h index 286ce1cf6..72073cc23 100644 --- a/src/input_common/drivers/mouse.h +++ b/src/input_common/drivers/mouse.h @@ -3,9 +3,9 @@ #pragma once -#include <stop_token> #include <thread> +#include "common/polyfill_thread.h" #include "common/vector_math.h" #include "input_common/input_engine.h" diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index 45ce588f0..8de86b61e 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp @@ -361,6 +361,12 @@ void SDLDriver::CloseJoystick(SDL_Joystick* sdl_joystick) { } } +void SDLDriver::PumpEvents() const { + if (initialized) { + SDL_PumpEvents(); + } +} + void SDLDriver::HandleGameControllerEvent(const SDL_Event& event) { switch (event.type) { case SDL_JOYBUTTONUP: { @@ -451,14 +457,6 @@ SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_en initialized = true; if (start_thread) { - poll_thread = std::thread([this] { - Common::SetCurrentThreadName("SDL_MainLoop"); - using namespace std::chrono_literals; - while (initialized) { - SDL_PumpEvents(); - std::this_thread::sleep_for(1ms); - } - }); vibration_thread = std::thread([this] { Common::SetCurrentThreadName("SDL_Vibration"); using namespace std::chrono_literals; @@ -481,7 +479,6 @@ SDLDriver::~SDLDriver() { initialized = false; if (start_thread) { - poll_thread.join(); vibration_thread.join(); SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER); } diff --git a/src/input_common/drivers/sdl_driver.h b/src/input_common/drivers/sdl_driver.h index d1b4471cf..366bcc496 100644 --- a/src/input_common/drivers/sdl_driver.h +++ b/src/input_common/drivers/sdl_driver.h @@ -36,6 +36,8 @@ public: /// Unregisters SDL device factories and shut them down. ~SDLDriver() override; + void PumpEvents() const; + /// Handle SDL_Events for joysticks from SDL_PollEvent void HandleGameControllerEvent(const SDL_Event& event); @@ -128,7 +130,6 @@ private: bool start_thread = false; std::atomic<bool> initialized = false; - std::thread poll_thread; std::thread vibration_thread; }; } // namespace InputCommon diff --git a/src/input_common/drivers/tas_input.cpp b/src/input_common/drivers/tas_input.cpp index 21c6ed405..f3ade90da 100644 --- a/src/input_common/drivers/tas_input.cpp +++ b/src/input_common/drivers/tas_input.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include <cstring> +#include <sstream> #include <fmt/format.h> #include "common/fs/file.h" diff --git a/src/input_common/drivers/virtual_amiibo.cpp b/src/input_common/drivers/virtual_amiibo.cpp index 0cd5129da..564a188e5 100644 --- a/src/input_common/drivers/virtual_amiibo.cpp +++ b/src/input_common/drivers/virtual_amiibo.cpp @@ -60,6 +60,8 @@ Common::Input::NfcState VirtualAmiibo::WriteNfcData( return Common::Input::NfcState::WriteFailed; } + amiibo_data = data; + return Common::Input::NfcState::Success; } @@ -91,6 +93,15 @@ VirtualAmiibo::Info VirtualAmiibo::LoadAmiibo(const std::string& filename) { return Info::Success; } +VirtualAmiibo::Info VirtualAmiibo::ReloadAmiibo() { + if (state == State::AmiiboIsOpen) { + SetNfc(identifier, {Common::Input::NfcState::NewAmiibo, amiibo_data}); + return Info::Success; + } + + return LoadAmiibo(file_path); +} + VirtualAmiibo::Info VirtualAmiibo::CloseAmiibo() { state = polling_mode == Common::Input::PollingMode::NFC ? State::WaitingForAmiibo : State::Initialized; @@ -98,4 +109,8 @@ VirtualAmiibo::Info VirtualAmiibo::CloseAmiibo() { return Info::Success; } +std::string VirtualAmiibo::GetLastFilePath() const { + return file_path; +} + } // namespace InputCommon diff --git a/src/input_common/drivers/virtual_amiibo.h b/src/input_common/drivers/virtual_amiibo.h index 9eac07544..9baeb3997 100644 --- a/src/input_common/drivers/virtual_amiibo.h +++ b/src/input_common/drivers/virtual_amiibo.h @@ -47,8 +47,11 @@ public: State GetCurrentState() const; Info LoadAmiibo(const std::string& amiibo_file); + Info ReloadAmiibo(); Info CloseAmiibo(); + std::string GetLastFilePath() const; + private: static constexpr std::size_t amiibo_size = 0x21C; static constexpr std::size_t amiibo_size_without_password = amiibo_size - 0x8; diff --git a/src/input_common/helpers/stick_from_buttons.cpp b/src/input_common/helpers/stick_from_buttons.cpp index 536d413a5..82aa6ac2f 100644 --- a/src/input_common/helpers/stick_from_buttons.cpp +++ b/src/input_common/helpers/stick_from_buttons.cpp @@ -294,6 +294,15 @@ public: } private: + static constexpr Common::Input::AnalogProperties properties{ + .deadzone = 0.0f, + .range = 1.0f, + .threshold = 0.5f, + .offset = 0.0f, + .inverted = false, + .toggle = false, + }; + Button up; Button down; Button left; @@ -311,23 +320,17 @@ private: float last_x_axis_value{}; float last_y_axis_value{}; Common::Input::ButtonStatus modifier_status{}; - const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; std::chrono::time_point<std::chrono::steady_clock> last_update; }; std::unique_ptr<Common::Input::InputDevice> StickFromButton::Create( const Common::ParamPackage& params) { const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); - auto up = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( - params.Get("up", null_engine)); - auto down = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( - params.Get("down", null_engine)); - auto left = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( - params.Get("left", null_engine)); - auto right = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( - params.Get("right", null_engine)); - auto modifier = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( - params.Get("modifier", null_engine)); + auto up = Common::Input::CreateInputDeviceFromString(params.Get("up", null_engine)); + auto down = Common::Input::CreateInputDeviceFromString(params.Get("down", null_engine)); + auto left = Common::Input::CreateInputDeviceFromString(params.Get("left", null_engine)); + auto right = Common::Input::CreateInputDeviceFromString(params.Get("right", null_engine)); + auto modifier = Common::Input::CreateInputDeviceFromString(params.Get("modifier", null_engine)); auto modifier_scale = params.Get("modifier_scale", 0.5f); auto modifier_angle = params.Get("modifier_angle", 5.5f); return std::make_unique<Stick>(std::move(up), std::move(down), std::move(left), diff --git a/src/input_common/helpers/touch_from_buttons.cpp b/src/input_common/helpers/touch_from_buttons.cpp index da4a3dca5..e064b13d9 100644 --- a/src/input_common/helpers/touch_from_buttons.cpp +++ b/src/input_common/helpers/touch_from_buttons.cpp @@ -10,8 +10,8 @@ namespace InputCommon { class TouchFromButtonDevice final : public Common::Input::InputDevice { public: using Button = std::unique_ptr<Common::Input::InputDevice>; - TouchFromButtonDevice(Button button_, int touch_id_, float x_, float y_) - : button(std::move(button_)), touch_id(touch_id_), x(x_), y(y_) { + TouchFromButtonDevice(Button button_, float x_, float y_) + : button(std::move(button_)), x(x_), y(y_) { last_button_value = false; button->SetCallback({ .on_change = @@ -34,7 +34,6 @@ public: .pressed = button_status, .x = {}, .y = {}, - .id = touch_id, }; status.x.properties = properties; status.y.properties = properties; @@ -60,23 +59,28 @@ public: } private: + static constexpr Common::Input::AnalogProperties properties{ + .deadzone = 0.0f, + .range = 1.0f, + .threshold = 0.5f, + .offset = 0.0f, + .inverted = false, + .toggle = false, + }; + Button button; bool last_button_value; - const int touch_id; const float x; const float y; - const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; }; std::unique_ptr<Common::Input::InputDevice> TouchFromButton::Create( const Common::ParamPackage& params) { const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); - auto button = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( - params.Get("button", null_engine)); - const auto touch_id = params.Get("touch_id", 0); + auto button = Common::Input::CreateInputDeviceFromString(params.Get("button", null_engine)); const float x = params.Get("x", 0.0f) / 1280.0f; const float y = params.Get("y", 0.0f) / 720.0f; - return std::make_unique<TouchFromButtonDevice>(std::move(button), touch_id, x, y); + return std::make_unique<TouchFromButtonDevice>(std::move(button), x, y); } } // namespace InputCommon diff --git a/src/input_common/input_engine.h b/src/input_common/input_engine.h index d4c264a8e..6cbcf5207 100644 --- a/src/input_common/input_engine.h +++ b/src/input_common/input_engine.h @@ -133,7 +133,7 @@ public: return Common::Input::CameraError::NotSupported; } - // Request nfc data from a controller + // Returns success if nfc is supported virtual Common::Input::NfcState SupportsNfc( [[maybe_unused]] const PadIdentifier& identifier) const { return Common::Input::NfcState::NotSupported; diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp index 4ac182147..fb8be42e2 100644 --- a/src/input_common/input_poller.cpp +++ b/src/input_common/input_poller.cpp @@ -229,13 +229,12 @@ private: class InputFromTouch final : public Common::Input::InputDevice { public: - explicit InputFromTouch(PadIdentifier identifier_, int touch_id_, int button_, bool toggle_, - bool inverted_, int axis_x_, int axis_y_, - Common::Input::AnalogProperties properties_x_, + explicit InputFromTouch(PadIdentifier identifier_, int button_, bool toggle_, bool inverted_, + int axis_x_, int axis_y_, Common::Input::AnalogProperties properties_x_, Common::Input::AnalogProperties properties_y_, InputEngine* input_engine_) - : identifier(identifier_), touch_id(touch_id_), button(button_), toggle(toggle_), - inverted(inverted_), axis_x(axis_x_), axis_y(axis_y_), properties_x(properties_x_), + : identifier(identifier_), button(button_), toggle(toggle_), inverted(inverted_), + axis_x(axis_x_), axis_y(axis_y_), properties_x(properties_x_), properties_y(properties_y_), input_engine(input_engine_) { UpdateCallback engine_callback{[this]() { OnChange(); }}; const InputIdentifier button_input_identifier{ @@ -271,8 +270,7 @@ public: } Common::Input::TouchStatus GetStatus() const { - Common::Input::TouchStatus status; - status.id = touch_id; + Common::Input::TouchStatus status{}; status.pressed = { .value = input_engine->GetButton(identifier, button), .inverted = inverted, @@ -307,7 +305,6 @@ public: private: const PadIdentifier identifier; - const int touch_id; const int button; const bool toggle; const bool inverted; @@ -919,7 +916,6 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTriggerDevice( std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTouchDevice( const Common::ParamPackage& params) { - const auto touch_id = params.Get("touch_id", 0); const auto deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f); const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f); const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f); @@ -954,8 +950,8 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTouchDevice( input_engine->PreSetAxis(identifier, axis_x); input_engine->PreSetAxis(identifier, axis_y); input_engine->PreSetButton(identifier, button); - return std::make_unique<InputFromTouch>(identifier, touch_id, button, toggle, inverted, axis_x, - axis_y, properties_x, properties_y, input_engine.get()); + return std::make_unique<InputFromTouch>(identifier, button, toggle, inverted, axis_x, axis_y, + properties_x, properties_y, input_engine.get()); } std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateBatteryDevice( diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index b2064ef95..942a13535 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp @@ -33,119 +33,113 @@ struct InputSubsystem::Impl { keyboard->SetMappingCallback(mapping_callback); keyboard_factory = std::make_shared<InputFactory>(keyboard); keyboard_output_factory = std::make_shared<OutputFactory>(keyboard); - Common::Input::RegisterFactory<Common::Input::InputDevice>(keyboard->GetEngineName(), - keyboard_factory); - Common::Input::RegisterFactory<Common::Input::OutputDevice>(keyboard->GetEngineName(), - keyboard_output_factory); + Common::Input::RegisterInputFactory(keyboard->GetEngineName(), keyboard_factory); + Common::Input::RegisterOutputFactory(keyboard->GetEngineName(), keyboard_output_factory); mouse = std::make_shared<Mouse>("mouse"); mouse->SetMappingCallback(mapping_callback); mouse_factory = std::make_shared<InputFactory>(mouse); mouse_output_factory = std::make_shared<OutputFactory>(mouse); - Common::Input::RegisterFactory<Common::Input::InputDevice>(mouse->GetEngineName(), - mouse_factory); - Common::Input::RegisterFactory<Common::Input::OutputDevice>(mouse->GetEngineName(), - mouse_output_factory); + Common::Input::RegisterInputFactory(mouse->GetEngineName(), mouse_factory); + Common::Input::RegisterOutputFactory(mouse->GetEngineName(), mouse_output_factory); touch_screen = std::make_shared<TouchScreen>("touch"); touch_screen_factory = std::make_shared<InputFactory>(touch_screen); - Common::Input::RegisterFactory<Common::Input::InputDevice>(touch_screen->GetEngineName(), - touch_screen_factory); + Common::Input::RegisterInputFactory(touch_screen->GetEngineName(), touch_screen_factory); gcadapter = std::make_shared<GCAdapter>("gcpad"); gcadapter->SetMappingCallback(mapping_callback); gcadapter_input_factory = std::make_shared<InputFactory>(gcadapter); gcadapter_output_factory = std::make_shared<OutputFactory>(gcadapter); - Common::Input::RegisterFactory<Common::Input::InputDevice>(gcadapter->GetEngineName(), - gcadapter_input_factory); - Common::Input::RegisterFactory<Common::Input::OutputDevice>(gcadapter->GetEngineName(), - gcadapter_output_factory); + Common::Input::RegisterInputFactory(gcadapter->GetEngineName(), gcadapter_input_factory); + Common::Input::RegisterOutputFactory(gcadapter->GetEngineName(), gcadapter_output_factory); udp_client = std::make_shared<CemuhookUDP::UDPClient>("cemuhookudp"); udp_client->SetMappingCallback(mapping_callback); udp_client_input_factory = std::make_shared<InputFactory>(udp_client); udp_client_output_factory = std::make_shared<OutputFactory>(udp_client); - Common::Input::RegisterFactory<Common::Input::InputDevice>(udp_client->GetEngineName(), - udp_client_input_factory); - Common::Input::RegisterFactory<Common::Input::OutputDevice>(udp_client->GetEngineName(), - udp_client_output_factory); + Common::Input::RegisterInputFactory(udp_client->GetEngineName(), udp_client_input_factory); + Common::Input::RegisterOutputFactory(udp_client->GetEngineName(), + udp_client_output_factory); tas_input = std::make_shared<TasInput::Tas>("tas"); tas_input->SetMappingCallback(mapping_callback); tas_input_factory = std::make_shared<InputFactory>(tas_input); tas_output_factory = std::make_shared<OutputFactory>(tas_input); - Common::Input::RegisterFactory<Common::Input::InputDevice>(tas_input->GetEngineName(), - tas_input_factory); - Common::Input::RegisterFactory<Common::Input::OutputDevice>(tas_input->GetEngineName(), - tas_output_factory); + Common::Input::RegisterInputFactory(tas_input->GetEngineName(), tas_input_factory); + Common::Input::RegisterOutputFactory(tas_input->GetEngineName(), tas_output_factory); camera = std::make_shared<Camera>("camera"); camera->SetMappingCallback(mapping_callback); camera_input_factory = std::make_shared<InputFactory>(camera); camera_output_factory = std::make_shared<OutputFactory>(camera); - Common::Input::RegisterFactory<Common::Input::InputDevice>(camera->GetEngineName(), - camera_input_factory); - Common::Input::RegisterFactory<Common::Input::OutputDevice>(camera->GetEngineName(), - camera_output_factory); + Common::Input::RegisterInputFactory(camera->GetEngineName(), camera_input_factory); + Common::Input::RegisterOutputFactory(camera->GetEngineName(), camera_output_factory); virtual_amiibo = std::make_shared<VirtualAmiibo>("virtual_amiibo"); virtual_amiibo->SetMappingCallback(mapping_callback); virtual_amiibo_input_factory = std::make_shared<InputFactory>(virtual_amiibo); virtual_amiibo_output_factory = std::make_shared<OutputFactory>(virtual_amiibo); - Common::Input::RegisterFactory<Common::Input::InputDevice>(virtual_amiibo->GetEngineName(), - virtual_amiibo_input_factory); - Common::Input::RegisterFactory<Common::Input::OutputDevice>(virtual_amiibo->GetEngineName(), - virtual_amiibo_output_factory); + Common::Input::RegisterInputFactory(virtual_amiibo->GetEngineName(), + virtual_amiibo_input_factory); + Common::Input::RegisterOutputFactory(virtual_amiibo->GetEngineName(), + virtual_amiibo_output_factory); #ifdef HAVE_SDL2 sdl = std::make_shared<SDLDriver>("sdl"); sdl->SetMappingCallback(mapping_callback); sdl_input_factory = std::make_shared<InputFactory>(sdl); sdl_output_factory = std::make_shared<OutputFactory>(sdl); - Common::Input::RegisterFactory<Common::Input::InputDevice>(sdl->GetEngineName(), - sdl_input_factory); - Common::Input::RegisterFactory<Common::Input::OutputDevice>(sdl->GetEngineName(), - sdl_output_factory); + Common::Input::RegisterInputFactory(sdl->GetEngineName(), sdl_input_factory); + Common::Input::RegisterOutputFactory(sdl->GetEngineName(), sdl_output_factory); #endif - Common::Input::RegisterFactory<Common::Input::InputDevice>( - "touch_from_button", std::make_shared<TouchFromButton>()); - Common::Input::RegisterFactory<Common::Input::InputDevice>( - "analog_from_button", std::make_shared<StickFromButton>()); + Common::Input::RegisterInputFactory("touch_from_button", + std::make_shared<TouchFromButton>()); + Common::Input::RegisterInputFactory("analog_from_button", + std::make_shared<StickFromButton>()); } void Shutdown() { - Common::Input::UnregisterFactory<Common::Input::InputDevice>(keyboard->GetEngineName()); - Common::Input::UnregisterFactory<Common::Input::OutputDevice>(keyboard->GetEngineName()); + Common::Input::UnregisterInputFactory(keyboard->GetEngineName()); + Common::Input::UnregisterOutputFactory(keyboard->GetEngineName()); keyboard.reset(); - Common::Input::UnregisterFactory<Common::Input::InputDevice>(mouse->GetEngineName()); - Common::Input::UnregisterFactory<Common::Input::OutputDevice>(mouse->GetEngineName()); + Common::Input::UnregisterInputFactory(mouse->GetEngineName()); + Common::Input::UnregisterOutputFactory(mouse->GetEngineName()); mouse.reset(); - Common::Input::UnregisterFactory<Common::Input::InputDevice>(touch_screen->GetEngineName()); + Common::Input::UnregisterInputFactory(touch_screen->GetEngineName()); touch_screen.reset(); - Common::Input::UnregisterFactory<Common::Input::InputDevice>(gcadapter->GetEngineName()); - Common::Input::UnregisterFactory<Common::Input::OutputDevice>(gcadapter->GetEngineName()); + Common::Input::UnregisterInputFactory(gcadapter->GetEngineName()); + Common::Input::UnregisterOutputFactory(gcadapter->GetEngineName()); gcadapter.reset(); - Common::Input::UnregisterFactory<Common::Input::InputDevice>(udp_client->GetEngineName()); - Common::Input::UnregisterFactory<Common::Input::OutputDevice>(udp_client->GetEngineName()); + Common::Input::UnregisterInputFactory(udp_client->GetEngineName()); + Common::Input::UnregisterOutputFactory(udp_client->GetEngineName()); udp_client.reset(); - Common::Input::UnregisterFactory<Common::Input::InputDevice>(tas_input->GetEngineName()); - Common::Input::UnregisterFactory<Common::Input::OutputDevice>(tas_input->GetEngineName()); + Common::Input::UnregisterInputFactory(tas_input->GetEngineName()); + Common::Input::UnregisterOutputFactory(tas_input->GetEngineName()); tas_input.reset(); + Common::Input::UnregisterInputFactory(camera->GetEngineName()); + Common::Input::UnregisterOutputFactory(camera->GetEngineName()); + camera.reset(); + + Common::Input::UnregisterInputFactory(virtual_amiibo->GetEngineName()); + Common::Input::UnregisterOutputFactory(virtual_amiibo->GetEngineName()); + virtual_amiibo.reset(); + #ifdef HAVE_SDL2 - Common::Input::UnregisterFactory<Common::Input::InputDevice>(sdl->GetEngineName()); - Common::Input::UnregisterFactory<Common::Input::OutputDevice>(sdl->GetEngineName()); + Common::Input::UnregisterInputFactory(sdl->GetEngineName()); + Common::Input::UnregisterOutputFactory(sdl->GetEngineName()); sdl.reset(); #endif - Common::Input::UnregisterFactory<Common::Input::InputDevice>("touch_from_button"); - Common::Input::UnregisterFactory<Common::Input::InputDevice>("analog_from_button"); + Common::Input::UnregisterInputFactory("touch_from_button"); + Common::Input::UnregisterInputFactory("analog_from_button"); } [[nodiscard]] std::vector<Common::ParamPackage> GetInputDevices() const { @@ -324,6 +318,12 @@ struct InputSubsystem::Impl { #endif } + void PumpEvents() const { +#ifdef HAVE_SDL2 + sdl->PumpEvents(); +#endif + } + void RegisterInput(const MappingData& data) { mapping_factory->RegisterInput(data); } @@ -472,6 +472,10 @@ void InputSubsystem::StopMapping() const { impl->mapping_factory->StopMapping(); } +void InputSubsystem::PumpEvents() const { + impl->PumpEvents(); +} + std::string GenerateKeyboardParam(int key_code) { Common::ParamPackage param; param.Set("engine", "keyboard"); diff --git a/src/input_common/main.h b/src/input_common/main.h index ced252383..6218c37f6 100644 --- a/src/input_common/main.h +++ b/src/input_common/main.h @@ -147,6 +147,9 @@ public: /// Stop polling from all backends. void StopMapping() const; + /// Signals SDL driver for new input events + void PumpEvents() const; + private: struct Impl; std::unique_ptr<Impl> impl; diff --git a/src/input_common/precompiled_headers.h b/src/input_common/precompiled_headers.h new file mode 100644 index 000000000..aabae730b --- /dev/null +++ b/src/input_common/precompiled_headers.h @@ -0,0 +1,6 @@ +// SPDX-FileCopyrightText: 2022 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "common/common_precompiled_headers.h" |