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
slouken@281
     1
/*
slouken@281
     2
    SDL - Simple DirectMedia Layer
slouken@769
     3
    Copyright (C) 1997-2004 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,
patmandin@1054
    54
	MCH_F30,
patmandin@1054
    55
	MCH_ARANYM
slouken@281
    56
};
slouken@281
    57
slouken@281
    58
void (*Atari_ShutdownEvents)(void);
slouken@281
    59
slouken@281
    60
static void Atari_InitializeEvents(_THIS)
slouken@281
    61
{
slouken@281
    62
	const char *envr;
slouken@281
    63
	unsigned long cookie_mch;
slouken@281
    64
slouken@281
    65
	/* Test if we are on an Atari machine or not */
slouken@281
    66
	if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
slouken@281
    67
		cookie_mch = 0;
slouken@281
    68
	}
slouken@281
    69
	cookie_mch >>= 16;
slouken@281
    70
slouken@281
    71
	/* Default is Ikbd, the faster except for clones */
slouken@281
    72
	switch(cookie_mch) {
slouken@281
    73
		case MCH_ST:
slouken@281
    74
		case MCH_STE:
slouken@281
    75
		case MCH_TT:
slouken@281
    76
		case MCH_F30:
patmandin@1054
    77
		case MCH_ARANYM:
slouken@281
    78
			this->InitOSKeymap=AtariIkbd_InitOSKeymap;
slouken@281
    79
			this->PumpEvents=AtariIkbd_PumpEvents;
slouken@281
    80
			Atari_ShutdownEvents=AtariIkbd_ShutdownEvents;
slouken@281
    81
			break;
slouken@281
    82
		default:
slouken@281
    83
			this->InitOSKeymap=AtariGemdos_InitOSKeymap;
slouken@281
    84
			this->PumpEvents=AtariGemdos_PumpEvents;
slouken@281
    85
			Atari_ShutdownEvents=AtariGemdos_ShutdownEvents;
slouken@281
    86
			break;
slouken@281
    87
	}
slouken@281
    88
slouken@281
    89
	envr = getenv("SDL_ATARI_EVENTSDRIVER");
slouken@281
    90
slouken@281
    91
 	if (!envr) {
slouken@281
    92
		return;
slouken@281
    93
	}
slouken@281
    94
slouken@281
    95
	if (strcmp(envr, "ikbd") == 0) {
slouken@281
    96
		this->InitOSKeymap=AtariIkbd_InitOSKeymap;
slouken@281
    97
		this->PumpEvents=AtariIkbd_PumpEvents;
slouken@281
    98
		Atari_ShutdownEvents=AtariIkbd_ShutdownEvents;
slouken@281
    99
	}
slouken@281
   100
slouken@281
   101
	if (strcmp(envr, "gemdos") == 0) {
slouken@281
   102
		this->InitOSKeymap=AtariGemdos_InitOSKeymap;
slouken@281
   103
		this->PumpEvents=AtariGemdos_PumpEvents;
slouken@281
   104
		Atari_ShutdownEvents=AtariGemdos_ShutdownEvents;
slouken@281
   105
	}
slouken@281
   106
slouken@281
   107
	if (strcmp(envr, "bios") == 0) {
slouken@281
   108
		this->InitOSKeymap=AtariBios_InitOSKeymap;
slouken@281
   109
		this->PumpEvents=AtariBios_PumpEvents;
slouken@281
   110
		Atari_ShutdownEvents=AtariBios_ShutdownEvents;
slouken@281
   111
	}
slouken@281
   112
}
slouken@281
   113
slouken@281
   114
void Atari_InitOSKeymap(_THIS)
slouken@281
   115
{
slouken@281
   116
	Atari_InitializeEvents(this);
slouken@281
   117
slouken@281
   118
	/* Call choosen routine */
slouken@281
   119
	this->InitOSKeymap(this);
slouken@281
   120
}
slouken@281
   121
slouken@281
   122
void Atari_PumpEvents(_THIS)
slouken@281
   123
{
slouken@281
   124
	Atari_InitializeEvents(this);
slouken@281
   125
slouken@281
   126
	/* Call choosen routine */
slouken@281
   127
	this->PumpEvents(this);
slouken@281
   128
}