| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * $Logfile: /DescentIII/Main/ddio_common/key.cpp $ |
| 21 | * $Revision: 27 $ |
| 22 | * $Date: 10/21/99 9:28p $ |
| 23 | * $Author: Jeff $ |
| 24 | * |
| 25 | * Keyboard common interface |
| 26 | * |
| 27 | * $Log: /DescentIII/Main/ddio_common/key.cpp $ |
| 28 | * |
| 29 | * 27 10/21/99 9:28p Jeff |
| 30 | * B.A. Macintosh code merge |
| 31 | * |
| 32 | * 26 8/31/99 5:30p Jason |
| 33 | * network statistics code |
| 34 | * |
| 35 | * 25 4/24/99 8:40p Samir |
| 36 | * debug key for mono screens moved into key handler. |
| 37 | * |
| 38 | * 24 4/24/99 5:41p Samir |
| 39 | * moved key to ascii, ascii to key to the ddio_common library. |
| 40 | * |
| 41 | * 23 4/22/99 2:00a Jeff |
| 42 | * pass in ddio_init_info |
| 43 | * |
| 44 | * 22 2/21/99 6:38p Samir |
| 45 | * mouse and key input better. buffered mouse. |
| 46 | * |
| 47 | * 21 2/05/99 1:16p Samir |
| 48 | * reset low level keys when flushing keyboard in the high level. added a |
| 49 | * function to the low level to reset the status of a key, called from |
| 50 | * high level key flush. |
| 51 | * |
| 52 | * 20 1/25/99 7:27p Samir |
| 53 | * fixed timing issues with emulated keyboard key down times. (Win32 sends |
| 54 | * multiple keydown messages, so ignore them.) |
| 55 | * |
| 56 | * 19 1/25/99 6:47p Samir |
| 57 | * allow slow keyboard |
| 58 | * |
| 59 | * 18 1/25/99 11:02a Samir |
| 60 | * revamped mouse and key controls. |
| 61 | * |
| 62 | * 17 10/21/98 6:51p Samir |
| 63 | * took out dynamic key updating. |
| 64 | * |
| 65 | * 16 10/21/98 12:02p Samir |
| 66 | * properly update odd keys when they are released throug |
| 67 | * ddio_KeyGetDownTime. |
| 68 | * |
| 69 | * 15 10/16/98 12:16p Samir |
| 70 | * more accurate key timing broke ddio_KeyDownTime, so key down time is |
| 71 | * rounded off 5 decimal places. |
| 72 | * |
| 73 | * 14 9/17/98 12:50p Samir |
| 74 | * added ddio_KeyFlushKey. |
| 75 | * |
| 76 | * 13 7/01/98 4:56p Samir |
| 77 | * changed some deinit stuff. |
| 78 | * |
| 79 | * 12 3/31/98 12:46p Samir |
| 80 | * keyboard IO system better. uses getmsgproc windows hook. |
| 81 | * |
| 82 | * 11 3/24/98 4:26p Samir |
| 83 | * added function to return the state of an adjusted key. |
| 84 | * |
| 85 | * 10 2/25/98 6:11p Samir |
| 86 | * Added functions to better deal with key flushing. |
| 87 | * |
| 88 | * 9 2/03/98 5:16p Matt |
| 89 | * Changed key buffer to be ushorts so shift,ctrl,etc. bits don't get |
| 90 | * lost. |
| 91 | * Added support for KEY_DEBUGGED. |
| 92 | * |
| 93 | * 8 1/21/98 6:47p Samir |
| 94 | * Added debugging info. |
| 95 | * |
| 96 | * 7 12/10/97 1:12p Samir |
| 97 | * Pass time to ddio_UpdateKeyState |
| 98 | * |
| 99 | * 6 10/29/97 4:14p Samir |
| 100 | * Keep record of key down count per key. |
| 101 | * |
| 102 | * 5 10/16/97 2:28p Samir |
| 103 | * move keyboard init into ddio_init and added preemptive select for |
| 104 | * keyboard. |
| 105 | * |
| 106 | * 4 8/29/97 11:54a Samir |
| 107 | * Fixed some problem with keycodes that were greater than 0x80, being |
| 108 | * sign extended upon return from KeyInKey. |
| 109 | * |
| 110 | * 3 8/13/97 5:41p Samir |
| 111 | * Took out annoying mprintf of keycode. |
| 112 | * |
| 113 | * 2 7/25/97 6:31p Samir |
| 114 | * Fixed some really stupid key queue buffer check bugs that could cause |
| 115 | * instability. |
| 116 | * |
| 117 | * 3 5/09/97 6:45p Samir |
| 118 | * Common keystate update function |
| 119 | * |
| 120 | * 2 5/08/97 1:54p Samir |
| 121 | * Took out prototype to ddio_Close |
| 122 | * |
| 123 | * 1 5/08/97 12:22p Samir |
| 124 | * Moved common keyboard code from ddio_win to ddio_common. |
| 125 | * |
| 126 | * $NoKeywords: $ |
| 127 | */ |
| 128 | |
| 129 | // Handles keyboard queue management |
| 130 | |
| 131 | #include "ddio.h"cxx . . $ `<file>/ddio/ddio.h`/ |
| 132 | #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/ |
| 133 | |
| 134 | #define KEY_QUEUE_SIZEcxx . . $ `ddio/key.cpp:134:9`! 16 |
| 135 | |
| 136 | // This is the key used as a debugging modifier |
| 137 | #define KEY_DEBUGcxx . . $ `ddio/key.cpp:137:9`! KEY_DELETEcxx . . $ `ddio/ddio_common.h:315:9`! |
| 138 | |
| 139 | // ---------------------------------------------------------------------------- |
| 140 | // Data for ddio_common keyboard code. |
| 141 | // ---------------------------------------------------------------------------- |
| 142 | |
| 143 | static bool DDIO_key_initcxx . . $ DDIO_key_init. = 0; |
| 144 | volatile uint8_tcxx . . $ uint8_t# DDIO_key_statecxx . . $ DDIO_key_state.[DDIO_MAX_KEYScxx . . $ `ddio/ddio_common.h:205:9`!]; |
| 145 | volatile int16_tcxx . . $ int16_t# DDIO_key_down_countcxx . . $ DDIO_key_down_count.[DDIO_MAX_KEYScxx . . $ `ddio/ddio_common.h:205:9`!]; |
| 146 | |
| 147 | static struct DDIO_key_queuecxx . . $ DDIO_key_queue# { |
| 148 | uint16_tcxx . . $ uint16_t# buffercxx . . $ DDIO_key_queue#buffer.[KEY_QUEUE_SIZEcxx . . $ `ddio/key.cpp:134:9`!]; // Keyboard buffer queue |
| 149 | int tailcxx . . $ DDIO_key_queue#tail.; |
| 150 | int headcxx . . $ DDIO_key_queue#head.; |
| 151 | } DDIO_key_queuecxx . . $ DDIO_key_queue.; |
| 152 | |
| 153 | // ---------------------------------------------------------------------------- |
| 154 | // Common initialization |
| 155 | // ---------------------------------------------------------------------------- |
| 156 | |
| 157 | bool ddio_KeyInitcxx . . $ ddio_KeyInit(4aa02e9b14a147be).(ddio_init_infocxx . . $ ddio_init_info# *init_info) { |
| 158 | if (ddio_InternalKeyInitcxx . . $ ddio_InternalKeyInit(4aa02e9b14a147be).(init_info)) { |
| 159 | DDIO_key_initcxx . . $ DDIO_key_init. = 1; |
| 160 | ddio_KeyFlushcxx . . $ ddio_KeyFlush(49f6e7a06ebc5aa8).(); |
| 161 | return 1; |
| 162 | } |
| 163 | |
| 164 | return 0; |
| 165 | } |
| 166 | |
| 167 | void ddio_KeyClosecxx . . $ ddio_KeyClose(49f6e7a06ebc5aa8).() { |
| 168 | if (DDIO_key_initcxx . . $ DDIO_key_init.) { |
| 169 | ddio_InternalKeyClosecxx . . $ ddio_InternalKeyClose(49f6e7a06ebc5aa8).(); |
| 170 | DDIO_key_initcxx . . $ DDIO_key_init. = 0; |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | // ---------------------------------------------------------------------------- |
| 175 | // Keyboard accessor functions |
| 176 | // ---------------------------------------------------------------------------- |
| 177 | |
| 178 | float ddio_KeyDownTimecxx . . $ ddio_KeyDownTime(5cde91ea12d43f46).(int key) { |
| 179 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(DDIO_key_init); |
| 180 | |
| 181 | // snap off shift states, etc. |
| 182 | return ddio_InternalKeyDownTimecxx . . $ ddio_InternalKeyDownTime(ef46aeb7cc924ea7).((uint8_tcxx . . $ uint8_t#)(key & 0xff)); |
| 183 | } |
| 184 | |
| 185 | // return number of times a key's been down since last call. |
| 186 | int ddio_KeyDownCountcxx . . $ ddio_KeyDownCount(7864480464b09eea).(int key) { |
| 187 | int count = DDIO_key_down_countcxx . . $ DDIO_key_down_count.[key]; |
| 188 | DDIO_key_down_countcxx . . $ DDIO_key_down_count.[key] = 0; |
| 189 | |
| 190 | return count; |
| 191 | } |
| 192 | |
| 193 | // returns the state of an ADJUSTED KEY VALUE |
| 194 | bool ddio_GetAdjKeyStatecxx . . $ ddio_GetAdjKeyState(83c267b20bac841a).(int adj_key) { |
| 195 | uint8_tcxx . . $ uint8_t# key_raw = adj_key & 0xff; |
| 196 | int key_test = 0; |
| 197 | |
| 198 | if (adj_key & KEY_SHIFTEDcxx . . $ `ddio/ddio_common.h:208:9`!) { |
| 199 | if (KEY_STATEcxx . . $ `ddio/ddio_common.h:204:9`!(KEY_LSHIFTcxx . . $ `ddio/ddio_common.h:275:9`!) || KEY_STATEcxx . . $ `ddio/ddio_common.h:204:9`!(KEY_RSHIFTcxx . . $ `ddio/ddio_common.h:276:9`!)) |
| 200 | key_test |= KEY_SHIFTEDcxx . . $ `ddio/ddio_common.h:208:9`!; |
| 201 | } |
| 202 | if (adj_key & KEY_ALTEDcxx . . $ `ddio/ddio_common.h:209:9`!) { |
| 203 | if (KEY_STATEcxx . . $ `ddio/ddio_common.h:204:9`!(KEY_LALTcxx . . $ `ddio/ddio_common.h:277:9`!) || KEY_STATEcxx . . $ `ddio/ddio_common.h:204:9`!(KEY_RALTcxx . . $ `ddio/ddio_common.h:278:9`!)) |
| 204 | key_test |= KEY_ALTEDcxx . . $ `ddio/ddio_common.h:209:9`!; |
| 205 | } |
| 206 | if (adj_key & KEY_CTRLEDcxx . . $ `ddio/ddio_common.h:210:9`!) { |
| 207 | if (KEY_STATEcxx . . $ `ddio/ddio_common.h:204:9`!(KEY_LCTRLcxx . . $ `ddio/ddio_common.h:279:9`!) || KEY_STATEcxx . . $ `ddio/ddio_common.h:204:9`!(KEY_RCTRLcxx . . $ `ddio/ddio_common.h:280:9`!)) |
| 208 | key_test |= KEY_CTRLEDcxx . . $ `ddio/ddio_common.h:210:9`!; |
| 209 | } |
| 210 | if (adj_key & KEY_DEBUGGEDcxx . . $ `ddio/ddio_common.h:211:9`!) { |
| 211 | if (KEY_STATEcxx . . $ `ddio/ddio_common.h:204:9`!(KEY_DEBUGcxx . . $ `ddio/key.cpp:137:9`!)) |
| 212 | key_test |= KEY_DEBUGGEDcxx . . $ `ddio/ddio_common.h:211:9`!; |
| 213 | } |
| 214 | |
| 215 | if (KEY_STATEcxx . . $ `ddio/ddio_common.h:204:9`!(key_raw)) |
| 216 | key_test |= key_raw; |
| 217 | |
| 218 | if (key_test == adj_key) |
| 219 | return true; |
| 220 | else |
| 221 | return false; |
| 222 | } |
| 223 | |
| 224 | // ---------------------------------------------------------------------------- |
| 225 | // Keyboard Queue functions |
| 226 | // ---------------------------------------------------------------------------- |
| 227 | |
| 228 | void ddio_KeyFlushcxx . . $ ddio_KeyFlush(49f6e7a06ebc5aa8).() { |
| 229 | int i; |
| 230 | |
| 231 | if (!DDIO_key_initcxx . . $ DDIO_key_init.) |
| 232 | return; |
| 233 | |
| 234 | // flush out internal key input system by gathering all data in buffer. |
| 235 | DDIO_key_queuecxx . . $ DDIO_key_queue..headcxx . . $ DDIO_key_queue#head. = DDIO_key_queuecxx . . $ DDIO_key_queue..tailcxx . . $ DDIO_key_queue#tail. = 0; |
| 236 | |
| 237 | for (i = 0; i < KEY_QUEUE_SIZEcxx . . $ `ddio/key.cpp:134:9`!; i++) { |
| 238 | DDIO_key_queuecxx . . $ DDIO_key_queue..buffercxx . . $ DDIO_key_queue#buffer.[i] = 0; |
| 239 | } |
| 240 | |
| 241 | // flush keyboard array too |
| 242 | for (i = 0; i < DDIO_MAX_KEYScxx . . $ `ddio/ddio_common.h:205:9`!; i++) { |
| 243 | DDIO_key_down_countcxx . . $ DDIO_key_down_count.[i] = 0; |
| 244 | DDIO_key_statecxx . . $ DDIO_key_state.[i] = 0; |
| 245 | ddio_InternalResetKeycxx . . $ ddio_InternalResetKey(ac50b47256ae7414).(i); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | void ddio_KeyFlushKeycxx . . $ ddio_KeyFlushKey(d4f767463ce0a6b3).(int key) { |
| 250 | DDIO_key_down_countcxx . . $ DDIO_key_down_count.[key] = 0; |
| 251 | DDIO_key_statecxx . . $ DDIO_key_state.[key] = 0; |
| 252 | } |
| 253 | |
| 254 | int ddio_KeyInKeycxx . . $ ddio_KeyInKey(b126dc7c1de90089).() { |
| 255 | unsigned key = 0; |
| 256 | |
| 257 | if (DDIO_key_queuecxx . . $ DDIO_key_queue..headcxx . . $ DDIO_key_queue#head. != DDIO_key_queuecxx . . $ DDIO_key_queue..tailcxx . . $ DDIO_key_queue#tail.) { |
| 258 | key = (unsigned)DDIO_key_queuecxx . . $ DDIO_key_queue..buffercxx . . $ DDIO_key_queue#buffer.[DDIO_key_queuecxx . . $ DDIO_key_queue..headcxx . . $ DDIO_key_queue#head.]; |
| 259 | // mprintf(1, "%x ", key); |
| 260 | DDIO_key_queuecxx . . $ DDIO_key_queue..headcxx . . $ DDIO_key_queue#head.++; |
| 261 | if (DDIO_key_queuecxx . . $ DDIO_key_queue..headcxx . . $ DDIO_key_queue#head. >= KEY_QUEUE_SIZEcxx . . $ `ddio/key.cpp:134:9`!) |
| 262 | DDIO_key_queuecxx . . $ DDIO_key_queue..headcxx . . $ DDIO_key_queue#head. = 0; |
| 263 | } |
| 264 | |
| 265 | return (int)key; |
| 266 | } |
| 267 | |
| 268 | int ddio_KeyPeekcxx . . $ ddio_KeyPeek(b126dc7c1de90089).() { |
| 269 | if (DDIO_key_queuecxx . . $ DDIO_key_queue..headcxx . . $ DDIO_key_queue#head. != DDIO_key_queuecxx . . $ DDIO_key_queue..tailcxx . . $ DDIO_key_queue#tail.) { |
| 270 | return (int)DDIO_key_queuecxx . . $ DDIO_key_queue..buffercxx . . $ DDIO_key_queue#buffer.[DDIO_key_queuecxx . . $ DDIO_key_queue..headcxx . . $ DDIO_key_queue#head.]; |
| 271 | } |
| 272 | return 0; |
| 273 | } |
| 274 | |
| 275 | void ddio_AddKeyToQueuecxx . . $ ddio_AddKeyToQueue(d4f767463ce0a6b3).(int key) { |
| 276 | int keycode = key; |
| 277 | int temp; |
| 278 | |
| 279 | if (DDIO_key_statecxx . . $ DDIO_key_state.[KEY_LSHIFTcxx . . $ `ddio/ddio_common.h:275:9`!] || DDIO_key_statecxx . . $ DDIO_key_state.[KEY_RSHIFTcxx . . $ `ddio/ddio_common.h:276:9`!]) |
| 280 | keycode |= KEY_SHIFTEDcxx . . $ `ddio/ddio_common.h:208:9`!; |
| 281 | if (DDIO_key_statecxx . . $ DDIO_key_state.[KEY_LCTRLcxx . . $ `ddio/ddio_common.h:279:9`!] || DDIO_key_statecxx . . $ DDIO_key_state.[KEY_RCTRLcxx . . $ `ddio/ddio_common.h:280:9`!]) |
| 282 | keycode |= KEY_CTRLEDcxx . . $ `ddio/ddio_common.h:210:9`!; |
| 283 | if (DDIO_key_statecxx . . $ DDIO_key_state.[KEY_LALTcxx . . $ `ddio/ddio_common.h:277:9`!] || DDIO_key_statecxx . . $ DDIO_key_state.[KEY_RALTcxx . . $ `ddio/ddio_common.h:278:9`!]) |
| 284 | keycode |= KEY_ALTEDcxx . . $ `ddio/ddio_common.h:209:9`!; |
| 285 | if (DDIO_key_statecxx . . $ DDIO_key_state.[KEY_CMDcxx . . $ `ddio/ddio_common.h:423:9`!]) |
| 286 | keycode |= KEY_CMDcxx . . $ `ddio/ddio_common.h:423:9`!; // DAJ |
| 287 | |
| 288 | #ifdef _DEBUGcxx . . $ `<built-in>:480:9`! |
| 289 | if (DDIO_key_statecxx . . $ DDIO_key_state.[KEY_DEBUGcxx . . $ `ddio/key.cpp:137:9`!]) |
| 290 | keycode |= KEY_DEBUGGEDcxx . . $ `ddio/ddio_common.h:211:9`!; |
| 291 | #endif |
| 292 | |
| 293 | temp = DDIO_key_queuecxx . . $ DDIO_key_queue..tailcxx . . $ DDIO_key_queue#tail. + 1; |
| 294 | if (temp >= KEY_QUEUE_SIZEcxx . . $ `ddio/key.cpp:134:9`!) |
| 295 | temp = 0; |
| 296 | |
| 297 | if (temp != DDIO_key_queuecxx . . $ DDIO_key_queue..headcxx . . $ DDIO_key_queue#head.) { |
| 298 | DDIO_key_queuecxx . . $ DDIO_key_queue..buffercxx . . $ DDIO_key_queue#buffer.[DDIO_key_queuecxx . . $ DDIO_key_queue..tailcxx . . $ DDIO_key_queue#tail.] = (uint16_tcxx . . $ uint16_t#)keycode; |
| 299 | DDIO_key_queuecxx . . $ DDIO_key_queue..tailcxx . . $ DDIO_key_queue#tail. = temp; |
| 300 | // mprintf(1, "%d ", keycode); |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | // Updates timing info for keys |
| 305 | void ddio_UpdateKeyStatecxx . . $ ddio_UpdateKeyState(918ebd27a9ddbad3).(int key, bool isdown) { |
| 306 | if (isdown) { |
| 307 | if (!DDIO_key_statecxx . . $ DDIO_key_state.[key]) { |
| 308 | ddio_AddKeyToQueuecxx . . $ ddio_AddKeyToQueue(d4f767463ce0a6b3).(key); |
| 309 | DDIO_key_down_countcxx . . $ DDIO_key_down_count.[key]++; |
| 310 | } |
| 311 | DDIO_key_statecxx . . $ DDIO_key_state.[key] = 1; |
| 312 | } else { |
| 313 | DDIO_key_statecxx . . $ DDIO_key_state.[key] = 0; |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | //////////////////////////////////////////////////////////////////////////////// |
| 318 | |
| 319 | static uint8_tcxx . . $ uint8_t# ascii_tablecxx . . $ ascii_table.[128] = { |
| 320 | 255, 255, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 255, 255, 'q', 'w', 'e', 'r', 't', 'y', |
| 321 | 'u', 'i', 'o', 'p', '[', ']', 255, 255, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', 39, '`', 255, '\\', |
| 322 | 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 255, '*', 255, ' ', 255, 255, 255, 255, 255, 255, 255, 255, |
| 323 | 255, 255, 255, 255, 255, '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.', 255, 255, 255, 255, |
| 324 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
| 325 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}; |
| 326 | |
| 327 | static uint8_tcxx . . $ uint8_t# shifted_ascii_tablecxx . . $ shifted_ascii_table.[128] = { |
| 328 | 255, 255, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', 255, 255, 'Q', 'W', 'E', 'R', 'T', 'Y', |
| 329 | 'U', 'I', 'O', 'P', '{', '}', 255, 255, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~', 255, '|', |
| 330 | 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', 255, 255, 255, ' ', 255, 255, 255, 255, 255, 255, 255, 255, |
| 331 | 255, 255, 255, 255, 255, '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.', 255, 255, 255, 255, |
| 332 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
| 333 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}; |
| 334 | |
| 335 | #define SHKcxx . . $ `ddio/key.cpp:335:9`! KEY_SHIFTEDcxx . . $ `ddio/ddio_common.h:208:9`! |
| 336 | |
| 337 | // keycode value for each ascii. |
| 338 | static int keycode_tablecxx . . $ keycode_table.[128] = { |
| 339 | 0, |
| 340 | 0, |
| 341 | 0, |
| 342 | 0, |
| 343 | 0, |
| 344 | 0, |
| 345 | 0, |
| 346 | 0, |
| 347 | 0, |
| 348 | KEY_TABcxx . . $ `ddio/ddio_common.h:270:9`!, |
| 349 | 0, |
| 350 | 0, |
| 351 | 0, |
| 352 | KEY_ENTERcxx . . $ `ddio/ddio_common.h:268:9`!, |
| 353 | 0, |
| 354 | 0, // 0-15 |
| 355 | 0, |
| 356 | 0, |
| 357 | 0, |
| 358 | 0, |
| 359 | 0, |
| 360 | 0, |
| 361 | 0, |
| 362 | 0, |
| 363 | 0, |
| 364 | 0, |
| 365 | 0, |
| 366 | KEY_ESCcxx . . $ `ddio/ddio_common.h:267:9`!, |
| 367 | 0, |
| 368 | 0, |
| 369 | 0, |
| 370 | 0, // 16-31 |
| 371 | KEY_SPACEBARcxx . . $ `ddio/ddio_common.h:271:9`!, |
| 372 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_1cxx . . $ `ddio/ddio_common.h:220:9`!, |
| 373 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_RAPOSTROcxx . . $ `ddio/ddio_common.h:265:9`!, |
| 374 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_3cxx . . $ `ddio/ddio_common.h:222:9`!, |
| 375 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_4cxx . . $ `ddio/ddio_common.h:223:9`!, |
| 376 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_5cxx . . $ `ddio/ddio_common.h:224:9`!, // 32-37 |
| 377 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_7cxx . . $ `ddio/ddio_common.h:226:9`!, |
| 378 | KEY_RAPOSTROcxx . . $ `ddio/ddio_common.h:265:9`!, |
| 379 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_9cxx . . $ `ddio/ddio_common.h:228:9`!, |
| 380 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_0cxx . . $ `ddio/ddio_common.h:219:9`!, |
| 381 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_8cxx . . $ `ddio/ddio_common.h:227:9`!, |
| 382 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_EQUALcxx . . $ `ddio/ddio_common.h:256:9`!, // 38-43 |
| 383 | KEY_COMMAcxx . . $ `ddio/ddio_common.h:260:9`!, |
| 384 | KEY_MINUScxx . . $ `ddio/ddio_common.h:255:9`!, |
| 385 | KEY_PERIODcxx . . $ `ddio/ddio_common.h:261:9`!, |
| 386 | KEY_SLASHcxx . . $ `ddio/ddio_common.h:257:9`!, |
| 387 | KEY_0cxx . . $ `ddio/ddio_common.h:219:9`!, |
| 388 | KEY_1cxx . . $ `ddio/ddio_common.h:220:9`!, |
| 389 | KEY_2cxx . . $ `ddio/ddio_common.h:221:9`!, |
| 390 | KEY_3cxx . . $ `ddio/ddio_common.h:222:9`!, // 44-51 |
| 391 | KEY_4cxx . . $ `ddio/ddio_common.h:223:9`!, |
| 392 | KEY_5cxx . . $ `ddio/ddio_common.h:224:9`!, |
| 393 | KEY_6cxx . . $ `ddio/ddio_common.h:225:9`!, |
| 394 | KEY_7cxx . . $ `ddio/ddio_common.h:226:9`!, |
| 395 | KEY_8cxx . . $ `ddio/ddio_common.h:227:9`!, |
| 396 | KEY_9cxx . . $ `ddio/ddio_common.h:228:9`!, |
| 397 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_SEMICOLcxx . . $ `ddio/ddio_common.h:262:9`!, |
| 398 | KEY_SEMICOLcxx . . $ `ddio/ddio_common.h:262:9`!, // 52-59 |
| 399 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_COMMAcxx . . $ `ddio/ddio_common.h:260:9`!, |
| 400 | KEY_EQUALcxx . . $ `ddio/ddio_common.h:256:9`!, |
| 401 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_PERIODcxx . . $ `ddio/ddio_common.h:261:9`!, |
| 402 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_SLASHcxx . . $ `ddio/ddio_common.h:257:9`!, |
| 403 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_2cxx . . $ `ddio/ddio_common.h:221:9`!, // 60-64 |
| 404 | KEY_Acxx . . $ `ddio/ddio_common.h:229:9`!, |
| 405 | KEY_Bcxx . . $ `ddio/ddio_common.h:230:9`!, |
| 406 | KEY_Ccxx . . $ `ddio/ddio_common.h:231:9`!, |
| 407 | KEY_Dcxx . . $ `ddio/ddio_common.h:232:9`!, |
| 408 | KEY_Ecxx . . $ `ddio/ddio_common.h:233:9`!, |
| 409 | KEY_Fcxx . . $ `ddio/ddio_common.h:234:9`!, |
| 410 | KEY_Gcxx . . $ `ddio/ddio_common.h:235:9`!, |
| 411 | KEY_Hcxx . . $ `ddio/ddio_common.h:236:9`!, |
| 412 | KEY_Icxx . . $ `ddio/ddio_common.h:237:9`!, |
| 413 | KEY_Jcxx . . $ `ddio/ddio_common.h:238:9`!, |
| 414 | KEY_Kcxx . . $ `ddio/ddio_common.h:239:9`!, // 65-75 |
| 415 | KEY_Lcxx . . $ `ddio/ddio_common.h:240:9`!, |
| 416 | KEY_Mcxx . . $ `ddio/ddio_common.h:241:9`!, |
| 417 | KEY_Ncxx . . $ `ddio/ddio_common.h:242:9`!, |
| 418 | KEY_Ocxx . . $ `ddio/ddio_common.h:243:9`!, |
| 419 | KEY_Pcxx . . $ `ddio/ddio_common.h:244:9`!, |
| 420 | KEY_Qcxx . . $ `ddio/ddio_common.h:245:9`!, |
| 421 | KEY_Rcxx . . $ `ddio/ddio_common.h:246:9`!, |
| 422 | KEY_Scxx . . $ `ddio/ddio_common.h:247:9`!, |
| 423 | KEY_Tcxx . . $ `ddio/ddio_common.h:248:9`!, |
| 424 | KEY_Ucxx . . $ `ddio/ddio_common.h:249:9`!, |
| 425 | KEY_Vcxx . . $ `ddio/ddio_common.h:250:9`!, // 76-86 |
| 426 | KEY_Wcxx . . $ `ddio/ddio_common.h:251:9`!, |
| 427 | KEY_Xcxx . . $ `ddio/ddio_common.h:252:9`!, |
| 428 | KEY_Ycxx . . $ `ddio/ddio_common.h:253:9`!, |
| 429 | KEY_Zcxx . . $ `ddio/ddio_common.h:254:9`!, |
| 430 | KEY_LBRACKETcxx . . $ `ddio/ddio_common.h:263:9`!, |
| 431 | KEY_BACKSLASHcxx . . $ `ddio/ddio_common.h:258:9`!, |
| 432 | KEY_RBRACKETcxx . . $ `ddio/ddio_common.h:264:9`!, // 87-93 |
| 433 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_6cxx . . $ `ddio/ddio_common.h:225:9`!, |
| 434 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_MINUScxx . . $ `ddio/ddio_common.h:255:9`!, |
| 435 | KEY_LAPOSTROcxx . . $ `ddio/ddio_common.h:266:9`!, // 94-96 |
| 436 | KEY_Acxx . . $ `ddio/ddio_common.h:229:9`!, |
| 437 | KEY_Bcxx . . $ `ddio/ddio_common.h:230:9`!, |
| 438 | KEY_Ccxx . . $ `ddio/ddio_common.h:231:9`!, |
| 439 | KEY_Dcxx . . $ `ddio/ddio_common.h:232:9`!, |
| 440 | KEY_Ecxx . . $ `ddio/ddio_common.h:233:9`!, |
| 441 | KEY_Fcxx . . $ `ddio/ddio_common.h:234:9`!, |
| 442 | KEY_Gcxx . . $ `ddio/ddio_common.h:235:9`!, |
| 443 | KEY_Hcxx . . $ `ddio/ddio_common.h:236:9`!, |
| 444 | KEY_Icxx . . $ `ddio/ddio_common.h:237:9`!, |
| 445 | KEY_Jcxx . . $ `ddio/ddio_common.h:238:9`!, |
| 446 | KEY_Kcxx . . $ `ddio/ddio_common.h:239:9`!, // 97-107 |
| 447 | KEY_Lcxx . . $ `ddio/ddio_common.h:240:9`!, |
| 448 | KEY_Mcxx . . $ `ddio/ddio_common.h:241:9`!, |
| 449 | KEY_Ncxx . . $ `ddio/ddio_common.h:242:9`!, |
| 450 | KEY_Ocxx . . $ `ddio/ddio_common.h:243:9`!, |
| 451 | KEY_Pcxx . . $ `ddio/ddio_common.h:244:9`!, |
| 452 | KEY_Qcxx . . $ `ddio/ddio_common.h:245:9`!, |
| 453 | KEY_Rcxx . . $ `ddio/ddio_common.h:246:9`!, |
| 454 | KEY_Scxx . . $ `ddio/ddio_common.h:247:9`!, |
| 455 | KEY_Tcxx . . $ `ddio/ddio_common.h:248:9`!, |
| 456 | KEY_Ucxx . . $ `ddio/ddio_common.h:249:9`!, |
| 457 | KEY_Vcxx . . $ `ddio/ddio_common.h:250:9`!, // 108-118 |
| 458 | KEY_Wcxx . . $ `ddio/ddio_common.h:251:9`!, |
| 459 | KEY_Xcxx . . $ `ddio/ddio_common.h:252:9`!, |
| 460 | KEY_Ycxx . . $ `ddio/ddio_common.h:253:9`!, |
| 461 | KEY_Zcxx . . $ `ddio/ddio_common.h:254:9`!, |
| 462 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_LBRACKETcxx . . $ `ddio/ddio_common.h:263:9`!, |
| 463 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_BACKSLASHcxx . . $ `ddio/ddio_common.h:258:9`!, // 119-124 |
| 464 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_RBRACKETcxx . . $ `ddio/ddio_common.h:264:9`!, |
| 465 | SHKcxx . . $ `ddio/key.cpp:335:9`! + KEY_LAPOSTROcxx . . $ `ddio/ddio_common.h:266:9`!, |
| 466 | 0, // 125-127 |
| 467 | }; |
| 468 | |
| 469 | // converts keycode to ASCII |
| 470 | int ddio_KeyToAsciicxx . . $ ddio_KeyToAscii(7864480464b09eea).(int code) { |
| 471 | int shifted; |
| 472 | |
| 473 | shifted = code & KEY_SHIFTEDcxx . . $ `ddio/ddio_common.h:208:9`!; |
| 474 | code &= 0xFF; |
| 475 | |
| 476 | if (code >= 127) |
| 477 | return 255; |
| 478 | |
| 479 | if (shifted) |
| 480 | return (int)shifted_ascii_tablecxx . . $ shifted_ascii_table.[code]; |
| 481 | else |
| 482 | return (int)ascii_tablecxx . . $ ascii_table.[code]; |
| 483 | } |
| 484 | |
| 485 | // converts ascii code to key |
| 486 | int ddio_AsciiToKeycxx . . $ ddio_AsciiToKey(7864480464b09eea).(int ascii) { |
| 487 | if (ascii < 0 || ascii >= 128) |
| 488 | return 0; |
| 489 | |
| 490 | if (ascii >= 'A' && ascii <= 'Z') { |
| 491 | // I'm lazy |
| 492 | return (SHKcxx . . $ `ddio/key.cpp:335:9`! + keycode_tablecxx . . $ keycode_table.[ascii]); |
| 493 | } else { |
| 494 | return keycode_tablecxx . . $ keycode_table.[ascii]; |
| 495 | } |
| 496 | } |