#### Archived

This topic is now archived and is closed to further replies.

# Newbie + DirectInput = This Topic

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

## Recommended Posts

Hey all, I''m trying to create my own 3d engine (like the rest of us ) but suffer from complete newbieism. Every time I try to compile my program, I get the same error messages from DirectInput. I''m sure there is a really simple fix for this, but right now it is beyond me! Any help would be greatly appriciated This is the compile error I keep getting, well a section of it anyway:
input.cpp
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(646) : error C2501: ''UINT_PTR'' : missing decl-specifiers
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(646) : error C2146: syntax error : missing '';'' before identifier ''uAppData''
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(646) : error C2501: ''uAppData'' : missing decl-specifiers
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(658) : error C2501: ''UINT_PTR'' : missing decl-specifiers
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(658) : error C2146: syntax error : missing '';'' before identifier ''uAppData''
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(658) : error C2501: ''uAppData'' : missing decl-specifiers
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(1056) : error C2501: ''UINT_PTR'' : missing decl-specifiers
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(1056) : error C2146: syntax error : missing '';'' before identifier ''uData''
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(1056) : error C2501: ''uData'' : missing decl-specifiers
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(1209) : error C2501: ''UINT_PTR'' : missing decl-specifiers
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(1209) : error C2146: syntax error : missing '';'' before identifier ''uAppData''
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(1209) : error C2501: ''uAppData'' : missing decl-specifiers


##### Share on other sites
Just for the record, I am having this same exact problem. I thought it was my compiler (I am using MSVC++ 4.0), but now that someone else has this problem, there must be a setting that I am overlooking (unless sledge also has an older compiler).

And I am sure it is not my code, because I have tried compiling both ShiningKnight''s game tutorials and the game from "OpenGL Game Programming."

##### Share on other sites
Included windows.h?

##### Share on other sites
Yes, sir, it is the first one included.

##### Share on other sites
Okay. Where is the DXSDK installed on your system? It looks as though it''s grabbing header files from your VC Include directory. That might be the way you intentionally have it set up, but if the most recent DX headers are anywhere else, put the directory first on your directory list for Include Files within the VC IDE.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//

[if you have a link proposal, email me.]

##### Share on other sites
No, it''s not a DX include problem, it''s your old compiler. Include this file: <basetsd.h> and you should be fine.

##### Share on other sites
I'm not sure if it is the old compiler, because I'm using MSVC++ 5.0 (yes, i guess that is still old to, but hey ) and it just wont work. I tried including basetsd.h and though it fixed the previous problem I had, now it gives me unresolved external symbols.

Here is exactly what went wrong:
--------------------Configuration: engine - Win32 Debug--------------------Compiling...main.cppC:\Program Files\DevStudio\VC\INCLUDE\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800engine.cppC:\Program Files\DevStudio\VC\INCLUDE\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800input.cppC:\Program Files\DevStudio\VC\INCLUDE\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800Linking...input.obj : error LNK2001: unresolved external symbol _c_dfDIKeyboardinput.obj : error LNK2001: unresolved external symbol _GUID_SysKeyboardinput.obj : error LNK2001: unresolved external symbol _c_dfDIMouseinput.obj : error LNK2001: unresolved external symbol _GUID_SysMouseinput.obj : error LNK2001: unresolved external symbol _DirectInput8Create@20input.obj : error LNK2001: unresolved external symbol _IID_IDirectInput8A...\bin\debug\engine.exe : fatal error LNK1120: 6 unresolved externalsError executing link.exe.engine.exe - 7 error(s), 0 warning(s)

[edited by - sledge on May 31, 2002 10:55:32 PM]

##### Share on other sites
To fix the DIRECTINPUT_VERSION errors, add this before you include dinput.h:
#define DIRECTINPUT_VERSION 0x0800

To fix the other errors, add dinput8.lib to the linker''s list of libraries.

##### Share on other sites
Possibly
dxguid.lib
also

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//

[if you have a link proposal, email me.]

##### Share on other sites
IndirectX: Thanks, "basetsd.h" did it for me.

Also, does anyone know where the sinf, cosf, and sqrtf functions are located? ShiningKnight uses them in his tutorials but I am getting undeclared indentifier errrors.

And are there any other header files I should include when using an older compiler. It seems like I always get errors when I use code made for 6.0.

