src/video/ataricommon/SDL_gemdosevents.c
changeset 1895 c121d94672cb
parent 1420 2405517b5eab
child 2019 d20f4510c718
--- a/src/video/ataricommon/SDL_gemdosevents.c	Thu Jul 06 18:01:37 2006 +0000
+++ b/src/video/ataricommon/SDL_gemdosevents.c	Mon Jul 10 21:04:37 2006 +0000
@@ -48,126 +48,134 @@
 static SDL_bool use_dev_mouse = SDL_FALSE;
 
 /* Special keys state */
-enum {
-	K_RSHIFT=0,
-	K_LSHIFT,
-	K_CTRL,
-	K_ALT,
-	K_CAPSLOCK,
-	K_CLRHOME,
-	K_INSERT
+enum
+{
+    K_RSHIFT = 0,
+    K_LSHIFT,
+    K_CTRL,
+    K_ALT,
+    K_CAPSLOCK,
+    K_CLRHOME,
+    K_INSERT
 };
 
-enum {
-	DEV_BUSY=0,
-	DEV_READY
+enum
+{
+    DEV_BUSY = 0,
+    DEV_READY
 };
 
 /* The translation tables from a console scancode to a SDL keysym */
 static SDLKey keymap[ATARIBIOS_MAXKEYS];
 
-static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym,
-	SDL_bool pressed);
+static SDL_keysym *TranslateKey(int scancode, int asciicode,
+                                SDL_keysym * keysym, SDL_bool pressed);
 static void UpdateSpecialKeys(int special_keys_state);
 
-void AtariGemdos_InitOSKeymap(_THIS)
+void
+AtariGemdos_InitOSKeymap(_THIS)
 {
-	int i, vectors_mask;
-	unsigned long dummy;
-
-	SDL_memset(gemdos_currentkeyboard, 0, sizeof(gemdos_currentkeyboard));
-	SDL_memset(gemdos_previouskeyboard, 0, sizeof(gemdos_previouskeyboard));
+    int i, vectors_mask;
+    unsigned long dummy;
 
-	/* Initialize keymap */
-	for ( i=0; i<sizeof(keymap); i++ )
-		keymap[i] = SDLK_UNKNOWN;
+    SDL_memset(gemdos_currentkeyboard, 0, sizeof(gemdos_currentkeyboard));
+    SDL_memset(gemdos_previouskeyboard, 0, sizeof(gemdos_previouskeyboard));
 
-	/* Functions keys */
-	for ( i = 0; i<10; i++ )
-		keymap[SCANCODE_F1 + i] = SDLK_F1+i;
+    /* Initialize keymap */
+    for (i = 0; i < sizeof(keymap); i++)
+        keymap[i] = SDLK_UNKNOWN;
+
+    /* Functions keys */
+    for (i = 0; i < 10; i++)
+        keymap[SCANCODE_F1 + i] = SDLK_F1 + i;
 
-	/* Cursor keypad */
-	keymap[SCANCODE_HELP] = SDLK_HELP;
-	keymap[SCANCODE_UNDO] = SDLK_UNDO;
-	keymap[SCANCODE_INSERT] = SDLK_INSERT;
-	keymap[SCANCODE_CLRHOME] = SDLK_HOME;
-	keymap[SCANCODE_UP] = SDLK_UP;
-	keymap[SCANCODE_DOWN] = SDLK_DOWN;
-	keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
-	keymap[SCANCODE_LEFT] = SDLK_LEFT;
+    /* Cursor keypad */
+    keymap[SCANCODE_HELP] = SDLK_HELP;
+    keymap[SCANCODE_UNDO] = SDLK_UNDO;
+    keymap[SCANCODE_INSERT] = SDLK_INSERT;
+    keymap[SCANCODE_CLRHOME] = SDLK_HOME;
+    keymap[SCANCODE_UP] = SDLK_UP;
+    keymap[SCANCODE_DOWN] = SDLK_DOWN;
+    keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
+    keymap[SCANCODE_LEFT] = SDLK_LEFT;
 
-	/* Special keys */
-	keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
-	keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
-	keymap[SCANCODE_TAB] = SDLK_TAB;
-	keymap[SCANCODE_ENTER] = SDLK_RETURN;
-	keymap[SCANCODE_DELETE] = SDLK_DELETE;
-	keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
-	keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
-	keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
-	keymap[SCANCODE_LEFTALT] = SDLK_LALT;
-	keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
+    /* Special keys */
+    keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
+    keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
+    keymap[SCANCODE_TAB] = SDLK_TAB;
+    keymap[SCANCODE_ENTER] = SDLK_RETURN;
+    keymap[SCANCODE_DELETE] = SDLK_DELETE;
+    keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
+    keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
+    keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
+    keymap[SCANCODE_LEFTALT] = SDLK_LALT;
+    keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
 
-	use_dev_mouse = (SDL_AtariDevMouse_Open()!=0) ? SDL_TRUE : SDL_FALSE;
+    use_dev_mouse = (SDL_AtariDevMouse_Open() != 0) ? SDL_TRUE : SDL_FALSE;
 
-	vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS;	/* XBIOS joystick events */
-	if (!use_dev_mouse) {
-		vectors_mask |= ATARI_XBIOS_MOUSEEVENTS;	/* XBIOS mouse events */
-	}
-	if (Getcookie(C_MiNT, &dummy)==C_FOUND) {
-		vectors_mask = 0;
-	}
-	SDL_AtariXbios_InstallVectors(vectors_mask);
+    vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS;  /* XBIOS joystick events */
+    if (!use_dev_mouse) {
+        vectors_mask |= ATARI_XBIOS_MOUSEEVENTS;        /* XBIOS mouse events */
+    }
+    if (Getcookie(C_MiNT, &dummy) == C_FOUND) {
+        vectors_mask = 0;
+    }
+    SDL_AtariXbios_InstallVectors(vectors_mask);
 }
 
-void AtariGemdos_PumpEvents(_THIS)
+void
+AtariGemdos_PumpEvents(_THIS)
 {
-	int i;
-	SDL_keysym keysym;
+    int i;
+    SDL_keysym keysym;
 
-	/* Update pressed keys */
-	SDL_memset(gemdos_currentkeyboard, 0, ATARIBIOS_MAXKEYS);
+    /* Update pressed keys */
+    SDL_memset(gemdos_currentkeyboard, 0, ATARIBIOS_MAXKEYS);
 
-	while (Cconis()!=DEV_BUSY) {
-		unsigned long key_pressed;
-		unsigned char scancode, asciicode;
+    while (Cconis() != DEV_BUSY) {
+        unsigned long key_pressed;
+        unsigned char scancode, asciicode;
 
-		key_pressed=Cnecin();
+        key_pressed = Cnecin();
 
-		asciicode = key_pressed;
-		scancode = key_pressed >> 16;
+        asciicode = key_pressed;
+        scancode = key_pressed >> 16;
 
-		gemdos_currentkeyboard[scancode]=0xFF;
-		gemdos_currentascii[scancode]=asciicode;
-	}
+        gemdos_currentkeyboard[scancode] = 0xFF;
+        gemdos_currentascii[scancode] = asciicode;
+    }
+
+    /* Read special keys */
+    UpdateSpecialKeys(Kbshift(-1));
 
-	/* Read special keys */
-	UpdateSpecialKeys(Kbshift(-1));
+    /* Now generate events */
+    for (i = 0; i < ATARIBIOS_MAXKEYS; i++) {
+        /* Key pressed ? */
+        if (gemdos_currentkeyboard[i] && !gemdos_previouskeyboard[i])
+            SDL_PrivateKeyboard(SDL_PRESSED,
+                                TranslateKey(i, gemdos_currentascii[i],
+                                             &keysym, SDL_TRUE));
 
-	/* Now generate events */
-	for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
-		/* Key pressed ? */
-		if (gemdos_currentkeyboard[i] && !gemdos_previouskeyboard[i])
-			SDL_PrivateKeyboard(SDL_PRESSED,
-				TranslateKey(i, gemdos_currentascii[i], &keysym, SDL_TRUE));
-			
-		/* Key unpressed ? */
-		if (gemdos_previouskeyboard[i] && !gemdos_currentkeyboard[i])
-			SDL_PrivateKeyboard(SDL_RELEASED,
-				TranslateKey(i, gemdos_currentascii[i], &keysym, SDL_FALSE));
-	}
+        /* Key unpressed ? */
+        if (gemdos_previouskeyboard[i] && !gemdos_currentkeyboard[i])
+            SDL_PrivateKeyboard(SDL_RELEASED,
+                                TranslateKey(i, gemdos_currentascii[i],
+                                             &keysym, SDL_FALSE));
+    }
 
-	if (use_dev_mouse) {
-		SDL_AtariDevMouse_PostMouseEvents(this, SDL_TRUE);
-	} else {
-		SDL_AtariXbios_PostMouseEvents(this, SDL_TRUE);
-	}
+    if (use_dev_mouse) {
+        SDL_AtariDevMouse_PostMouseEvents(this, SDL_TRUE);
+    } else {
+        SDL_AtariXbios_PostMouseEvents(this, SDL_TRUE);
+    }
 
-	/* Will be previous table */
-	SDL_memcpy(gemdos_previouskeyboard, gemdos_currentkeyboard, ATARIBIOS_MAXKEYS);
+    /* Will be previous table */
+    SDL_memcpy(gemdos_previouskeyboard, gemdos_currentkeyboard,
+               ATARIBIOS_MAXKEYS);
 }
 
