Skip to content

Qt: Add Create game shortcut functionality#12746

Merged
GovanifY merged 1 commit intoPCSX2:masterfrom
kamfretoz:game-shortcut
Oct 27, 2025
Merged

Qt: Add Create game shortcut functionality#12746
GovanifY merged 1 commit intoPCSX2:masterfrom
kamfretoz:game-shortcut

Conversation

@kamfretoz
Copy link
Copy Markdown
Contributor

@kamfretoz kamfretoz commented May 29, 2025

Description of Changes

This PR adds in the ability to automatically create a desktop shortcut for a game. macOS are not included.

To use: Right click on a game in the game list -> Create Game Shortcut

Closes #8349

Preview:

image

Rationale behind Changes

QoL Improvements and accessibility

Suggested Testing Steps

Test creating shortcut, and see if it loads PCSX2 and the game properly.

Did you use AI to help find, test, or implement this issue or feature?

Nada

@kamfretoz
Copy link
Copy Markdown
Contributor Author

Shortcut creation has been implemented for Windows.

2025-05-30.22-32-22.mp4

@kamfretoz kamfretoz force-pushed the game-shortcut branch 5 times, most recently from 43a2791 to 0e349b1 Compare May 31, 2025 07:26
@kamfretoz
Copy link
Copy Markdown
Contributor Author

You can now include the launch arguments before creating the shortcut.

2025-05-31.17-16-06.mp4

@bigol83
Copy link
Copy Markdown

bigol83 commented May 31, 2025

Works great on Windows, incredible job. I am using a website with save files icons to add them manually.

@kamfretoz
Copy link
Copy Markdown
Contributor Author

Works great on Windows, incredible job. I am using a website with save files icons to add them manually.

Thank you for testing!

In regards to the icons, i decided to not continue exploring for options as its deemed unfeasible. Therefore users will have to manually add their own icons if they desired.

@kamfretoz kamfretoz marked this pull request as ready for review May 31, 2025 12:54
@Mrlinkwii Mrlinkwii removed the Voodoo label May 31, 2025
@Calinou
Copy link
Copy Markdown

Calinou commented Jun 1, 2025

Is it possible to make it create a start menu shortcut as well? I want to keep my desktop free of any icons (OLED monitor), but I like having start menu entries to run apps/games quickly.

It's esssentially a matter of copying the generated shortcut to %APPDATA%/Microsoft/Windows/Start Menu/Programs (then optionally a subfolder like PCSX2, if categorization is desired).

I think most of the time, when you create a desktop shortcut, you'll also want a start menu entry, so it's safe to do it automatically. People who don't want the desktop icon can remove it manually, and the start menu entry will still be available.

@kamfretoz
Copy link
Copy Markdown
Contributor Author

kamfretoz commented Jun 1, 2025

Is it possible to make it create a start menu shortcut as well?

Done, now you can choose which one you want to create.
I've also made the path be XDG spec compliant.
image

@kamfretoz kamfretoz force-pushed the game-shortcut branch 5 times, most recently from b9d2f1a to a729449 Compare June 7, 2025 12:48
@kamfretoz kamfretoz force-pushed the game-shortcut branch 2 times, most recently from 404f385 to e4d061c Compare June 13, 2025 14:58
@kamfretoz kamfretoz force-pushed the game-shortcut branch 2 times, most recently from 215453e to da5a04e Compare June 23, 2025 08:20
@fthomys
Copy link
Copy Markdown
Contributor

fthomys commented Jun 29, 2025

very nice, works on windows!

is it possible to add a menu when adding a shortcut to click the arguments like --fullscreen etc?

looking forward

@RedDevilus
Copy link
Copy Markdown
Contributor

very nice, works on windows!

is it possible to add a menu when adding a shortcut to click the arguments like --fullscreen etc?

looking forward

https://pcsx2.net/docs/post/cli/

-fullscreen was always one dash and the most others now also with Qt GUI, just to make sure you are properly using the command-line arguments.

Copy link
Copy Markdown
Member

@chaoticgd chaoticgd left a comment

Choose a reason for hiding this comment

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

Found some issues. I haven't gone over the implementation of EscapeCmdLine yet.

Comment thread pcsx2-qt/ShortcutCreationDialog.cpp Outdated
Comment thread tests/ctest/common/path_tests.cpp Outdated
Copy link
Copy Markdown
Member

@chaoticgd chaoticgd left a comment

Choose a reason for hiding this comment

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

Did a proper review this time. Haven't checked some of the Windows API stuff, someone else should look over that.

Comment thread common/Linux/LnxMisc.cpp Outdated
Comment thread pcsx2-qt/ShortcutCreationDialog.cpp Outdated
Comment thread pcsx2-qt/ShortcutCreationDialog.cpp Outdated
Comment thread common/FileSystem.cpp Outdated
Comment thread common/FileSystem.cpp Outdated
@SpAGgeTtie
Copy link
Copy Markdown

where can I download this?

@fthomys
Copy link
Copy Markdown
Contributor

fthomys commented Oct 9, 2025

where can I download this?

Currently you need to build pcsx2 by yourself.
See https://pcsx2.net/docs/advanced/building and using this branch

Copy link
Copy Markdown
Member

@chaoticgd chaoticgd left a comment

Choose a reason for hiding this comment

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

Had another look.

