I have a problem when I want to add a keybaordbutton to the action maps
I don't really know this suff, I started from sunlights tutorial and added things I need along the way. Now I want to add a stuff when the user presses the space bar I did exactlye the same as Sunlight did for the ESCAPE key, but it isn't working
Did I forget something? this is what I did:
Code:
GUID g_guidApp =
{ 0xbd0e8406, 0xfb56, 0x4322, { 0x8b, 0xc6, 0xbd, 0x6e, 0x48, 0x1f, 0x55, 0x64 } };
DWORD g_dwGenre = DIVIRTUAL_ARCADE_SIDE2SIDE;
LPCTSTR g_tszActionMapName = _T("Sample");
enum Actions
{ ACTIONS_SHOOT, //Mine
ACTIONS_LEFTRIGHT,
ACTIONS_LEFT,
ACTIONS_RIGHT,
ACTIONS_QUIT,
ACTIONS_NONE
};
bool g_bQuit;
bool g_bLeft, g_bRight;
bool g_bshoot; //mine
DIACTION g_rgActions[] =
{
// Genre-defined virtual axes
{ ACTIONS_LEFTRIGHT, DIAXIS_ARCADES_LATERAL, 0, "Left/Right" },
{ ACTIONS_SHOOT, DIKEYBOARD_A, 0, "shoot" }, //Mine
// Actions mapped to keys as well as to virtual controls
{ ACTIONS_LEFT, DIKEYBOARD_LEFT, 0, "Left" },
{ ACTIONS_RIGHT, DIKEYBOARD_RIGHT, 0, "Right" },
// Actions mapped to keys
{ ACTIONS_QUIT, DIKEYBOARD_ESCAPE, 0, "Quit" },
};
DWORD g_nActions = sizeof(g_rgActions) / sizeof(DIACTION);
////////////////////////////////////////////////////////////////////////////////
// Input handling
#define AXIS_THRESHOLD 20
void HandleAction(UINT nAction, DWORD dwData)
{
int nAxisPos = (int)dwData;
switch (nAction)
{
case ACTIONS_LEFTRIGHT:
if (nAxisPos < -AXIS_THRESHOLD)
{
g_bLeft = true;
g_bRight = false;
}
else if (nAxisPos > AXIS_THRESHOLD)
{
g_bRight = true;
g_bLeft = false;
}
else
{
g_bLeft = g_bRight = false;
}
break;
case ACTIONS_SHOOT: //Mine
if (dwData != 0)
g_bshoot = true;
break;
case ACTIONS_LEFT:
g_bLeft = (dwData != 0);
break;
case ACTIONS_RIGHT:
g_bRight = (dwData != 0);
g_bshoot = true;
break;
case ACTIONS_QUIT:
g_bQuit = true;
break;
default:
break;
}
}
What did I miss?
thx
-- Maes