Skip to main content
gamedev.net
🔒 Locked

DInput Question - - -

Started by IOStream Nov 30, 2001 at 5:24 PM 10 replies 1.4k views
Original Post
IOStream
IOStream
I have this error, "''DirectInputCreate'' : undeclared identifier", which is keeping me from compiling a demo from Andre Lamothe''s TWGPG. I have included DINPUT.LIB in the Project Settings and I have included the #include call in the main .CPP source. And yes, I have set the source paths to the DX8 SDK directory for the LIB and INCLUDE files... What else can be done to rid this error from my project?
DrunkenCoder
DrunkenCoder
Got this before. No sooner than LaMothe writes a really great book on DirectX, and Microsoft restructures the whole damn mess.
You''re probably compiling the DirectX 8 libraries with DirectX 6 code. above the .h include, you can define DIRECTINPUT_VERSION to be 0x0600. That makes sure you are getting the old library.
don''t worry about the interface being old, it''s still a good library, and if you use DX8 you won''t be able to go by Lamothe''s book cause the whole setup is different. If i remember correctly, even with the define I had to fight with it before it worked, but it DOES work.

--------------------------------------------------------------



who says ya can''''t code drunk? 103 errors ain''''t that bad..........
who says ya can''t code drunk? 103 errors ain''t that bad..........
DrunkenCoder
DrunkenCoder
also, If you''re brave enough to try a newer interface, You can use v.7 instead of v.6 and LaMothe''s examples still work with little or no modification.

--------------------------------------------------------------

who says ya can''''t code drunk? 103 errors ain''''t that bad..........
who says ya can''t code drunk? 103 errors ain''t that bad..........
IOStream
IOStream
Thanks for the heads-up man. I changed the version and all like you said, but theres one problem: it doesnt load > it just fails whenever i try to initiate the program.

what do you think?
Oluseyi
Oluseyi
Use the debugger. Set a breakpoint on any line in your source code (use F9) and start the debugger (F5). It will execute up to that line and allow you to step over a single statement (F10), into a function (F11), out of a statement (Shift+F11) and run up to the cursor (Ctrl+F10). While debugging, two windows open up by default at the bottom of your MSVC screen, the Watch and Variables windows. The Variables window displays all variables involved in the current (and previous if the value changes) statement; the Watch window allows you to monitor the value of a variable.

Using this tool, you should be able to find out where things go wrong. Also remember to check return values from functions (e.g check that the return from DirectInputCreate() SUCCEEDED):

HRESULT hr = DirectInput8Create(...);
if FAILED(hr)
{
MsgBox(...); // report the error
return -1; // return some kind of error value
}


Good luck.


Start Here!
IOStream
IOStream
Thanks for the advice, but it didn''t exactly work. It froze my system during the debugging stage. I believe there''s an HDC error somewhere in the code or some HDC setup I''m missing...
donmc
donmc
i encountered the same problem. i had done a reformat, installed DX8 sdk, and tried compiling something i wrote under DX7.

error C2065: ''DirectInputCreate'' : undeclared identifier

the problem is calling DirectInputCreate was the quick and dirty way to create a DI object and get the newest interface. That was, of course, until MS changed the newest interface.

the easiest (but not the only way to fix ur problem) is to include the dinput8.lib by going to project->settings->link tab-> and adding "dinput8.lib" under the "object/library modules" field.

then change your function call from "DirectInputCreate" to "DirectInput8Create". notice the parameter lists are different so make the necessary changes.

of course it would be wise to check the HRESULT to see if that''s where ur code is bombing. like,

if(DirectInput8Create(...) != DI_OK)
{ // put error code here }

or the "preferred" MS way

if(FAILED(DirectInput8Create(...))
{ // error handler }

of course u can check to see what error code you are generating:

DIERR_BETADIRECTINPUTVERSION
DIERR_INVALIDPARAM
DIERR_OLDDIRECTINPUTVERSION
DIERR_OUTOFMEMORY
"They that can give up essential liberty to obtain temporary safety deserve neither liberty nor safety."- Benjamin Franklin
IOStream
IOStream
what are the parameters for the DInput8Create function?

oh yeah, i did checked to see if it was the DInput initiation that is making the app fail, and it is -
Oluseyi
Oluseyi
quote:
Original post by donmc
...calling DirectInputCreate was the quick and dirty way to create a DI object and get the newest interface. That was, of course, until MS changed the newest interface.

Yet another incentive to use vanilla COM.

quote:
Original post by IOStream
what are the parameters for the DInput8Create function?

If you downloaded the DirectX 8.x SDK, there''s an included compiled help file (.chi [index] and .chm) It lists all documented functions and includes a good number of instructional articles (and I personally prefer it to every single tutorial I''ve ever seen).
Oluseyi
Oluseyi
quote:
Original post by Anonymous Poster
i agree that querying the interface should be the "fail-safe" method. remember, however, that MS created the function to wrap all the dirty stuff so that the caller needn''t be concerned with anything but the latest interface.

The caller isn''t.

quote:
it was their responsibility not to break pre-existing code by renaming the function(or more importantly changing the parms). doing that destroys the whole concept of COM programming. if they weren''t going to guarantee the compatibility of the wrapper functions, they shouldn''t have included them.

Wrapper functions, schwrapper functions.

If you wish to use a specific version of the interface and associated wrapper functions, you need to define the SDK version (this is covered in every DirectX tutorial and document). For example, if you wanted to use Direct3D6 with DX8 libs, you''d do
#define D3DSDK_VERSION 0x0600 

or something to that effect.

quote:
the whole COM "contract" is supposed to be that if my code compiles under a given iteration of DX, then my code will compile in all future versions too. go figure that MS would break their COM promise.

They didn''t. The COM implementation remains the same - CoInitialize(), CoCreateInstance(), QueryInterface(); by using the wrapper functions, though, you tie yourself in to one specific version of the interface.

Topic Locked

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

Sign in to reply to this topic.