Comment thread common/FileSystem.cpp Outdated
Comment thread common/Path.h Outdated
Comment thread common/Linux/LnxMisc.cpp Outdated
Copy link
Copy Markdown
Member

@JordanTheToaster JordanTheToaster left a comment

Choose a reason for hiding this comment

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

Works as expected on Windows.

Comment thread common/FileSystem.cpp Outdated
Comment thread common/FileSystem.cpp Outdated
Comment thread common/FileSystem.cpp Outdated
Copy link
Copy Markdown
Member

@chaoticgd chaoticgd left a comment

Choose a reason for hiding this comment

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

Found some more issues. Still haven't reviewed all the Windows API stuff.

Copy link
Copy Markdown
Member

@chaoticgd chaoticgd left a comment

Choose a reason for hiding this comment

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

This is looking good on Linux now. The history is a bit messy, so it should probably be squashed.

I still haven't looked at a lot of the Windows API stuff, so someone else needs to review that. I'm particularly worried about how the command line arguments are escaped on Windows. The fact that environment variables are substituted implies it may be doing a trip through cmd.exe, although I'm not sure if there's any other quirks with how it's parsed, so someone else will have to look into it.

@kamfretoz
Copy link
Copy Markdown
Contributor Author

The history is a bit messy, so it should probably be squashed.

Squashed.

Comment thread pcsx2-qt/ShortcutCreationDialog.cpp Outdated
Comment thread pcsx2-qt/ShortcutCreationDialog.cpp Outdated
Comment thread pcsx2-qt/ShortcutCreationDialog.cpp Outdated
Comment thread pcsx2-qt/ShortcutCreationDialog.cpp Outdated
Comment thread pcsx2-qt/ShortcutCreationDialog.cpp Outdated
@TheLastRar
Copy link
Copy Markdown
Contributor

I still haven't looked at a lot of the Windows API stuff, so someone else needs to review that. I'm particularly worried about how the command line arguments are escaped on Windows. The fact that environment variables are substituted implies it may be doing a trip through cmd.exe, although I'm not sure if there's any other quirks with how it's parsed, so someone else will have to look into it.

I got asked to look into this, unfortunately I'm unfamiliar with this area of Windows, so most of what I've picked out was either testing or googling.

While shortcuts do resolve environment variables, they don't seem to handle any cmd's metacharacters
I tested specifically & and ^, both had no effect in a shortcut, which suggests cmd isn't involved.
Some googling suggests that Windows uses IContextMenu::InvokeCommand for invoking shortcuts (somehow?) https://learn.microsoft.com/en-us/windows/win32/shell/links#link-files

As an aside, Everyone quotes command line arguments the wrong way suggests that you need to escape \n and \v, while I don't think you are going to encounter those, adding those should be simple enough.

As for the shortcut creation code, it seems to align with MS's example code.

@kamfretoz
Copy link
Copy Markdown
Contributor Author

Addressed everything.

Copy link
Copy Markdown
Member

@TellowKrinkle TellowKrinkle left a comment

Choose a reason for hiding this comment

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

I assume you've tested this with paths that contain all the characters you escape (so \, $, %, ", and ` on Linux) to make sure the escaping is parsed properly by the system?

@kamfretoz
Copy link
Copy Markdown
Contributor Author

After further testing, turns out there were MORE cases that were unexpectedly handled incorrectly. whoowee i sure do love FreeDesktop Desktop Entry's simple specification!

Drafting for now.

@kamfretoz
Copy link
Copy Markdown
Contributor Author

I tested them again and while PCSX2's CLI parser doesn't seem to work with all of them yet, the .desktop file output does seem to work.

Copy link
Copy Markdown
Member

@GovanifY GovanifY left a comment

Choose a reason for hiding this comment

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

First, let me preface that I don't really want to let this PR stay in forever limbo and so I'm putting all of this as comments and I'm not requesting formally changes.

The special character handling seems a bit too complex for my liking, the strcspn usage seems like it could easily break, although unsure if it does in this current situation.

WriteLnFmt feels like it could be abused if the name contains format specifies and is then piped to printf.

Also, why do we need an async wanring at all? I assume if a shortcut creation fail, you can just call the warning and then return.

There's a bunch of code duplication in EscapeShortcutCommandLine where the ifdef shouldn't apply to most of the code.

Besides that it looks like a bunch of work went into this PR so kudos! Just make sure to test with a bunch of weird names on purpose to see if you can break the implem

Comment thread bin/resources/icons/PCSX2.svg Outdated
Copy link
Copy Markdown
Member

@GovanifY GovanifY left a comment

Choose a reason for hiding this comment

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

I'm assuming everything got tested; If so probably good enough to merge for now and fix later should issues arise

@GovanifY
Copy link
Copy Markdown
Member

A few hours of trial and error can save you 10 minutes of windows testing

Copy link
Copy Markdown
Contributor

@TheTechnician27 TheTechnician27 left a comment

Choose a reason for hiding this comment

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

Image

I get this when I download and run the AppImage of the PR.

@chaoticgd
Copy link
Copy Markdown
Member

Looks like the same issue as before. It was probably accidentally reverted somehow.

@kamfretoz
Copy link
Copy Markdown
Contributor Author

Looks like the same issue as before. It was probably accidentally reverted somehow.

Whoops, fixed.

@GovanifY
Copy link
Copy Markdown
Member

Advienne que pourra

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.

[Feature Request]: Add the ability to create shortcuts for the games