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