Annotation of hatari/src/keymap.c, revision 1.1.1.4

1.1       root        1: /*
                      2:   Hatari
                      3: 
1.1.1.3   root        4:   Here we process a key press and the remapping of the scancodes.
1.1       root        5: */
                      6: 
                      7: #include <stdio.h>
1.1.1.2   root        8: #include <SDL_keysym.h>           /* Needed for SDLK_LAST */
1.1       root        9: 
                     10: #include "main.h"
                     11: #include "debug.h"
                     12: #include "keymap.h"
                     13: #include "memAlloc.h"
                     14: #include "misc.h"
1.1.1.3   root       15: #include "dialog.h"
                     16: #include "ikbd.h"
                     17: #include "joy.h"
                     18: #include "shortcut.h"
                     19: #include "screen.h"
1.1.1.4 ! root       20: #include "debugui.h"
1.1       root       21: 
1.1.1.2   root       22: 
                     23: /*-----------------------------------------------------------------------*/
1.1       root       24: /*
                     25:   Remap table of Windows keys to ST Scan codes, -ve is invalid key(ie doesn't occur on ST)
                     26: 
                     27:   PC Keyboard:-
                     28: 
                     29:     Esc  F1  F2  F3  F4    F5  F6  F7  F8    F9  F10 F11 F12       Print Scroll Pause
                     30: 
                     31:      1   59  60  61  62    63  64  65  66    67  68  87  88                70     69
                     32: 
                     33: 
                     34: �  !   "   �   $   %   ^   &   *   (   )   _   +                                 Page
                     35: `  1   2   3   4   5   6   7   8   9   0   -   =   <-               Ins   Home    Up
                     36: 
                     37: 41 2   3   4   5   6   7   8   9   10  11  12  13  14               82     71     73
                     38:                                                                     --     --     --
                     39:                                                        |
                     40:                                              {   }     |                         Page
                     41: Tab  Q   W   E   R   T   Y   U   I   O   P   [   ] <----            Del   End    Down
                     42:                                                   
                     43: 15   16  17  18  19  20  21  22  23  24  25  26  27  28             83     79     81
                     44:                                                                     --     --     --
                     45: 
                     46:                                            :   @   ~                       ^
                     47: Caps   A   S   D   F   G   H   J   K   L   ;   '   #                       |
                     48: 
                     49: 58     30  31  32  33  34  35  36  37  38  39  40  43                      72
                     50:                                                                            --
                     51:   
                     52: ^   |                               <   >   ?   ^
                     53: |   \   Z   X   C   V   B   N   M   ,   .   /   |                     <-   |   ->
                     54: 
                     55: 42  86  44  45  46  47  48  49  50  51  52  53  54                    75   80  77
                     56:                                                                       --   --  --
                     57: 
                     58: Ctrl  Alt          SPACE             Alt Gr      Ctrl
                     59: 
                     60:  29    56            57                56         29
                     61:                                                   --
                     62: 
                     63:   And:-
                     64: 
                     65: Num
                     66: Lock   /    *    -
                     67: 
                     68: 69     53   55   74
                     69: --     --
                     70: 
                     71:  7    8     9    +
                     72: Home  ^   Pg Up
                     73: 
                     74: 71    72    73   78
                     75: 
                     76: 
                     77: 4     5     6
                     78: <-          ->
                     79: 
                     80: 75    76    77
                     81: 
                     82: 
                     83: 1     2     3
                     84: End   |   Pg Dn  Enter
                     85: 
                     86: 79    70    81    28
                     87:                   --
                     88: 
                     89: 0     .
                     90: Ins   Del
                     91: 
                     92: 82    83
                     93: 
                     94: 
                     95: */
                     96: 
                     97: 
                     98: /* SDL Key to ST scan code map table */
