Page 1 of 1

User-friendly tilde typing in the console

Posted: Mon May 09, 2016 9:32 am
by mankrip
This tutorial will allow the user to type the tilde character in the console, without affecting the default behavior of the tilde key.

If the prompt is empty, the tilde key will behave as usual, but if it isn't, the desired character will be typed.

Open keys.c

In the function Key_Init, change these values to true:

Code: Select all

	consolekeys['`'] = true;
	consolekeys['~'] = true;
In the function Key_Event, add this line:

Code: Select all

//
// if not a consolekey, send to the interpreter no matter what mode is
//
	if ( (key_dest == key_menu && menubound[key])
	|| (key_dest == key_console && !consolekeys[key])
	|| (key_dest == key_console && (key == '`' || key == '~') && !key_lines[edit_line][1]) // mankrip - tilde typing when the prompt is empty
	|| (key_dest == key_game && ( !con_forcedup || !consolekeys[key] ) ) )
	{