Skip to content

Commit 30febc3

Browse files
committed
1 parent 02c6259 commit 30febc3

5 files changed

Lines changed: 30 additions & 16 deletions

File tree

src/CarnageGame.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,6 @@ void CarnageGame::InputEventLost()
168168

169169
void CarnageGame::InputEvent(KeyInputEvent& inputEvent)
170170
{
171-
if (inputEvent.HasPressed(eKeycode_TILDE)) // show debug console
172-
{
173-
gDebugConsoleWindow.mWindowShown = !gDebugConsoleWindow.mWindowShown;
174-
return;
175-
}
176171
if (inputEvent.HasPressed(eKeycode_F3))
177172
{
178173
gRenderManager.ReloadRenderPrograms();

src/ConsoleWindow.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,6 @@ int ConsoleWindow::TextEditCallback(ImGuiInputTextCallbackData* data)
118118
{
119119
switch (data->EventFlag)
120120
{
121-
case ImGuiInputTextFlags_CallbackCharFilter:
122-
{
123-
if (data->EventChar == L'`')
124-
{
125-
ToggleWindowShown();
126-
return 1;
127-
}
128-
break;
129-
}
130121
case ImGuiInputTextFlags_CallbackCompletion:
131122
{
132123
// Locate beginning of current word

src/InputsDefs.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,14 @@ struct KeyInputEvent: public BaseInputEvent
229229
{
230230
return (mMods & bits) == bits;
231231
}
232-
// test whether specific key was pressed
232+
// test whether specific key was pressed or released
233233
inline bool HasPressed(eKeycode keycode) const
234234
{
235-
return mPressed && keycode == mKeycode;
235+
return mPressed && (keycode == mKeycode);
236+
}
237+
inline bool HasReleased(eKeycode keycode) const
238+
{
239+
return !mPressed && (keycode == mKeycode);
236240
}
237241
public:
238242
eKeycode mKeycode;

src/InputsManager.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "InputsManager.h"
33
#include "ImGuiManager.h"
44
#include "CarnageGame.h"
5+
#include "ConsoleWindow.h"
56

67
InputsManager gInputs;
78

@@ -73,6 +74,12 @@ void InputsManager::InputEvent(GamepadInputEvent& inputEvent)
7374

7475
void InputsManager::InputEvent(KeyInputEvent& inputEvent)
7576
{
77+
if (HandleDebugKeys(inputEvent))
78+
{
79+
InputEventConsumed(nullptr);
80+
return;
81+
}
82+
7683
mKeyboardKeys[inputEvent.mKeycode] = inputEvent.mPressed;
7784

7885
for (InputEventsHandler* currentHandler: mInputHandlers)
@@ -142,3 +149,19 @@ void InputsManager::UpdateFrame()
142149
mInputHandlers.push_back(&gGuiManager);
143150
mInputHandlers.push_back(&gCarnageGame);
144151
}
152+
153+
bool InputsManager::HandleDebugKeys(KeyInputEvent& inputEvent)
154+
{
155+
// show/hide debug console window
156+
if (inputEvent.HasPressed(eKeycode_TILDE) || inputEvent.HasReleased(eKeycode_TILDE))
157+
{
158+
if (inputEvent.HasPressed(eKeycode_TILDE))
159+
{
160+
gDebugConsoleWindow.ToggleWindowShown();
161+
}
162+
inputEvent.SetConsumed();
163+
return true;
164+
}
165+
166+
return false;
167+
}

src/InputsManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class InputsManager final: public cxx::noncopyable
8686

8787
private:
8888
void InputEventConsumed(InputEventsHandler* handler);
89+
bool HandleDebugKeys(KeyInputEvent& inputEvent);
8990

9091
private:
9192
InputEventsHandler* mLastInputsHandler = nullptr;

0 commit comments

Comments
 (0)