2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
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.
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.
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
25 "@(#) $Id: libsdl-1.2.11-libcaca.patch,v 1.1 2006/09/18 16:06:06 mr_bones_ Exp $";
31 #ifdef CACA_API_VERSION_1
36 #include "../../events/SDL_sysevents.h"
37 #include "../../events/SDL_events_c.h"
38 #include "SDL_cacavideo.h"
39 #include "SDL_cacaevents_c.h"
41 void Caca_PumpEvents(_THIS)
47 if( ! this->screen ) /* Wait till we got the screen initialised */
53 /* Get libcaca event */
54 SDL_mutexP(Caca_mutex);
55 event = caca_get_event(CACA_EVENT_ANY);
56 SDL_mutexV(Caca_mutex);
58 if ( event & (CACA_EVENT_KEY_PRESS | CACA_EVENT_KEY_RELEASE)) {
60 switch ( event & 0xffffff )
62 case CACA_KEY_LEFT: key = SDLK_LEFT; break;
63 case CACA_KEY_RIGHT: key = SDLK_RIGHT; break;
64 case CACA_KEY_UP: key = SDLK_UP; break;
65 case CACA_KEY_DOWN: key = SDLK_DOWN; break;
66 default: key = event & 0xff; break;
69 /* printf("Key pressed: %d (%c)\n", key, key); */
70 keysym.scancode = key;
72 keysym.mod = KMOD_NONE;
74 if ( SDL_TranslateUNICODE ) {
77 posted += SDL_PrivateKeyboard((event & CACA_EVENT_KEY_PRESS) ? SDL_PRESSED : SDL_RELEASED, &keysym);
79 else if ( event & (CACA_EVENT_MOUSE_PRESS | CACA_EVENT_MOUSE_RELEASE) ) {
80 /* FIXME: we currently ignore the button type! */
81 int button = event & 0x00ffffff;
85 posted += SDL_PrivateMouseButton((event & CACA_EVENT_MOUSE_PRESS) ? SDL_PRESSED : SDL_RELEASED, button, 0, 0);
87 else if ( event & CACA_EVENT_MOUSE_MOTION ) {
88 int new_x = 0, new_y = 0;
89 new_x = ((event & 0x00fff000) >> 12) * Caca_w / caca_get_width();
90 new_y = ((event & 0x00000fff) >> 0) * Caca_h / caca_get_height();
91 posted += SDL_PrivateMouseMotion(0, 0, new_x, new_y);
96 void Caca_InitOSKeymap(_THIS)