-
Notifications
You must be signed in to change notification settings - Fork 194
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
Port/inputsource: Refactor Abstracted Input Handler #558
Open
Yangff
wants to merge
61
commits into
UE4SS-RE:main
Choose a base branch
from
Yangff:port/inputsource
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Define prupose driven string types in Macros.hpp Use IOSTR/File::StringType for IO purpose, it's pinned to utf8/string type Use SYSSTR/SystemStringType for interacting with STL, it's the prefer type based on platform; On windows this is wchar_t/wstring and on Linux this is char/string Use STR/UEStringType for interacting with Unreal Engine, it's utf16. On Windows we uses wchar_t/wstring to avoid extra copy/casting from u16string On Linux we uses u16string which cannot be used in many STL functions. With this patch, the only changes on string type on Windows should just be the type aliases, and almost all actual types should stay unchanged. For the IO, write_string_to_file will keep receiving utf16, aka wchar_t on windows. A new write_file_string_to_file is added to allow receiving of utf8 string A new WinFile using WinAPI is provided and to avoid the buggy BOM detection on the old code. It also avoids the use of wstring to handle UTF-8 chars.
A new sets of to_xxxx/[_string] functions is provided * to_ue/to_system/to_file can easily turn a string-like type to its new type For a string view or XXchar* that doesn't need to be encoded for conversion, these functions return it as is, so its return type may be the corresponding string or string view (see can_be_string_view_t) For a different underlying type of string, they create a new string to hold the converted result * to_ue_string/to_system_string/to_file_string will force the corresponding string type to be returned, which is appropriate if your target can't accept a string view.
…STL (System String)
… calling UE related thing
Store ModifierKeys in a uint32_t
* Use HAS_INPUT macro with --ue4ssInput option * Init InputSource System * Set Input Source according to the settings * Use thread safe get_events_safe callback
This PR is effectively impossible to review in its current state because it's based on #557. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The original Input Handler only accepted input from Win32. In the refactoring we have defined the input source as Input Source, which allows different input sources to be defined for different scenarios. QueueInputSource allows messages from other threads to generate keyboard input and be dispatched and responded to by the
process_event
thread via the SPSC queue.Almost all of the definitions remain unchanged, with the only exception that
get_events()
has been replaced byget_events_safe()
, which allows the use of mutex protection when accessingm_key_set
.ModifierKeys are re-implemented using bitwise operations on
uint32_t
, which simplifies storing and comparing modifier keys.This PR depends on the string change so you can see those commits...
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Compiled and tested on Palworld, may need extra tests to ensure keys are responsed correctly as I only tested basic ones.
Checklist
Please delete options that are not relevant. Update the list as the PR progresses.
Screenshots (if appropriate)
Additional context
Add any other context about the pull request here.