From 63cb1eb3ac4d2c0f4f08cf1392b25babfc574077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=ABBielBdeLuna=C2=BB?= <«7318.tk@gmail.com»> Date: Sat, 23 Mar 2024 09:24:32 +0100 Subject: [PATCH] added the printing of the key/button pressed --- neo/framework/KeyInput.cpp | 18 ++++++++++++++++++ neo/framework/KeyInput.h | 1 + 2 files changed, 19 insertions(+) diff --git a/neo/framework/KeyInput.cpp b/neo/framework/KeyInput.cpp index 299519c9..38df124e 100644 --- a/neo/framework/KeyInput.cpp +++ b/neo/framework/KeyInput.cpp @@ -196,6 +196,8 @@ static const keyname_t keynames[] = {NULL, 0, NULL} }; +idCVar in_namePressed( "in_namePressed", "0", CVAR_BOOL|CVAR_SYSTEM, "print the name of the key/button pressed" ); + static const int MAX_KEYS = K_LAST_KEY+1; // DG: was 256, made it more flexible class idKey { @@ -758,6 +760,10 @@ Called by the system for both key up and key down events void idKeyInput::PreliminaryKeyEvent( int keynum, bool down ) { keys[keynum].down = down; + if( cvarSystem->GetCVarBool( "in_namePressed") ) { + KeyReveal( keynum ); + } + #ifdef ID_DOOM_LEGACY if ( down && keynum < 127 ) { // DG: only ASCII keys are of interest here lastKeys[ 0 + ( lastKeyIndex & 15 )] = keynum; @@ -775,6 +781,18 @@ void idKeyInput::PreliminaryKeyEvent( int keynum, bool down ) { #endif } +/* +=================== +idKeyInput::KeyReveal + +simple print in the console the name of the key pressed +=================== +*/ +void idKeyInput::KeyReveal( int keyNum ) { + const char* keyName = KeyNumToString( keyNum, false ); + common->Printf( "pressed the \"%s\"key.\n", keyName ); +} + /* ================= idKeyInput::ExecKeyBinding diff --git a/neo/framework/KeyInput.h b/neo/framework/KeyInput.h index 402649bd..a8e1f07e 100644 --- a/neo/framework/KeyInput.h +++ b/neo/framework/KeyInput.h @@ -312,6 +312,7 @@ public: static const char * BindingFromKey( const char *key ); static bool KeyIsBoundTo( int keyNum, const char *binding ); static void WriteBindings( idFile *f ); + static void KeyReveal( int keyNum ); }; #endif /* !__KEYINPUT_H__ */