/* SDL - Simple DirectMedia Layer Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Sam Lantinga slouken@libsdl.org */ #ifdef SAVE_RCSID static char rcsid = "@(#) $Id$"; #endif /* Handle the event stream, converting DirectFB input events into SDL events */ #include #include #include #include #include #include #include #include #include "SDL.h" #include "SDL_sysevents.h" #include "SDL_sysvideo.h" #include "SDL_events_c.h" #include "SDL_DirectFB_video.h" #include "SDL_DirectFB_events.h" /* The translation tables from a DirectFB keycode to a SDL keysym */ static SDLKey keymap[256]; static SDL_keysym *DirectFB_TranslateKey (DFBInputEvent *ev, SDL_keysym *keysym); static int DirectFB_TranslateButton (DFBInputEvent *ev); static int posted = 0; void DirectFB_PumpEvents (_THIS) { DFBInputEvent evt; while (HIDDEN->eventbuffer->GetEvent (HIDDEN->eventbuffer, DFB_EVENT (&evt)) == DFB_OK) { SDL_keysym keysym; switch (evt.type) { case DIET_BUTTONPRESS: posted += SDL_PrivateMouseButton(SDL_PRESSED, DirectFB_TranslateButton (&evt), 0, 0); break; case DIET_BUTTONRELEASE: posted += SDL_PrivateMouseButton(SDL_RELEASED, DirectFB_TranslateButton (&evt), 0, 0); break; case DIET_KEYPRESS: posted += SDL_PrivateKeyboard(SDL_PRESSED, DirectFB_TranslateKey(&evt, &keysym)); break; case DIET_KEYRELEASE: posted += SDL_PrivateKeyboard(SDL_RELEASED, DirectFB_TranslateKey(&evt, &keysym)); break; case DIET_AXISMOTION: if (evt.flags & DIEF_AXISREL) { if (evt.axis == DIAI_X) posted += SDL_PrivateMouseMotion(0, 1, evt.axisrel, 0); else if (evt.axis == DIAI_Y) posted += SDL_PrivateMouseMotion(0, 1, 0, evt.axisrel); } break; default: ; } } } void DirectFB_InitOSKeymap (_THIS) { int i; /* Initialize the DirectFB key translation table */ for (i=0; iscancode = ev->key_id; keysym->mod = KMOD_NONE; /* FIXME */ keysym->unicode = (DFB_KEY_TYPE (ev->key_symbol) == DIKT_UNICODE) ? ev->key_symbol : 0; if (ev->key_symbol > 0 && ev->key_symbol < 128) keysym->sym = ev->key_symbol; else keysym->sym = keymap[ev->key_id]; return keysym; } static int DirectFB_TranslateButton (DFBInputEvent *ev) { switch (ev->button) { case DIBI_LEFT: return 1; case DIBI_MIDDLE: return 2; case DIBI_RIGHT: return 3; default: return 0; } }