1 /* 2 3 Copyright (C) 2015-2018 Night Dive Studios, LLC. 4 Copyright (C) 2019 Shockolate Project 5 6 This program is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program. If not, see <http://www.gnu.org/licenses/>. 18 19 */ 20 #ifndef __KB_H 21 #define __KB_H 22 /* 23 * $Source: n:/project/lib/src/input/RCS/kbs.h $ 24 * $Revision: 1.1 $ 25 * $Author: kaboom $ 26 * $Date: 1994/02/12 18:28:21 $ 27 * 28 * Types for keyboard system. 29 * 30 * This file is part of the input library. 31 */ 32 33 #ifndef __KBS_H 34 #define __KBS_H 35 typedef struct { 36 uchar code; 37 uchar state; 38 uchar ascii; // Added for Mac version 39 uchar modifiers; // " " " " 40 } kbs_event; 41 #endif /* !__KBS_H */ 42 43 /* 44 * $Source: n:/project/lib/src/input/RCS/kbdecl.h $ 45 * $Revision: 1.4 $ 46 * $Author: kaboom $ 47 * $Date: 1994/02/12 18:21:29 $ 48 * 49 * Declarations for keyboard library. 50 * 51 * $Log: kbdecl.h $ 52 * Revision 1.4 1994/02/12 18:21:29 kaboom 53 * Moved event structure. 54 * 55 * Revision 1.3 1993/04/29 17:19:59 mahk 56 * added kb_get_cooked 57 * 58 * Revision 1.2 1993/04/28 17:01:48 mahk 59 * Added kb_flush_bios 60 * 61 * Revision 1.1 1993/03/10 17:16:41 kaboom 62 * Initial revision 63 * 64 */ 65 66 #ifdef __INLINE_FUNCTIONS__ 67 #define kb_state(code) (kbd_lowmem_start[KBD_ARRAY_START + code] & KBA_STATE) 68 #else 69 extern uchar kb_state(uchar code); 70 #endif 71 72 #define kb_init kb_startup 73 #define kb_close kb_shutdown 74 extern int kb_startup(void *init_buf); 75 extern int kb_shutdown(void); 76 77 extern kbs_event kb_next(void); 78 extern kbs_event kb_look_next(void); 79 extern void kb_flush(void); 80 extern uchar kb_get_state(uchar kb_code); 81 extern void kb_clear_state(uchar kb_code, uchar bits); 82 extern void kb_set_state(uchar kb_code, uchar bits); 83 extern void kb_set_signal(uchar code, uchar int_no); 84 extern int kb_get_flags(); 85 extern void kb_set_flags(int flags); 86 extern void kb_generate(kbs_event e); 87 // extern void kb_flush_bios(void); // For Mac version 88 #define kb_flush_bios kb_flush 89 extern uchar kb_get_cooked(ushort *key); 90 #define KBA_STATE (1) 91 #define KBA_REPEAT (2) 92 #define KBA_SIGNAL (4) 93 #define __KBD_INC (1) 94 extern char *kbd_lowmem_start; 95 #define __KBERR_INC (1) 96 #define KBE_ALLOC_LOWMEM (0) 97 #define KBE_FREE_LOWMEM (1) 98 #define KBE_MEM_THRASHED (2) 99 #define KBE_REAL_HANDLER (3) 100 #define KBE_PROT_HANDLER (4) 101 #define KBE_MEM_LOCK (5) 102 #define KBE_MEM_UNLOCK (6) 103 #define KBF_BLOCK (1) 104 #define KBF_CHAIN (2) 105 #define KBF_SIGNAL (4) 106 #define KBD_GLOBAL_START (0) 107 #define KBD_QUEUE_HEAD (KBD_GLOBAL_START) 108 #define KBD_LAST_CODES (KBD_QUEUE_HEAD + 4) 109 #define KBD_OLD_REAL_HANDLER (KBD_LAST_CODES + 4) 110 #define KBD_STATUS_FLAGS (KBD_OLD_REAL_HANDLER + 4) 111 #define KBD_GLOBAL_SIZE (KBD_STATUS_FLAGS + 4) 112 #define KBD_QUEUE_START (KBD_GLOBAL_SIZE) 113 #define KBD_QUEUE_SIZE (1024) 114 #define KBD_QUEUE_END (KBD_QUEUE_START + KBD_QUEUE_SIZE) 115 #define KBD_ARRAY_START (KBD_QUEUE_END) 116 #define KBD_ARRAY_SIZE (256) 117 #define KBD_ARRAY_END (KBD_ARRAY_START + KBD_ARRAY_SIZE) 118 #define KBD_SIGLIST_START (KBD_ARRAY_END) 119 #define KBD_SIGLIST_SIZE (256) 120 #define KBD_SIGLIST_END (KBD_SIGLIST_START + KBD_SIGLIST_SIZE) 121 #define KBD_LOWBUF_SIZE (KBD_SIGLIST_END) 122 #define KBD_HANDLER_START (KBD_LOWBUF_SIZE) 123 #define KBC_SHIFT_PREFIX (0x0e0) 124 #define KBC_PAUSE_PREFIX (0x0e1) 125 #define KBC_PAUSE_DOWN (0x0e11d) 126 #define KBC_PAUSE_UP (0x0e19d) 127 #define KBC_PRSCR_DOWN (0x02a) 128 #define KBC_PRSCR_UP (0x0aa) 129 #define KBC_PAUSE (0x07f) 130 #define KBC_NONE (0x0ff) 131 #define KBS_UP (0) 132 #define KBS_DOWN (1) 133 134 // DG: constants for values of kbs_event::modifiers, also used in sshockKeyStates[] 135 // (those constants are based on the values that were hardcoded in kb_cook()) 136 #define KB_MOD_CTRL (0x01) 137 #define KB_MOD_SHIFT (0x04) 138 #define KB_MOD_ALT (0x08) 139 140 // currente state of the keys, based on the SystemShock/Mac Keycodes (sshockKeyStates[keyCode] has the state for that 141 // key) 142 extern uchar sshockKeyStates[256]; 143 // this one is only used in sshockKeyStates[], it's set if a button is pressed 144 // (together with the CTRL/SHIFT/ALT modifiers, if they were pressed as while the key was pressed) 145 #define KB_MOD_PRESSED (0x10) 146 147 #endif /* !__KB_H */ 148