Strange Direct Input Behaviour

This is a discussion on Strange Direct Input Behaviour within the Windows Programming forums, part of the Platform Specific Boards category; I've made a program using Direct Input from this webpage: . Using their tutorials and code, I've been able ...

  1. #1
    Registered User Diamonds's Avatar
    Join Date
    Oct 2002

    Strange Direct Input Behaviour

    I've made a program using Direct Input from this webpage: . Using their tutorials and code, I've been able to map keys to do different things.

    The code works with an array to detect keys pressed with these two datastructures:

    enum Actions 
    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.

    The code runs some function called ConfigureInput which shows a display box using the windows GUI where you can tell different keys to do different actions within the program.

    // Display the input configuration box
    BOOL ConfigureInput()
        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
        // Display action configuration
        g_pDI->ConfigureDevices(NULL, &dicdp, DICD_EDIT, NULL);
        // Devices are no longer valid, so reinitialise.
        for (int iDevice = 0; iDevice < g_nDevices; iDevice++)
        delete [] g_pDeviceArray;
        g_pDeviceArray = NULL;
        g_nDevices = 0;
        HRESULT h = g_pDI->EnumDevicesBySemantics(NULL, &g_diaf, 
        if (FAILED(h))
            return FALSE;
        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.

    Well, the crazy part is that the program somehow REMEMBERS that I've mapped the "ERROR" control to the 'e' key when I restart the program. Even more crazy is that if I now take the .exe to a different computer, it knows that 'e' is mapped to "ERROR" as well. Which doesn't make any since because the GUI in which you map keys is contained and is part of the program which responds to those mapped keys! HOW DOES IT REMEMBER? I can even re-compile the thing and it remembers.

    Last edited by Diamonds; 06-20-2003 at 03:24 AM.

  2. #2
    Registered User Diamonds's Avatar
    Join Date
    Oct 2002

  3. #3
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Isn't bumping your thread against board rules?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Direct Input: Mouse->Acquire
    By Epo in forum Game Programming
    Replies: 7
    Last Post: 09-12-2004, 08:46 PM
  2. h/w help
    By helpme in forum C Programming
    Replies: 20
    Last Post: 10-21-2003, 10:36 AM
  3. GetClientRect strange behaviour
    By btq in forum Windows Programming
    Replies: 2
    Last Post: 10-02-2002, 03:13 PM
  4. Strange behaviour
    By PrivatePanic in forum Windows Programming
    Replies: 11
    Last Post: 07-23-2002, 01:54 AM
  5. strange behaviour by rhide
    By ustuzou in forum C++ Programming
    Replies: 0
    Last Post: 03-17-2002, 11:31 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21