1.1.1.2   root       99: char Default_KeyToSTScanCode[SDLK_LAST] = {
                    100: /* ST Code,  PC Code */
1.1       root      101:   -1,    /* 0 */
                    102:   -1,    /* 1 */
                    103:   -1,    /* 2 */
                    104:   -1,    /* 3 */
                    105:   -1,    /* 4 */
                    106:   -1,    /* 5 */
                    107:   -1,    /* 6 */
                    108:   -1,    /* 7 */
                    109:   0x0E,  /* SDLK_BACKSPACE=8 */
                    110:   0x0F,  /* SDLK_TAB=9 */
                    111:   -1,    /* 10 */
                    112:   -1,    /* 11 */
                    113:   -1,    /* SDLK_CLEAR = 12 */
                    114:   0x1C,  /* SDLK_RETURN = 13 */
                    115:   -1,    /* 14 */
                    116:   -1,    /* 15 */
                    117:   -1,    /* 16 */
                    118:   -1,    /* 17 */
                    119:   -1,    /* 18 */
                    120:   -1,    /* SDLK_PAUSE = 19 */
                    121:   -1,    /* 20 */
                    122:   -1,    /* 21 */
                    123:   -1,    /* 22 */
                    124:   -1,    /* 23 */
                    125:   -1,    /* 24 */
                    126:   -1,    /* 25 */
                    127:   -1,    /* 26 */
                    128:   0x01,  /* SDLK_ESCAPE = 27 */
                    129:   -1,    /* 28 */
                    130:   -1,    /* 29 */
                    131:   -1,    /* 30 */
                    132:   -1,    /* 31 */
                    133:   0x39,  /* SDLK_SPACE = 32 */
                    134:   -1,    /* SDLK_EXCLAIM = 33 */
                    135:   -1,    /* SDLK_QUOTEDBL = 34 */
                    136:   -1,    /* SDLK_HASH = 35 */
                    137:   -1,    /* SDLK_DOLLAR = 36 */
                    138:   -1,    /* 37 */
                    139:   -1,    /* SDLK_AMPERSAND = 38 */
                    140:   -1,    /* SDLK_QUOTE = 39 */
                    141:   0x63,  /* SDLK_LEFTPAREN = 40 */
                    142:   0x64,  /* SDLK_RIGHTPAREN = 41 */
                    143:   -1,    /* SDLK_ASTERISK = 42 */
                    144:   0x1B,  /* SDLK_PLUS = 43 */
                    145:   0x33,  /* SDLK_COMMA = 44 */
                    146:   0x35,  /* SDLK_MINUS = 45 */
                    147:   0x34,  /* SDLK_PERIOD = 46 */
                    148:   -1,    /* SDLK_SLASH = 47 */
                    149:   0x0B,  /* SDLK_0 = 48 */
                    150:   0x02,  /* SDLK_1 = 49 */
                    151:   0x03,  /* SDLK_2 = 50 */
                    152:   0x04,  /* SDLK_3 = 51 */
                    153:   0x05,  /* SDLK_4 = 52 */
                    154:   0x06,  /* SDLK_5 = 53 */
                    155:   0x07,  /* SDLK_6 = 54 */
                    156:   0x08,  /* SDLK_7 = 55 */
                    157:   0x09,  /* SDLK_8 = 56 */
                    158:   0x0A,  /* SDLK_9 = 57 */
                    159:   -1,    /* SDLK_COLON = 58 */
                    160:   -1,    /* SDLK_SEMICOLON = 59 */
                    161:   0x60,  /* SDLK_LESS = 60 */
                    162:   -1,    /* SDLK_EQUALS = 61 */
                    163:   -1,    /* SDLK_GREATER  = 62 */
                    164:   -1,    /* SDLK_QUESTION = 63 */
                    165:   -1,    /* SDLK_AT = 64 */
                    166:   -1,    /* 65 */  /* Skip uppercase letters */
                    167:   -1,    /* 66 */
                    168:   -1,    /* 67 */
                    169:   -1,    /* 68 */
                    170:   -1,    /* 69 */
                    171:   -1,    /* 70 */
                    172:   -1,    /* 71 */
                    173:   -1,    /* 72 */
                    174:   -1,    /* 73 */
                    175:   -1,    /* 74 */
                    176:   -1,    /* 75 */
                    177:   -1,    /* 76 */
                    178:   -1,    /* 77 */
                    179:   -1,    /* 78 */
                    180:   -1,    /* 79 */
                    181:   -1,    /* 80 */
                    182:   -1,    /* 81 */
                    183:   -1,    /* 82 */
                    184:   -1,    /* 83 */
                    185:   -1,    /* 84 */
                    186:   -1,    /* 85 */
                    187:   -1,    /* 86 */
                    188:   -1,    /* 87 */
                    189:   -1,    /* 88 */
                    190:   -1,    /* 89 */
                    191:   -1,    /* 90 */
                    192:   -1,    /* SDLK_LEFTBRACKET = 91 */
                    193:   -1,    /* SDLK_BACKSLASH = 92 */
                    194:   -1,    /* SDLK_RIGHTBRACKET = 93 */
                    195:   -1,    /* SDLK_CARET = 94 */
                    196:   -1,    /* SDLK_UNDERSCORE = 95 */
                    197:   -1,    /* SDLK_BACKQUOTE = 96 */
                    198:   0x1E,  /* SDLK_a = 97 */
                    199:   0x30,  /* SDLK_b = 98 */
                    200:   0x2E,  /* SDLK_c = 99 */
                    201:   0x20,  /* SDLK_d = 100 */
                    202:   0x12,  /* SDLK_e = 101 */
                    203:   0x21,  /* SDLK_f = 102 */
                    204:   0x22,  /* SDLK_g = 103 */
                    205:   0x23,  /* SDLK_h = 104 */
                    206:   0x17,  /* SDLK_i = 105 */
                    207:   0x24,  /* SDLK_j = 106 */
                    208:   0x25,  /* SDLK_k = 107 */
                    209:   0x26,  /* SDLK_l = 108 */
                    210:   0x32,  /* SDLK_m = 109 */
                    211:   0x31,  /* SDLK_n = 110 */
                    212:   0x18,  /* SDLK_o = 111 */
                    213:   0x19,  /* SDLK_p = 112 */
                    214:   0x10,  /* SDLK_q = 113 */
                    215:   0x13,  /* SDLK_r = 114 */
                    216:   0x1F,  /* SDLK_s = 115 */
                    217:   0x14,  /* SDLK_t = 116 */
                    218:   0x16,  /* SDLK_u = 117 */
                    219:   0x2F,  /* SDLK_v = 118 */
                    220:   0x11,  /* SDLK_w = 119 */
                    221:   0x2D,  /* SDLK_x = 120 */
                    222:   0x15,  /* SDLK_y = 121 */
                    223:   0x2C,  /* SDLK_z = 122 */
                    224:   -1,    /* 123 */
                    225:   -1,    /* 124 */
                    226:   -1,    /* 125 */
                    227:   -1,    /* 126 */
                    228:   0x53,  /* SDLK_DELETE = 127 */
                    229:   /* End of ASCII mapped keysyms */
                    230:   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 128-143*/
                    231:   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144-159*/
                    232:   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160-175*/
                    233:   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176-191*/
                    234:   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192-207*/
                    235:   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208-223*/
                    236:   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224-239*/
                    237:   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240-255*/
                    238:   /* Numeric keypad: */
                    239:   0x70,    /* SDLK_KP0 = 256 */
                    240:   0x6D,    /* SDLK_KP1 = 257 */
                    241:   0x6E,    /* SDLK_KP2 = 258 */
                    242:   0x6F,    /* SDLK_KP3 = 259 */
                    243:   0x6A,    /* SDLK_KP4 = 260 */
                    244:   0x6B,    /* SDLK_KP5 = 261 */
                    245:   0x6C,    /* SDLK_KP6 = 262 */
                    246:   0x67,    /* SDLK_KP7 = 263 */
                    247:   0x68,    /* SDLK_KP8 = 264 */
                    248:   0x69,    /* SDLK_KP9 = 265 */
                    249:   0x71,    /* SDLK_KP_PERIOD = 266 */
                    250:   0x65,    /* SDLK_KP_DIVIDE = 267 */
                    251:   0x66,    /* SDLK_KP_MULTIPLY = 268 */
                    252:   0x4A,    /* SDLK_KP_MINUS = 269 */
                    253:   0x4E,    /* SDLK_KP_PLUS = 270 */
                    254:   0x72,    /* SDLK_KP_ENTER = 271 */
                    255:   -1,      /* SDLK_KP_EQUALS = 272 */
                    256:   /* Arrows + Home/End pad */
                    257:   0x48,    /* SDLK_UP = 273 */
                    258:   0x50,    /* SDLK_DOWN = 274 */
                    259:   0x4D,    /* SDLK_RIGHT = 275 */
                    260:   0x4B,    /* SDLK_LEFT = 276 */
                    261:   0x52,    /* SDLK_INSERT = 277 */
                    262:   0x47,    /* SDLK_HOME = 278 */
                    263:   0x61,    /* SDLK_END = 279 */
                    264:   0x63,    /* SDLK_PAGEUP = 280 */
                    265:   0x64,    /* SDLK_PAGEDOWN = 281 */
                    266:   /* Function keys */
                    267:   0x3B,    /* SDLK_F1 = 282 */
                    268:   0x3C,    /* SDLK_F2 = 283 */
                    269:   0x3D,    /* SDLK_F3 = 284 */
                    270:   0x3E,    /* SDLK_F4 = 285 */
                    271:   0x3F,    /* SDLK_F5 = 286 */
                    272:   0x40,    /* SDLK_F6 = 287 */
                    273:   0x41,    /* SDLK_F7 = 288 */
                    274:   0x42,    /* SDLK_F8 = 289 */
                    275:   0x43,    /* SDLK_F9 = 290 */
                    276:   0x44,    /* SDLK_F10 = 291 */
                    277:   -1,      /* SDLK_F11 = 292 */
                    278:   -1,      /* SDLK_F12 = 293 */
                    279:   -1,      /* SDLK_F13 = 294 */
                    280:   -1,      /* SDLK_F14 = 295 */
                    281:   -1,      /* SDLK_F15 = 296 */
                    282:   -1,      /* 297 */
                    283:   -1,      /* 298 */
                    284:   -1,      /* 299 */
                    285:   /* Key state modifier keys */
                    286:   -1,    /* SDLK_NUMLOCK = 300 */
                    287:   0x3A,    /* SDLK_CAPSLOCK = 301 */
                    288:   0x61,    /* SDLK_SCROLLOCK = 302 */
                    289:   0x36,    /* SDLK_RSHIFT = 303 */
                    290:   0x2A,    /* SDLK_LSHIFT = 304 */
                    291:   0x1D,    /* SDLK_RCTRL = 305 */
                    292:   0x1D,    /* SDLK_LCTRL = 306 */
                    293:   0x38,    /* SDLK_RALT = 307 */
                    294:   0x38,    /* SDLK_LALT = 308 */
                    295:   -1,      /* SDLK_RMETA = 309 */
                    296:   -1,      /* SDLK_LMETA = 310 */
                    297:   -1,      /* SDLK_LSUPER = 311 */  /* Left "Windows" key */
                    298:   -1,      /* SDLK_RSUPER = 312 */  /* Right "Windows" key */
                    299:   -1,      /* SDLK_MODE = 313 */  /* "Alt Gr" key */
                    300:   -1,      /* SDLK_COMPOSE = 314 */ /* Multi-key compose key */
                    301:   /* Miscellaneous function keys */
                    302:   0x62,    /* SDLK_HELP = 315 */
                    303:   0x63,    /* SDLK_PRINT = 316 */
                    304:   -1,      /* SDLK_SYSREQ = 317 */
                    305:   -1,      /* SDLK_BREAK = 318 */
                    306:   -1,      /* SDLK_MENU = 319 */
                    307: };
                    308: 
                    309: 
