annotate src/video/caca/SDL_cacaevents.c @ 5103:3500563bb2f8 SDL-1.2

Ozkan Sezer to slouken The attached small patch updates SDL's libtoolized files for pe-x86_64 magic, ie win/x64.
author Sam Lantinga <slouken@libsdl.org>
date Wed, 26 Jan 2011 12:26:27 -0800
parents d1c0ac95d023
children
rev   line source
4315
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Library General Public License for more details.
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 #ifdef SAVE_RCSID
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 static char rcsid =
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 "@(#) $Id: libsdl-1.2.11-libcaca.patch,v 1.1 2006/09/18 16:06:06 mr_bones_ Exp $";
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 #endif
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 #include <stdio.h>
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 #include <caca.h>
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 #ifdef CACA_API_VERSION_1
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 #include <caca0.h>
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 #endif
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 #include "SDL.h"
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 #include "../../events/SDL_sysevents.h"
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 #include "../../events/SDL_events_c.h"
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 #include "SDL_cacavideo.h"
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 #include "SDL_cacaevents_c.h"
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 void Caca_PumpEvents(_THIS)
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 {
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 int posted = 0;
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 int event;
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 SDL_keysym keysym;
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 if( ! this->screen ) /* Wait till we got the screen initialised */
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 return;
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 do {
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 posted = 0;
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 /* Get libcaca event */
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 SDL_mutexP(Caca_mutex);
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 event = caca_get_event(CACA_EVENT_ANY);
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 SDL_mutexV(Caca_mutex);
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 if ( event & (CACA_EVENT_KEY_PRESS | CACA_EVENT_KEY_RELEASE)) {
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 int key;
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 switch ( event & 0xffffff )
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 {
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 case CACA_KEY_LEFT: key = SDLK_LEFT; break;
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 case CACA_KEY_RIGHT: key = SDLK_RIGHT; break;
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 case CACA_KEY_UP: key = SDLK_UP; break;
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 case CACA_KEY_DOWN: key = SDLK_DOWN; break;
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 default: key = event & 0xff; break;
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 }
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 /* Key pressed */
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 /* printf("Key pressed: %d (%c)\n", key, key); */
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 keysym.scancode = key;
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 keysym.sym = key;
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 keysym.mod = KMOD_NONE;
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 keysym.unicode = 0;
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 if ( SDL_TranslateUNICODE ) {
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 keysym.unicode = key;
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 }
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 posted += SDL_PrivateKeyboard((event & CACA_EVENT_KEY_PRESS) ? SDL_PRESSED : SDL_RELEASED, &keysym);
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 }
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 else if ( event & (CACA_EVENT_MOUSE_PRESS | CACA_EVENT_MOUSE_RELEASE) ) {
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 /* FIXME: we currently ignore the button type! */
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 int button = event & 0x00ffffff;
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 if ( button > 3 ) {
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 button = 1;
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 }
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 posted += SDL_PrivateMouseButton((event & CACA_EVENT_MOUSE_PRESS) ? SDL_PRESSED : SDL_RELEASED, button, 0, 0);
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 }
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 else if ( event & CACA_EVENT_MOUSE_MOTION ) {
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 int new_x = 0, new_y = 0;
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 new_x = ((event & 0x00fff000) >> 12) * Caca_w / caca_get_width();
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 new_y = ((event & 0x00000fff) >> 0) * Caca_h / caca_get_height();
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 posted += SDL_PrivateMouseMotion(0, 0, new_x, new_y);
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 }
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 } while ( posted );
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 }
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 void Caca_InitOSKeymap(_THIS)
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 {
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 return;
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 }
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100
d1c0ac95d023 Added missing caca files
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101