- moved key definitions to their own header.

- moved VM hooks to vmthunks.cpp.
- header cleanup for c_bind.h to avoid including high level game definitions.
This commit is contained in:
Christoph Oelckers 2020-04-11 18:06:52 +02:00
parent 756a743974
commit d7a9bdc858
5 changed files with 170 additions and 151 deletions

View file

@ -34,13 +34,16 @@
#ifndef __C_BINDINGS_H__ #ifndef __C_BINDINGS_H__
#define __C_BINDINGS_H__ #define __C_BINDINGS_H__
#include "doomdef.h" #include "keydef.h"
#include "zstring.h"
#include "tarray.h"
struct event_t; struct event_t;
class FConfigFile; class FConfigFile;
class FCommandLine; class FCommandLine;
void C_NameKeys (char *str, int first, int second); void C_NameKeys (char *str, int first, int second);
FString C_NameKeys (int *keys, int count, bool colors = false);
class FKeyBindings class FKeyBindings
{ {
@ -92,7 +95,6 @@ bool C_DoKey (event_t *ev, FKeyBindings *binds, FKeyBindings *doublebinds);
// Stuff used by the customize controls menu // Stuff used by the customize controls menu
void C_SetDefaultBindings (); void C_SetDefaultBindings ();
void C_UnbindAll (); void C_UnbindAll ();
void C_NameKeys(char* str, int first, int second);
extern const char *KeyNames[]; extern const char *KeyNames[];

View file

@ -718,6 +718,7 @@ void C_DeinitConsole ()
// Make sure all tab commands are cleared before the memory for // Make sure all tab commands are cleared before the memory for
// their names is deallocated. // their names is deallocated.
C_ClearTabCommands (); C_ClearTabCommands ();
C_ClearDynCCmds();
// Free AddToConsole()'s work buffer // Free AddToConsole()'s work buffer
if (work != NULL) if (work != NULL)
@ -1316,22 +1317,6 @@ void C_HideConsole ()
} }
} }
DEFINE_ACTION_FUNCTION(_Console, HideConsole)
{
C_HideConsole();
return 0;
}
DEFINE_ACTION_FUNCTION(_Console, Printf)
{
PARAM_PROLOGUE;
PARAM_VA_POINTER(va_reginfo) // Get the hidden type information array
FString s = FStringFormat(VM_ARGS_NAMES);
Printf("%s\n", s.GetChars());
return 0;
}
static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer) static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer)
{ {
int data1 = ev->data1; int data1 = ev->data1;
@ -1793,18 +1778,6 @@ void C_MidPrint (FFont *font, const char *msg, bool bold)
} }
} }
DEFINE_ACTION_FUNCTION(_Console, MidPrint)
{
PARAM_PROLOGUE;
PARAM_POINTER(fnt, FFont);
PARAM_STRING(text);
PARAM_BOOL(bold);
const char *txt = text[0] == '$'? GStrings(&text[1]) : text.GetChars();
C_MidPrint(fnt, txt, bold);
return 0;
}
/****** Tab completion code ******/ /****** Tab completion code ******/
struct TabData struct TabData

137
src/console/keydef.h Normal file
View file

