File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -168,11 +168,6 @@ void CarnageGame::InputEventLost()
168168
169169void 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 ();
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 }
237241public:
238242 eKeycode mKeycode ;
Original file line number Diff line number Diff line change 22#include " InputsManager.h"
33#include " ImGuiManager.h"
44#include " CarnageGame.h"
5+ #include " ConsoleWindow.h"
56
67InputsManager gInputs ;
78
@@ -73,6 +74,12 @@ void InputsManager::InputEvent(GamepadInputEvent& inputEvent)
7374
7475void 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+ }
Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ class InputsManager final: public cxx::noncopyable
8686
8787private:
8888 void InputEventConsumed (InputEventsHandler* handler);
89+ bool HandleDebugKeys (KeyInputEvent& inputEvent);
8990
9091private:
9192 InputEventsHandler* mLastInputsHandler = nullptr ;
You can’t perform that action at this time.
0 commit comments