Sign in to follow this  
Guest bartels

DirectInput problems

Recommended Posts

I am still trying to have keystrokes in my gauges.I really can't make it, I am definitely not good at using DirectX...I tried to do like it was coded in the DirectInput keyboard sample, and the very first line fails:HRESULT result = DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&g_pDI, NULL);Compilation gives the following error:'DirectInput8Create' : different types for formal and actual parameter 3That's strange, because this line is exactly the same as in the sample "keyboard.cpp".If you know anything about DirectX or DirectInput, please let me know, I'm stuck.Thanks for any help !!

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

I can't recall why, but I use:if( FAILED( hr = DirectInputCreate( GetModuleHandle(NULL), DIRECTINPUT_VERSION, /*IID_IDirectInput, (VOID**)*/&g_pDI, NULL ) ) ).... together with #define DIRECTINPUT_VERSION 0x0300 before #include . Maybe it was something with the DirectX version.Arne Bartels

Share this post


Link to post
Share on other sites

I have just discovered that the problem is the difference between C and C++. My gauges are in C, based on the FS2002 SDK. The DirectX SDK and samples are in C++.I have just compiled a very small C++ sample and it works fine. The same in C does NOT work.Can someone tell me how can I compile the FS2002 gauges in C++ instead of C?Thanks in advance !!

Share this post


Link to post
Share on other sites

I finally could make it work, everything is fine.I have understood that COM objects could also be called from C using their virtual table pointer. It is strange, but it works.Keyboard shortcuts now work fine in my gauges.Thanks for your help !!

Share this post


Link to post
Share on other sites

If you insist on compiling in C++ you can do several things: - save your gauges source with .cpp extension, so they will be compiled as C++ code (provided you use the fs2k2gauges.h which is adapted to allow C++ compiling). The main gauge code will still be plain C, but this way should give better results if compiled together with C++ parts.- use different files for different code, e.g. let all gauge specific code in .c files and the C++ part in .cpp files, add the .cpp to the gauge project (VC++, makefile approach is different). To allow access to the C++ parts create an interface .h file that uses extern "C" declaration for C-style functions, include the interface .h from both C and C++ files and profgram the functions itself in the C++ part. e.g. in the interface .h #ifdef __cplusplusextern "C" {#endifanytype0 function0(anytype00 variable00,....);anytype1 function1(anytype10 variable10,....);...#ifdef __cplusplus}#endifPlace the actual function code in the .cpp fileanytype0 function0(anytype00 variable00,....){....//You can place any C++ specific code here, because it is a C++ file...}...The functions are plain C style and can be called this way both from .c and .cpp files.-the last way as you described is that possibly C and C++ access is possible for COM- and related code (I haven't tried this approach yet).Arne Bartels

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this