src/video/ataricommon/SDL_atarievents.c
author Sam Lantinga
Sat, 07 Dec 2002 06:54:47 +0000
changeset 557 0ce5a68278fd
parent 297 f6ffac90895c
child 769 b8d311d90021
permissions -rw-r--r--
Updated Atari port for new system headers (thanks Patrice!)
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  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 };
    56 
    57 void (*Atari_ShutdownEvents)(void);
    58 
    59 static void Atari_InitializeEvents(_THIS)
    60 {
    61 	const char *envr;
    62 	unsigned long cookie_mch;
    63 
    64 	/* Test if we are on an Atari machine or not */
    65 	if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
    66 		cookie_mch = 0;
    67 	}
    68 	cookie_mch >>= 16;
    69 
    70 	/* Default is Ikbd, the faster except for clones */
    71 	switch(cookie_mch) {
    72 		case MCH_ST:
    73 		case MCH_STE:
    74 		case MCH_TT:
    75 		case MCH_F30:
    76 			this->InitOSKeymap=AtariIkbd_InitOSKeymap;
    77 			this->PumpEvents=AtariIkbd_PumpEvents;
    78 			Atari_ShutdownEvents=AtariIkbd_ShutdownEvents;
    79 			break;
    80 		default:
    81 			this->InitOSKeymap=AtariGemdos_InitOSKeymap;
    82 			this->PumpEvents=AtariGemdos_PumpEvents;
    83 			Atari_ShutdownEvents=AtariGemdos_ShutdownEvents;
    84 			break;
    85 	}
    86 
    87 	envr = getenv("SDL_ATARI_EVENTSDRIVER");
    88 
    89  	if (!envr) {
    90 		return;
    91 	}
    92 
    93 	if (strcmp(envr, "ikbd") == 0) {
    94 		this->InitOSKeymap=AtariIkbd_InitOSKeymap;
    95 		this->PumpEvents=AtariIkbd_PumpEvents;
    96 		Atari_ShutdownEvents=AtariIkbd_ShutdownEvents;
    97 	}
    98 
    99 	if (strcmp(envr, "gemdos") == 0) {
   100 		this->InitOSKeymap=AtariGemdos_InitOSKeymap;
   101 		this->PumpEvents=AtariGemdos_PumpEvents;
   102 		Atari_ShutdownEvents=AtariGemdos_ShutdownEvents;
   103 	}
   104 
   105 	if (strcmp(envr, "bios") == 0) {
   106 		this->InitOSKeymap=AtariBios_InitOSKeymap;
   107 		this->PumpEvents=AtariBios_PumpEvents;
   108 		Atari_ShutdownEvents=AtariBios_ShutdownEvents;
   109 	}
   110 }
   111 
   112 void Atari_InitOSKeymap(_THIS)
   113 {
   114 	Atari_InitializeEvents(this);
   115 
   116 	/* Call choosen routine */
   117 	this->InitOSKeymap(this);
   118 }
   119 
   120 void Atari_PumpEvents(_THIS)
   121 {
   122 	Atari_InitializeEvents(this);
   123 
   124 	/* Call choosen routine */
   125 	this->PumpEvents(this);
   126 }