File:  [RetroPC.NET] / xmil / nds / win32s / ndsinput.cpp
Revision 1.1: download - view: text, annotated - select for diffs
Tue Mar 24 22:52:53 2009 JST (16 years, 7 months ago) by yui
Branches: MAIN
CVS tags: HEAD
add nds-win32 simulation project

#include "compiler.h"
#include "libnds.h"


struct tagKeyBind
{
	UINT16 wKey;
	UINT16 wBit;
};

static const tagKeyBind keybind[10] =
{
	{'X',			KEY_A},
	{'Z',			KEY_B},
	{'A',			KEY_SELECT},
	{'S',			KEY_START},
	{VK_RIGHT,		KEY_RIGHT},
	{VK_LEFT,		KEY_LEFT},
	{VK_UP,			KEY_UP},
	{VK_DOWN,		KEY_DOWN},
	{'W',			KEY_R},
	{'Q',			KEY_L},
};

	UINT16 g_wKeyReg;

// ----

void ndsinput_initialize()
{
	REG_KEYINPUT = 0xffff;
}

void ndsinput_keydown(UINT16 wKey)
{
	const tagKeyBind *pKb = keybind;
	const tagKeyBind *pKbEnd = keybind + NELEMENTS(keybind);
	do
	{
		if (wKey == pKb->wKey)
		{
			REG_KEYINPUT &= ~pKb->wBit;
			break;
		}
		pKb++;
	} while(pKb < pKbEnd);
}

void ndsinput_keyup(UINT16 wKey)
{
	const tagKeyBind *pKb = keybind;
	const tagKeyBind *pKbEnd = keybind + NELEMENTS(keybind);
	do
	{
		if (wKey == pKb->wKey)
		{
			REG_KEYINPUT |= pKb->wBit;
			break;
		}
		pKb++;
	} while(pKb < pKbEnd);
}


RetroPC.NET-CVS <cvs@retropc.net>