1.1.1.3   root      310: /* List of ST scan codes to NOT de-bounce when running in maximum speed */
                    311: char DebounceExtendedKeys[] = {
                    312:   0x1d,  /* CTRL */
                    313:   0x2a,  /* Left SHIFT */
                    314:   0x01,  /* ESC */
                    315:   0x38,  /* ALT */
                    316:   0x36,  /* Right SHIFT */
                    317:   0      /* term */
                    318: };
                    319: 
                    320: 
1.1.1.2   root      321: char Loaded_KeyToSTScanCode[SDLK_LAST];
1.1       root      322: BOOL bRemapKeyLoaded=FALSE;
                    323: 
                    324: 
1.1.1.2   root      325: /*-----------------------------------------------------------------------*/
1.1       root      326: /*
                    327:   Remap SDL Key to ST Scan code
                    328: */
                    329: char Keymap_RemapKeyToSTScanCode(unsigned int Key)
                    330: {
1.1.1.2   root      331:   if( Key >= SDLK_LAST )  return -1;  /* Avoid illegal keys */
1.1       root      332:   /* Use default or loaded? */
                    333:   if (bRemapKeyLoaded)
                    334:     return(Loaded_KeyToSTScanCode[Key]);
                    335:   else
                    336:     return(Default_KeyToSTScanCode[Key]);
                    337: }
                    338: 