@ -0,0 +1,137 @@
#pragma once
#include <stdio.h>
#include <string.h>
//
// Keyboard definition. Everything below = 0x100 matches
// a mode 1 keyboard scan code.
//
enum EKeyCodes
{
KEY_PAUSE = 0xc5, // DIK_PAUSE
KEY_RIGHTARROW = 0xcd, // DIK_RIGHT
KEY_LEFTARROW = 0xcb, // DIK_LEFT
KEY_UPARROW = 0xc8, // DIK_UP
KEY_DOWNARROW = 0xd0, // DIK_DOWN
KEY_ESCAPE = 0x01, // DIK_ESCAPE
KEY_ENTER = 0x1c, // DIK_RETURN
KEY_SPACE = 0x39, // DIK_SPACE
KEY_TAB = 0x0f, // DIK_TAB
KEY_F1 = 0x3b, // DIK_F1
KEY_F2 = 0x3c, // DIK_F2
KEY_F3 = 0x3d, // DIK_F3
KEY_F4 = 0x3e, // DIK_F4
KEY_F5 = 0x3f, // DIK_F5
KEY_F6 = 0x40, // DIK_F6
KEY_F7 = 0x41, // DIK_F7
KEY_F8 = 0x42, // DIK_F8
KEY_F9 = 0x43, // DIK_F9
KEY_F10 = 0x44, // DIK_F10
KEY_F11 = 0x57, // DIK_F11
KEY_F12 = 0x58, // DIK_F12
KEY_GRAVE = 0x29, // DIK_GRAVE
KEY_BACKSPACE = 0x0e, // DIK_BACK
KEY_EQUALS = 0x0d, // DIK_EQUALS
KEY_MINUS = 0x0c, // DIK_MINUS
KEY_LSHIFT = 0x2A, // DIK_LSHIFT
KEY_LCTRL = 0x1d, // DIK_LCONTROL
KEY_LALT = 0x38, // DIK_LMENU
KEY_RSHIFT = 0x36,
KEY_RCTRL = 0x9d,
KEY_RALT = 0xb8,
KEY_INS = 0xd2, // DIK_INSERT
KEY_DEL = 0xd3, // DIK_DELETE
KEY_END = 0xcf, // DIK_END
KEY_HOME = 0xc7, // DIK_HOME
KEY_PGUP = 0xc9, // DIK_PRIOR
KEY_PGDN = 0xd1, // DIK_NEXT
KEY_FIRSTMOUSEBUTTON = 0x100,
KEY_MOUSE1 = 0x100,
KEY_MOUSE2 = 0x101,
KEY_MOUSE3 = 0x102,
KEY_MOUSE4 = 0x103,
KEY_MOUSE5 = 0x104,
KEY_MOUSE6 = 0x105,
KEY_MOUSE7 = 0x106,
KEY_MOUSE8 = 0x107,
KEY_FIRSTJOYBUTTON = 0x108,
KEY_JOY1 = KEY_FIRSTJOYBUTTON+0,
KEY_JOY2,
KEY_JOY3,
KEY_JOY4,
KEY_JOY5,
KEY_JOY6,
KEY_JOY7,
KEY_JOY8,
KEY_LASTJOYBUTTON = 0x187,
KEY_JOYPOV1_UP = 0x188,
KEY_JOYPOV1_RIGHT = 0x189,
KEY_JOYPOV1_DOWN = 0x18a,
KEY_JOYPOV1_LEFT = 0x18b,
KEY_JOYPOV2_UP = 0x18c,
KEY_JOYPOV3_UP = 0x190,
KEY_JOYPOV4_UP = 0x194,
KEY_MWHEELUP = 0x198,
KEY_MWHEELDOWN = 0x199,
KEY_MWHEELRIGHT = 0x19A,
KEY_MWHEELLEFT = 0x19B,
KEY_JOYAXIS1PLUS = 0x19C,
KEY_JOYAXIS1MINUS = 0x19D,
KEY_JOYAXIS2PLUS = 0x19E,
KEY_JOYAXIS2MINUS = 0x19F,
KEY_JOYAXIS3PLUS = 0x1A0,
KEY_JOYAXIS3MINUS = 0x1A1,
KEY_JOYAXIS4PLUS = 0x1A2,
KEY_JOYAXIS4MINUS = 0x1A3,
KEY_JOYAXIS5PLUS = 0x1A4,
KEY_JOYAXIS5MINUS = 0x1A5,
KEY_JOYAXIS6PLUS = 0x1A6,
KEY_JOYAXIS6MINUS = 0x1A7,
KEY_JOYAXIS7PLUS = 0x1A8,
KEY_JOYAXIS7MINUS = 0x1A9,
KEY_JOYAXIS8PLUS = 0x1AA,
KEY_JOYAXIS8MINUS = 0x1AB,
KEY_PAD_LTHUMB_RIGHT = 0x1AC,
KEY_PAD_LTHUMB_LEFT = 0x1AD,
KEY_PAD_LTHUMB_DOWN = 0x1AE,
KEY_PAD_LTHUMB_UP = 0x1AF,
KEY_PAD_RTHUMB_RIGHT = 0x1B0,
KEY_PAD_RTHUMB_LEFT = 0x1B1,
KEY_PAD_RTHUMB_DOWN = 0x1B2,
KEY_PAD_RTHUMB_UP = 0x1B3,
KEY_PAD_DPAD_UP = 0x1B4,
KEY_PAD_DPAD_DOWN = 0x1B5,
KEY_PAD_DPAD_LEFT = 0x1B6,
KEY_PAD_DPAD_RIGHT = 0x1B7,
KEY_PAD_START = 0x1B8,
KEY_PAD_BACK = 0x1B9,
KEY_PAD_LTHUMB = 0x1BA,
KEY_PAD_RTHUMB = 0x1BB,
KEY_PAD_LSHOULDER = 0x1BC,
KEY_PAD_RSHOULDER = 0x1BD,
KEY_PAD_LTRIGGER = 0x1BE,
KEY_PAD_RTRIGGER = 0x1BF,
KEY_PAD_A = 0x1C0,
KEY_PAD_B = 0x1C1,
KEY_PAD_X = 0x1C2,
KEY_PAD_Y = 0x1C3,
NUM_KEYS = 0x1C4,
NUM_JOYAXISBUTTONS = 8,
};

View file

@ -99,127 +99,7 @@ enum ESkillLevels
// a mode 1 keyboard scan code. // a mode 1 keyboard scan code.
// //
#define KEY_PAUSE 0xc5 // DIK_PAUSE #include "keydef.h"
#define KEY_RIGHTARROW 0xcd // DIK_RIGHT
#define KEY_LEFTARROW 0xcb // DIK_LEFT
#define KEY_UPARROW 0xc8 // DIK_UP
#define KEY_DOWNARROW 0xd0 // DIK_DOWN
#define KEY_ESCAPE 0x01 // DIK_ESCAPE
#define KEY_ENTER 0x1c // DIK_RETURN
#define KEY_SPACE 0x39 // DIK_SPACE
#define KEY_TAB 0x0f // DIK_TAB
#define KEY_F1 0x3b // DIK_F1
#define KEY_F2 0x3c // DIK_F2
#define KEY_F3 0x3d // DIK_F3
#define KEY_F4 0x3e // DIK_F4
#define KEY_F5 0x3f // DIK_F5
#define KEY_F6 0x40 // DIK_F6
#define KEY_F7 0x41 // DIK_F7
#define KEY_F8 0x42 // DIK_F8
#define KEY_F9 0x43 // DIK_F9
#define KEY_F10 0x44 // DIK_F10
#define KEY_F11 0x57 // DIK_F11
#define KEY_F12 0x58 // DIK_F12
#define KEY_GRAVE 0x29 // DIK_GRAVE
#define KEY_BACKSPACE 0x0e // DIK_BACK
#define KEY_EQUALS 0x0d // DIK_EQUALS
#define KEY_MINUS 0x0c // DIK_MINUS
#define KEY_LSHIFT 0x2A // DIK_LSHIFT
#define KEY_LCTRL 0x1d // DIK_LCONTROL
#define KEY_LALT 0x38 // DIK_LMENU
#define KEY_RSHIFT KEY_LSHIFT
#define KEY_RCTRL KEY_LCTRL
#define KEY_RALT KEY_LALT
#define KEY_INS 0xd2 // DIK_INSERT
#define KEY_DEL 0xd3 // DIK_DELETE
#define KEY_END 0xcf // DIK_END
#define KEY_HOME 0xc7 // DIK_HOME
#define KEY_PGUP 0xc9 // DIK_PRIOR
#define KEY_PGDN 0xd1 // DIK_NEXT
#define KEY_MOUSE1 0x100
#define KEY_MOUSE2 0x101
#define KEY_MOUSE3 0x102
#define KEY_MOUSE4 0x103
#define KEY_MOUSE5 0x104
#define KEY_MOUSE6 0x105
#define KEY_MOUSE7 0x106
#define KEY_MOUSE8 0x107
#define KEY_FIRSTJOYBUTTON 0x108
#define KEY_JOY1 (KEY_FIRSTJOYBUTTON+0)
#define KEY_JOY2 (KEY_FIRSTJOYBUTTON+1)
#define KEY_JOY3 (KEY_FIRSTJOYBUTTON+2)
#define KEY_JOY4 (KEY_FIRSTJOYBUTTON+3)
#define KEY_JOY5 (KEY_FIRSTJOYBUTTON+4)
#define KEY_JOY6 (KEY_FIRSTJOYBUTTON+5)
#define KEY_JOY7 (KEY_FIRSTJOYBUTTON+6)
#define KEY_JOY8 (KEY_FIRSTJOYBUTTON+7)
#define KEY_LASTJOYBUTTON 0x187
#define KEY_JOYPOV1_UP 0x188
#define KEY_JOYPOV1_RIGHT 0x189
#define KEY_JOYPOV1_DOWN 0x18a
#define KEY_JOYPOV1_LEFT 0x18b
#define KEY_JOYPOV2_UP 0x18c
#define KEY_JOYPOV3_UP 0x190
#define KEY_JOYPOV4_UP 0x194
#define KEY_MWHEELUP 0x198
#define KEY_MWHEELDOWN 0x199
#define KEY_MWHEELRIGHT 0x19A
#define KEY_MWHEELLEFT 0x19B
#define KEY_JOYAXIS1PLUS 0x19C
#define KEY_JOYAXIS1MINUS 0x19D
#define KEY_JOYAXIS2PLUS 0x19E
#define KEY_JOYAXIS2MINUS 0x19F
#define KEY_JOYAXIS3PLUS 0x1A0
#define KEY_JOYAXIS3MINUS 0x1A1
#define KEY_JOYAXIS4PLUS 0x1A2
#define KEY_JOYAXIS4MINUS 0x1A3
#define KEY_JOYAXIS5PLUS 0x1A4
#define KEY_JOYAXIS5MINUS 0x1A5
#define KEY_JOYAXIS6PLUS 0x1A6
#define KEY_JOYAXIS6MINUS 0x1A7
#define KEY_JOYAXIS7PLUS 0x1A8
#define KEY_JOYAXIS7MINUS 0x1A9
#define KEY_JOYAXIS8PLUS 0x1AA
#define KEY_JOYAXIS8MINUS 0x1AB
#define NUM_JOYAXISBUTTONS 8
#define KEY_PAD_LTHUMB_RIGHT 0x1AC
#define KEY_PAD_LTHUMB_LEFT 0x1AD
#define KEY_PAD_LTHUMB_DOWN 0x1AE
#define KEY_PAD_LTHUMB_UP 0x1AF
#define KEY_PAD_RTHUMB_RIGHT 0x1B0
#define KEY_PAD_RTHUMB_LEFT 0x1B1
#define KEY_PAD_RTHUMB_DOWN 0x1B2
#define KEY_PAD_RTHUMB_UP 0x1B3
#define KEY_PAD_DPAD_UP 0x1B4
#define KEY_PAD_DPAD_DOWN 0x1B5
#define KEY_PAD_DPAD_LEFT 0x1B6
#define KEY_PAD_DPAD_RIGHT 0x1B7
#define KEY_PAD_START 0x1B8
#define KEY_PAD_BACK 0x1B9
#define KEY_PAD_LTHUMB 0x1BA
#define KEY_PAD_RTHUMB 0x1BB
#define KEY_PAD_LSHOULDER 0x1BC
#define KEY_PAD_RSHOULDER 0x1BD
#define KEY_PAD_LTRIGGER 0x1BE
#define KEY_PAD_RTRIGGER 0x1BF
#define KEY_PAD_A 0x1C0
#define KEY_PAD_B 0x1C1
#define KEY_PAD_X 0x1C2
#define KEY_PAD_Y 0x1C3
#define NUM_KEYS 0x1C4
// [RH] dmflags bits (based on Q2's) // [RH] dmflags bits (based on Q2's)
enum enum

View file

@ -3406,6 +3406,33 @@ DEFINE_ACTION_FUNCTION(DOptionMenuItemCommand, DoCommand)
return 0; return 0;
} }
DEFINE_ACTION_FUNCTION(_Console, MidPrint)
{
PARAM_PROLOGUE;
PARAM_POINTER(fnt, FFont);
PARAM_STRING(text);
PARAM_BOOL(bold);
const char* txt = text[0] == '$' ? GStrings(&text[1]) : text.GetChars();
C_MidPrint(fnt, txt, bold);
return 0;
}
DEFINE_ACTION_FUNCTION(_Console, HideConsole)
{
C_HideConsole();
return 0;
}
DEFINE_ACTION_FUNCTION(_Console, Printf)
{
PARAM_PROLOGUE;
PARAM_VA_POINTER(va_reginfo) // Get the hidden type information array
FString s = FStringFormat(VM_ARGS_NAMES);
Printf("%s\n", s.GetChars());
return 0;
}