| 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_lnx/lnxkey_sdl.cpp $ |
| 21 | * $Revision: 1.6 $ |
| 22 | * $Date: 2001/02/07 09:18:02 $ |
| 23 | * $Author: icculus $ |
| 24 | * |
| 25 | * Linux Xwindows routines |
| 26 | * |
| 27 | * $Log: lnxkey_sdl.cpp,v $ |
| 28 | * Revision 1.6 2001/02/07 09:18:02 icculus |
| 29 | * Fullscreen/windowed toggle keybinding attempts to toggle regardless of |
| 30 | * renderer, now. Otherwise, 2D surfaces (movies) wouldn't toggle. Glide uses |
| 31 | * can just risk it. |
| 32 | * |
| 33 | * Revision 1.5 2001/01/11 11:40:53 icculus |
| 34 | * Added CTRL-G and ALT-Enter keybindings. |
| 35 | * |
| 36 | * Revision 1.4 2000/09/22 19:01:49 icculus |
| 37 | * SDLK_WORLD* support. |
| 38 | * |
| 39 | * Revision 1.3 2000/06/29 09:52:45 hercules |
| 40 | * Don't poll for events twice per frame (already done in mouse driver) |
| 41 | * |
| 42 | * Revision 1.2 2000/06/24 01:15:15 icculus |
| 43 | * patched to compile. |
| 44 | * |
| 45 | * Revision 1.1 2000/04/27 11:16:01 icculus |
| 46 | * First (and hopefully last) commit. |
| 47 | * |
| 48 | * Revision 1.1.1.1 2000/04/18 00:00:33 icculus |
| 49 | * initial checkin |
| 50 | * |
| 51 | * |
| 52 | * 6 8/19/99 3:45p Jeff |
| 53 | * commented out mprintfs |
| 54 | * |
| 55 | * 5 8/19/99 1:32p Jeff |
| 56 | * fixed o key. Added scroll lock, caps lock and print screen keys. |
| 57 | * |
| 58 | * 4 7/15/99 11:37a Jeff |
| 59 | * moved autorepeat calls to lnxapp.cpp |
| 60 | * |
| 61 | * 3 7/14/99 9:06p Jeff |
| 62 | * added comment header |
| 63 | * |
| 64 | * $NoKeywords: $ |
| 65 | */ |
| 66 | |
| 67 | #include <SDL.h> |
| 68 | |
| 69 | #include "ddio.h"cxx . . $ `<file>/ddio/ddio.h`/ |
| 70 | #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/ |
| 71 | |
| 72 | |
| 73 | extern bool ddio_mouseGrabbedcxx . . $ ddio_mouseGrabbed.; |
| 74 | |
| 75 | extern volatile struct tLnxKeyscxx . . $ tLnxKeys# { |
| 76 | unioncxx . . $ tLnxKeys#$anonymous_type_0# { |
| 77 | int up_tickscxx . . $ tLnxKeys#$anonymous_type_0#up_ticks.; |
| 78 | float up_timecxx . . $ tLnxKeys#$anonymous_type_0#up_time.; |
| 79 | }; |
| 80 | unioncxx . . $ tLnxKeys#$anonymous_type_1# { |
| 81 | int down_tickscxx . . $ tLnxKeys#$anonymous_type_1#down_ticks.; |
| 82 | float down_timecxx . . $ tLnxKeys#$anonymous_type_1#down_time.; |
| 83 | }; |
| 84 | bool statuscxx . . $ tLnxKeys#status.; |
| 85 | } LKeyscxx . . $ LKeys.[DDIO_MAX_KEYScxx . . $ `ddio/ddio_common.h:205:9`!]; |
| 86 | |
| 87 | int sdlkey_to_ddiocodecxx . . $ sdlkey_to_ddiocode.[27] = {0, KEY_Acxx . . $ `ddio/ddio_common.h:229:9`!, KEY_Bcxx . . $ `ddio/ddio_common.h:230:9`!, KEY_Ccxx . . $ `ddio/ddio_common.h:231:9`!, KEY_Dcxx . . $ `ddio/ddio_common.h:232:9`!, KEY_Ecxx . . $ `ddio/ddio_common.h:233:9`!, KEY_Fcxx . . $ `ddio/ddio_common.h:234:9`!, KEY_Gcxx . . $ `ddio/ddio_common.h:235:9`!, KEY_Hcxx . . $ `ddio/ddio_common.h:236:9`!, |
| 88 | KEY_Icxx . . $ `ddio/ddio_common.h:237:9`!, KEY_Jcxx . . $ `ddio/ddio_common.h:238:9`!, KEY_Kcxx . . $ `ddio/ddio_common.h:239:9`!, KEY_Lcxx . . $ `ddio/ddio_common.h:240:9`!, KEY_Mcxx . . $ `ddio/ddio_common.h:241:9`!, KEY_Ncxx . . $ `ddio/ddio_common.h:242:9`!, KEY_Ocxx . . $ `ddio/ddio_common.h:243:9`!, KEY_Pcxx . . $ `ddio/ddio_common.h:244:9`!, KEY_Qcxx . . $ `ddio/ddio_common.h:245:9`!, |
| 89 | KEY_Rcxx . . $ `ddio/ddio_common.h:246:9`!, KEY_Scxx . . $ `ddio/ddio_common.h:247:9`!, KEY_Tcxx . . $ `ddio/ddio_common.h:248:9`!, KEY_Ucxx . . $ `ddio/ddio_common.h:249:9`!, KEY_Vcxx . . $ `ddio/ddio_common.h:250:9`!, KEY_Wcxx . . $ `ddio/ddio_common.h:251:9`!, KEY_Xcxx . . $ `ddio/ddio_common.h:252:9`!, KEY_Ycxx . . $ `ddio/ddio_common.h:253:9`!, KEY_Zcxx . . $ `ddio/ddio_common.h:254:9`!}; |
| 90 | |
| 91 | static inline uint8_tcxx . . $ uint8_t# sdlkeycode_to_keycodecxx . . $ sdlkeycode_to_keycode(32407b39b2dfce37).(uint32_tcxx . . $ uint32_t# sdlkeycode) { |
| 92 | // unceremoniously taken from Heretic source code with a few modifications. |
| 93 | // (by Outrage. Not Loki. We know better. :) --ryan.) |
| 94 | int rc = sdlkeycode; |
| 95 | |
| 96 | switch (rc) { |
| 97 | case SDLK_DELETEcxx . . $ SDLK_DELETE.: |
| 98 | rc = KEY_DELETEcxx . . $ `ddio/ddio_common.h:315:9`!; |
| 99 | break; |
| 100 | case SDLK_INSERTcxx . . $ SDLK_INSERT.: |
| 101 | rc = KEY_INSERTcxx . . $ `ddio/ddio_common.h:312:9`!; |
| 102 | break; |
| 103 | case SDLK_PAGEUPcxx . . $ SDLK_PAGEUP.: |
| 104 | rc = KEY_PAGEUPcxx . . $ `ddio/ddio_common.h:314:9`!; |
| 105 | break; |
| 106 | case SDLK_PAGEDOWNcxx . . $ SDLK_PAGEDOWN.: |
| 107 | rc = KEY_PAGEDOWNcxx . . $ `ddio/ddio_common.h:317:9`!; |
| 108 | break; |
| 109 | case SDLK_HOMEcxx . . $ SDLK_HOME.: |
| 110 | rc = KEY_HOMEcxx . . $ `ddio/ddio_common.h:313:9`!; |
| 111 | break; |
| 112 | case SDLK_ENDcxx . . $ SDLK_END.: |
| 113 | rc = KEY_ENDcxx . . $ `ddio/ddio_common.h:316:9`!; |
| 114 | break; |
| 115 | case SDLK_LEFTcxx . . $ SDLK_LEFT.: |
| 116 | rc = KEY_LEFTcxx . . $ `ddio/ddio_common.h:320:9`!; |
| 117 | break; |
| 118 | case SDLK_RIGHTcxx . . $ SDLK_RIGHT.: |
| 119 | rc = KEY_RIGHTcxx . . $ `ddio/ddio_common.h:321:9`!; |
| 120 | break; |
| 121 | case SDLK_DOWNcxx . . $ SDLK_DOWN.: |
| 122 | rc = KEY_DOWNcxx . . $ `ddio/ddio_common.h:319:9`!; |
| 123 | break; |
| 124 | case SDLK_UPcxx . . $ SDLK_UP.: |
| 125 | rc = KEY_UPcxx . . $ `ddio/ddio_common.h:318:9`!; |
| 126 | break; |
| 127 | case SDLK_ESCAPEcxx . . $ SDLK_ESCAPE.: |
| 128 | rc = KEY_ESCcxx . . $ `ddio/ddio_common.h:267:9`!; |
| 129 | break; |
| 130 | case SDLK_RETURNcxx . . $ SDLK_RETURN.: |
| 131 | rc = KEY_ENTERcxx . . $ `ddio/ddio_common.h:268:9`!; |
| 132 | break; |
| 133 | case SDLK_TABcxx . . $ SDLK_TAB.: |
| 134 | rc = KEY_TABcxx . . $ `ddio/ddio_common.h:270:9`!; |
| 135 | break; |
| 136 | case SDLK_F1cxx . . $ SDLK_F1.: |
| 137 | rc = KEY_F1cxx . . $ `ddio/ddio_common.h:282:9`!; |
| 138 | break; |
| 139 | case SDLK_F2cxx . . $ SDLK_F2.: |
| 140 | rc = KEY_F2cxx . . $ `ddio/ddio_common.h:283:9`!; |
| 141 | break; |
| 142 | case SDLK_F3cxx . . $ SDLK_F3.: |
| 143 | rc = KEY_F3cxx . . $ `ddio/ddio_common.h:284:9`!; |
| 144 | break; |
| 145 | case SDLK_F4cxx . . $ SDLK_F4.: |
| 146 | rc = KEY_F4cxx . . $ `ddio/ddio_common.h:285:9`!; |
| 147 | break; |
| 148 | case SDLK_F5cxx . . $ SDLK_F5.: |
| 149 | rc = KEY_F5cxx . . $ `ddio/ddio_common.h:286:9`!; |
| 150 | break; |
| 151 | case SDLK_F6cxx . . $ SDLK_F6.: |
| 152 | rc = KEY_F6cxx . . $ `ddio/ddio_common.h:287:9`!; |
| 153 | break; |
| 154 | case SDLK_F7cxx . . $ SDLK_F7.: |
| 155 | rc = KEY_F7cxx . . $ `ddio/ddio_common.h:288:9`!; |
| 156 | break; |
| 157 | case SDLK_F8cxx . . $ SDLK_F8.: |
| 158 | rc = KEY_F8cxx . . $ `ddio/ddio_common.h:289:9`!; |
| 159 | break; |
| 160 | case SDLK_F9cxx . . $ SDLK_F9.: |
| 161 | rc = KEY_F9cxx . . $ `ddio/ddio_common.h:290:9`!; |
| 162 | break; |
| 163 | case SDLK_F10cxx . . $ SDLK_F10.: |
| 164 | rc = KEY_F10cxx . . $ `ddio/ddio_common.h:291:9`!; |
| 165 | break; |
| 166 | case SDLK_F11cxx . . $ SDLK_F11.: |
| 167 | rc = KEY_F11cxx . . $ `ddio/ddio_common.h:292:9`!; |
| 168 | break; |
| 169 | case SDLK_F12cxx . . $ SDLK_F12.: |
| 170 | rc = KEY_F12cxx . . $ `ddio/ddio_common.h:293:9`!; |
| 171 | break; |
| 172 | case SDLK_BACKSPACEcxx . . $ SDLK_BACKSPACE.: |
| 173 | rc = KEY_BACKSPcxx . . $ `ddio/ddio_common.h:269:9`!; |
| 174 | break; |
| 175 | case SDLK_PAUSEcxx . . $ SDLK_PAUSE.: |
| 176 | rc = KEY_PAUSEcxx . . $ `ddio/ddio_common.h:323:9`!; |
| 177 | break; |
| 178 | case SDLK_KP_PLUScxx . . $ SDLK_KP_PLUS.: |
| 179 | rc = KEY_PADPLUScxx . . $ `ddio/ddio_common.h:306:9`!; |
| 180 | break; |
| 181 | case SDLK_KP_MINUScxx . . $ SDLK_KP_MINUS.: |
| 182 | rc = KEY_PADMINUScxx . . $ `ddio/ddio_common.h:305:9`!; |
| 183 | break; |
| 184 | case SDLK_KP_ENTERcxx . . $ SDLK_KP_ENTER.: |
| 185 | rc = KEY_PADENTERcxx . . $ `ddio/ddio_common.h:310:9`!; |
| 186 | break; |
| 187 | case SDLK_KP_PERIODcxx . . $ SDLK_KP_PERIOD.: |
| 188 | rc = KEY_PADPERIODcxx . . $ `ddio/ddio_common.h:307:9`!; |
| 189 | break; |
| 190 | case SDLK_KP_DIVIDEcxx . . $ SDLK_KP_DIVIDE.: |
| 191 | rc = KEY_PADDIVIDEcxx . . $ `ddio/ddio_common.h:308:9`!; |
| 192 | break; |
| 193 | case SDLK_KP_MULTIPLYcxx . . $ SDLK_KP_MULTIPLY.: |
| 194 | rc = KEY_PADMULTIPLYcxx . . $ `ddio/ddio_common.h:309:9`!; |
| 195 | break; |
| 196 | case SDLK_KP_0cxx . . $ SDLK_KP_0.: |
| 197 | rc = KEY_PAD0cxx . . $ `ddio/ddio_common.h:295:9`!; |
| 198 | break; |
| 199 | case SDLK_KP_1cxx . . $ SDLK_KP_1.: |
| 200 | rc = KEY_PAD1cxx . . $ `ddio/ddio_common.h:296:9`!; |
| 201 | break; |
| 202 | case SDLK_KP_2cxx . . $ SDLK_KP_2.: |
| 203 | rc = KEY_PAD2cxx . . $ `ddio/ddio_common.h:297:9`!; |
| 204 | break; |
| 205 | case SDLK_KP_3cxx . . $ SDLK_KP_3.: |
| 206 | rc = KEY_PAD3cxx . . $ `ddio/ddio_common.h:298:9`!; |
| 207 | break; |
| 208 | case SDLK_KP_4cxx . . $ SDLK_KP_4.: |
| 209 | rc = KEY_PAD4cxx . . $ `ddio/ddio_common.h:299:9`!; |
| 210 | break; |
| 211 | case SDLK_KP_5cxx . . $ SDLK_KP_5.: |
| 212 | rc = KEY_PAD5cxx . . $ `ddio/ddio_common.h:300:9`!; |
| 213 | break; |
| 214 | case SDLK_KP_6cxx . . $ SDLK_KP_6.: |
| 215 | rc = KEY_PAD6cxx . . $ `ddio/ddio_common.h:301:9`!; |
| 216 | break; |
| 217 | case SDLK_KP_7cxx . . $ SDLK_KP_7.: |
| 218 | rc = KEY_PAD7cxx . . $ `ddio/ddio_common.h:302:9`!; |
| 219 | break; |
| 220 | case SDLK_KP_8cxx . . $ SDLK_KP_8.: |
| 221 | rc = KEY_PAD8cxx . . $ `ddio/ddio_common.h:303:9`!; |
| 222 | break; |
| 223 | case SDLK_KP_9cxx . . $ SDLK_KP_9.: |
| 224 | rc = KEY_PAD9cxx . . $ `ddio/ddio_common.h:304:9`!; |
| 225 | break; |
| 226 | case SDLK_SPACEcxx . . $ SDLK_SPACE.: |
| 227 | rc = KEY_SPACEBARcxx . . $ `ddio/ddio_common.h:271:9`!; |
| 228 | break; |
| 229 | case SDLK_1cxx . . $ SDLK_1.: |
| 230 | rc = KEY_1cxx . . $ `ddio/ddio_common.h:220:9`!; |
| 231 | break; |
| 232 | case SDLK_2cxx . . $ SDLK_2.: |
| 233 | rc = KEY_2cxx . . $ `ddio/ddio_common.h:221:9`!; |
| 234 | break; |
| 235 | case SDLK_3cxx . . $ SDLK_3.: |
| 236 | rc = KEY_3cxx . . $ `ddio/ddio_common.h:222:9`!; |
| 237 | break; |
| 238 | case SDLK_4cxx . . $ SDLK_4.: |
| 239 | rc = KEY_4cxx . . $ `ddio/ddio_common.h:223:9`!; |
| 240 | break; |
| 241 | case SDLK_5cxx . . $ SDLK_5.: |
| 242 | rc = KEY_5cxx . . $ `ddio/ddio_common.h:224:9`!; |
| 243 | break; |
| 244 | case SDLK_6cxx . . $ SDLK_6.: |
| 245 | rc = KEY_6cxx . . $ `ddio/ddio_common.h:225:9`!; |
| 246 | break; |
| 247 | case SDLK_7cxx . . $ SDLK_7.: |
| 248 | rc = KEY_7cxx . . $ `ddio/ddio_common.h:226:9`!; |
| 249 | break; |
| 250 | case SDLK_8cxx . . $ SDLK_8.: |
| 251 | rc = KEY_8cxx . . $ `ddio/ddio_common.h:227:9`!; |
| 252 | break; |
| 253 | case SDLK_9cxx . . $ SDLK_9.: |
| 254 | rc = KEY_9cxx . . $ `ddio/ddio_common.h:228:9`!; |
| 255 | break; |
| 256 | case SDLK_0cxx . . $ SDLK_0.: |
| 257 | rc = KEY_0cxx . . $ `ddio/ddio_common.h:219:9`!; |
| 258 | break; |
| 259 | |
| 260 | // modifier keys |
| 261 | case SDLK_LSHIFTcxx . . $ SDLK_LSHIFT.: |
| 262 | rc = KEY_LSHIFTcxx . . $ `ddio/ddio_common.h:275:9`!; |
| 263 | break; |
| 264 | case SDLK_RSHIFTcxx . . $ SDLK_RSHIFT.: |
| 265 | rc = KEY_RSHIFTcxx . . $ `ddio/ddio_common.h:276:9`!; |
| 266 | break; |
| 267 | case SDLK_LCTRLcxx . . $ SDLK_LCTRL.: |
| 268 | rc = KEY_LCTRLcxx . . $ `ddio/ddio_common.h:279:9`!; |
| 269 | break; |
| 270 | case SDLK_RCTRLcxx . . $ SDLK_RCTRL.: |
| 271 | rc = KEY_RCTRLcxx . . $ `ddio/ddio_common.h:280:9`!; |
| 272 | break; |
| 273 | case SDLK_LALTcxx . . $ SDLK_LALT.: |
| 274 | case SDLK_LGUIcxx . . $ SDLK_LGUI.: |
| 275 | rc = KEY_LALTcxx . . $ `ddio/ddio_common.h:277:9`!; |
| 276 | break; |
| 277 | case SDLK_RALTcxx . . $ SDLK_RALT.: |
| 278 | case SDLK_RGUIcxx . . $ SDLK_RGUI.: |
| 279 | rc = KEY_RALTcxx . . $ `ddio/ddio_common.h:278:9`!; |
| 280 | break; |
| 281 | |
| 282 | // since we look at unmodified keycodes, we don't have to worry about shifted states, I think. |
| 283 | case SDLK_EQUALScxx . . $ SDLK_EQUALS.: |
| 284 | rc = KEY_EQUALcxx . . $ `ddio/ddio_common.h:256:9`!; |
| 285 | break; |
| 286 | case SDLK_MINUScxx . . $ SDLK_MINUS.: |
| 287 | rc = KEY_MINUScxx . . $ `ddio/ddio_common.h:255:9`!; |
| 288 | break; |
| 289 | case SDLK_LEFTBRACKETcxx . . $ SDLK_LEFTBRACKET.: |
| 290 | rc = KEY_LBRACKETcxx . . $ `ddio/ddio_common.h:263:9`!; |
| 291 | break; |
| 292 | case SDLK_RIGHTBRACKETcxx . . $ SDLK_RIGHTBRACKET.: |
| 293 | rc = KEY_RBRACKETcxx . . $ `ddio/ddio_common.h:264:9`!; |
| 294 | break; |
| 295 | case SDLK_BACKSLASHcxx . . $ SDLK_BACKSLASH.: |
| 296 | rc = KEY_BACKSLASHcxx . . $ `ddio/ddio_common.h:258:9`!; |
| 297 | break; |
| 298 | case SDLK_BACKQUOTEcxx . . $ SDLK_BACKQUOTE.: |
| 299 | rc = KEY_LAPOSTROcxx . . $ `ddio/ddio_common.h:266:9`!; |
| 300 | break; |
| 301 | case SDLK_QUOTEcxx . . $ SDLK_QUOTE.: |
| 302 | rc = KEY_RAPOSTROcxx . . $ `ddio/ddio_common.h:265:9`!; |
| 303 | break; |
| 304 | case SDLK_SEMICOLONcxx . . $ SDLK_SEMICOLON.: |
| 305 | rc = KEY_SEMICOLcxx . . $ `ddio/ddio_common.h:262:9`!; |
| 306 | break; |
| 307 | case SDLK_PERIODcxx . . $ SDLK_PERIOD.: |
| 308 | rc = KEY_PERIODcxx . . $ `ddio/ddio_common.h:261:9`!; |
| 309 | break; |
| 310 | case SDLK_SLASHcxx . . $ SDLK_SLASH.: |
| 311 | rc = KEY_SLASHcxx . . $ `ddio/ddio_common.h:257:9`!; |
| 312 | break; |
| 313 | case SDLK_COMMAcxx . . $ SDLK_COMMA.: |
| 314 | rc = KEY_COMMAcxx . . $ `ddio/ddio_common.h:260:9`!; |
| 315 | break; |
| 316 | case SDLK_NUMLOCKCLEARcxx . . $ SDLK_NUMLOCKCLEAR.: |
| 317 | rc = KEY_NUMLOCKcxx . . $ `ddio/ddio_common.h:272:9`!; |
| 318 | break; |
| 319 | case SDLK_PRINTSCREENcxx . . $ SDLK_PRINTSCREEN.: |
| 320 | rc = KEY_PRINT_SCREENcxx . . $ `ddio/ddio_common.h:322:9`!; |
| 321 | break; |
| 322 | case SDLK_SCROLLLOCKcxx . . $ SDLK_SCROLLLOCK.: |
| 323 | rc = KEY_SCROLLOCKcxx . . $ `ddio/ddio_common.h:273:9`!; |
| 324 | break; |
| 325 | case SDLK_CAPSLOCKcxx . . $ SDLK_CAPSLOCK.: |
| 326 | rc = KEY_CAPSLOCKcxx . . $ `ddio/ddio_common.h:274:9`!; |
| 327 | break; |
| 328 | |
| 329 | // convert 'a' - 'z' to 0-27, and then convert to ddio format. |
| 330 | default: |
| 331 | if (rc >= SDLK_acxx . . $ SDLK_a. && rc <= SDLK_zcxx . . $ SDLK_z.) { |
| 332 | rc = (rc - SDLK_acxx . . $ SDLK_a.) + 1; |
| 333 | } else { |
| 334 | rc = 0; |
| 335 | } |
| 336 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(rc >= 0 && rc <= 26); |
| 337 | rc = sdlkey_to_ddiocodecxx . . $ sdlkey_to_ddiocode.[rc]; |
| 338 | break; |
| 339 | } |
| 340 | |
| 341 | return (uint8_tcxx . . $ uint8_t#)rc; |
| 342 | } |
| 343 | |
| 344 | int sdlKeyFiltercxx . . $ sdlKeyFilter(5d4fa56947397a26).(const SDL_Event *event) { |
| 345 | uint8_tcxx . . $ uint8_t# kc = 0; |
| 346 | |
| 347 | if ((event->type != SDL_KEYUP) && (event->type != SDL_KEYDOWN)) |
| 348 | return (1); |
| 349 | |
| 350 | switch (event->key.state) { |
| 351 | case SDL_PRESSEDcxx . . $ `<external>/12778062723415653681/SDL_events.h:50:9`!: |
| 352 | if (event->key.repeat) break; // ignore these, we only want to know if it's a first time pressed, not a key-repeat. |
| 353 | kc = sdlkeycode_to_keycodecxx . . $ sdlkeycode_to_keycode(32407b39b2dfce37).(event->key.keysym.sym); |
| 354 | if (event->key.keysym.mod & KMOD_CTRLcxx . . $ KMOD_CTRL.) { |
| 355 | switch (kc) { |
| 356 | case KEY_Gcxx . . $ `ddio/ddio_common.h:235:9`!: // toggle grabbed input. |
| 357 | ddio_mouseGrabbedcxx . . $ ddio_mouseGrabbed. = !ddio_mouseGrabbedcxx . . $ ddio_mouseGrabbed.; |
| 358 | SDL_SetRelativeMouseMode(ddio_mouseGrabbedcxx . . $ ddio_mouseGrabbed. ? SDL_TRUEcxx . . $ SDL_TRUE. : SDL_FALSEcxx . . $ SDL_FALSE.); |
| 359 | return 0; |
| 360 | } // switch |
| 361 | } // if |
| 362 | |
| 363 | else if (event->key.keysym.mod & KMOD_ALTcxx . . $ KMOD_ALT.) { |
| 364 | if ((kc == KEY_ENTERcxx . . $ `ddio/ddio_common.h:268:9`!) || (kc == KEY_PADENTERcxx . . $ `ddio/ddio_common.h:310:9`!)) { |
| 365 | extern SDL_Window *GSDLWindowcxx . . $ GSDLWindow.; |
| 366 | Uint32cxx . . $ Uint32# flags = SDL_GetWindowFlags(GSDLWindowcxx . . $ GSDLWindow.); |
| 367 | // (In SDL2, SDL_WINDOW_FULLSCREEN_DESKTOP is SDL_WINDOW_FULLSCREEN plus an extra bit set, so just check for _any_ fullscreen in this bitwise AND.) |
| 368 | if (flags & SDL_WINDOW_FULLSCREEN) { |
| 369 | flags &= ~SDL_WINDOW_FULLSCREEN_DESKTOP; |
| 370 | } else { |
| 371 | flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; |
| 372 | } |
| 373 | SDL_SetWindowFullscreen(GSDLWindowcxx . . $ GSDLWindow., flags); |
| 374 | return(0); |
| 375 | } // if |
| 376 | } // else if |
| 377 | |
| 378 | LKeyscxx . . $ LKeys.[kc].down_timecxx . . $ tLnxKeys#$anonymous_type_1#down_time. = timer_GetTimecxx . . $ `ddio/ddio.h:236:9`!(); |
| 379 | LKeyscxx . . $ LKeys.[kc].statuscxx . . $ tLnxKeys#status. = true; |
| 380 | ddio_UpdateKeyStatecxx . . $ ddio_UpdateKeyState(918ebd27a9ddbad3).(kc, true); |
| 381 | break; |
| 382 | |
| 383 | case SDL_RELEASEDcxx . . $ `<external>/12778062723415653681/SDL_events.h:49:9`!: |
| 384 | kc = sdlkeycode_to_keycodecxx . . $ sdlkeycode_to_keycode(32407b39b2dfce37).(event->key.keysym.sym); |
| 385 | if (LKeyscxx . . $ LKeys.[kc].statuscxx . . $ tLnxKeys#status.) { |
| 386 | LKeyscxx . . $ LKeys.[kc].up_timecxx . . $ tLnxKeys#$anonymous_type_0#up_time. = timer_GetTimecxx . . $ `ddio/ddio.h:236:9`!(); |
| 387 | LKeyscxx . . $ LKeys.[kc].statuscxx . . $ tLnxKeys#status. = false; |
| 388 | ddio_UpdateKeyStatecxx . . $ ddio_UpdateKeyState(918ebd27a9ddbad3).(kc, false); |
| 389 | } // if |
| 390 | break; |
| 391 | } // switch |
| 392 | |
| 393 | return (0); |
| 394 | } // sdlKeyFilter |
| 395 | |
| 396 | bool ddio_sdl_InternalKeyInitcxx . . $ ddio_sdl_InternalKeyInit(4aa02e9b14a147be).(ddio_init_infocxx . . $ ddio_init_info# *init_info) { |
| 397 | // reset key list |
| 398 | for (int i = 0; i < DDIO_MAX_KEYScxx . . $ `ddio/ddio_common.h:205:9`!; i++) { |
| 399 | LKeyscxx . . $ LKeys.[i].down_tickscxx . . $ tLnxKeys#$anonymous_type_1#down_ticks. = 0; |
| 400 | LKeyscxx . . $ LKeys.[i].up_tickscxx . . $ tLnxKeys#$anonymous_type_0#up_ticks. = 0; |
| 401 | LKeyscxx . . $ LKeys.[i].statuscxx . . $ tLnxKeys#status. = false; |
| 402 | } |
| 403 | return true; |
| 404 | } |
| 405 | |
| 406 | void ddio_sdl_InternalKeyClosecxx . . $ ddio_sdl_InternalKeyClose(49f6e7a06ebc5aa8).() {} |
| 407 | |
| 408 | bool ddio_sdl_InternalKeyStatecxx . . $ ddio_sdl_InternalKeyState(cef82f9be00a201a).(uint8_tcxx . . $ uint8_t# key) { return LKeyscxx . . $ LKeys.[key].statuscxx . . $ tLnxKeys#status.; } |
| 409 | |
| 410 | void ddio_sdl_InternalKeySuspendcxx . . $ ddio_sdl_InternalKeySuspend(49f6e7a06ebc5aa8).() {} |
| 411 | |
| 412 | void ddio_sdl_InternalKeyResumecxx . . $ ddio_sdl_InternalKeyResume(49f6e7a06ebc5aa8).() {} |
| 413 | |
| 414 | float ddio_sdl_InternalKeyDownTimecxx . . $ ddio_sdl_InternalKeyDownTime(ef46aeb7cc924ea7).(uint8_tcxx . . $ uint8_t# key) { |
| 415 | float down_time = 0.0f; |
| 416 | if (LKeyscxx . . $ LKeys.[key].statuscxx . . $ tLnxKeys#status.) { |
| 417 | float timer = timer_GetTimecxx . . $ `ddio/ddio.h:236:9`!(); |
| 418 | down_time = timer - LKeyscxx . . $ LKeys.[key].down_timecxx . . $ tLnxKeys#$anonymous_type_1#down_time.; |
| 419 | LKeyscxx . . $ LKeys.[key].down_timecxx . . $ tLnxKeys#$anonymous_type_1#down_time. = timer; |
| 420 | } else { |
| 421 | down_time = LKeyscxx . . $ LKeys.[key].up_timecxx . . $ tLnxKeys#$anonymous_type_0#up_time. - LKeyscxx . . $ LKeys.[key].down_timecxx . . $ tLnxKeys#$anonymous_type_1#down_time.; |
| 422 | LKeyscxx . . $ LKeys.[key].down_timecxx . . $ tLnxKeys#$anonymous_type_1#down_time. = LKeyscxx . . $ LKeys.[key].up_timecxx . . $ tLnxKeys#$anonymous_type_0#up_time. = 0.0f; |
| 423 | } |
| 424 | |
| 425 | return down_time; |
| 426 | } |
| 427 | |
| 428 | void ddio_sdl_InternalResetKeycxx . . $ ddio_sdl_InternalResetKey(ac50b47256ae7414).(uint8_tcxx . . $ uint8_t# key) { |
| 429 | LKeyscxx . . $ LKeys.[key].down_timecxx . . $ tLnxKeys#$anonymous_type_1#down_time. = 0.0f; |
| 430 | LKeyscxx . . $ LKeys.[key].up_timecxx . . $ tLnxKeys#$anonymous_type_0#up_time. = 0.0f; |
| 431 | LKeyscxx . . $ LKeys.[key].statuscxx . . $ tLnxKeys#status. = false; |
| 432 | } |
| 433 | |
| 434 | void ddio_sdl_InternalKeyFramecxx . . $ ddio_sdl_InternalKeyFrame(49f6e7a06ebc5aa8).(void) { |
| 435 | // Sam 6/28 - This is already done in the mouse handling code |
| 436 | // SDL_PumpEvents(); |
| 437 | } |