1.1.1.2   root      339: 
                    340: /*-----------------------------------------------------------------------*/
1.1       root      341: /*
                    342:   Load keyboard remap file
                    343: */
                    344: void Keymap_LoadRemapFile(char *pszFileName)
                    345: {
                    346:   char szString[1024];
                    347:   unsigned int STScanCode,PCScanCode;
                    348:   FILE *in;
                    349: 
1.1.1.2   root      350:   /* Default to not loaded */
1.1       root      351:   bRemapKeyLoaded = FALSE;
                    352:   Memory_Set(Loaded_KeyToSTScanCode,-1,sizeof(Loaded_KeyToSTScanCode));
                    353: 
1.1.1.2   root      354:   /* Attempt to load file */
1.1       root      355:   if (strlen(pszFileName)>0) {
1.1.1.2   root      356:     /* Open file */
1.1       root      357:     in = fopen(pszFileName, "r");
                    358:     if (in) {
                    359:       while(!feof(in)) {
1.1.1.2   root      360:         /* Read line from file */
1.1       root      361:         fgets(szString, 1024, in);
1.1.1.2   root      362:         /* Remove white-space from start of line */
1.1       root      363:         Misc_RemoveWhiteSpace(szString,sizeof(szString));
                    364:         if (strlen(szString)>0) {
1.1.1.2   root      365:           /* Is a comment? */
1.1       root      366:           if ( (szString[0]==';') || (szString[0]=='#') )
                    367:             continue;
1.1.1.2   root      368:           /* Read values */
1.1       root      369:           sscanf(szString,"%d,%d",&STScanCode,&PCScanCode);
1.1.1.2   root      370:           /* Store into remap table, check both value within range */
                    371:           if ( (PCScanCode>=0) && (PCScanCode<SDLK_LAST) && (STScanCode>=0) && (STScanCode<256) )
1.1       root      372:             Loaded_KeyToSTScanCode[PCScanCode] = STScanCode;
                    373:         }
                    374:       }
1.1.1.2   root      375:       /* Loaded OK */
1.1       root      376:       bRemapKeyLoaded = TRUE;
                    377: 
                    378:       fclose(in);
                    379:     }
                    380:   }
                    381: }
