145 lines
4.5 KiB
C
145 lines
4.5 KiB
C
#ifndef CGDOOM_KBD_H
|
|
#define CGDOOM_KBD_H
|
|
|
|
/* 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
|
|
the keyboard. The PC build maps a subset of them to PC keys.
|
|
|
|
Each keymap is an array of keycodes, each either -1 (unbound) or a valid
|
|
enumerated KEYCODE_X value (see below). The meaning of each entry is
|
|
indicated by the array CGD_KeymapEntries which is an array of Doom 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. */
|
|
|
|
#include <stdint.h>
|
|
|
|
//---
|
|
// Keymaps
|
|
//---
|
|
|
|
#define CGDOOM_KEYMAP_SIZE 27
|
|
|
|
/* Array of Doom keys indicating the meaning of keymap indices. */
|
|
extern int16_t CGD_KeymapEntries[CGDOOM_KEYMAP_SIZE];
|
|
/* Type of custom keymaps */
|
|
typedef int16_t CGDoom_Keymap[CGDOOM_KEYMAP_SIZE];
|
|
|
|
/* Default keymaps (selectable in the main menu) */
|
|
extern const CGDoom_Keymap CGD_Keymap_CGDoom_0_03;
|
|
extern const CGDoom_Keymap CGD_Keymap_ThumbsOnly;
|
|
extern const CGDoom_Keymap CGD_Keymap_FullHands;
|
|
|
|
/* Load/copy a keymap. */
|
|
void CGD_CopyKeymap(CGDoom_Keymap dest, const CGDoom_Keymap src);
|
|
|
|
//---
|
|
// 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);
|
|
|
|
/* Scan keyboard (the previous state is also retained). */
|
|
void CGD_UpdateKeyboardState(void);
|
|
|
|
/* Check if a Doom key has just been pressed, or released. */
|
|
int CGD_KeyWasJustPressed(int key);
|
|
int CGD_KeyWasJustReleased(int key);
|
|
|
|
//---
|
|
// Physical keyboard driver
|
|
//---
|
|
|
|
/* Copy of the keyboard state, one byte per row */
|
|
typedef uint8_t CGDoom_KeyboardState[12] __attribute__((aligned(2)));
|
|
|
|
/* Keyboard scanning function (very short), uses either the KEYSC or SDL */
|
|
void CGD_ScanKeyboard(CGDoom_KeyboardState state);
|
|
|
|
/* PRGM_Getkey() but with the direct driver. */
|
|
int CGD_PRGM_Getkey(void);
|
|
|
|
/* 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);
|
|
|
|
/* 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
|
|
|
|
#endif /* CGDOOM_KBD_H */
|