1/*
2    SDL - Simple DirectMedia Layer
3    Copyright (C) 1997-2012 Sam Lantinga
4
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
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    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with this library; if not, write to the Free Software
17    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
19    Sam Lantinga
20    slouken@libsdl.org
21*/
22#include "SDL_config.h"
23
24/* Being a nds driver, there's no event stream. We just define stubs for
25   most of the API. */
26#include <nds.h>
27#include "SDL.h"
28#include "../../events/SDL_sysevents.h"
29#include "../../events/SDL_events_c.h"
30#include "SDL_ndsvideo.h"
31#include "SDL_ndsevents_c.h"
32
33static SDLKey keymap[NDS_NUMKEYS];
34char keymem[NDS_NUMKEYS];	/* memorize states of buttons */
35
36void NDS_PumpEvents(_THIS)
37{
38	scanKeys();
39	int i;
40	SDL_keysym keysym;
41	keysym.mod=KMOD_NONE;
42	for(i=0;i<NDS_NUMKEYS;i++)
43	{
44		keysym.scancode=i;
45		keysym.sym=keymap[i];
46		if(keysHeld()&(1<<i) && !keymem[i])
47		{
48			keymem[i]=1;
49			//printf("key released %d\n",i);
50			SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
51		}
52		if(!(keysHeld()&(1<<i)) && keymem[i])
53		{
54			keymem[i]=0;
55			//printf("key pressed %d\n",i);
56			SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
57		}
58	}
59	//touchPosition touch;
60	//touch=touchReadXY();
61	//if (touch.px!=0 || touch.py!=0)
62	//	SDL_PrivateMouseMotion(SDL_PRESSED, 0, touch.px, touch.py);
63}
64
65void NDS_InitOSKeymap(_THIS)
66{
67	SDL_memset(keymem,1,NDS_NUMKEYS);
68	keymap[KEY_A]=SDLK_a;
69	keymap[KEY_B]=SDLK_s;
70	keymap[KEY_X]=SDLK_w;
71	keymap[KEY_Y]=SDLK_d;
72	keymap[KEY_L]=SDLK_q;
73	keymap[KEY_R]=SDLK_e;
74	keymap[KEY_UP]=SDLK_UP;
75	keymap[KEY_DOWN]=SDLK_DOWN;
76	keymap[KEY_LEFT]=SDLK_LEFT;
77	keymap[KEY_RIGHT]=SDLK_RIGHT;
78	keymap[KEY_SELECT]=SDLK_SPACE;
79	keymap[KEY_START]=SDLK_RETURN;
80}
81
82/* end of SDL_gbaevents.c ... */
83
84