Hello, recently I have started to learn directX, using the Dev-cpp IDE with MingW. For the lessons and samples about Direct3D theres no problem (all works fine), but when I start with DirectInput it seems that something isn't working properly (or maybe I fail to include-link-define something. That is what I do: I set up the linker options with all the libs (*.a in devcpp) that the 'setup dev-cpp for dx' manual says (libd3d8.a, libd3dx8d.a, libgdi32.a, libdxguid.a, libddraw.a, libdinput.a, libdinput8.a, also the winmm.a for the timeGetTime() function); then I use
Then I use some structures for the DirectInput object and devices:Code:#define INITGUID #define STRICT #define WIN32_LEAN_AND_MEAN #define DIRECTINPUT_VERSION 0x0800 #include <windows.h> #include <D3DX8.h> #include <dinput.h>
but on de compilation it appears the error "syntax error before '='" referred to those 3 lines above, even if I declare them as 'LPDIRECTINPUT8 g_lpdi;' the error is "syntax error before ';'", so that means that the 'LPDIRECTINPUT8' is not defined (no?); I have opened the dinput.h include file from the DX8 includes dir inside the 'includes' dir of dev-cpp, and there is thatCode:LPDIRECTINPUT8 g_lpdi = NULL; // DirectInput object LPDIRECTINPUTDEVICE8 g_pKeyboard = NULL; // DirectInput device for keyboard LPDIRECTINPUTDEVICE8 g_pMouse = NULL; // DirectInput device for mouse
structure declared as
I have find another similar structures named 'LPDIRECTINPUT', 'LPDIRECTINPUTDEVICE', I tried to work with them and there's any error, the program is right compiled.Code:typedef struct IDirectInput8 *LPDIRECTINPUT8;
Then continuing with the DirectInput lesson I have to set up the object, using the 'DirectInput8Create()' function, using the next code:
but the compiler shows the error "'IID_IDirectInput8' undeclared (first use this function)"; it seems like that function haven't prototype, so I must define previously it: 'void IID_IDirectInput8();', recompile the code and now I haven't the last error but get a new one: "implicit declaration of function `int DirectInput8Create(...)'"; I research inside dinput.h and there is that function:Code:DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&g_lpdi, NULL);
ok, as far as I defined '#define DIRECTINPUT_VERSION 0x0800' I shoud use that function; I opted to try using 'DirectInputCreate()' instead 'DirectInput8Create()':Code:#if DIRECTINPUT_VERSION > 0x0700 extern HRESULT WINAPI DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter); #else extern HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter); extern HRESULT WINAPI DirectInputCreateW(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTW *ppDI, LPUNKNOWN punkOuter); #ifdef UNICODE #define DirectInputCreate DirectInputCreateW #else #define DirectInputCreate DirectInputCreateA #endif
and now the error is : "passing `void (*)()' as argument 3 of `DirectInputCreateA(HINSTANCE__ *, long unsigned int, IDirectInputA **, IUnknown *)'"; right look at dinput.h I see that I have to use the parameters on 'DirectInputCreateA()' function, so I change all into:Code:DirectInputCreate(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&g_lpdi, NULL);
and there's no compiler errors. For me, it seems a strange thing: all the Direct3D on DX8 works well as the original code (also the samples for DX9 works well with a minimal variations), but DirectInput needs so strange variations?Code://as a global definition LPDIRECTINPUTA *ppDI; //and the function DirectInputCreate(GetModuleHandle(NULL), DIRECTINPUT_VERSION, ppDI, NULL);
Have someone got those problems? Still another, must that direct input creation style affect on the program working? (I have stop here following the lesson, becasue I'm afraid that that modification can cause future problems).
Thank's in advance, and sorry for the large and boring post
Niara(vosk)



LinkBack URL
About LinkBacks


