CGDoom/cgdoom/cgdoom-kbd.h

127 lines
3.9 KiB
C
Raw Normal View History

#ifndef CGDOOM_KBD_H
#define CGDOOM_KBD_H
2021-10-01 00:27:53 +02:00
/* CGDoom's keyboard driver and control settings
Instead of using libfxcg functions which only provide single-key analysis
(GetKey, GetKeyWait, and PRGM_GetKey mainly), CGDoom uses a simple KEYSC
driver adapter from gint's. The following matrix codes identify all keys on
2021-10-01 00:27:53 +02:00
the keyboard. The PC build maps a subset of them to PC keys.
CGDoom also defines symbolic keys other than Doom's. The particular encoding
used by Doom for keys is quite unclear to me (ASCII characters and the like)
and not necessarily suitable for the calculator, so this module also handles
input configuration. */
/* Copy of the keyboard state, one byte per row */
typedef uint8_t CGD_KeyboardState[12] __attribute__((aligned(2)));
/* Keyboard scanning function (very short), uses either the KEYSC or SDL */
void CGD_ScanKeyboard(CGD_KeyboardState state);
/* Default keymaps for use in UI code */
extern const uint16_t CGD_Keymap_CGDoom_0_3[];
extern const uint16_t CGD_Keymap_ThumbsOnly[];
extern const uint16_t CGD_Keymap_FullHands[];
2021-09-30 17:11:09 +02:00
/* Dynamic keymap (the format is slightly different, see cgdoom-kbd.c) */
extern uint16_t CGD_Keymap[];
/* Load a default keymap */
void CGD_LoadKeymap(const uint16_t *template);
2021-09-30 17:11:09 +02:00
/* Key name from matrix code */
const char *CGD_KeyName(int keycode);
/* PRGM_Getkey() but with the direct driver */
int CGD_PRGM_Getkey(void);
2021-10-01 00:27:53 +02:00
//---
// Doom keys
//---
#include "doomdef.h"
/* Key extensions for cheats, debugs, performance, etc. */
#define SKEY_CHEAT 0x101
#define SKEY_DECVP 0x102
#define SKEY_INCVP 0x103
#define SKEY_NOCLIP 0x104
#define SKEY_GAMMA 0x105
#define SKEY_FREEMEM 0x106
#define SKEY_FPSCOUNTER 0x107
#define SKEY_FRAMESKIP 0x108
#define SKEY_PROFILER 0x109
/* Display name for a key (eg. "Strafe left") */
const char *CGD_DoomKey_DisplayName(int key);
/* Technical name for a key (eg. "STRAFE_LEFT") */
const char *CGD_DoomKey_TechnicalName(int key);
/* Key from technical name */
int CGD_DoomKey_FromTechnicalName(const char *technical_name, int length);
//---
// Physical keys
//---
/* Matrix codes generated by the keyboard driver. */
#define KEYCODE_F1 0x91
#define KEYCODE_F2 0x92
#define KEYCODE_F3 0x93
#define KEYCODE_F4 0x94
#define KEYCODE_F5 0x95
#define KEYCODE_F6 0x96
#define KEYCODE_SHIFT 0x81
#define KEYCODE_OPTN 0x82
#define KEYCODE_VARS 0x83
#define KEYCODE_MENU 0x84
#define KEYCODE_LEFT 0x85
#define KEYCODE_UP 0x86
#define KEYCODE_ALPHA 0x71
#define KEYCODE_SQUARE 0x72
#define KEYCODE_POWER 0x73
#define KEYCODE_EXIT 0x74
#define KEYCODE_DOWN 0x75
#define KEYCODE_RIGHT 0x76
#define KEYCODE_XOT 0x61
#define KEYCODE_LOG 0x62
#define KEYCODE_LN 0x63
#define KEYCODE_SIN 0x64
#define KEYCODE_COS 0x65
#define KEYCODE_TAN 0x66
#define KEYCODE_FRAC 0x51
#define KEYCODE_FD 0x52
#define KEYCODE_LEFTP 0x53
#define KEYCODE_RIGHTP 0x54
#define KEYCODE_COMMA 0x55
#define KEYCODE_ARROW 0x56
#define KEYCODE_7 0x41
#define KEYCODE_8 0x42
#define KEYCODE_9 0x43
#define KEYCODE_DEL 0x44
#define KEYCODE_4 0x31
#define KEYCODE_5 0x32
#define KEYCODE_6 0x33
#define KEYCODE_MUL 0x34
#define KEYCODE_DIV 0x35
#define KEYCODE_1 0x21
#define KEYCODE_2 0x22
#define KEYCODE_3 0x23
#define KEYCODE_PLUS 0x24
#define KEYCODE_MINUS 0x25
#define KEYCODE_0 0x11
#define KEYCODE_DOT 0x12
#define KEYCODE_EXP 0x13
#define KEYCODE_NEG 0x14
#define KEYCODE_EXE 0x15
#define KEYCODE_ACON 0x07
2021-10-01 00:27:53 +02:00
/* Display name for a key (eg. "x^2") */
const char *CGD_PhysicalKey_DisplayName(int key);
/* Technical name for a key (eg. "SQUARE") */
const char *CGD_PhysicalKey_TechnicalName(int key);
/* Key from technical name */
int CGD_PhysicalKey_FromTechnicalName(const char *technical_name, int length);
#endif /* CGDOOM_KBD_H */