made keys F13 to F24 bindable

This commit is contained in:
myT 2017-10-03 23:58:41 +02:00
parent 1d6663ebc1
commit c3027a56b7
5 changed files with 56 additions and 27 deletions

View file

@ -1,6 +1,8 @@
DD Mmm 17 - 1.49
add: keys F13 to F24 are now bindable
add: new cvar type and range extension for compatible mods like CPMA 1.50
add: new help commands for commands and cvars of the engine and compatible mods like CPMA 1.50

View file

@ -25,6 +25,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "client_help.h"
static char LastKeyTooHigh[K_LAST_KEY < 256 ? 1 : -1];
static cvar_t* m_speed;
static cvar_t* m_accel;
static cvar_t* m_accelStyle; // 0=original, 1=new

View file

@ -87,6 +87,18 @@ static const keyname_t keynames[] =
{"F10", K_F10},
{"F11", K_F11},
{"F12", K_F12},
{"F13", K_F13},
{"F14", K_F14},
{"F15", K_F15},
{"F16", K_F16},
{"F17", K_F17},
{"F18", K_F18},
{"F19", K_F19},
{"F20", K_F20},
{"F21", K_F21},
{"F22", K_F22},
{"F23", K_F23},
{"F24", K_F24},
{"INS", K_INS},
{"DEL", K_DEL},
@ -1042,9 +1054,7 @@ void CL_KeyEvent( int key, qbool down, unsigned time )
// send the bound action
kb = keys[key].binding;
if ( !kb ) {
if (key >= 200) {
Com_Printf( "%s is unbound, use controls menu to set.\n", Key_KeynumToString( key ) );
}
// unbound
} else if (kb[0] == '+') {
int i;
char button[1024], *buttonPtr;

View file

@ -151,6 +151,9 @@ typedef enum {
K_AUX15,
K_AUX16,
// never change anything above as it will mess up mod code
// what follows is new in CNQ3
K_MOUSE6,
K_MOUSE7,
K_MOUSE8,
@ -161,6 +164,16 @@ typedef enum {
K_BACKSLASH,
K_F16,
K_F17,
K_F18,
K_F19,
K_F20,
K_F21,
K_F22,
K_F23,
K_F24,
K_LAST_KEY // this had better be <256!
} keyNum_t;

View file

@ -121,33 +121,35 @@ MapKey
Map from windows to quake keynums
=======
*/
static int MapKey (int key)
static int MapKey( int wParam, int lParam )
{
int result;
int modified;
qbool is_extended;
//Com_Printf( "0x%X\n", key );
modified = ( key >> 16 ) & 255;
if ( modified > 127 )
return 0;
if ( key & ( 1 << 24 ) )
// the K_F13 to K_F24 values are *not* contiguous for mod compatibility reasons
switch ( wParam )
{
is_extended = qtrue;
}
else
{
is_extended = qfalse;
case VK_F13: return K_F13;
case VK_F14: return K_F14;
case VK_F15: return K_F15;
case VK_F16: return K_F16;
case VK_F17: return K_F17;
case VK_F18: return K_F18;
case VK_F19: return K_F19;
case VK_F20: return K_F20;
case VK_F21: return K_F21;
case VK_F22: return K_F22;
case VK_F23: return K_F23;
case VK_F24: return K_F24;
default: break;
}
result = s_scantokey[modified];
const int scanCode = ( lParam >> 16 ) & 255;
if ( scanCode > 127 )
return 0; // why?
if ( !is_extended )
const qbool isExtended = (lParam & ( 1 << 24 )) != 0;
const int result = s_scantokey[scanCode];
if ( !isExtended )
{
//Com_Printf( "!extended 0x%X\n", result );
switch ( result )
{
case K_HOME:
@ -180,7 +182,6 @@ static int MapKey (int key)
}
else
{
//Com_Printf( "extended 0x%X\n", result );
switch ( result )
{
case K_PAUSE:
@ -316,12 +317,12 @@ LRESULT CALLBACK MainWndProc (
}
// fall through
case WM_KEYDOWN:
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, MapKey( lParam ), qtrue, 0, NULL );
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, MapKey( wParam, lParam ), qtrue, 0, NULL );
break;
case WM_SYSKEYUP:
case WM_KEYUP:
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, MapKey( lParam ), qfalse, 0, NULL );
Sys_QueEvent( g_wv.sysMsgTime, SE_KEY, MapKey( wParam, lParam ), qfalse, 0, NULL );
break;
case WM_CHAR: