summaryrefslogtreecommitdiffstats
path: root/src/input_common/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/drivers')
-rw-r--r--src/input_common/drivers/gc_adapter.h2
-rw-r--r--src/input_common/drivers/mouse.cpp1
-rw-r--r--src/input_common/drivers/mouse.h2
-rw-r--r--src/input_common/drivers/sdl_driver.cpp15
-rw-r--r--src/input_common/drivers/sdl_driver.h3
-rw-r--r--src/input_common/drivers/tas_input.cpp1
-rw-r--r--src/input_common/drivers/virtual_amiibo.cpp15
-rw-r--r--src/input_common/drivers/virtual_amiibo.h3
8 files changed, 29 insertions, 13 deletions
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;