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

LV2/cellPad: Implement priority-based connection updates #14458

Merged
merged 2 commits into from
Aug 10, 2023

Conversation

elad335
Copy link
Contributor

@elad335 elad335 commented Aug 9, 2023

  • Fix max_connect value in cellPadGetInfo, this value is the unmodified one from cellPadInit.
  • cellPadGetInfo does not execute even a single syscall to read controller state, it relies on data updates from the _cfg_ev_hndlr input thread. This thread has a priority of 512 and most of the threads in The Simposns Game have priority of 256 including the main thread which calls the cellPad functions. This means, that in order for a connection to be registered the IO thread (_cfg_ev_hndlr) needs to able to run first which means it is dependant on the LV2 schedular to allow it. I went along and implemented this functionality HLE style for LV2, I think this probably has more uses. Written in LLE style with event queue in the end.

This fixes input in The Simpsons Game which expects controller readings to report disconnected at first then connected.
Fixes #6093

This value is saved and loaded from cellPadInit as is.
rpcs3/Emu/Io/PadHandler.cpp Outdated Show resolved Hide resolved
rpcs3/Emu/Io/PadHandler.cpp Outdated Show resolved Hide resolved
rpcs3/Emu/Cell/Modules/cellPad.cpp Outdated Show resolved Hide resolved
rpcs3/Emu/Cell/Modules/cellPad.cpp Outdated Show resolved Hide resolved
rpcs3/Emu/Cell/Modules/cellPad.h Outdated Show resolved Hide resolved
rpcs3/Emu/Cell/Modules/cellPad.cpp Outdated Show resolved Hide resolved
@Blackbird88
Copy link

This also fixes The Godfather: Don's Edition [BLUS30023] pad detection. It no longer requires the pad to be disconnected and reconnected to progress.

@elad335 elad335 force-pushed the spu-log branch 2 times, most recently from 5a9b624 to 80cffd6 Compare August 9, 2023 17:43
@elad335 elad335 marked this pull request as ready for review August 9, 2023 17:43
@elad335 elad335 changed the title [WIP] LV2/cellPad: Implement priority-based connection updates LV2/cellPad: Implement priority-based connection updates Aug 9, 2023
@elad335
Copy link
Contributor Author

elad335 commented Aug 9, 2023

I need regression testing with other games, possibly disconecting and reconnecting controller fast to see if anything breaks.

// Wakeup
ppu.check_state();

[[maybe_unused]] const u64 arg1 = ppu.gpr[5];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why maybe unused.
Makes no sense

return std::min<u32>(max_connect, CELL_PAD_MAX_PORT_NUM);
}

bool may_be_connected(u32 port_no) const
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the may_be is necessary.
From a cell perspective it's either true or not.
It doesn't matter what the game thinks here

Copy link
Contributor Author

@elad335 elad335 Aug 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this is an old result from thread, it does not reflect the state of cellPadGetData which also executes hid syscalls.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well then it's probably more fitting to say confirmed_connected or something like that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because it is not a confirmation, it is a merely a cached result that may be inaccuarte if the game's thread prority is lower than 512. I renamed to "is_reportedly_connected".

info->reported_statuses[index] = (state & CELL_PAD_STATUS_CONNECTED) | CELL_PAD_STATUS_ASSIGN_CHANGES;
}

extern void PadStateNotifyStateChange(u32 index, u32 state)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

snake_case

@elad335 elad335 force-pushed the spu-log branch 2 times, most recently from ecd1bcd to 6d8bac6 Compare August 10, 2023 05:10
@elad335
Copy link
Contributor Author

elad335 commented Aug 10, 2023

Btw I do not touch cellPadPeriphGetInfo for now because it seems more accurate on first glance, but this optimization exists in cellPadPeriphGeData.

@elad335 elad335 merged commit 4bbe885 into RPCS3:master Aug 10, 2023
@tommapar97
Copy link

Hi, ever since I updated the application's been having issues with multimonitor setups. Can't fullscreen on main monitor, it defaults to the second monitor, and same thing happens with drop down menus on the emulator UI itself.

@RainbowCookie32
Copy link
Contributor

Already reported on #14405, don't post on unrelated PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The Simpsons the Game [BLES00142] - Broken Controller Input
5 participants