Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cellPad: don't report fake move pads as connected #15365

Merged
merged 2 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions rpcs3/Emu/Cell/Modules/cellPad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ void cellPad_NotifyStateChange(usz index, u64 /*state*/, bool locked)
const auto& pads = handler->GetPads();
const auto& pad = pads[index];

if (pad->is_fake_move)
{
return;
}

pad_data_internal& reported_info = info->reported_info[index];
const u32 old_status = reported_info.port_status;

Expand Down Expand Up @@ -193,7 +198,7 @@ error_code cellPadInit(ppu_thread& ppu, u32 max_connect)

for (usz i = 0; i < config.get_max_connect(); ++i)
{
if (pads[i]->m_port_status & CELL_PAD_STATUS_CONNECTED)
if (!pads[i]->is_fake_move && (pads[i]->m_port_status & CELL_PAD_STATUS_CONNECTED))
{
send_sys_io_connect_event(i, CELL_PAD_STATUS_CONNECTED);
}
Expand Down Expand Up @@ -259,7 +264,7 @@ error_code cellPadClearBuf(u32 port_no)
const auto& pads = handler->GetPads();
const auto& pad = pads[port_no];

if (!config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
if (pad->is_fake_move || !config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
return not_an_error(CELL_PAD_ERROR_NO_DEVICE);

clear_pad_buffer(pad);
Expand Down Expand Up @@ -620,7 +625,7 @@ error_code cellPadGetData(u32 port_no, vm::ptr<CellPadData> data)
const auto& pads = handler->GetPads();
const auto& pad = pads[port_no];

if (!config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
if (pad->is_fake_move || !config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
return not_an_error(CELL_PAD_ERROR_NO_DEVICE);

pad_get_data(port_no, data.get_ptr());
Expand Down Expand Up @@ -700,7 +705,7 @@ error_code cellPadPeriphGetData(u32 port_no, vm::ptr<CellPadPeriphData> data)
const auto& pads = handler->GetPads();
const auto& pad = pads[port_no];

if (!config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
if (pad->is_fake_move || !config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
return not_an_error(CELL_PAD_ERROR_NO_DEVICE);

pad_get_data(port_no, &data->cellpad_data, true);
Expand Down Expand Up @@ -732,7 +737,7 @@ error_code cellPadGetRawData(u32 port_no, vm::ptr<CellPadData> data)
const auto& pads = handler->GetPads();
const auto& pad = pads[port_no];

if (!config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
if (pad->is_fake_move || !config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
return not_an_error(CELL_PAD_ERROR_NO_DEVICE);

// ?
Expand Down Expand Up @@ -796,7 +801,7 @@ error_code cellPadSetActDirect(u32 port_no, vm::ptr<CellPadActParam> param)
const auto& pads = handler->GetPads();
const auto& pad = pads[port_no];

if (!config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
if (pad->is_fake_move || !config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
return not_an_error(CELL_PAD_ERROR_NO_DEVICE);

// TODO: find out if this is checked here or later or at all
Expand Down Expand Up @@ -923,7 +928,7 @@ error_code cellPadGetCapabilityInfo(u32 port_no, vm::ptr<CellPadCapabilityInfo>
const auto& pads = handler->GetPads();
const auto& pad = pads[port_no];

if (!config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
if (pad->is_fake_move || !config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
return not_an_error(CELL_PAD_ERROR_NO_DEVICE);

// Should return the same as device capability mask, psl1ght has it backwards in pad->h
Expand Down Expand Up @@ -979,7 +984,7 @@ error_code cellPadInfoPressMode(u32 port_no)
const auto& pads = handler->GetPads();
const auto& pad = pads[port_no];

if (!config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
if (pad->is_fake_move || !config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
return not_an_error(CELL_PAD_ERROR_NO_DEVICE);

return not_an_error((pad->m_device_capability & CELL_PAD_CAPABILITY_PRESS_MODE) ? 1 : 0);
Expand All @@ -1006,7 +1011,7 @@ error_code cellPadInfoSensorMode(u32 port_no)
const auto& pads = handler->GetPads();
const auto& pad = pads[port_no];

if (!config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
if (pad->is_fake_move || !config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
return not_an_error(CELL_PAD_ERROR_NO_DEVICE);

return not_an_error((pad->m_device_capability & CELL_PAD_CAPABILITY_SENSOR_MODE) ? 1 : 0);
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/Io/PadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ void PadHandlerBase::process()

pad->m_port_status |= CELL_PAD_STATUS_CONNECTED + CELL_PAD_STATUS_ASSIGN_CHANGES;

if (m_emulation)
if (m_emulation && !pad->is_fake_move)
{
pad_state_notify_state_change(i, CELL_PAD_STATUS_CONNECTED);
}
Expand Down Expand Up @@ -776,7 +776,7 @@ void PadHandlerBase::process()

pad->m_port_status |= CELL_PAD_STATUS_CONNECTED + CELL_PAD_STATUS_ASSIGN_CHANGES;

if (m_emulation)
if (m_emulation && !pad->is_fake_move)
{
pad_state_notify_state_change(i, CELL_PAD_STATUS_CONNECTED);
}
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/Emu/Io/pad_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ struct Pad
bool ldd{false};
CellPadData ldd_data{};

bool is_fake_move = false;

explicit Pad(pad_handler handler, u32 port_status, u32 device_capability, u32 device_type)
: m_pad_handler(handler)
, m_port_status(port_status)
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/Input/pad_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "Emu/system_config.h"
#include "Emu/RSX/Overlays/HomeMenu/overlay_home_menu.h"
#include "Emu/RSX/Overlays/overlay_message.h"
#include "Emu/Cell/Modules/cellGem.h"
#include "Utilities/Thread.h"
#include "util/atomic.hpp"

Expand Down Expand Up @@ -169,6 +170,7 @@ void pad_thread::Init()
cur_pad_handler->Init();

m_pads[i] = std::make_shared<Pad>(handler_type, CELL_PAD_STATUS_DISCONNECTED, pad_settings[i].device_capability, pad_settings[i].device_type);
m_pads[i]->is_fake_move = (g_cfg.io.move == move_handler::fake && i >= (CELL_PAD_MAX_PORT_NUM - CELL_GEM_MAX_NUM));

if (pad_settings[i].is_ldd_pad)
{
Expand Down