1.1.1.3   root      382: 
                    383: 
                    384: 
                    385: /*-----------------------------------------------------------------------*/
                    386: /*
                    387:   Scan list of keys to NOT de-bounce when running in maximum speed, eg ALT,SHIFT,CTRL etc...
                    388:   Return TRUE if key requires de-bouncing
                    389: */
                    390: BOOL Keymap_DebounceSTKey(char STScanCode)
                    391: {
                    392:   int i=0;
                    393: 
                    394:   /* Are we in maximum speed, and have disabled key repeat? */
                    395:   if ( (ConfigureParams.Configure.nMinMaxSpeed!=MINMAXSPEED_MIN) && (ConfigureParams.Keyboard.bDisableKeyRepeat) ) {
                    396:     /* We should de-bounce all non extended keys, eg leave ALT,SHIFT,CTRL etc... held */
                    397:     while (DebounceExtendedKeys[i]) {
                    398:       if (STScanCode==DebounceExtendedKeys[i])
                    399:         return(FALSE);
                    400:       i++;
                    401:     }
                    402: 
                    403:     /* De-bounce key */
                    404:     return(TRUE);
                    405:   }
                    406: 
                    407:   /* Do not de-bounce key */
                    408:   return(FALSE);
                    409: }
                    410: 
                    411: 
                    412: /*-----------------------------------------------------------------------*/
                    413: /*
                    414:   Debounce any PC key held down if running with key repeat disabled
                    415:   This is called each ST frame, so keys get held down for one VBL which is enough for 68000 code to scan
                    416: */
                    417: void Keymap_DebounceAllKeys(void)
                    418: {
                    419:   unsigned int Key;
                    420:   char STScanCode;
                    421: 
                    422:   /* Are we in maximum speed, and have disabled key repeat? */
1.1.1.4 ! root      423:   if ( (ConfigureParams.Configure.nMinMaxSpeed!=MINMAXSPEED_MIN) && (ConfigureParams.Keyboard.bDisableKeyRepeat) )
        !           424:   {
1.1.1.3   root      425:     /* Now run through each PC key looking for ones held down */
1.1.1.4 ! root      426:     for(Key=0; Key<SDLK_LAST; Key++)
        !           427:     {
1.1.1.3   root      428:       /* Is key held? */
1.1.1.4 ! root      429:       if (Keyboard.KeyStates[Key])
        !           430:       {
1.1.1.3   root      431:         /* Get scan code */
                    432:         STScanCode = Keymap_RemapKeyToSTScanCode(Key);
1.1.1.4 ! root      433:         if (STScanCode != (char)-1)
        !           434:         {
1.1.1.3   root      435:           /* Does this require de-bouncing? */
                    436:           if (Keymap_DebounceSTKey(STScanCode))
                    437:             Keymap_KeyUp(Key, 0);
                    438:         }
                    439:       }
                    440:     }
                    441:   }
                    442: 
                    443: }
                    444: 
                    445: 
                    446: /*-----------------------------------------------------------------------*/
                    447: /*
                    448:   User press key down
                    449: */
                    450: void Keymap_KeyDown( unsigned int sdlkey, unsigned int sdlmod )
                    451: {
                    452:   BOOL bPreviousKeyState;
                    453:   char STScanCode;
                    454:   unsigned int Key;
                    455: 
                    456:   Key = sdlkey;
                    457: 
                    458:   /* If using cursor emulation, DON'T send keys to keyboard processor!!! Some games use keyboard as pause! */
                    459:   if ( (ConfigureParams.Joysticks.Joy[0].bCursorEmulation || ConfigureParams.Joysticks.Joy[1].bCursorEmulation)
                    460:             && !(sdlmod&(KMOD_LSHIFT|KMOD_RSHIFT)) )
1.1.1.4 ! root      461:   {
1.1.1.3   root      462:     if( Key==SDLK_UP )         { cursorJoyEmu |= 1; return; }
                    463:     else if( Key==SDLK_DOWN )  { cursorJoyEmu |= 2; return; }
                    464:     else if( Key==SDLK_LEFT )  { cursorJoyEmu |= 4; return; }
                    465:     else if( Key==SDLK_RIGHT ) { cursorJoyEmu |= 8; return; }
                    466:     else if( Key==SDLK_RCTRL || Key==SDLK_KP0 )  { cursorJoyEmu |= 128; return; }
1.1.1.4 ! root      467:   }
1.1.1.3   root      468: 
                    469:   /* Set down */
                    470:   bPreviousKeyState = Keyboard.KeyStates[Key];
                    471:   Keyboard.KeyStates[Key] = TRUE;
                    472: 
                    473:   /* Jump directly to the debugger? */
                    474:   if( sdlkey==SDLK_PAUSE && bEnableDebug)
1.1.1.4 ! root      475:   {
1.1.1.3   root      476:     if(bInFullScreen)  Screen_ReturnFromFullScreen();
                    477:     DebugUI();
1.1.1.4 ! root      478:   }
1.1.1.3   root      479: 
                    480:   /* If pressed short-cut key, retain keypress until safe to execute (start of VBL) */
1.1.1.4 ! root      481:   if ( (sdlmod&KMOD_MODE) || (sdlmod==KMOD_LMETA)
        !           482:        ||(sdlkey==SDLK_F11) || (sdlkey==SDLK_F12) )
        !           483:   {
1.1.1.3   root      484:     ShortCutKey.Key = sdlkey;
                    485:     if( sdlmod&(KMOD_LCTRL|KMOD_RCTRL) )  ShortCutKey.bCtrlPressed = TRUE;
                    486:     if( sdlmod&(KMOD_LSHIFT|KMOD_RSHIFT) )  ShortCutKey.bShiftPressed = TRUE;
1.1.1.4 ! root      487:   }
1.1.1.3   root      488:   else
1.1.1.4 ! root      489:   {
1.1.1.3   root      490:     STScanCode = Keymap_RemapKeyToSTScanCode(Key);
1.1.1.4 ! root      491:     if (STScanCode != (char)-1)
        !           492:     {
1.1.1.3   root      493:       if (!bPreviousKeyState)
                    494:         IKBD_PressSTKey(STScanCode,TRUE);
1.1.1.4 ! root      495:     }
        !           496:   }
1.1.1.3   root      497: 
                    498: }
                    499: 
                    500: 
                    501: /*-----------------------------------------------------------------------*/
                    502: /*
                    503:   User released key
                    504: */
                    505: void Keymap_KeyUp(unsigned int sdlkey, unsigned int sdlmod)
                    506: {
                    507:   char STScanCode;
                    508:   unsigned int Key;
                    509: 
                    510:   Key = sdlkey;
                    511:   
                    512: 
                    513:   /* If using cursor emulation, DON'T send keys to keyboard processor!!! Some games use keyboard as pause! */
                    514:   if ( (ConfigureParams.Joysticks.Joy[0].bCursorEmulation || ConfigureParams.Joysticks.Joy[1].bCursorEmulation)
                    515:             && !(sdlmod&(KMOD_LSHIFT|KMOD_RSHIFT)) )
1.1.1.4 ! root      516:   {
1.1.1.3   root      517:     if( Key==SDLK_UP )         { cursorJoyEmu &= ~1; return; }
                    518:     else if( Key==SDLK_DOWN )  { cursorJoyEmu &= ~2; return; }
                    519:     else if( Key==SDLK_LEFT )  { cursorJoyEmu &= ~4; return; }
                    520:     else if( Key==SDLK_RIGHT ) { cursorJoyEmu &= ~8; return; }
                    521:     else if( Key==SDLK_RCTRL || Key==SDLK_KP0 )  { cursorJoyEmu &= ~128; return; }
1.1.1.4 ! root      522:   }
1.1.1.3   root      523: 
                    524:   /* Release key (only if was pressed) */
                    525:   STScanCode = Keymap_RemapKeyToSTScanCode(Key);
1.1.1.4 ! root      526:   if (STScanCode != (char)-1)
        !           527:   {
1.1.1.3   root      528:     if (Keyboard.KeyStates[Key])
                    529:       IKBD_PressSTKey(STScanCode,FALSE);
                    530:   }
                    531: 
                    532:   Keyboard.KeyStates[Key] = FALSE;
                    533: }
                    534: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.