From ad8ffb96789f90180982b344540870a2d4e2d60b Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 31 May 2018 08:12:40 +0800 Subject: init --- .../SDL/src/video/directfb/SDL_DirectFB_events.c | 219 +++++++++++++++++++++ 1 file changed, 219 insertions(+) create mode 100644 3rdparty/SDL/src/video/directfb/SDL_DirectFB_events.c (limited to '3rdparty/SDL/src/video/directfb/SDL_DirectFB_events.c') diff --git a/3rdparty/SDL/src/video/directfb/SDL_DirectFB_events.c b/3rdparty/SDL/src/video/directfb/SDL_DirectFB_events.c new file mode 100644 index 0000000..246b75b --- /dev/null +++ b/3rdparty/SDL/src/video/directfb/SDL_DirectFB_events.c @@ -0,0 +1,219 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* Handle the event stream, converting DirectFB input events into SDL events */ + +#include +#include +#include +#include +#include + +#include + +#include "SDL.h" +#include "../SDL_sysvideo.h" +#include "../../events/SDL_sysevents.h" +#include "../../events/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); + } + else if (evt.flags & DIEF_AXISABS) + { + static int last_x, last_y; + if (evt.axis == DIAI_X) + last_x = evt.axisabs; + else if (evt.axis == DIAI_Y) + last_y = evt.axisabs; + posted += SDL_PrivateMouseMotion(0, 0, last_x, last_y); + } + 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 - DIKI_UNKNOWN]; + + 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; + } +} -- cgit v1.1-26-g67d0