19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*
29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    SDL - Simple DirectMedia Layer
39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Copyright (C) 1997-2012 Sam Lantinga
49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    This library is free software; you can redistribute it and/or
69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    modify it under the terms of the GNU Lesser General Public
79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    License as published by the Free Software Foundation; either
89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    version 2.1 of the License, or (at your option) any later version.
99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    This library is distributed in the hope that it will be useful,
119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    but WITHOUT ANY WARRANTY; without even the implied warranty of
129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Lesser General Public License for more details.
149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    You should have received a copy of the GNU Lesser General Public
169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    License along with this library; if not, write to the Free Software
179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Sam Lantinga
209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    slouken@libsdl.org
219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/
229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_config.h"
239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Being a nds driver, there's no event stream. We just define stubs for
259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall   most of the API. */
269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <nds.h>
279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL.h"
289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../../events/SDL_sysevents.h"
299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../../events/SDL_events_c.h"
309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_ndsvideo.h"
319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_ndsevents_c.h"
329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDLKey keymap[NDS_NUMKEYS];
349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallchar keymem[NDS_NUMKEYS];	/* memorize states of buttons */
359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid NDS_PumpEvents(_THIS)
379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	scanKeys();
399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	int i;
409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	SDL_keysym keysym;
419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	keysym.mod=KMOD_NONE;
429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	for(i=0;i<NDS_NUMKEYS;i++)
439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	{
449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keysym.scancode=i;
459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		keysym.sym=keymap[i];
469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		if(keysHeld()&(1<<i) && !keymem[i])
479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		{
489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			keymem[i]=1;
499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			//printf("key released %d\n",i);
509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		}
529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		if(!(keysHeld()&(1<<i)) && keymem[i])
539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		{
549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			keymem[i]=0;
559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			//printf("key pressed %d\n",i);
569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall			SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall		}
589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	}
599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	//touchPosition touch;
609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	//touch=touchReadXY();
619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	//if (touch.px!=0 || touch.py!=0)
629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	//	SDL_PrivateMouseMotion(SDL_PRESSED, 0, touch.px, touch.py);
639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid NDS_InitOSKeymap(_THIS)
669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	SDL_memset(keymem,1,NDS_NUMKEYS);
689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	keymap[KEY_A]=SDLK_a;
699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	keymap[KEY_B]=SDLK_s;
709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	keymap[KEY_X]=SDLK_w;
719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	keymap[KEY_Y]=SDLK_d;
729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	keymap[KEY_L]=SDLK_q;
739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	keymap[KEY_R]=SDLK_e;
749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	keymap[KEY_UP]=SDLK_UP;
759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	keymap[KEY_DOWN]=SDLK_DOWN;
769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	keymap[KEY_LEFT]=SDLK_LEFT;
779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	keymap[KEY_RIGHT]=SDLK_RIGHT;
789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	keymap[KEY_SELECT]=SDLK_SPACE;
799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall	keymap[KEY_START]=SDLK_RETURN;
809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* end of SDL_gbaevents.c ... */
839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
84