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