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

New ImGui IO event API #23

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

New ImGui IO event API #23

wants to merge 8 commits into from

Conversation

jonpas
Copy link
Member

@jonpas jonpas commented Feb 24, 2024

This pull request reworks the Unreal backend for ImGui to use the new IO event API introduced in ImGui 1.87.

Most of the intermediate storage has been removed in this project as core ImGui now handles it correctly even at low framerates. Certain missing keybinds have been added (such as Super/Command).

It is advisable for users of this project to thoroughly review and test this before it is merged.

@jonpas jonpas added the enhancement New feature or request label Feb 24, 2024
{
if (MouseIndex < Utilities::GetArraySize(MouseButtonsDown))
const ImGuiKey& ImKey = ImGuiInterops::UnrealToImGuiKey(Key);
IO.AddKeyEvent(ImKey, bIsDown);

Choose a reason for hiding this comment

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

The UnrealToImGuiKey has ImGuiKey_LeftShift, ImGuiKey_RightShift, ImGuiKey_LeftControl, ImGuiKey_RightControl, ImGuiKey_LeftAlt, ImGuiKey_RightAlt, ImGuiKey_LeftSuper and ImGuiKey_RightSuper But we also need to pass events for ImGuiKey_ModShift, ImGuiKey_ModControl, ImGuiKey_ModAlt and ImGuiKey_ModSuper.

Maybe you can have a UnrealToImGuiModKeyMap map UnrealToImGuiKeyMap just like as:

{
    EKeys::LeftShift : ImGuiKey_ModShift,
    EKeys::RigthShift : ImGuiKey_ModShift,
    EKeys::LeftControl : ImGuiKey_ModCtrl,
    EKeys::RightControl : ImGuiKey_ModCtrl,
    EKeys::LeftAlt : ImGuiKey_ModAlt,
    EKeys::RightAlt : ImGuiKey_ModAlt,
    EKeys::LeftCommand : ImGuiKey_ModSuper,
    EKeys::RightCommand : ImGuiKey_ModSuper,
}

And then:

if(ImGuiInterops::UnrealToImGuiModKey(Key) != ImGuiKey_None)
{
    // Will need UnrealToImGuiModKey function just like UnrealToImGuiKey, maybe without the log
    IO.AddKeyEvent(ImGuiInterops::UnrealToImGuiModKey(Key), bIsDown);
}

Choose a reason for hiding this comment

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

Without these anything that uses Mod keys break with this PR change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants