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

InputSource, replaces #558 #749

Merged
merged 9 commits into from
Mar 12, 2025
Merged

InputSource, replaces #558 #749

merged 9 commits into from
Mar 12, 2025

Conversation

UE4SS
Copy link
Collaborator

@UE4SS UE4SS commented Jan 8, 2025

This PR is rebased onto main.
The old one is a disaster of a PR, this one contains only the InputSource commits and is rebased onto main.
Please see #558 for details.

This PR needs testing.
Keybinds seem to work fine for me on Linux using Proton, tested with Palworld.
Someone needs to test on Windows natively.

Copy link
Contributor

github-actions bot commented Jan 8, 2025

MSVC-Game__Debug__Win64 Download Logs
Build Details
Name Information
PR Commit aedd3f1
Merge Commit 2c55c2e
Size 46.93 MB
Last Updated Mar 12, 25, 2:21:52 PM UTC
Expires At Mar 26, 25, 2:21:47 PM UTC

MSVC-Game__Shipping__Win64 Download Logs
Build Details
Name Information
PR Commit aedd3f1
Merge Commit 2c55c2e
Size 28.59 MB
Last Updated Mar 12, 25, 2:25:47 PM UTC
Expires At Mar 26, 25, 2:25:44 PM UTC

@narknon
Copy link
Collaborator

narknon commented Jan 9, 2025

How crazy would it be to make the register_keydown_event and other functions/lambdas just compile into nothing rather than wrapping every use of them in ifdefs?

@UE4SS
Copy link
Collaborator Author

UE4SS commented Jan 9, 2025

How crazy would it be to make the register_keydown_event and other functions/lambdas just compile into nothing rather than wrapping every use of them in ifdefs?

I agree.
I think it's better to wrap the contents of the functions with #ifdef instead so that it's empty when not supported.

@UE4SS
Copy link
Collaborator Author

UE4SS commented Jan 9, 2025

How crazy would it be to make the register_keydown_event and other functions/lambdas just compile into nothing rather than wrapping every use of them in ifdefs?

I agree. I think it's better to wrap the contents of the functions with #ifdef instead so that it's empty when not supported.

Although this could be tricky with functions that use a type that is also #ifdef'd out, like get_input_handler.
You'd have to dummy that type to make it compile, and then it also returns a reference which means there needs to be an #else that returns a static version of the dummy type.
It makes it more complicated to implement but removes all burden from users of the API which I think is better.

Note that get_input_handler doesn't seem to be used anywhere, and doesn't exist before this PR so it should probably be removed.

@narknon
Copy link
Collaborator

narknon commented Jan 9, 2025

Can you just ifdef the members?

@UE4SS
Copy link
Collaborator Author

UE4SS commented Jan 9, 2025

Can you just ifdef the members?

I don't see how that would help here.
If the members are ifdef'd out, anything that uses those members won't compile.

@narknon
Copy link
Collaborator

narknon commented Jan 9, 2025

Won't the only things using the members be the ifdef'd functions? Idk, I haven't looked closely at it.

@UE4SS
Copy link
Collaborator Author

UE4SS commented Jan 9, 2025

Won't the only things using the members be the ifdef'd functions? Idk, I haven't looked closely at it.

Members and functions are currently fully ifdef'd out.
As a result, users of those members and functions also need an ifdef around them or they won't compile.
This would be inconvenient for mods that register keybinds for example.
They shouldn't have to ifdef their own calls to the registration function.
If we remove get_input_handler, I think the registration functions are the only place where this matters as everything else is internal stuff.

@UE4SS
Copy link
Collaborator Author

UE4SS commented Jan 11, 2025

The discussion above has been resolved, the current status is now:

  1. Waiting for someone to test and confirm that keybinds work as expected on native Windows.
    There are build artifacts above, you don't have to build it yourself.
  2. Waiting for @Yangff to possibly have a quick look.

@igromanru
Copy link
Contributor

igromanru commented Mar 7, 2025

I tested the latest build from here with my mods, mainly with my StackManage mod, which utilize multiple RegisterKeyBind with same primary key and different modifiers.
https://github.com/igromanru/StackManager-UE4SS-AF/blob/2a0c2471152805f449aeb34c22298eafccf9c662/Scripts/main.lua#L12
Couldn't find any issues.

Yangff and others added 8 commits March 7, 2025 14:43
Input Source: add windows platform code
Store ModifierKeys in a uint32_t
Input Source: Input Handler in UE4SS

* Use HAS_INPUT macro with --ue4ssInput option
* Init InputSource System
* Set Input Source according to the settings
* Use thread safe get_events_safe callback

Input Source: Apply HAS_INPUT macro

Input Source: Use safe getter for input event
Various fixes, probably from broken cherry-pick

Input: clang-format
@Yangff
Copy link
Contributor

Yangff commented Mar 12, 2025

hmm.. it looks good to me.

@UE4SS
Copy link
Collaborator Author

UE4SS commented Mar 12, 2025

Approval is pending by @narknon, and it's ready to be merged immediately after.

@narknon narknon self-requested a review March 12, 2025 13:07
@narknon
Copy link
Collaborator

narknon commented Mar 12, 2025

If you don't mind, please manually squash the last two commits then do a normal merge. Not a huge deal though.

Made Handler.hpp always be the correct header to include

Fixed build when --ue4ssInput=n

Moved back various definitions from KeyDef.hpp to Handler.hpp

Replaced include-guard with #pragma once for Handler.hpp

Co-authored-by: UE4SS <[email protected]>
@UE4SS UE4SS merged commit af67a0f into main Mar 12, 2025
13 checks passed
@narknon narknon deleted the inputsource branch March 12, 2025 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants