Trying to DirectInput in 1.4 for Joysticks use-strage error?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
dubayou
Posts: 1
Joined: Mon Mar 17, 2008 5:57 pm

Trying to DirectInput in 1.4 for Joysticks use-strage error?

Post by dubayou »

Im working on a game for one of my classes, and i wanted it to have joystick capability, so i took the hello world v.1 tutorial and took code from http://s-fonline.com/webhosting/dhenton9000/joydemo.php


Using Irrlicht 1.4
DirectX SDK Jan 2008

This is in the head:

Code: Select all

#include <irrlicht.h>
#include <wchar.h>
#include <dinput.h>

#include <stdlib.h>

using namespace irr;

using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

#pragma comment(lib, "Irrlicht.lib")
#pragma comment(lib, "dinput.lib")
#pragma comment(lib, "dxguid.lib")

#define SafeRelease(x) if (x) { x->Release(); x=NULL;}
this is the code in my winmain that triggers the error

Code: Select all

// Create the DI object
if (DirectInputCreate(hInstance, DIRECTINPUT_VERSION, &lpDI, NULL) != DI_OK)
{
	ErrStr = Err_DirectInputCreate;
	CleanupDirectInput();
    return FALSE;
}
//Enumerate joysticks//
LPVOID pdi = lpDI;
lpDI->EnumDevices(DIDEVTYPE_JOYSTICK,EnumJoy,pdi,DIEDFL_ATTACHEDONLY);


if (g_lpDIDeviceJoystick)
{

	GetJoystickInput( &g_X,  &g_Y, &g_bButton );
}
and the errors.

Code: Select all

error C3861: 'DirectInputCreate': identifier not found	408	
error C2065: 'DIDEVTYPE_JOYSTICK' : undeclared identifier	416	

And the only think i think that would do this is one/all of these header lines.
#include <dinput.h>
#pragma comment(lib, "dinput.lib")
#pragma comment(lib, "dxguid.lib")

but i have all of that installed and all directory's are pointed to the respected parts

any ideas?
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Looking in the August 2007 dinput.h

Code: Select all

#if DIRECTINPUT_VERSION > 0x0700

extern HRESULT WINAPI DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter);

#else
It looks like DIRECTINPUT_VERSION defaults to 0x0800, so you'll want to use DirectInput8Create().

Similiary, DIDEVTYPE_JOYSTICK appears to have been replaced with DI8DEVTYPE_GAMEPAD (or more specific types).
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply