Code:
enum Actions
{
ACTIONS_LEFTRIGHT,
ACTIONS_LEFT,
ACTIONS_RIGHT,
ACTIONS_UP,
ACTIONS_DOWN,
ACTIONS_QUIT,
ACTIONS_HELP,
ACTIONS_PAUSE,
ACTIONS_ERROR,
ACTIONS_NONE
};
DIACTION g_rgActions[] =
{
// Genre-defined virtual axes
{ ACTIONS_LEFTRIGHT, DIAXIS_ARCADES_LATERAL, 0, "Left/Right" },
// Actions mapped to keys as well as to virtual controls
{ ACTIONS_LEFT, DIKEYBOARD_LEFT, 0, "Left" },
{ ACTIONS_LEFT, DIKEYBOARD_NUMPAD4, 0, "Left" },
{ ACTIONS_RIGHT, DIKEYBOARD_RIGHT, 0, "Right" },
{ ACTIONS_RIGHT, DIKEYBOARD_NUMPAD6, 0, "Right" },
{ ACTIONS_UP, DIKEYBOARD_UP, 0, "Up" },
{ ACTIONS_UP, DIKEYBOARD_NUMPAD8, 0, "Up" },
{ ACTIONS_DOWN, DIKEYBOARD_DOWN, 0, "Down" },
{ ACTIONS_DOWN, DIKEYBOARD_NUMPAD2, 0, "Down" },
{ ACTIONS_PAUSE, DIKEYBOARD_P, 0, "Pause" },
{ ACTIONS_HELP, DIKEYBOARD_F1, 0, "Help" },
{ ACTIONS_ERROR, DIKEYBOARD_E, 0, "ERROR" },
// Actions mapped to keys
{ ACTIONS_QUIT, DIKEYBOARD_ESCAPE, DIA_APPFIXED, "Quit" },
};
Using the simple format, I've added the ACTION_ERROR key which is suppost to keymap to the E key. However when the program is run, hitting E does nothing.
Code:
// Display the input configuration box
BOOL ConfigureInput()
{
DICONFIGUREDEVICESPARAMS dicdp;
ZeroMemory(&dicdp, sizeof(dicdp));
dicdp.dwSize = sizeof(dicdp);
dicdp.dwcUsers = 1;
dicdp.lptszUserNames = NULL;
dicdp.dwcFormats = 1;
dicdp.lprgFormats = &g_diaf;
dicdp.hwnd = hWndMain;
dicdp.lpUnkDDSTarget = NULL;
// Set up a colour set, which will allow us to make the configuration box
// look like the rest of our program.
// If this is initialised to zero, DirectInput will use the default colour set.
dicdp.dics.dwSize = sizeof(DICOLORSET);
// Let go of any devices so that the configuration interface can have a go
UnacquireDevices();
// Display action configuration
g_pDD->FlipToGDISurface();
g_pDI->ConfigureDevices(NULL, &dicdp, DICD_EDIT, NULL);
// Devices are no longer valid, so reinitialise.
for (int iDevice = 0; iDevice < g_nDevices; iDevice++)
g_pDeviceArray[iDevice]->Release();
delete [] g_pDeviceArray;
g_pDeviceArray = NULL;
g_nDevices = 0;
HRESULT h = g_pDI->EnumDevicesBySemantics(NULL, &g_diaf,
DIEnumDevicesBySemanticsCallback,
NULL, DIEDBSFL_ATTACHEDONLY);
if (FAILED(h))
return FALSE;
AcquireDevices();
return TRUE;
}
Well, reviewing this shows that the E key is NOT mapped to anything, so using the GUI while the program is running I manually set "ERROR" to the 'e' key. Exiting the windows GUI and letting the main program run shows that the 'e' key will do as it is suppost to.