User-friendly tilde typing in the console

Post tutorials on how to do certain tasks within game or engine code here.

Moderator: InsideQC Admins

User-friendly tilde typing in the console

Postby mankrip » Mon May 09, 2016 9:32 am

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] ) ) )
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
Dev blog / Twitter / YouTube
User avatar
Posts: 915
Joined: Fri Jul 04, 2008 3:02 am

Return to Programming Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest