Skip to main content
gamedev.net
🔒 Locked

DirectInput8Create problem

Started by akdjr Apr 13, 2002 at 7:11 PM 1 replies 900+ views
Original Post
akdjr
akdjr
ok, i''m using DirectInput8 for my game and i am having a very annoying problem. i have the runtimes and the sdk installed properly. basically, when i call DirectInput8Create in my initialization function, it fails and doesn''t return any of the error codes in the MS documentation. here is the snippet of my function: bool cInputSystem::Initalize(HWND hWnd, HINSTANCE hInstance) { HRESULT retVal; retVal = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)lpDI, NULL); if (retVal != DI_OK) { switch (retVal) { case DIERR_BETADIRECTINPUTVERSION: { MessageBox(hWnd, "DIERR_BETADIRECTINPUTVERSION", "ERROR", MB_OK); break; } case DIERR_INVALIDPARAM: { MessageBox(hWnd, "DIERR_INVALIDPARAM", "ERROR", MB_OK); break; } case DIERR_OLDDIRECTINPUTVERSION: { MessageBox(hWnd, "DIERR_OLDDIRECTINPUTVERSION", "ERROR", MB_OK); break; } case DIERR_OUTOFMEMORY: { MessageBox(hWnd, "DIERR_OUTOFMEMORY", "ERROR", MB_OK); break; } default: { MessageBox(hWnd, "Unknown DirectInput Creation Error", "ERROR", MB_OK); break; } } return false; } keyboard = new cKeyboard(lpDI, hWnd); mouse = new cMouse(lpDI, hWnd); if (!keyboard || !mouse) { MessageBox(hWnd, "Couldn''t Create keyboard and mouse!", "ERROR", MB_OK); return false; } return true; } basically the result that it gives me is "Unknown DirectInput Creation Error", so i have no idea why it is screwing up, or even how for that matter. any ideas? if you need to see some more snippets, just tell me. thanks!
intransigent-seal
intransigent-seal
This is a weird one. Try checking for a DIERR_GENERIC result to see if it''s actually an unknown error. If it isn''t that, then keep adding possible results to your case statement until you find the culprit.
You might want to check for DIERR_ALREADYINITIALIZED as well.

John B
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.
akdjr
akdjr
LOL!!!
i just figured it out!
i forgot to pass the DIRECTINPUT8 structure by reference.
--> retVal = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&lpDI, NULL);

this is why i never liked DirectX that much - wayyy too many pointers, but meh.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.