Skip to content

Add game invitation handling to the home menu - #19128

Open
primetime43 wants to merge 22 commits into
RPCS3:masterfrom
primetime43:master
Open

Add game invitation handling to the home menu#19128
primetime43 wants to merge 22 commits into
RPCS3:masterfrom
primetime43:master

Conversation

@primetime43

@primetime43 primetime43 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Adds a Game Invites page to the Friends menu where RPCN invites can be accepted or rejected.
Invites are now passed to the game after the home menu closes, matching expected PS3 behavior.

Fixes & completes #18417

Split the friends dialog invite flow into friend requests and game invitations, add a dedicated game invite page, and wire accept/reject actions with the proper prompts. Accepting now routes through a new `np_handler::select_invitation` helper that validates invite messages, notifies the game, and marks invites as used. Also added locking around selected-message state in `np_handler` to make selection access thread-safe, plus new localized strings for the added UI text.
Fix style issues to follow RPCS3 guide
Track RPCN invite messages in a dedicated in-memory list, append new invites from the callback, and remove invites immediately after accept/dismiss so stale entries are not reprocessed on reload. Also make `np_handler::select_invitation` return `bool` consistently and clear selected invitation data if the system notification fails.
Move `m_list_dirty = true` inside the successful insert path in `add_game_invite`, so the friends invite overlay only refreshes when a new invite is actually added instead of on duplicate/no-op updates.
Extract home menu close logic into a reusable `request_close` method that accepts an optional callback. Use this in the friends list dialog to close the home menu before processing a game invite, matching native PS3 behavior where the invitation is reported after the home menu closes.
@primetime43

Copy link
Copy Markdown
Contributor Author

Attempt to fix the issue reported here #18417

#18417 (comment)

Comment thread rpcs3/Emu/RSX/Overlays/FriendsList/overlay_friends_list_dialog.cpp Outdated
Refactor the game invitation handler to always use the home menu close flow. Remove the fallback path that called select_invitation directly and manually removed the invite, since the home menu dialog is always expected to be present.
@digant73

digant73 commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

@primetime43 if this PR completely implements #18417 then add the following line on PR so the related FR is automatically closed once this PR is merged:

fixes #18417

Run the selected home menu action after SYSTEM_MENU_CLOSE and before DRAWING_END. This allows games to process the selected invitation during the expected menu close sequence. RPCS3#18417
Comment thread rpcs3/Emu/Cell/Modules/cellSysutil.cpp Outdated
Default to nullptr & removed second overload
Adjust system menu close sequencing so `CELL_SYSUTIL_SYSTEM_MENU_CLOSE` is processed before reporting selected actions. The close callback is now queued via `sysutil_register_cb`, with `CELL_SYSUTIL_DRAWING_END` sent afterward, and `status->active` is cleared immediately when closing begins. In the home menu overlay, normal exit and screenshot exit are now handled separately so only `exit_for_screenshot` sets the screenshot request flag.
Send `CELL_SYSUTIL_DRAWING_END` immediately with the system menu close commands so games process the full close sequence before any selected action callback runs. Also log the selected NP invitation message ID to make invitation selection flow easier to trace.
When a basic NP handler is registered, selecting an invitation now queues and sends `SCE_NP_BASIC_EVENT_RECV_INVITATION_RESULT` with populated attachment data instead of only relying on the sysutil command. It falls back to `CELL_SYSUTIL_NP_INVITATION_SELECTED` when no basic handler exists, and consistently clears selection/logs an error if notification delivery fails.
Centralize the home menu command declarations and simplify invitation event payload setup without changing behavior.
@primetime43

Copy link
Copy Markdown
Contributor Author

@Megamouse this is ready for a final code review. I've confirmed it's now working properly.

Comment thread rpcs3/Emu/Cell/Modules/cellSysutil.cpp
Comment thread rpcs3/Emu/Cell/Modules/cellSysutil.cpp Outdated
Keep send_close_home_menu_cmds focused on dispatching system menu events. Register deferred close actions from the home menu overlay after the system menu close commands have been sent.
Replace register_close_callback() with take_close_callback() to return the callback instead of registering it internally. Move sysutil_register_cb wrapping to the friends list dialog, which is the only caller that needs it. The pad thread now calls the callback directly after taking ownership.
@Megamouse

