src/video/ataricommon/SDL_biosevents.c
changeset 2030 d774e9d7c2a8
parent 2019 d20f4510c718
child 2031 f54073d86c82
     1.1 --- a/src/video/ataricommon/SDL_biosevents.c	Sat Sep 16 17:13:41 2006 +0000
     1.2 +++ b/src/video/ataricommon/SDL_biosevents.c	Wed Sep 20 19:47:09 2006 +0000
     1.3 @@ -39,31 +39,10 @@
     1.4  #include "SDL_xbiosevents_c.h"
     1.5  #include "SDL_ataridevmouse_c.h"
     1.6  
     1.7 -/* To save state of keyboard */
     1.8 -#define ATARIBIOS_MAXKEYS 128
     1.9 -
    1.10  static unsigned char bios_currentkeyboard[ATARIBIOS_MAXKEYS];
    1.11  static unsigned char bios_previouskeyboard[ATARIBIOS_MAXKEYS];
    1.12 -static unsigned char bios_currentascii[ATARIBIOS_MAXKEYS];
    1.13  static SDL_bool use_dev_mouse = SDL_FALSE;
    1.14  
    1.15 -/* Special keys state */
    1.16 -enum
    1.17 -{
    1.18 -    K_RSHIFT = 0,
    1.19 -    K_LSHIFT,
    1.20 -    K_CTRL,
    1.21 -    K_ALT,
    1.22 -    K_CAPSLOCK,
    1.23 -    K_CLRHOME,
    1.24 -    K_INSERT
    1.25 -};
    1.26 -
    1.27 -/* The translation tables from a console scancode to a SDL keysym */
    1.28 -static SDLKey keymap[ATARIBIOS_MAXKEYS];
    1.29 -
    1.30 -static SDL_keysym *TranslateKey(int scancode, int asciicode,
    1.31 -                                SDL_keysym * keysym, SDL_bool pressed);
    1.32  static void UpdateSpecialKeys(int special_keys_state);
    1.33  
    1.34  void
    1.35 @@ -75,36 +54,6 @@
    1.36      SDL_memset(bios_currentkeyboard, 0, sizeof(bios_currentkeyboard));
    1.37      SDL_memset(bios_previouskeyboard, 0, sizeof(bios_previouskeyboard));
    1.38  
    1.39 -    /* Initialize keymap */
    1.40 -    for (i = 0; i < ATARIBIOS_MAXKEYS; i++)
    1.41 -        keymap[i] = SDLK_UNKNOWN;
    1.42 -
    1.43 -    /* Functions keys */
    1.44 -    for (i = 0; i < 10; i++)
    1.45 -        keymap[SCANCODE_F1 + i] = SDLK_F1 + i;
    1.46 -
    1.47 -    /* Cursor keypad */
    1.48 -    keymap[SCANCODE_HELP] = SDLK_HELP;
    1.49 -    keymap[SCANCODE_UNDO] = SDLK_UNDO;
    1.50 -    keymap[SCANCODE_INSERT] = SDLK_INSERT;
    1.51 -    keymap[SCANCODE_CLRHOME] = SDLK_HOME;
    1.52 -    keymap[SCANCODE_UP] = SDLK_UP;
    1.53 -    keymap[SCANCODE_DOWN] = SDLK_DOWN;
    1.54 -    keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
    1.55 -    keymap[SCANCODE_LEFT] = SDLK_LEFT;
    1.56 -
    1.57 -    /* Special keys */
    1.58 -    keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
    1.59 -    keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
    1.60 -    keymap[SCANCODE_TAB] = SDLK_TAB;
    1.61 -    keymap[SCANCODE_ENTER] = SDLK_RETURN;
    1.62 -    keymap[SCANCODE_DELETE] = SDLK_DELETE;
    1.63 -    keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
    1.64 -    keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
    1.65 -    keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
    1.66 -    keymap[SCANCODE_LEFTALT] = SDLK_LALT;
    1.67 -    keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
    1.68 -
    1.69      use_dev_mouse = (SDL_AtariDevMouse_Open() != 0) ? SDL_TRUE : SDL_FALSE;
    1.70  
    1.71      vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS;  /* XBIOS joystick events */
    1.72 @@ -129,15 +78,8 @@
    1.73  
    1.74      while (Bconstat(_CON)) {
    1.75          unsigned long key_pressed;
    1.76 -        unsigned char asciicode, scancode;
    1.77 -
    1.78 -        key_pressed = Bconin(_CON);
    1.79 -
    1.80 -        asciicode = key_pressed;
    1.81 -        scancode = key_pressed >> 16;
    1.82 -
    1.83 -        bios_currentkeyboard[scancode] = 0xFF;
    1.84 -        bios_currentascii[scancode] = asciicode;
    1.85 +        key_pressed=Bconin(_CON);
    1.86 +        bios_currentkeyboard[(key_pressed>>16)&(ATARIBIOS_MAXKEYS-1)]=0xFF;
    1.87      }
    1.88  
    1.89      /* Read special keys */
    1.90 @@ -148,14 +90,12 @@
    1.91          /* Key pressed ? */
    1.92          if (bios_currentkeyboard[i] && !bios_previouskeyboard[i])
    1.93              SDL_PrivateKeyboard(SDL_PRESSED,
    1.94 -                                TranslateKey(i, bios_currentascii[i],
    1.95 -                                             &keysym, SDL_TRUE));
    1.96 +                                SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
    1.97  
    1.98          /* Key unpressed ? */
    1.99          if (bios_previouskeyboard[i] && !bios_currentkeyboard[i])
   1.100              SDL_PrivateKeyboard(SDL_RELEASED,
   1.101 -                                TranslateKey(i, bios_currentascii[i],
   1.102 -                                             &keysym, SDL_FALSE));
   1.103 +                                SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE));
   1.104      }
   1.105  
   1.106      if (use_dev_mouse) {
   1.107 @@ -166,7 +106,7 @@
   1.108  
   1.109      /* Will be previous table */
   1.110      SDL_memcpy(bios_previouskeyboard, bios_currentkeyboard,
   1.111 -               ATARIBIOS_MAXKEYS);
   1.112 +               sizeof(bios_previouskeyboard));
   1.113  }
   1.114  
   1.115  static void
   1.116 @@ -187,27 +127,6 @@
   1.117      UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK);
   1.118  }
   1.119  
   1.120 -static SDL_keysym *
   1.121 -TranslateKey(int scancode, int asciicode, SDL_keysym * keysym,
   1.122 -             SDL_bool pressed)
   1.123 -{
   1.124 -    /* Set the keysym information */
   1.125 -    keysym->scancode = scancode;
   1.126 -
   1.127 -    if (asciicode)
   1.128 -        keysym->sym = asciicode;
   1.129 -    else
   1.130 -        keysym->sym = keymap[scancode];
   1.131 -
   1.132 -    keysym->mod = KMOD_NONE;
   1.133 -    keysym->unicode = 0;
   1.134 -    if (SDL_TranslateUNICODE && pressed) {
   1.135 -        keysym->unicode = SDL_AtariToUnicodeTable[asciicode];
   1.136 -    }
   1.137 -
   1.138 -    return (keysym);
   1.139 -}
   1.140 -
   1.141  void
   1.142  AtariBios_ShutdownEvents(void)
   1.143  {