2017-04-22 15:38:04 +00:00
|
|
|
// Distributed under the MIT License (MIT) (see accompanying LICENSE file)
|
|
|
|
|
|
|
|
#include "ImGuiInputState.h"
|
|
|
|
|
2017-09-22 19:23:42 +00:00
|
|
|
#include <algorithm>
|
2018-02-02 22:50:55 +00:00
|
|
|
#include <limits>
|
|
|
|
#include <type_traits>
|
2017-09-22 19:23:42 +00:00
|
|
|
|
2017-04-22 15:38:04 +00:00
|
|
|
|
|
|
|
FImGuiInputState::FImGuiInputState()
|
|
|
|
{
|
2019-06-23 19:29:25 +00:00
|
|
|
Reset();
|
2017-04-22 15:38:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FImGuiInputState::AddCharacter(TCHAR Char)
|
|
|
|
{
|
2020-02-03 20:11:04 +00:00
|
|
|
InputCharacters.Add(Char);
|
2017-04-22 15:38:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FImGuiInputState::SetKeyDown(uint32 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()
|
|
|
|
{
|
2020-02-03 20:11:04 +00:00
|
|
|
ClearCharacters();
|
2017-04-22 15:38:04 +00:00
|
|
|
|
2022-02-25 21:40:13 +00:00
|
|
|
KeyDownEvents.Reset();
|
|
|
|
KeyUpEvents.Reset();
|
|
|
|
|
2017-04-22 15:38:04 +00:00
|
|
|
KeysUpdateRange.SetEmpty();
|
|
|
|
MouseButtonsUpdateRange.SetEmpty();
|
|
|
|
|
|
|
|
MouseWheelDelta = 0.f;
|
2019-08-01 20:41:12 +00:00
|
|
|
|
|
|
|
bTouchProcessed = bTouchDown;
|
2017-04-22 15:38:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FImGuiInputState::ClearCharacters()
|
|
|
|
{
|
2020-02-03 20:11:04 +00:00
|
|
|
InputCharacters.Empty();
|
2017-08-19 20:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FImGuiInputState::ClearKeys()
|
|
|
|
{
|
|
|
|
using std::fill;
|
|
|
|
fill(KeysDown, &KeysDown[Utilities::GetArraySize(KeysDown)], false);
|
|
|
|
|
2019-06-23 19:29:25 +00:00
|
|
|
// Mark the whole array as dirty because potentially each entry could be affected.
|
2017-08-19 20:19:38 +00:00
|
|
|
KeysUpdateRange.SetFull();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FImGuiInputState::ClearMouseButtons()
|
|
|
|
{
|
|
|
|
using std::fill;
|
|
|
|
fill(MouseButtonsDown, &MouseButtonsDown[Utilities::GetArraySize(MouseButtonsDown)], false);
|
|
|
|
|
2019-06-23 19:29:25 +00:00
|
|
|
// Mark the whole array as dirty because potentially each entry could be affected.
|
2017-08-19 20:19:38 +00:00
|
|
|
MouseButtonsUpdateRange.SetFull();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FImGuiInputState::ClearMouseAnalogue()
|
|
|
|
{
|
|
|
|
MousePosition = FVector2D::ZeroVector;
|
|
|
|
MouseWheelDelta = 0.f;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FImGuiInputState::ClearModifierKeys()
|
|
|
|
{
|
|
|
|
bIsControlDown = false;
|
|
|
|
bIsShiftDown = false;
|
|
|
|
bIsAltDown = false;
|
2017-04-22 15:38:04 +00:00
|
|
|
}
|
2018-05-17 22:25:47 +00:00
|
|
|
|
|
|
|
void FImGuiInputState::ClearNavigationInputs()
|
|
|
|
{
|
|
|
|
using std::fill;
|
|
|
|
fill(NavigationInputs, &NavigationInputs[Utilities::GetArraySize(NavigationInputs)], 0.f);
|
|
|
|
}
|
|
|
|
|