Skip to content

Commit 67910d6

Browse files
committed
Fixed erasure of first character on console command submit
1 parent a0957c0 commit 67910d6

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

examples/game/src/tools/DevConsole.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,23 @@ void DevConsole::OnUpdate()
3838
if ((key >= 32) && (key <= 125)) inputText += key;
3939
}
4040

41+
int latestKey = Siege::Input::GetLatestKey();
42+
4143
// Remove characters on backspace
42-
if (Siege::Input::IsKeyDown(Siege::Key::KEY_BACKSPACE) && !inputText.IsEmpty())
44+
if (latestKey == Siege::Key::KEY_BACKSPACE && !inputText.IsEmpty())
4345
inputText.PopBack();
4446

4547
// Get the last command you ran - only works once.
46-
if (Siege::Input::IsKeyDown(Siege::Key::KEY_UP) && !lastInput.IsEmpty())
48+
if (latestKey == Siege::Key::KEY_UP && !lastInput.IsEmpty())
4749
inputText = lastInput;
4850

4951
// Process the command on enter
50-
if (Siege::Input::IsKeyDown(Siege::Key::KEY_ENTER))
52+
if (latestKey == Siege::Key::KEY_ENTER)
5153
{
5254
// Process the input into command and argument format
5355
auto args = inputText.Split(' ');
5456
Siege::String command(!args.empty() ? args[0] : nullptr);
5557
Siege::String argument(args.size() > 1 ? args[1] : nullptr);
56-
command.Erase(0, 1);
5758

5859
// Run the appropriate instructions for specified command
5960
if (command == "load")

examples/render/src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ int main()
4444

4545
Siege::Window window("Render Example", {WIDTH, HEIGHT});
4646

47-
window.DisableCursor();
47+
Siege::Input::DisableCursor();
4848

4949
Siege::Input::SetInputWindowSource(reinterpret_cast<GLFWwindow*>(window.GetRawWindow()));
5050

@@ -147,7 +147,7 @@ int main()
147147
currentTime = newTime;
148148

149149
window.Update();
150-
window.ToggleCursor(inputEnabled);
150+
Siege::Input::ToggleCursor(inputEnabled);
151151

152152
if (Siege::Input::IsKeyJustPressed(Siege::Key::KEY_ESCAPE)) inputEnabled = !inputEnabled;
153153

tests/core/test_SceneSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include <core/Statics.h>
1010
#include <core/entity/Entity.h>
11-
#include <core/render/ResourceSystem.h>
11+
#include <core/ResourceSystem.h>
1212
#include <core/scene/SceneFile.h>
1313
#include <core/scene/SceneSystem.h>
1414
#include <utest.h>

0 commit comments

Comments
 (0)