Compare commits

..

1 Commits

Author SHA1 Message Date
lizzie 03d1c622d5 [input/sdl] nuke SDL_Vibration thread
Signed-off-by: lizzie <lizzie@eden-emu.dev>
2026-09-02 13:44:36 +02:00
6 changed files with 14 additions and 66 deletions
@@ -28,13 +28,13 @@ object NativeConfig {
* Reads values in the global config file and saves them.
*/
@Synchronized
external fun reloadGlobalConfig(): Boolean
external fun reloadGlobalConfig()
/**
* Saves global settings values in memory to disk.
*/
@Synchronized
external fun saveGlobalConfig(): Boolean
external fun saveGlobalConfig()
/**
* Creates per-game config for the specified parameters. Must be unloaded once per-game config
@@ -54,7 +54,7 @@ object NativeConfig {
* Saves per-game settings values in memory to disk.
*/
@Synchronized
external fun savePerGameConfig(): Boolean
external fun savePerGameConfig()
/**
* Destroys the stored per-game config object. This does not save the config.
+8 -13
View File
@@ -45,16 +45,12 @@ void Java_org_yuzu_yuzu_1emu_utils_NativeConfig_unloadGlobalConfig(JNIEnv* env,
global_config.reset();
}
jboolean Java_org_yuzu_yuzu_1emu_utils_NativeConfig_reloadGlobalConfig(JNIEnv* env, jobject obj) {
if (global_config)
global_config->AndroidConfig::ReloadAllValues();
return global_config != nullptr;
void Java_org_yuzu_yuzu_1emu_utils_NativeConfig_reloadGlobalConfig(JNIEnv* env, jobject obj) {
global_config->AndroidConfig::ReloadAllValues();
}
jboolean Java_org_yuzu_yuzu_1emu_utils_NativeConfig_saveGlobalConfig(JNIEnv* env, jobject obj) {
if (global_config)
global_config->AndroidConfig::SaveAllValues();
return global_config != nullptr;
void Java_org_yuzu_yuzu_1emu_utils_NativeConfig_saveGlobalConfig(JNIEnv* env, jobject obj) {
global_config->AndroidConfig::SaveAllValues();
}
void Java_org_yuzu_yuzu_1emu_utils_NativeConfig_initializePerGameConfig(JNIEnv* env, jobject obj,
@@ -67,14 +63,13 @@ void Java_org_yuzu_yuzu_1emu_utils_NativeConfig_initializePerGameConfig(JNIEnv*
std::make_unique<AndroidConfig>(config_file_name, Config::ConfigType::PerGameConfig);
}
jboolean Java_org_yuzu_yuzu_1emu_utils_NativeConfig_isPerGameConfigLoaded(JNIEnv* env, jobject obj) {
jboolean Java_org_yuzu_yuzu_1emu_utils_NativeConfig_isPerGameConfigLoaded(JNIEnv* env,
jobject obj) {
return per_game_config != nullptr;
}
jboolean Java_org_yuzu_yuzu_1emu_utils_NativeConfig_savePerGameConfig(JNIEnv* env, jobject obj) {
if (per_game_config)
per_game_config->AndroidConfig::SaveAllValues();
return per_game_config != nullptr;
void Java_org_yuzu_yuzu_1emu_utils_NativeConfig_savePerGameConfig(JNIEnv* env, jobject obj) {
per_game_config->AndroidConfig::SaveAllValues();
}
void Java_org_yuzu_yuzu_1emu_utils_NativeConfig_unloadPerGameConfig(JNIEnv* env, jobject obj) {
+1 -1
View File
@@ -358,7 +358,7 @@ private:
ConnectionState(boost::asio::ip::tcp::socket&& client_socket_, async_pipe signal_pipe_, Kernel::KernelCore& kernel)
: client_socket{std::move(client_socket_)}
, signal_pipe{std::move(signal_pipe_)}
, signal_pipe{signal_pipe_}
, active_thread{kernel, nullptr}
{}
-3
View File
@@ -1021,9 +1021,6 @@ Result KProcess::Run(KernelCore& kernel, s32 priority, size_t stack_size) {
// Suspend for debug, if we should.
if (kernel.System().DebuggerEnabled()) {
LOG_INFO(Debug_GDBStub,
"GDB stub enabled; suspending guest process until a debugger continues execution on port {}",
Settings::values.gdbstub_port.GetValue());
main_thread->RequestSuspend(kernel, SuspendType::Debug);
}
+1 -40
View File
@@ -697,16 +697,6 @@ SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_en
SDL_AddEventWatch(&SDLEventWatcher, this);
initialized = true;
if (start_thread) {
vibration_thread = std::thread([this] {
Common::SetCurrentThreadName("SDL_Vibration");
using namespace std::chrono_literals;
while (initialized) {
SendVibrations();
std::this_thread::sleep_for(250ms); // 4 TPS
}
});
}
// Because the events for joystick connection happens before we have our event watcher added, we
// can just open all the joysticks right here
int joystick_count = 0;
@@ -725,7 +715,6 @@ SDLDriver::~SDLDriver() {
initialized = false;
if (start_thread) {
vibration_thread.join();
SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD);
}
}
@@ -805,10 +794,7 @@ Common::Input::DriverResult SDLDriver::SetVibration(
.type = Common::Input::VibrationAmplificationType::Exponential,
};
vibration_queue.Push(VibrationRequest{
.identifier = identifier,
.vibration = new_vibration,
});
joystick->RumblePlay(new_vibration);
return Common::Input::DriverResult::Success;
}
@@ -852,31 +838,6 @@ bool SDLDriver::IsVibrationEnabled(const PadIdentifier& identifier) {
return true;
}
void SDLDriver::SendVibrations() {
std::vector<VibrationRequest> filtered_vibrations{};
while (!vibration_queue.Empty()) {
VibrationRequest request;
vibration_queue.Pop(request);
const auto joystick = GetSDLJoystickByGUID(request.identifier.guid.RawString(),
static_cast<int>(request.identifier.port));
const auto it = std::find_if(filtered_vibrations.begin(), filtered_vibrations.end(),
[request](VibrationRequest vibration) {
return vibration.identifier == request.identifier;
});
if (it == filtered_vibrations.end()) {
filtered_vibrations.push_back(std::move(request));
continue;
}
*it = request;
}
for (const auto& vibration : filtered_vibrations) {
const auto joystick = GetSDLJoystickByGUID(vibration.identifier.guid.RawString(),
static_cast<int>(vibration.identifier.port));
joystick->RumblePlay(vibration.vibration);
}
}
Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, const Common::UUID& guid,
s32 axis, float value) const {
Common::ParamPackage params{};
+1 -6
View File
@@ -113,16 +113,11 @@ private:
/// Returns true if the button is on the left joycon
bool IsButtonOnLeftSide(Settings::NativeButton::Values button) const;
/// Queue of vibration request to controllers
Common::SPSCQueue<VibrationRequest> vibration_queue;
/// Map of GUID of a list of corresponding virtual Joysticks
::Common::unordered_map<Common::UUID, std::vector<std::shared_ptr<SDLJoystick>>> joystick_map;
std::mutex joystick_map_mutex;
bool start_thread = false;
std::atomic<bool> initialized = false;
std::thread vibration_thread;
bool start_thread;
};
} // namespace InputCommon