Copy link
Copy Markdown
Contributor

You need to rebase properly and resolve conflicts in your history. Otherwise this can't be merged

@Megamouse
Megamouse requested a review from RipleyTom August 7, 2026 07:06

@RipleyTom RipleyTom left a comment

Copy link
Copy Markdown
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 this is correct, SCE_NP_BASIC_EVENT_RECV_INVITATION_RESULT is only sent as the result of calling a sceNpBasicRecv... function.

I looked a bit into it and I think we are indeed missing something but what we're missing is SCE_NP_BASIC_EVENT_INCOMING_BOOTABLE_INVITATION or SCE_NP_BASIC_EVENT_INCOMING_BOOTABLE_CUSTOM_DATA_MESSAGE(depending on message type) being passed to the basic_handler.

Then the application will call a recv function and handle the rest itself.

Hmm nvm we already send those messages when the message arrive so something else must be missing else.

@primetime43

Copy link
Copy Markdown
Contributor Author

I don't think this is correct, SCE_NP_BASIC_EVENT_RECV_INVITATION_RESULT is only sent as the result of calling a sceNpBasicRecv... function.

I looked a bit into it and I think we are indeed missing something but what we're missing is SCE_NP_BASIC_EVENT_INCOMING_BOOTABLE_INVITATION or SCE_NP_BASIC_EVENT_INCOMING_BOOTABLE_CUSTOM_DATA_MESSAGE(depending on message type) being passed to the basic_handler.

Then the application will call a recv function and handle the rest itself.

Hmm nvm we already send those messages when the message arrive so something else must be missing else.

I have confirmed the invites and joining works on the issue page. So it's working, are you saying the code isn't correct though?

@RipleyTom

Copy link
Copy Markdown
Contributor

Yes even if it works, all this seems like a workaround, the callback system, etc. We're missing a signal which makes the application itself calls sceNpBasicRecv...

@RipleyTom

Copy link
Copy Markdown
Contributor

Normal procedure would be the game receiving CELL_SYSUTIL_NP_INVITATION_SELECTED, then the game would call sceNpBasicRecvMessageAttachmentLoad(SCE_NP_BASIC_SELECTED_INVITATION_DATA, buffer, &size) to get the data.

@primetime43

Copy link
Copy Markdown
Contributor Author

Normal procedure would be the game receiving CELL_SYSUTIL_NP_INVITATION_SELECTED, then the game would call sceNpBasicRecvMessageAttachmentLoad(SCE_NP_BASIC_SELECTED_INVITATION_DATA, buffer, &size) to get the data.

yea you're right, I think I see it now. Its fabricating the response right now, thus it working.

Store the selected invitation data and notify the game with CELL_SYSUTIL_NP_INVITATION_SELECTED. Let the game retrieve the invitation through sceNpBasicRecvMessageAttachmentLoad instead of fabricating a SCE_NP_BASIC_EVENT_RECV_INVITATION_RESULT event.
Queue CELL_SYSUTIL_NP_INVITATION_SELECTED immediately after the home menu close commands instead of deferring it through an additional sysutil callback cycle.

This allows the game to receive the selection notification and retrieve the stored invitation through sceNpBasicRecvMessageAttachmentLoad.
Expose registered NP custom menu actions in the home menu and route selection through np_handler so games receive the expected callback after the menu closes. This also preserves pending close callbacks on home menu exit and defers invitation selection until system menu close callbacks have been processed.
Integrate game custom invitation actions into the Friends invitation flow

Automatically invoke the sole active ME action when accepting an
invitation and let the game's sceNpBasicRecvMessageCustom call consume
the selected message. Preserve CELL_SYSUTIL_NP_INVITATION_SELECTED as
the fallback for games using the standard flow.

This avoids fabricating NP events and removes the redundant custom
invitation menu entry.
@primetime43

primetime43 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@Megamouse @RipleyTom I think I've got it working reliably now. No fabricated payload in the code anymore. Review it and let me know of anything that may need fixed. Thanks.

Also, sorry for all of the pushes on here. I didn't think my machine could handle building it to test it locally, but found out today it can.

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.

4 participants