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