-static void UpdateSpecialKeys(int special_keys_state)
+static void
+UpdateSpecialKeys(int special_keys_state)
 {
 #define UPDATE_SPECIAL_KEYS(numbit,scancode) \
 	{	\
@@ -177,37 +185,41 @@
 		}	\
 	}
 
-	UPDATE_SPECIAL_KEYS(K_RSHIFT, SCANCODE_RIGHTSHIFT);
-	UPDATE_SPECIAL_KEYS(K_LSHIFT, SCANCODE_LEFTSHIFT);
-	UPDATE_SPECIAL_KEYS(K_CTRL, SCANCODE_LEFTCONTROL);
-	UPDATE_SPECIAL_KEYS(K_ALT, SCANCODE_LEFTALT);
-	UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK);
+    UPDATE_SPECIAL_KEYS(K_RSHIFT, SCANCODE_RIGHTSHIFT);
+    UPDATE_SPECIAL_KEYS(K_LSHIFT, SCANCODE_LEFTSHIFT);
+    UPDATE_SPECIAL_KEYS(K_CTRL, SCANCODE_LEFTCONTROL);
+    UPDATE_SPECIAL_KEYS(K_ALT, SCANCODE_LEFTALT);
+    UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK);
 }
 
-static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym,
-	SDL_bool pressed)
+static SDL_keysym *
+TranslateKey(int scancode, int asciicode, SDL_keysym * keysym,
+             SDL_bool pressed)
 {
-	/* Set the keysym information */
-	keysym->scancode = scancode;
+    /* Set the keysym information */
+    keysym->scancode = scancode;
 
-	if (asciicode)
-		keysym->sym = asciicode;		
-	else
-		keysym->sym = keymap[scancode];
+    if (asciicode)
+        keysym->sym = asciicode;
+    else
+        keysym->sym = keymap[scancode];
 
-	keysym->mod = KMOD_NONE;
-	keysym->unicode = 0;
-	if (SDL_TranslateUNICODE && pressed) {
-		keysym->unicode = SDL_AtariToUnicodeTable[asciicode];
-	}
+    keysym->mod = KMOD_NONE;
+    keysym->unicode = 0;
+    if (SDL_TranslateUNICODE && pressed) {
+        keysym->unicode = SDL_AtariToUnicodeTable[asciicode];
+    }
 
-	return(keysym);
+    return (keysym);
 }
 
-void AtariGemdos_ShutdownEvents(void)
+void
+AtariGemdos_ShutdownEvents(void)
 {
-	SDL_AtariXbios_RestoreVectors();
-	if (use_dev_mouse) {
-		SDL_AtariDevMouse_Close();
-	}
+    SDL_AtariXbios_RestoreVectors();
+    if (use_dev_mouse) {
+        SDL_AtariDevMouse_Close();
+    }
 }
+
+/* vi: set ts=4 sw=4 expandtab: */