mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-29 22:20:48 +00:00
cellGem: update gun handler connection periodically
This commit is contained in:
parent
fd66b6b103
commit
8f660fc6b1
@ -321,13 +321,28 @@ public:
|
|||||||
|
|
||||||
void update_connections()
|
void update_connections()
|
||||||
{
|
{
|
||||||
|
connected_controllers = 0;
|
||||||
|
|
||||||
|
const auto update_connection = [this](u32 i, bool connected)
|
||||||
|
{
|
||||||
|
if (connected)
|
||||||
|
{
|
||||||
|
connected_controllers++;
|
||||||
|
controllers[i].status = CELL_GEM_STATUS_READY;
|
||||||
|
controllers[i].port = port_num(i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
controllers[i].status = CELL_GEM_STATUS_DISCONNECTED;
|
||||||
|
controllers[i].port = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
switch (g_cfg.io.move)
|
switch (g_cfg.io.move)
|
||||||
{
|
{
|
||||||
case move_handler::real:
|
case move_handler::real:
|
||||||
case move_handler::fake:
|
case move_handler::fake:
|
||||||
{
|
{
|
||||||
connected_controllers = 0;
|
|
||||||
|
|
||||||
std::lock_guard lock(pad::g_pad_mutex);
|
std::lock_guard lock(pad::g_pad_mutex);
|
||||||
const auto handler = pad::get_pad_thread(true);
|
const auto handler = pad::get_pad_thread(true);
|
||||||
if (!handler) break;
|
if (!handler) break;
|
||||||
@ -335,51 +350,41 @@ public:
|
|||||||
for (u32 i = 0; i < CELL_GEM_MAX_NUM; i++)
|
for (u32 i = 0; i < CELL_GEM_MAX_NUM; i++)
|
||||||
{
|
{
|
||||||
const auto& pad = ::at32(handler->GetPads(), pad_num(i));
|
const auto& pad = ::at32(handler->GetPads(), pad_num(i));
|
||||||
const bool connected = (pad && (pad->m_port_status & CELL_PAD_STATUS_CONNECTED) && i < attribute.max_connect);
|
const bool connected = pad && (pad->m_port_status & CELL_PAD_STATUS_CONNECTED) && i < attribute.max_connect;
|
||||||
const bool is_real_move = g_cfg.io.move != move_handler::real || pad->m_pad_handler == pad_handler::move;
|
const bool is_real_move = g_cfg.io.move != move_handler::real || pad->m_pad_handler == pad_handler::move;
|
||||||
|
|
||||||
if (connected && is_real_move)
|
update_connection(i, connected && is_real_move);
|
||||||
{
|
|
||||||
connected_controllers++;
|
|
||||||
controllers[i].status = CELL_GEM_STATUS_READY;
|
|
||||||
controllers[i].port = port_num(i);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
controllers[i].status = CELL_GEM_STATUS_DISCONNECTED;
|
|
||||||
controllers[i].port = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case move_handler::mouse:
|
||||||
case move_handler::raw_mouse:
|
case move_handler::raw_mouse:
|
||||||
{
|
{
|
||||||
connected_controllers = 0;
|
|
||||||
|
|
||||||
auto& handler = g_fxo->get<MouseHandlerBase>();
|
auto& handler = g_fxo->get<MouseHandlerBase>();
|
||||||
std::lock_guard mouse_lock(handler.mutex);
|
std::lock_guard mouse_lock(handler.mutex);
|
||||||
|
|
||||||
const MouseInfo& info = handler.GetInfo();
|
const MouseInfo& info = handler.GetInfo();
|
||||||
|
|
||||||
for (u32 i = 0; i < CELL_GEM_MAX_NUM; i++)
|
for (u32 i = 0; i < CELL_GEM_MAX_NUM; i++)
|
||||||
{
|
{
|
||||||
const bool connected = i < attribute.max_connect && info.status[i] == CELL_MOUSE_STATUS_CONNECTED;
|
update_connection(i, i < attribute.max_connect && info.status[i] == CELL_MOUSE_STATUS_CONNECTED);
|
||||||
|
|
||||||
if (connected)
|
|
||||||
{
|
|
||||||
connected_controllers++;
|
|
||||||
controllers[i].status = CELL_GEM_STATUS_READY;
|
|
||||||
controllers[i].port = port_num(i);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
controllers[i].status = CELL_GEM_STATUS_DISCONNECTED;
|
|
||||||
controllers[i].port = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
#ifdef HAVE_LIBEVDEV
|
||||||
|
case move_handler::gun:
|
||||||
|
{
|
||||||
|
gun_thread& gun = g_fxo->get<gun_thread>();
|
||||||
|
std::scoped_lock lock(gun.handler.mutex);
|
||||||
|
gun.num_devices = gun.handler.init() ? gun.handler.get_num_guns() : 0;
|
||||||
|
|
||||||
|
for (u32 i = 0; i < CELL_GEM_MAX_NUM; i++)
|
||||||
|
{
|
||||||
|
update_connection(i, i < attribute.max_connect && i < gun.num_devices);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
case move_handler::null:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user