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

fix(input/five): DirectInput mouseDev unacquire #3072

Conversation

tens0rfl0w
Copy link
Contributor

Goal of this PR

Currently, when using DirectInput as the input method for the mouse, mouse inputs are still passed through to the game, even when an overlay such as a NUI or the client console is focused. This results in unintended user interactions with the game.

How is this PR achieving the goal

This PR hooks into the recaptureLostDevices function, which re-acquires a DirectInput mouse device that has lost focus, to block execution of the function when the game has no focus. Additionally, it un-acquires the game's DirectInput mouse device by directly accessing its memory address and invoking Unacquire on the object when a focus switch is invoked.

This PR applies to the following area(s)

FiveM

Successfully tested on

Game builds: 2060, 2699, 3258, 3407

Platforms: Windows (Client)

Checklist

  • Code compiles and has been tested successfully.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

Fixes issues

fixes #1010

@github-actions github-actions bot added the invalid Requires changes before it's considered valid and can be (re)triaged label Jan 16, 2025
Copy link
Contributor

@Nobelium-cfx Nobelium-cfx left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for the contribution!

@Nobelium-cfx Nobelium-cfx added the ready-to-merge This PR is enqueued for merging label Feb 4, 2025
@prikolium-cfx prikolium-cfx merged commit 7a6ab03 into citizenfx:master Feb 5, 2025
2 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Requires changes before it's considered valid and can be (re)triaged ready-to-merge This PR is enqueued for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DirectInput mouse mode doesn't get affected by UI focus
3 participants