DirectInput setup in Delphi

Started by
-1 comments, last by hanykom 14 years, 4 months ago
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. (To Admins: Sorry I made two same topics, because first I didn't noticed that I was in wrong category.) 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;

This topic is closed to new replies.

Advertisement