Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions Source/Platform/InputManagerPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ private void UpdateKeyboard(ImGuiIOPtr io)
}
}

// Handle mod keys separately as 2 buttons map to 1 key
io.AddKeyEvent(ImGuiKey.ModShift, Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift));
io.AddKeyEvent(ImGuiKey.ModCtrl, Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl));
io.AddKeyEvent(ImGuiKey.ModAlt, Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt));
#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS
io.AddKeyEvent(ImGuiKey.ModSuper, Input.GetKey(KeyCode.LeftCommand) || Input.GetKey(KeyCode.RightCommand));
#else
io.AddKeyEvent(ImGuiKey.ModSuper, Input.GetKey(KeyCode.LeftWindows) || Input.GetKey(KeyCode.RightWindows));
#endif

// Text input.
while (Event.PopEvent(_textInputEvent))
{
Expand Down Expand Up @@ -87,11 +97,19 @@ static ImGuiKey KeyToImGuiKeyShortcut(KeyCode keyToConvert, KeyCode startKey1, I
>= KeyCode.Keypad0 and <= KeyCode.Keypad9 => KeyToImGuiKeyShortcut(key, KeyCode.Keypad0, ImGuiKey.Keypad0),
>= KeyCode.A and <= KeyCode.Z => KeyToImGuiKeyShortcut(key, KeyCode.A, ImGuiKey.A),
>= KeyCode.Alpha0 and <= KeyCode.Alpha9 => KeyToImGuiKeyShortcut(key, KeyCode.Alpha0, ImGuiKey._0),
// BUG: mod keys make everything slow.
// KeyCode.LeftShift or KeyCode.RightShift => ImGuiKey.ModShift,
// KeyCode.LeftControl or KeyCode.RightControl => ImGuiKey.ModCtrl,
// KeyCode.LeftAlt or KeyCode.RightAlt => ImGuiKey.ModAlt,
// KeyCode.LeftWindows or KeyCode.RightWindows => ImGuiKey.ModSuper,
KeyCode.LeftControl => ImGuiKey.LeftCtrl,
KeyCode.RightControl => ImGuiKey.RightCtrl,
KeyCode.LeftShift => ImGuiKey.LeftShift,
KeyCode.RightShift => ImGuiKey.RightShift,
KeyCode.LeftAlt => ImGuiKey.LeftAlt,
KeyCode.RightAlt => ImGuiKey.RightAlt,
#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS
KeyCode.LeftCommand => ImGuiKey.LeftSuper,
KeyCode.RightCommand => ImGuiKey.RightSuper,
#else
KeyCode.LeftWindows => ImGuiKey.LeftSuper,
KeyCode.RightWindows => ImGuiKey.RightSuper,
#endif
KeyCode.Menu => ImGuiKey.Menu,
KeyCode.UpArrow => ImGuiKey.UpArrow,
KeyCode.DownArrow => ImGuiKey.DownArrow,
Expand Down Expand Up @@ -137,4 +155,4 @@ static ImGuiKey KeyToImGuiKeyShortcut(KeyCode keyToConvert, KeyCode startKey1, I
return imguikey != ImGuiKey.None;
}
}
}
}