src/video/ataricommon/SDL_atarievents.c
changeset 281 c5010ab8ba35
child 297 f6ffac90895c
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/video/ataricommon/SDL_atarievents.c	Sun Feb 17 19:54:28 2002 +0000
     1.3 @@ -0,0 +1,126 @@
     1.4 +/*
     1.5 +    SDL - Simple DirectMedia Layer
     1.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
     1.7 +
     1.8 +    This library is free software; you can redistribute it and/or
     1.9 +    modify it under the terms of the GNU Library General Public
    1.10 +    License as published by the Free Software Foundation; either
    1.11 +    version 2 of the License, or (at your option) any later version.
    1.12 +
    1.13 +    This library is distributed in the hope that it will be useful,
    1.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.16 +    Library General Public License for more details.
    1.17 +
    1.18 +    You should have received a copy of the GNU Library General Public
    1.19 +    License along with this library; if not, write to the Free
    1.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.21 +
    1.22 +    Sam Lantinga
    1.23 +    slouken@libsdl.org
    1.24 +*/
    1.25 +
    1.26 +#ifdef SAVE_RCSID
    1.27 +static char rcsid =
    1.28 + "@(#) $Id$";
    1.29 +#endif
    1.30 +
    1.31 +/*
    1.32 + *	Atari keyboard events manager
    1.33 + *
    1.34 + *	Patrice Mandin
    1.35 + *
    1.36 + *	This routines choose what the final event manager will be
    1.37 + */
    1.38 +
    1.39 +#include <stdlib.h>
    1.40 +#include <string.h>
    1.41 +
    1.42 +#include <sys/cookie.h>
    1.43 +
    1.44 +#include "SDL.h"
    1.45 +#include "SDL_sysevents.h"
    1.46 +#include "SDL_events_c.h"
    1.47 +
    1.48 +#include "SDL_atarievents_c.h"
    1.49 +#include "SDL_biosevents_c.h"
    1.50 +#include "SDL_gemdosevents_c.h"
    1.51 +#include "SDL_ikbdevents_c.h"
    1.52 +
    1.53 +enum {
    1.54 +	MCH_ST=0,
    1.55 +	MCH_STE,
    1.56 +	MCH_TT,
    1.57 +	MCH_F30
    1.58 +};
    1.59 +
    1.60 +void (*Atari_ShutdownEvents)(void);
    1.61 +
    1.62 +static void Atari_InitializeEvents(_THIS)
    1.63 +{
    1.64 +	const char *envr;
    1.65 +	unsigned long cookie_mch;
    1.66 +
    1.67 +	/* Test if we are on an Atari machine or not */
    1.68 +	if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
    1.69 +		cookie_mch = 0;
    1.70 +	}
    1.71 +	cookie_mch >>= 16;
    1.72 +
    1.73 +	/* Default is Ikbd, the faster except for clones */
    1.74 +	switch(cookie_mch) {
    1.75 +		case MCH_ST:
    1.76 +		case MCH_STE:
    1.77 +		case MCH_TT:
    1.78 +		case MCH_F30:
    1.79 +			this->InitOSKeymap=AtariIkbd_InitOSKeymap;
    1.80 +			this->PumpEvents=AtariIkbd_PumpEvents;
    1.81 +			Atari_ShutdownEvents=AtariIkbd_ShutdownEvents;
    1.82 +			break;
    1.83 +		default:
    1.84 +			this->InitOSKeymap=AtariGemdos_InitOSKeymap;
    1.85 +			this->PumpEvents=AtariGemdos_PumpEvents;
    1.86 +			Atari_ShutdownEvents=AtariGemdos_ShutdownEvents;
    1.87 +			break;
    1.88 +	}
    1.89 +
    1.90 +	envr = getenv("SDL_ATARI_EVENTSDRIVER");
    1.91 +
    1.92 + 	if (!envr) {
    1.93 +		return;
    1.94 +	}
    1.95 +
    1.96 +	if (strcmp(envr, "ikbd") == 0) {
    1.97 +		this->InitOSKeymap=AtariIkbd_InitOSKeymap;
    1.98 +		this->PumpEvents=AtariIkbd_PumpEvents;
    1.99 +		Atari_ShutdownEvents=AtariIkbd_ShutdownEvents;
   1.100 +	}
   1.101 +
   1.102 +	if (strcmp(envr, "gemdos") == 0) {
   1.103 +		this->InitOSKeymap=AtariGemdos_InitOSKeymap;
   1.104 +		this->PumpEvents=AtariGemdos_PumpEvents;
   1.105 +		Atari_ShutdownEvents=AtariGemdos_ShutdownEvents;
   1.106 +	}
   1.107 +
   1.108 +	if (strcmp(envr, "bios") == 0) {
   1.109 +		this->InitOSKeymap=AtariBios_InitOSKeymap;
   1.110 +		this->PumpEvents=AtariBios_PumpEvents;
   1.111 +		Atari_ShutdownEvents=AtariBios_ShutdownEvents;
   1.112 +	}
   1.113 +}
   1.114 +
   1.115 +void Atari_InitOSKeymap(_THIS)
   1.116 +{
   1.117 +	Atari_InitializeEvents(this);
   1.118 +
   1.119 +	/* Call choosen routine */
   1.120 +	this->InitOSKeymap(this);
   1.121 +}
   1.122 +
   1.123 +void Atari_PumpEvents(_THIS)
   1.124 +{
   1.125 +	Atari_InitializeEvents(this);
   1.126 +
   1.127 +	/* Call choosen routine */
   1.128 +	this->PumpEvents(this);
   1.129 +}