src/video/ataricommon/SDL_atarievents.c
author Patrice Mandin
Sun, 01 Jan 2006 19:14:11 +0000
changeset 1209 a55ac374271c
parent 1079 39b5606fa543
child 1221 8ef3e7e92a91
permissions -rw-r--r--
Added preliminary missingtranslation from Atari to Unicode charset
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@1079
    55
	MCH_CLONE,
patmandin@1054
    56
	MCH_ARANYM
slouken@281
    57
};
slouken@281
    58
slouken@281
    59
void (*Atari_ShutdownEvents)(void);
slouken@281
    60
slouken@281
    61
static void Atari_InitializeEvents(_THIS)
slouken@281
    62
{
slouken@281
    63
	const char *envr;
slouken@281
    64
	unsigned long cookie_mch;
slouken@281
    65
slouken@281
    66
	/* Test if we are on an Atari machine or not */
slouken@281
    67
	if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
slouken@281
    68
		cookie_mch = 0;
slouken@281
    69
	}
slouken@281
    70
	cookie_mch >>= 16;
slouken@281
    71
slouken@281
    72
	/* Default is Ikbd, the faster except for clones */
slouken@281
    73
	switch(cookie_mch) {
slouken@281
    74
		case MCH_ST:
slouken@281
    75
		case MCH_STE:
slouken@281
    76
		case MCH_TT:
slouken@281
    77
		case MCH_F30:
patmandin@1054
    78
		case MCH_ARANYM:
slouken@281
    79
			this->InitOSKeymap=AtariIkbd_InitOSKeymap;
slouken@281
    80
			this->PumpEvents=AtariIkbd_PumpEvents;
slouken@281
    81
			Atari_ShutdownEvents=AtariIkbd_ShutdownEvents;
slouken@281
    82
			break;
slouken@281
    83
		default:
slouken@281
    84
			this->InitOSKeymap=AtariGemdos_InitOSKeymap;
slouken@281
    85
			this->PumpEvents=AtariGemdos_PumpEvents;
slouken@281
    86
			Atari_ShutdownEvents=AtariGemdos_ShutdownEvents;
slouken@281
    87
			break;
slouken@281
    88
	}
slouken@281
    89
slouken@281
    90
	envr = getenv("SDL_ATARI_EVENTSDRIVER");
slouken@281
    91
slouken@281
    92
 	if (!envr) {
slouken@281
    93
		return;
slouken@281
    94
	}
slouken@281
    95
slouken@281
    96
	if (strcmp(envr, "ikbd") == 0) {
slouken@281
    97
		this->InitOSKeymap=AtariIkbd_InitOSKeymap;
slouken@281
    98
		this->PumpEvents=AtariIkbd_PumpEvents;
slouken@281
    99
		Atari_ShutdownEvents=AtariIkbd_ShutdownEvents;
slouken@281
   100
	}
slouken@281
   101
slouken@281
   102
	if (strcmp(envr, "gemdos") == 0) {
slouken@281
   103
		this->InitOSKeymap=AtariGemdos_InitOSKeymap;
slouken@281
   104
		this->PumpEvents=AtariGemdos_PumpEvents;
slouken@281
   105
		Atari_ShutdownEvents=AtariGemdos_ShutdownEvents;
slouken@281
   106
	}
slouken@281
   107
slouken@281
   108
	if (strcmp(envr, "bios") == 0) {
slouken@281
   109
		this->InitOSKeymap=AtariBios_InitOSKeymap;
slouken@281
   110
		this->PumpEvents=AtariBios_PumpEvents;
slouken@281
   111
		Atari_ShutdownEvents=AtariBios_ShutdownEvents;
slouken@281
   112
	}
slouken@281
   113
}
slouken@281
   114
slouken@281
   115
void Atari_InitOSKeymap(_THIS)
slouken@281
   116
{
slouken@281
   117
	Atari_InitializeEvents(this);
slouken@281
   118
slouken@281
   119
	/* Call choosen routine */
slouken@281
   120
	this->InitOSKeymap(this);
slouken@281
   121
}
slouken@281
   122
slouken@281
   123
void Atari_PumpEvents(_THIS)
slouken@281
   124
{
slouken@281
   125
	Atari_InitializeEvents(this);
slouken@281
   126
slouken@281
   127
	/* Call choosen routine */
slouken@281
   128
	this->PumpEvents(this);
slouken@281
   129
}
patmandin@1209
   130
patmandin@1209
   131
Uint16 SDL_AtariToUnicode(Uint8 caracter)
patmandin@1209
   132
{
patmandin@1209
   133
	/* Translate from Atari charset to Unicode */
patmandin@1209
   134
	if ((caracter>=32) && (caracter<=127)) {
patmandin@1209
   135
		return (Uint16) caracter;
patmandin@1209
   136
	}
patmandin@1209
   137
patmandin@1209
   138
	return 0;
patmandin@1209
   139
}