You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
1.8 KiB
78 lines
1.8 KiB
#ifndef __INPUT_CONTROLLER_HEADER__
|
|
#define __INPUT_CONTROLLER_HEADER__
|
|
|
|
#define STRICT
|
|
#define DIRECTINPUT_VERSION 0x0800
|
|
#define _CRT_SECURE_NO_DEPRECATE
|
|
#ifndef _WIN32_DCOM
|
|
#define _WIN32_DCOM
|
|
#endif
|
|
|
|
#include <windows.h>
|
|
#include <stdio.h>
|
|
#include <tchar.h>
|
|
#include <commctrl.h>
|
|
#include <basetsd.h>
|
|
|
|
#pragma warning(push)
|
|
#pragma warning(disable:6000 28251)
|
|
#include <dinput.h>
|
|
#pragma warning(pop)
|
|
|
|
#include <dinputd.h>
|
|
#include <assert.h>
|
|
#include <oleauto.h>
|
|
#include <shellapi.h>
|
|
|
|
// Stuff to filter out XInput devices
|
|
#include <wbemidl.h>
|
|
|
|
|
|
struct XINPUT_DEVICE_NODE
|
|
{
|
|
DWORD dwVidPid;
|
|
XINPUT_DEVICE_NODE* pNext;
|
|
};
|
|
|
|
struct DI_ENUM_CONTEXT
|
|
{
|
|
DIJOYCONFIG* pPreferredJoyCfg;
|
|
bool bPreferredJoyCfgValid;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Defines, constants, and global variables
|
|
//-----------------------------------------------------------------------------
|
|
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
|
|
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
|
|
|
|
|
|
|
|
|
|
class inputController{
|
|
private:
|
|
bool m_bInitDX;
|
|
bool m_bFilterOutXinputDevices;
|
|
bool m_bQeryDeviceDone;
|
|
bool m_bDeviceIsConnected;
|
|
XINPUT_DEVICE_NODE* m_pXInputDeviceList;
|
|
LPDIRECTINPUT8 m_pDI;
|
|
LPDIRECTINPUTDEVICE8 m_pJoystick;
|
|
|
|
HRESULT SetupForIsXInputDevice( void );
|
|
bool IsXInputDevice( const GUID* pGuidProductFromDirectInput );
|
|
void CleanupForIsXInputDevice( void );
|
|
bool CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, void* pContext );
|
|
bool CALLBACK EnumObjectsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi, void* pContext );
|
|
public:
|
|
inputController();
|
|
~inputController();
|
|
HRESULT UpdateInputState( HWND hDlg );
|
|
};
|
|
|
|
#endif
|