src/video/gem/SDL_gemevents.c
changeset 2030 d774e9d7c2a8
parent 2019 d20f4510c718
child 2043 adf732f1f016
     1.1 --- a/src/video/gem/SDL_gemevents.c	Sat Sep 16 17:13:41 2006 +0000
     1.2 +++ b/src/video/gem/SDL_gemevents.c	Wed Sep 20 19:47:09 2006 +0000
     1.3 @@ -41,91 +41,29 @@
     1.4  #include "../ataricommon/SDL_xbiosevents_c.h"
     1.5  #include "../ataricommon/SDL_ataridevmouse_c.h"
     1.6  
     1.7 -/* Defines */
     1.8 -
     1.9 -#define ATARIBIOS_MAXKEYS 128
    1.10 -
    1.11  /* Variables */
    1.12  
    1.13  static unsigned char gem_currentkeyboard[ATARIBIOS_MAXKEYS];
    1.14  static unsigned char gem_previouskeyboard[ATARIBIOS_MAXKEYS];
    1.15 -static unsigned char gem_currentascii[ATARIBIOS_MAXKEYS];
    1.16 -
    1.17 -/* The translation tables from a console scancode to a SDL keysym */
    1.18 -static SDLKey keymap[ATARIBIOS_MAXKEYS];
    1.19  
    1.20  /* Functions prototypes */
    1.21  
    1.22 -static SDL_keysym *TranslateKey(int scancode, int asciicode,
    1.23 -                                SDL_keysym * keysym, SDL_bool pressed);
    1.24  static int do_messages(_THIS, short *message);
    1.25  static void do_keyboard(short kc, short ks);
    1.26  static void do_mouse(_THIS, short mx, short my, short mb, short ks);
    1.27  
    1.28  /* Functions */
    1.29  
    1.30 -static SDL_keysym *
    1.31 -TranslateKey(int scancode, int asciicode, SDL_keysym * keysym,
    1.32 -             SDL_bool pressed)
    1.33 -{
    1.34 -    /* Set the keysym information */
    1.35 -    keysym->scancode = scancode;
    1.36 -
    1.37 -    if (asciicode)
    1.38 -        keysym->sym = asciicode;
    1.39 -    else
    1.40 -        keysym->sym = keymap[scancode];
    1.41 -
    1.42 -    keysym->mod = KMOD_NONE;
    1.43 -    keysym->unicode = 0;
    1.44 -    if (SDL_TranslateUNICODE && pressed) {
    1.45 -        keysym->unicode = SDL_AtariToUnicodeTable[asciicode];
    1.46 -    }
    1.47 -
    1.48 -    return (keysym);
    1.49 -}
    1.50 -
    1.51  void
    1.52  GEM_InitOSKeymap(_THIS)
    1.53  {
    1.54 -    int i;
    1.55 -
    1.56      SDL_memset(gem_currentkeyboard, 0, sizeof(gem_currentkeyboard));
    1.57      SDL_memset(gem_previouskeyboard, 0, sizeof(gem_previouskeyboard));
    1.58 -    SDL_memset(gem_currentascii, 0, sizeof(gem_currentascii));
    1.59 -
    1.60 -    /* Initialize keymap */
    1.61 -    for (i = 0; i < ATARIBIOS_MAXKEYS; i++)
    1.62 -        keymap[i] = SDLK_UNKNOWN;
    1.63 -
    1.64 -    /* Functions keys */
    1.65 -    for (i = 0; i < 10; i++)
    1.66 -        keymap[SCANCODE_F1 + i] = SDLK_F1 + i;
    1.67 -
    1.68 -    /* Cursor keypad */
    1.69 -    keymap[SCANCODE_HELP] = SDLK_HELP;
    1.70 -    keymap[SCANCODE_UNDO] = SDLK_UNDO;
    1.71 -    keymap[SCANCODE_INSERT] = SDLK_INSERT;
    1.72 -    keymap[SCANCODE_CLRHOME] = SDLK_HOME;
    1.73 -    keymap[SCANCODE_UP] = SDLK_UP;
    1.74 -    keymap[SCANCODE_DOWN] = SDLK_DOWN;
    1.75 -    keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
    1.76 -    keymap[SCANCODE_LEFT] = SDLK_LEFT;
    1.77 -
    1.78 -    /* Special keys */
    1.79 -    keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
    1.80 -    keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
    1.81 -    keymap[SCANCODE_TAB] = SDLK_TAB;
    1.82 -    keymap[SCANCODE_ENTER] = SDLK_RETURN;
    1.83 -    keymap[SCANCODE_DELETE] = SDLK_DELETE;
    1.84 -    keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
    1.85 -    keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
    1.86 -    keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
    1.87 -    keymap[SCANCODE_LEFTALT] = SDLK_LALT;
    1.88 -    keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
    1.89  
    1.90      /* Mouse init */
    1.91      GEM_mouse_relative = SDL_FALSE;
    1.92 +
    1.93 +    SDL_Atari_InitInternalKeymap(this);
    1.94  }
    1.95  
    1.96  void
    1.97 @@ -204,14 +142,12 @@
    1.98          /* Key pressed ? */
    1.99          if (gem_currentkeyboard[i] && !gem_previouskeyboard[i])
   1.100              SDL_PrivateKeyboard(SDL_PRESSED,
   1.101 -                                TranslateKey(i, gem_currentascii[i],
   1.102 -                                             &keysym, SDL_TRUE));
   1.103 +                                SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
   1.104  
   1.105          /* Key unpressed ? */
   1.106          if (gem_previouskeyboard[i] && !gem_currentkeyboard[i])
   1.107              SDL_PrivateKeyboard(SDL_RELEASED,
   1.108 -                                TranslateKey(i, gem_currentascii[i],
   1.109 -                                             &keysym, SDL_FALSE));
   1.110 +                                SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE));
   1.111      }
   1.112  
   1.113      SDL_memcpy(gem_previouskeyboard, gem_currentkeyboard,
   1.114 @@ -355,11 +291,8 @@
   1.115      int scancode, asciicode;
   1.116  
   1.117      if (kc) {
   1.118 -        scancode = (kc >> 8) & 127;
   1.119 -        asciicode = kc & 255;
   1.120 -
   1.121 -        gem_currentkeyboard[scancode] = 0xFF;
   1.122 -        gem_currentascii[scancode] = asciicode;
   1.123 +        scancode=(kc>>8) & (ATARIBIOS_MAXKEYS-1);
   1.124 +        gem_currentkeyboard[scancode]=0xFF;
   1.125      }
   1.126  
   1.127      /* Read special keys */