window: auto-hide the cursor over the game window #958

Manually merged
github merged 2 commits from gh-pr/958/head into gh-pr/958/base 2026-11-26 09:38:13 +00:00
Owner

@⁠Aryansh1520 on GitHub · 2026-10-01 14:27 UTC · original
Aryansh1520:feat/cursor-auto-hide → main · +78 −8 · 8 files · 2 commits · merged 2026-10-03 14:15 UTC

Closes #282

Problem

The host cursor stays visible over the game window for the whole session. In games that draw their own cursor (e.g. Blue Prince) there are two pointers on screen, and in every other game the pointer just sits on top of the picture.

Fix

All changes are in hostInput.cpp, inside HostInputWaitEvent, which is the window loop's single event wait:

  • The cursor is hidden when the window is created.
  • Any mouse motion, button or wheel event shows it again. After 2 s with no mouse activity it is hidden again.
  • Only real mouse input counts as activity. Synthetic touch/pen mouse events (SDL_TOUCH_MOUSEID / SDL_PEN_MOUSEID) are ignored, and so is zero-delta motion, which some platforms send on focus or cursor visibility changes.
  • The loop uses SDL_WaitEventTimeout only while the cursor is visible. Once it is hidden, the loop goes back to blocking on SDL_WaitEvent, so there are no extra wakeups.
  • F7 mouse-to-joystick is unaffected, because relative mode already hides the cursor. The cursor is restored in HostInputShutdown.
  • Mouse events still reach the game and the system overlay unchanged. Only the cursor's visibility changes.

This uses only SDL_HideCursor / SDL_ShowCursor, which SDL3 implements for X11, Wayland, Cocoa and Win32 and which only affect the cursor while it is over the emulator window. There is no platform-specific code.

Testing

  • Linux (CachyOS): the cursor hides at startup, reappears on mouse movement and hides again after about 2 s idle. The desktop cursor outside the window is unaffected, and F7 capture/release still works.
  • Not tested on Windows or macOS. I'd appreciate a quick check there.
**@⁠Aryansh1520** on GitHub · 2026-10-01 14:27 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/958) `Aryansh1520:feat/cursor-auto-hide` → `main` · +78 −8 · 8 files · 2 commits · merged 2026-10-03 14:15 UTC Closes #282 ## Problem The host cursor stays visible over the game window for the whole session. In games that draw their own cursor (e.g. Blue Prince) there are two pointers on screen, and in every other game the pointer just sits on top of the picture. ## Fix All changes are in `hostInput.cpp`, inside `HostInputWaitEvent`, which is the window loop's single event wait: - The cursor is hidden when the window is created. - Any mouse motion, button or wheel event shows it again. After 2 s with no mouse activity it is hidden again. - Only real mouse input counts as activity. Synthetic touch/pen mouse events (`SDL_TOUCH_MOUSEID` / `SDL_PEN_MOUSEID`) are ignored, and so is zero-delta motion, which some platforms send on focus or cursor visibility changes. - The loop uses `SDL_WaitEventTimeout` only while the cursor is visible. Once it is hidden, the loop goes back to blocking on `SDL_WaitEvent`, so there are no extra wakeups. - F7 mouse-to-joystick is unaffected, because relative mode already hides the cursor. The cursor is restored in `HostInputShutdown`. - Mouse events still reach the game and the system overlay unchanged. Only the cursor's visibility changes. This uses only `SDL_HideCursor` / `SDL_ShowCursor`, which SDL3 implements for X11, Wayland, Cocoa and Win32 and which only affect the cursor while it is over the emulator window. There is no platform-specific code. ## Testing - Linux (CachyOS): the cursor hides at startup, reappears on mouse movement and hides again after about 2 s idle. The desktop cursor outside the window is unaffected, and F7 capture/release still works. - Not tested on Windows or macOS. I'd appreciate a quick check there.
Hide the cursor when the game window is created and whenever the mouse
has been idle for two seconds; any mouse motion, button or wheel event
shows it again. Games that draw their own cursor (e.g. Blue Prince) no
longer show the host pointer on top of it.

Only real mouse input counts as activity: synthetic touch/pen mouse
events and zero-delta motion (sent by some platforms on focus or cursor
visibility changes) are ignored. The event loop only waits with a
timeout while the cursor is visible, so it still blocks indefinitely
once the cursor is hidden. The cursor is restored on shutdown.

Uses SDL_HideCursor/SDL_ShowCursor, which SDL implements for X11,
Wayland, Cocoa and Win32 and which only affect the cursor over the
emulator window.

Closes #282
Co-authored-by: Anatolii Kucheruk <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:38:12 +00:00
github manually merged commit dba08444d1 into gh-pr/958/base 2026-11-26 09:38:13 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-01 14:34 UTC · original

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 0f5399ed-8a6f-4913-949d-0acdf35c5ccc

📥 Commits

Reviewing files that changed from the base of the PR and between 44798085bd and 845783ae85f619c5031d032a059d73785394d27f.

📒 Files selected for processing (1)
  • src/graphics/presentation/window/hostInput.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The input window now hides the cursor at initialization. Qualifying mouse movement, button, or wheel events show it and reset a two-second idle deadline. The cursor hides when that deadline expires, and shutdown clears the deadline and shows the cursor.

Suggested reviewers: nmzik

Priority: ⬇️ Low

Change: Feature · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 84578

