mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 13:31:27 +12:00
LogitechG27: use named_thread instead of std::thread
This commit is contained in:
parent
bc18b3592c
commit
8d9ba4329d
2 changed files with 12 additions and 11 deletions
|
@ -58,12 +58,12 @@ usb_device_logitech_g27::usb_device_logitech_g27(u32 controller_index, const std
|
||||||
if (!m_enabled)
|
if (!m_enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_house_keeping_thread = std::thread([this]()
|
m_house_keeping_thread = std::make_unique<named_thread<std::function<void()>>>("Logitech G27", [this]()
|
||||||
{
|
{
|
||||||
while (!m_stop_thread)
|
while (thread_ctrl::state() != thread_state::aborting)
|
||||||
{
|
{
|
||||||
sdl_refresh();
|
sdl_refresh();
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
thread_ctrl::wait_for(5'000'000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -88,12 +88,14 @@ static void clear_sdl_joysticks(std::map<u32, std::vector<SDL_Joystick*>>& joyst
|
||||||
|
|
||||||
usb_device_logitech_g27::~usb_device_logitech_g27()
|
usb_device_logitech_g27::~usb_device_logitech_g27()
|
||||||
{
|
{
|
||||||
// stop the house keeping thread
|
|
||||||
m_stop_thread = true;
|
|
||||||
|
|
||||||
// wait for the house keeping thread to finish
|
// wait for the house keeping thread to finish
|
||||||
if (m_house_keeping_thread.joinable())
|
if (m_house_keeping_thread)
|
||||||
m_house_keeping_thread.join();
|
{
|
||||||
|
auto& thread = *m_house_keeping_thread;
|
||||||
|
thread = thread_state::aborting;
|
||||||
|
thread();
|
||||||
|
m_house_keeping_thread.reset();
|
||||||
|
}
|
||||||
|
|
||||||
// Close sdl handles
|
// Close sdl handles
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Emu/Io/usb_device.h"
|
#include "Emu/Io/usb_device.h"
|
||||||
|
#include "Utilities/Thread.h"
|
||||||
#include "LogitechG27Config.h"
|
#include "LogitechG27Config.h"
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
|
@ -14,7 +15,6 @@
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
enum class logitech_g27_ffb_state
|
enum class logitech_g27_ffb_state
|
||||||
{
|
{
|
||||||
|
@ -122,6 +122,5 @@ private:
|
||||||
|
|
||||||
bool m_enabled = false;
|
bool m_enabled = false;
|
||||||
|
|
||||||
std::thread m_house_keeping_thread;
|
std::unique_ptr<named_thread<std::function<void()>>> m_house_keeping_thread;
|
||||||
atomic_t<bool> m_stop_thread { false };
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue