• Advertisement
Sign in to follow this  

DirectInput Setup in Delphi

This topic is 2999 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello guys, I'm trying to setup a DirectInput in Delphi, but no success. I've found thread here on gamdev http://www.gamedev.net/community/forums/topic.asp?topic_id=41630&whichpage=1𲠂 which is very realtive to my problem. Please very much, could anyone post here some resource code what would solve my problem. I'm posting my wrong code fragment. From what I know it's probably problem in the DirectInput(8)Create function which needs as a third parameter a pointer to the instance which has to be initialized by that, but when I set a pointer, Delphi alerts that there must be same types of actual and formal parametres and when I set directly variable of that instance (g_lpDirectInput) program can be compiled, but the DirectInput is initialized neither. Please help, what to do. g_lpDirectInput: IDirectInput; //mozna sem patri jako typ neco jineho g_plpDirectInput: ^IDirectInput; g_lpDIDevice: IDirectInputDevice; //tady mozna taky function InitDirectInput(l_hinst:Cardinal;hWnd:HWND): HRESULT; begin Result:= E_FAIL; //s tim ukazatelem to stejne taky nefunguje g_plpDirectInput:=@g_lpDirectInput; //vytvoreni instance DirectInput { Result:=DirectInput8Create(l_hinst, DIRECTINPUT_VERSION, IID_IDirectInput8, g_plpDirectInput, nil);} Result:=DirectInputCreate(l_hinst, DIRECTINPUT_VERSION, g_lpDirectInput, nil); if FAILED(Result)then begin Result:= E_FAIL; Exit; end; //vytvoreni DirectInput zarizeni - Klavesnice Result := g_lpDirectInput.CreateDevice(GUID_SysKeyboard, g_lpDIDevice, nil); if FAILED(Result)then begin Result:= E_FAIL; Exit; end; //nastaveni datoveho formatu klavesnice Result := g_lpDIDevice.SetDataFormat(c_dfDIKeyboard); if FAILED(Result)then begin Result:= E_FAIL; Exit; end; //nastaveni chovani klavesnice Result := g_lpDIDevice.SetCooperativeLevel(hWnd, DISCL_FOREGROUND or DISCL_NONEXCLUSIVE); if FAILED(Result)then begin Result:= E_FAIL; Exit; end; //ziskani pristupu k zarizeni Result := g_lpDIDevice.Acquire(); if FAILED(Result)then begin Result:= E_FAIL; Exit; end; Result:=S_OK; end;

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement