Um die Funktion in c++ ein zu binden muß du nur die richtigen header ein bin den unter MS C++ ist das ganz einfach lat dir ein fach das DiretX SDK bei ms runter da ist ein sehr einfacheres beispiel dabei.
Code:
.....
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
#include "resource.h"
CMNJoystick* g_pMNJoy;
.....
// Register with the DirectInput subsystem and get a pointer
// to a IDirectInput interface we can use.
// Create a DInput object
if( SUCCEEDED( hr = DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION,IID_IDirectInput8, (VOID**)&g_pDI, NULL ) ) )
{
// Look for a simple joystick we can use for this sample program.
if(SUCCEEDED( hr = g_pDI->EnumDevices( DI8DEVCLASS_GAMECTRL,EnumJoysticksCallback,NULL, DIEDFL_ATTACHEDONLY ) ) )
{
// Make sure we got a joystick
if( NULL == g_pJoystick )
{
MessageBox( NULL, TEXT("Keinen JoyStick gefunden. Oder kann nicht Initalisieren"),TEXT("MN Joystickclass"),MB_ICONERROR | MB_OK );
return FALSE;
}
// Set the data format to "simple joystick" - a predefined data format
//
// A data format specifies which controls on a device we are interested in,
// and how they should be reported. This tells DInput that we will be
// passing a DIJOYSTATE2 structure to IDirectInputDevice::GetDeviceState().
if(SUCCEEDED( hr = g_pJoystick->SetDataFormat( &c_dfDIJoystick2 ) ) )
{
// Set the cooperative level to let DInput know how this device should
// interact with the system and with other DInput applications.
//DISCL_EXCLUSIVE |DISCL_FOREGROUND
if(SUCCEEDED( hr = g_pJoystick->SetCooperativeLevel( hDlg, DISCL_EXCLUSIVE|DISCL_BACKGROUND ) ) )
{
// Enumerate the joystick objects. The callback function enabled user
// interface elements for objects that are found, and sets the min/max
// values property for discovered axes.
if(SUCCEEDED( hr = g_pJoystick->EnumObjects( EnumObjectsCallback,(VOID*)hDlg, DIDFT_ALL ) ) )
{
ATLTRACE("Nun kann es los gehen\n");
g_hClientThreadMsg = CreateEvent(NULL,TRUE,FALSE,NULL);
g_hClientThreadExit = CreateEvent(NULL,TRUE,FALSE,NULL);
m_hClientThreadHandle=(HANDLE)_beginthreadex(NULL,0,ClientThread,this,CREATE_SUSPENDED,reinterpret_cast<unsigned int*>(&m_dwClientThreadId));
SetThreadPriority(m_hClientThreadHandle, THREAD_PRIORITY_NORMAL);
ResumeThread(m_hClientThreadHandle);
if(WaitForSingleObject(g_hClientThreadMsg,30000) == WAIT_OBJECT_0)
{
ATLTRACE("Thread läuft mal sehen ob daten kommen\n");
}
}
}
else
{
m_pRoboclient->TraceIt("SetCooperativeLevel not OK");
}
}
...
so ähnlich halt ist ein aus zug aus meinem code per DirektX
Lesezeichen