The change hides the cursor over the game window and shows it again on real mouse activity. No concrete merge-blocking risk was found. Windows and macOS behavior was not tested by the author.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 84578

The change is confined to cursor visibility and event waiting in the existing application window. No expanded input authority was identified, but platform-specific cursor behavior and wait-failure recovery remain incompletely verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The observed exposure is the application's existing window and event loop. Input reaching that loop can influence cursor visibility and wait timing, but the reviewed delta adds no new input route, privileged operation, credential access, or cross-service call.

Trust Boundaries and Controls

  • observed — Touch/pen device identifiers and zero-motion checks classify cursor activity only; they are not authentication or event-authorization controls. Events excluded from cursor activity still reach the existing dispatcher when the wait succeeds.

Resilience and Maintainability Implications

  • observed — Shutdown requests relative-mode release before clearing software mouse state, but does not require that release to succeed. The immediate-parent comparison shows this failure-handling gap predates the cursor change; the PR adds deadline reset and cursor restoration without establishing an increase in capture authority or exposure.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the cursor auto-hide behavior, input filtering, event-loop changes, shutdown behavior, and testing. It directly matches the changeset.
Title check ✅ Passed The title clearly and concisely identifies the primary change: automatically hiding the cursor over the game window.
Linked Issues check ✅ Passed The changes implement the coding requirements in #282. hostInput.cpp hides the cursor at initialization, shows it after real nonzero mouse motion, button, or wheel input, and hides it again after tw…
Out of Scope Changes check ✅ Passed The changes remain within #282. The event-loop timeout and input-event filtering directly support cursor visibility and idle detection. The reported preservation of game input, overlay input, and F7 b…
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-01 14:34 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/958#issuecomment-5933638220) <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/958?cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> Navigate logical layers of code changes, visualize relationships, and explore their blast radius. <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `0f5399ed-8a6f-4913-949d-0acdf35c5ccc` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 44798085bd26fd27078671789f5e8426aeb21521 and 845783ae85f619c5031d032a059d73785394d27f. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `src/graphics/presentation/window/hostInput.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The input window now hides the cursor at initialization. Qualifying mouse movement, button, or wheel events show it and reset a two-second idle deadline. The cursor hides when that deadline expires, and shutdown clears the deadline and shows the cursor. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬇️ Low <!-- change_assessment_commit:"845783ae85f619c5031d032a059d73785394d27f" --> **Change:** Feature · **Severity of issue fixed:** Low <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _⚪ Minimal_ · up to `84578` <!-- final_review_risk_coverage:{"sourceCommitId":"845783ae85f619c5031d032a059d73785394d27f","coveredCommitId":"845783ae85f619c5031d032a059d73785394d27f","kind":"reviewed"} --> The change hides the cursor over the game window and shows it again on real mouse activity. No concrete merge-blocking risk was found. Windows and macOS behavior was not tested by the author. <!-- final_review_risk_end --> <!-- architecture_review_start --> ### Security Architecture Review **Security architecture risk:** _🔵 Low_ · up to `84578` The change is confined to cursor visibility and event waiting in the existing application window. No expanded input authority was identified, but platform-specific cursor behavior and wait-failure recovery remain incompletely verified. **Retained concerns** No architecture-level concerns identified. <details> <summary>Security review details</summary> **Security Blast Radius** - _inferred_ — The observed exposure is the application's existing window and event loop. Input reaching that loop can influence cursor visibility and wait timing, but the reviewed delta adds no new input route, privileged operation, credential access, or cross-service call. **Trust Boundaries and Controls** - _observed_ — Touch/pen device identifiers and zero-motion checks classify cursor activity only; they are not authentication or event-authorization controls. Events excluded from cursor activity still reach the existing dispatcher when the wait succeeds. **Resilience and Maintainability Implications** - _observed_ — Shutdown requests relative-mode release before clearing software mouse state, but does not require that release to succeed. The immediate-parent comparison shows this failure-handling gap predates the cursor change; the PR adds deadline reset and cursor restoration without establishing an increase in capture authority or exposure. </details> <!-- architecture_review_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :----------------: | :--------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------- | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 1 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Description check | ✅ Passed | The description clearly explains the cursor auto-hide behavior, input filtering, event-loop changes, shutdown behavior, and testing. It directly matches the changeset. | | Title check | ✅ Passed | The title clearly and concisely identifies the primary change: automatically hiding the cursor over the game window. | | Linked Issues check | ✅ Passed | The changes implement the coding requirements in `#282`. `hostInput.cpp` hides the cursor at initialization, shows it after real nonzero mouse motion, button, or wheel input, and hides it again after tw… | | Out of Scope Changes check | ✅ Passed | The changes remain within `#282`. The event-loop timeout and input-event filtering directly support cursor visibility and idle detection. The reported preservation of game input, overlay input, and F7 b… | </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autopilot</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts > Autopilot is currently an internal CodeRabbit preview. <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=958)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠Nmzik on GitHub · 2026-10-03 14:14 UTC · original

@⁠Aryansh1520 All good. There will be one new option in UI/CLI to auto disable mouse cursor

**@⁠Nmzik** on GitHub · 2026-10-03 14:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/958#issuecomment-5969991175) @⁠Aryansh1520 All good. There will be one new option in UI/CLI to auto disable mouse cursor
This discussion has been locked. Commenting is limited to contributors.
No description provided.