##### Share on other sites
The floating point trig functions are not included in VC''s math.h AFAIK. You can use the following substitutes (BTW, they''re considerably faster than the standard versions):
//modified Taylor series sine approximationinline float sinf(float angle){	float sq = angle*angle;	float cu = sq*angle;	float pe = cu*sq;	float se = pe*sq;	float no = se*sq;	float el = no*sq;	return angle-		   0.166666666666f*cu+		   0.008333333333f*pe-		   0.000198412698f*se+		   0.000002755732f*no-		   0.000000025052f*el;}
//modified Taylor series cosine approximationinline float cosf(float angle){	float sq = angle*angle;	float qu = sq*sq;	float he = qu*sq;	float oc = he*sq;	float de = oc*sq;	return 1-		   0.500000000000f*sq+		   0.041666666666f*qu-		   0.001388888888f*he+		   0.000024801587f*oc-		   0.000000275573f*de;}
inline float tan(float angle){	return sinf(angle)/cosf(angle);}

Later,
ZE.

PS: Let me know if there are any issues with those. They''re pinpoint accurate except around the edges (+-180), and BE SURE that your input is in radians and is within the range of -180 to 180 (-2pi to 2pi).

//email me.//zealouselixir software.//msdn.//n00biez.//

[if you have a link proposal, email me.]

##### Share on other sites
The compiler probs should go away if you ensure that the DirectX include and lib dirs are above the others in your compiler options.

How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

##### Share on other sites
Zealous,

Thanks for the code. Where are the standard ones at? I am wondering why ShiningKnight would put them in his tutorial but forget to include the header for them.

Also, do you have a sqrtf function?

##### Share on other sites
inline float sqrtf(float x){	static float error = 0.0001f;	float guess = x;	float result = x;	while(absval(x-guess*guess) > error)	{		guess = result;		result = 0.5f*(guess+x/guess);	}	return result;}

If the floating point functions aren''t in math.h, they aren''t anywhere. Some implementations simply don''t include them. You can always use
int Root = (float)sin((float)Angle);
but that can be slow.

Hope that helps.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//

[if you have a link proposal, email me.]

##### Share on other sites
Oh yeah. You might need this.
inline float absval(float a){	return (a > 0) ? (a) : (-a);}

Pretty standard fare.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//

[if you have a link proposal, email me.]

##### Share on other sites
Thanks again for all the code, Zealous. I will assume they work wonders, but I won''t be able to see for myself until I get this code to compile. Check out this error:

  --------------------Configuration: Shining3D - Win32 Debug--------------------Linking...LINK : fatal error LNK1000: unknown error; consult documentation for technical support optionsError executing link.exe.Shining3D.exe - 1 error(s), 0 warning(s)

At first I was getting an error that it could not open "dxguid.lib," so I changed the project options to include the MSSDK library folder. Then the error changed into the one above. Any ideas?

##### Share on other sites
Try rewriting your code. Simplify complex statements, use temporary variables or typedefs, break large functions into smaller ones.

##### Share on other sites
I''m assuming you''ve tried doing a Rebuild All.

##### Share on other sites
those sin/cos/tan approximations look quite interesting..
just wondering if they require the input value to be in the 0-2pi range?

alo..

I was under the impression that the generic cos/sin/tan calls were already fairly fast as they used lookup tables.. (since the real sin/cos forumlas are infinite... - well. I think they are)

or am I missing something?

##### Share on other sites
quote:
Original post by RipTorn
those sin/cos/tan approximations look quite interesting..
just wondering if they require the input value to be in the 0-2pi range?

quote:
Previously, I said,
PS: Let me know if there are any issues with those. They''re pinpoint accurate except around the edges (+-180), and BE SURE that your input is in radians and is within the range of -180 to 180 (-2pi to 2pi).

quote:
Said RipTorn,
I was under the impression that the generic cos/sin/tan calls were already fairly fast as they used lookup tables.. (since the real sin/cos forumlas are infinite... - well. I think they are)
or am I missing something?

Many sines are irrational. However, both the standard functions and my implementations generate very accurate approximations. Mine are marginally faster, and no, the standard versions do NOT use lookup tables.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//

[if you have a link proposal, email me.]

##### Share on other sites
Yes, I have tried doing a Rebuild All.

##### Share on other sites
I have 0 experience with VC5. There are probably service packs available for it, if the problem is mendable. Otherwise, I really can''t help except to suggest that you try it on another compiler.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//

[if you have a link proposal, email me.]

##### Share on other sites
I''ve been thinking about upgrading, so I guess now is the time. I would buy VC++.NET but it needs NT (or XP, I think), while I am using Windows ME. Can you still purchase VC++ 6.0 new?