/* SDL - Simple DirectMedia Layer Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Sam Lantinga slouken@libsdl.org */ #ifdef SAVE_RCSID static char rcsid = "@(#) $Id$"; #endif /* * GEM SDL video driver implementation * inspired from the Dummy SDL driver * * Patrice Mandin * and work from * Olivier Landemarre, Johan Klockars, Xavier Joubert, Claude Attard */ #include #include #include "SDL.h" #include "SDL_sysevents.h" #include "SDL_events_c.h" #include "SDL_gemvideo.h" #include "SDL_gemevents_c.h" #include "../ataricommon/SDL_atarikeys.h" /* for keyboard scancodes */ /* Defines */ #define ATARIBIOS_MAXKEYS 128 /* Variables */ static unsigned char gem_currentkeyboard[ATARIBIOS_MAXKEYS]; static unsigned char gem_previouskeyboard[ATARIBIOS_MAXKEYS]; static unsigned char gem_currentascii[ATARIBIOS_MAXKEYS]; static short prevmousex, prevmousey, prevmouseb; /* The translation tables from a console scancode to a SDL keysym */ static SDLKey keymap[ATARIBIOS_MAXKEYS]; /* Functions prototypes */ static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym); static int do_messages(_THIS, short *message); static void do_keyboard(short kc, short ks); static void do_mouse(_THIS, short mx, short my, short mb); /* Functions */ static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym) { /* Set the keysym information */ keysym->scancode = scancode; if (asciicode) keysym->sym = asciicode; else keysym->sym = keymap[scancode]; keysym->mod = KMOD_NONE; keysym->unicode = 0; return(keysym); } void GEM_InitOSKeymap(_THIS) { int i; memset(gem_currentkeyboard, 0, sizeof(gem_currentkeyboard)); memset(gem_previouskeyboard, 0, sizeof(gem_previouskeyboard)); memset(gem_currentascii, 0, sizeof(gem_currentascii)); /* Initialize keymap */ for ( i=0; i>8) & 127; asciicode=kc & 255; gem_currentkeyboard[scancode]=0xFF; gem_currentascii[scancode]=asciicode; } if (!ks) graf_mkstate(&dummy, &dummy, &dummy, &ks); /* Read special keys */ if (ks & K_RSHIFT) gem_currentkeyboard[SCANCODE_RIGHTSHIFT]=0xFF; if (ks & K_LSHIFT) gem_currentkeyboard[SCANCODE_LEFTSHIFT]=0xFF; if (ks & K_CTRL) gem_currentkeyboard[SCANCODE_LEFTCONTROL]=0xFF; if (ks & K_ALT) gem_currentkeyboard[SCANCODE_LEFTALT]=0xFF; } static void do_mouse(_THIS, short mx, short my, short mb) { /* Mouse motion ? */ if ((prevmousex!=mx) || (prevmousey!=my)) { if (GEM_mouse_relative) { short wind_pxy[8]; wind_get(GEM_handle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3]); SDL_PrivateMouseMotion(0, 1, mx-wind_pxy[0], my-wind_pxy[1]); } else { SDL_PrivateMouseMotion(0, 1, mx, my); } prevmousex = mx; prevmousey = my; } /* Mouse button ? */ if (prevmouseb!=mb) { int i; for (i=0;i<3;i++) { int curbutton, prevbutton; curbutton = mb & (1<