Skip to content

Qt: Add hotkey support for toggling individual pnach cheats during gameplay - #14692

Closed
Eudemir1986 wants to merge 4 commits into
PCSX2:masterfrom
Eudemir1986:berserk-filter-hotkey
Closed

Qt: Add hotkey support for toggling individual pnach cheats during gameplay#14692
Eudemir1986 wants to merge 4 commits into
PCSX2:masterfrom
Eudemir1986:berserk-filter-hotkey

Conversation

@Eudemir1986

Copy link
Copy Markdown

Description of Changes

Adds 16 configurable hotkey slots (ToggleCheatSlot1 to ToggleCheatSlot16) under Controllers → Hotkeys → System. Each slot reads the target cheat name from a dedicated [CheatHotkeys] section in PCSX2.ini. When triggered, the hotkey toggles the named cheat on or off in real time and displays an OSD message confirming the state.

Configuration Example

Pnach file (9685E636.pnach):

[60fps]
patch=1,EE,003B408C,extended,01
[No Red Filter]
patch=1,EE,D03DC4C2,extended,FFFD
patch=1,EE,003D87EC,byte,00

PCSX2.ini:

[Hotkeys]
ToggleCheatSlot1 = SDL-0/LeftStick
ToggleCheatSlot2 = SDL-0/RightStick
[CheatHotkeys]
CheatToggleSlot1 = No Red Filter
CheatToggleSlot2 = 60fps

Important: The cheat name in [CheatHotkeys] must match exactly the name between brackets in the pnach file — case sensitive, space sensitive.

Rationale behind Changes

Users currently have no way to toggle individual pnach cheats during gameplay without opening a menu. This is particularly useful for cheats that need to be toggled mid-game (e.g. 60fps patches that break cutscenes, visual filters that should only be active during specific gameplay moments).

Resolves: #12374, #4514, #5567, #10147, #11945, #841

Suggested Testing Steps

  1. Create a pnach cheat with a named section (see example above)
  2. Add the hotkey mapping under [Hotkeys] in PCSX2.ini
  3. Add the cheat name under [CheatHotkeys] in PCSX2.ini
  4. Assign the hotkey button in Controllers → Hotkeys → System → Toggle Cheat Slot 1
  5. Launch a game with the cheat enabled and press the mapped button
  6. Verify the OSD shows "Cheat Slot 1 (No Red Filter): OFF" and the cheat is disabled
  7. Press again and verify "ON" and the cheat re-enables

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

Yes. Claude Sonnet 4.6 (Anthropic) was used throughout the implementation process for code guidance, debugging, and build system support. The author is not a developer and has no prior C++ or emulator development experience. The feature was researched and implemented over approximately 3 weeks of iterative sessions (June 19 – July 12, 2026), combining manual testing, runtime debugging with PCSX2 EE Debugger, Cheat Engine and RenderDoc, and AI-assisted code implementation.

Captura de tela 2026-07-13 002228 Captura de tela 2026-07-13 001735 Captura de tela 2026-07-13 001813 Captura de tela 2026-07-13 002551 Captura de tela 2026-07-13 001926

@github-actions github-actions Bot 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.

Thank you for submitting a contribution to PCSX2

As this is your first pull request, please be aware of the contributing guidelines.

Additionally, as per recent changes in GitHub Actions, your pull request will need to be approved by a maintainer before GitHub Actions can run against it. You can find more information about this change here.

Please be patient until this happens. In the meantime if you'd like to confirm the builds are passing, you have the option of opening a PR on your own fork, just make sure your fork's master branch is up to date!

@RedPanda4552

Copy link
Copy Markdown
Contributor

Rejecting per LLM policy. Leaving it to other members to override.

https://pcsx2.net/docs/contributing/#large-language-model-llm-usage-policy

@Eudemir1986

Copy link
Copy Markdown
Author

Hi @RedPanda4552,
Thank you for the feedback and for leaving it open to other members.
I'd like to respectfully contest this decision based on the policy itself.
The policy states that contributors may use LLMs for "partial code generation" and must NOT use them for "full code generation." I believe my contribution falls within the acceptable range for the following reasons:

The implementation logic was mine. I spent approximately 3 weeks reverse engineering the problem using PCSX2 EE Debugger, Cheat Engine, and RenderDoc before writing a single line of code. The decision to use Host::GetStringSettingValue, Host::Internal::GetGameSettingsLayer, VMManager::ReloadPatches, and the [CheatHotkeys] INI section was based on my own analysis of PCSX2's architecture.
I can fully explain the implementation. The hotkey reads the cheat name from a dedicated [CheatHotkeys] section to avoid conflicts with PCSX2's existing hotkey binding system. It uses GetGameSettingsLayer() instead of the global settings layer to ensure per-game cheat state is modified correctly. ReloadPatches(true, true, true, true) is called to apply the change immediately without requiring a restart.
Claude was used as a coding assistant, not a code generator. Every decision about what to implement and how was made by me. Claude helped with C++ syntax and build system commands — the same way a developer might use Stack Overflow or documentation.
The policy says "leaving it to other members to override" — I hope the team will reconsider given the above context.

@Eudemir1986

Eudemir1986 commented Jul 13, 2026

Copy link
Copy Markdown
Author

I've refactored the implementation based on feedback from the community and additional technical review.
Changes in the updated commit (379de22):

Centralized all logic into a single HotkeyToggleCheatSlot() helper function
Added Host::GetSettingsLock() before accessing GetGameSettingsLayer(), released before ReloadPatches()
Changed ReloadPatches(false, true, false, false) to avoid unnecessary pnach file re-reads and duplicate OSD messages
Replaced #include "INISettingsInterface.h" with common/SettingsInterface.h
All OSD messages now use TRANSLATE_FS/TRANSLATE_SV following project conventions
Added #include for std::find
Improved error feedback for unconfigured slots and missing per-game settings layer
Removed unrelated change to the existing ReloadPatches hotkey
16 DEFINE_HOTKEY entries reduced to one line each

The diff went from +453 to approximately +95 lines. I'd appreciate if the team could reconsider reopening this PR.

cc @TJnotJT @refractionpcsx2

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]: Hotkey Game Fixes (hear me out)

2 participants