mirror of
https://github.com/kevinporetti/UnrealImGui.git
synced 2025-01-18 08:20:32 +00:00
97 lines
1.9 KiB
C++
97 lines
1.9 KiB
C++
// Distributed under the MIT License (MIT) (see accompanying LICENSE file)
|
|
|
|
#include "ImGuiInputState.h"
|
|
|
|
#include <algorithm>
|
|
#include <limits>
|
|
#include <type_traits>
|
|
|
|
|
|
FImGuiInputState::FImGuiInputState()
|
|
{
|
|
Reset();
|
|
}
|
|
|
|
void FImGuiInputState::AddCharacter(TCHAR Char)
|
|
{
|
|
InputCharacters.Add(Char);
|
|
}
|
|
|
|
void FImGuiInputState::SetKeyDown(ImGuiKey KeyIndex, bool bIsDown)
|
|
{
|
|
if (KeyIndex < Utilities::GetArraySize(KeysDown))
|
|
{
|
|
if (KeysDown[KeyIndex] != bIsDown)
|
|
{
|
|
KeysDown[KeyIndex] = bIsDown;
|
|
KeysUpdateRange.AddPosition(KeyIndex);
|
|
}
|
|
}
|
|
}
|
|
|
|
void FImGuiInputState::SetMouseDown(uint32 MouseIndex, bool bIsDown)
|
|
{
|
|
if (MouseIndex < Utilities::GetArraySize(MouseButtonsDown))
|
|
{
|
|
if (MouseButtonsDown[MouseIndex] != bIsDown)
|
|
{
|
|
MouseButtonsDown[MouseIndex] = bIsDown;
|
|
MouseButtonsUpdateRange.AddPosition(MouseIndex);
|
|
}
|
|
}
|
|
}
|
|
|
|
void FImGuiInputState::ClearUpdateState()
|
|
{
|
|
ClearCharacters();
|
|
|
|
KeyDownEvents.Reset();
|
|
KeyUpEvents.Reset();
|
|
MouseButtonDownEvents.Reset();
|
|
MouseButtonUpEvents.Reset();
|
|
|
|
KeysUpdateRange.SetEmpty();
|
|
MouseButtonsUpdateRange.SetEmpty();
|
|
|
|
MouseWheelDelta = 0.f;
|
|
|
|
bTouchProcessed = bTouchDown;
|
|
}
|
|
|
|
void FImGuiInputState::ClearCharacters()
|
|
{
|
|
InputCharacters.Empty();
|
|
}
|
|
|
|
void FImGuiInputState::ClearKeys()
|
|
{
|
|
using std::fill;
|
|
fill(KeysDown, &KeysDown[Utilities::GetArraySize(KeysDown)], false);
|
|
|
|
// Mark the whole array as dirty because potentially each entry could be affected.
|
|
KeysUpdateRange.SetFull();
|
|
}
|
|
|
|
void FImGuiInputState::ClearMouseButtons()
|
|
{
|
|
using std::fill;
|
|
fill(MouseButtonsDown, &MouseButtonsDown[Utilities::GetArraySize(MouseButtonsDown)], false);
|
|
|
|
// Mark the whole array as dirty because potentially each entry could be affected.
|
|
MouseButtonsUpdateRange.SetFull();
|
|
}
|
|
|
|
void FImGuiInputState::ClearMouseAnalogue()
|
|
{
|
|
MousePosition = FVector2D::ZeroVector;
|
|
MouseWheelDelta = 0.f;
|
|
}
|
|
|
|
void FImGuiInputState::ClearModifierKeys()
|
|
{
|
|
bIsControlDown = false;
|
|
bIsShiftDown = false;
|
|
bIsAltDown = false;
|
|
}
|
|
|