src/video/ataricommon/SDL_atarievents.c
author Patrice Mandin
Thu, 05 May 2005 10:52:22 +0000
changeset 1054 e89d7f826b4a
parent 769 b8d311d90021
child 1079 39b5606fa543
permissions -rw-r--r--
Add support for ARAnyM Atari emulator
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2004 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Library General Public
     7     License as published by the Free Software Foundation; either
     8     version 2 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Library General Public License for more details.
    14 
    15     You should have received a copy of the GNU Library General Public
    16     License along with this library; if not, write to the Free
    17     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 
    23 #ifdef SAVE_RCSID
    24 static char rcsid =
    25  "@(#) $Id$";
    26 #endif
    27 
    28 /*
    29  *	Atari keyboard events manager
    30  *
    31  *	Patrice Mandin
    32  *
    33  *	This routines choose what the final event manager will be
    34  */
    35 
    36 #include <stdlib.h>
    37 #include <string.h>
    38 
    39 #include <mint/cookie.h>
    40 
    41 #include "SDL.h"
    42 #include "SDL_sysevents.h"
    43 #include "SDL_events_c.h"
    44 
    45 #include "SDL_atarievents_c.h"
    46 #include "SDL_biosevents_c.h"
    47 #include "SDL_gemdosevents_c.h"
    48 #include "SDL_ikbdevents_c.h"
    49 
    50 enum {
    51 	MCH_ST=0,
    52 	MCH_STE,
    53 	MCH_TT,
    54 	MCH_F30,
    55 	MCH_ARANYM
    56 };
    57 
    58 void (*Atari_ShutdownEvents)(void);
    59 
    60 static void Atari_InitializeEvents(_THIS)
    61 {
    62 	const char *envr;
    63 	unsigned long cookie_mch;
    64 
    65 	/* Test if we are on an Atari machine or not */
    66 	if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
    67 		cookie_mch = 0;
    68 	}
    69 	cookie_mch >>= 16;
    70 
    71 	/* Default is Ikbd, the faster except for clones */
    72 	switch(cookie_mch) {
    73 		case MCH_ST:
    74 		case MCH_STE:
    75 		case MCH_TT:
    76 		case MCH_F30:
    77 		case MCH_ARANYM:
    78 			this->InitOSKeymap=AtariIkbd_InitOSKeymap;
    79 			this->PumpEvents=AtariIkbd_PumpEvents;
    80 			Atari_ShutdownEvents=AtariIkbd_ShutdownEvents;
    81 			break;
    82 		default:
    83 			this->InitOSKeymap=AtariGemdos_InitOSKeymap;
    84 			this->PumpEvents=AtariGemdos_PumpEvents;
    85 			Atari_ShutdownEvents=AtariGemdos_ShutdownEvents;
    86 			break;
    87 	}
    88 
    89 	envr = getenv("SDL_ATARI_EVENTSDRIVER");
    90 
    91  	if (!envr) {
    92 		return;
    93 	}
    94 
    95 	if (strcmp(envr, "ikbd") == 0) {
    96 		this->InitOSKeymap=AtariIkbd_InitOSKeymap;
    97 		this->PumpEvents=AtariIkbd_PumpEvents;
    98 		Atari_ShutdownEvents=AtariIkbd_ShutdownEvents;
    99 	}
   100 
   101 	if (strcmp(envr, "gemdos") == 0) {
   102 		this->InitOSKeymap=AtariGemdos_InitOSKeymap;
   103 		this->PumpEvents=AtariGemdos_PumpEvents;
   104 		Atari_ShutdownEvents=AtariGemdos_ShutdownEvents;
   105 	}
   106 
   107 	if (strcmp(envr, "bios") == 0) {
   108 		this->InitOSKeymap=AtariBios_InitOSKeymap;
   109 		this->PumpEvents=AtariBios_PumpEvents;
   110 		Atari_ShutdownEvents=AtariBios_ShutdownEvents;
   111 	}
   112 }
   113 
   114 void Atari_InitOSKeymap(_THIS)
   115 {
   116 	Atari_InitializeEvents(this);
   117 
   118 	/* Call choosen routine */
   119 	this->InitOSKeymap(this);
   120 }
   121 
   122 void Atari_PumpEvents(_THIS)
   123 {
   124 	Atari_InitializeEvents(this);
   125 
   126 	/* Call choosen routine */
   127 	this->PumpEvents(this);
   128 }