2020-06-23 07:47:46 +00:00
|
|
|
#pragma once
|
|
|
|
#include "ControllerSpec1.1.h"
|
|
|
|
#include "Button.h"
|
2020-07-01 03:37:55 +00:00
|
|
|
#include "N64Controller.h"
|
2020-06-23 07:47:46 +00:00
|
|
|
#define DIRECTINPUT_VERSION 0x0800
|
|
|
|
#include <Windows.h>
|
|
|
|
#include <dinput.h>
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
class CDirectInput
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum ScanResult
|
|
|
|
{
|
|
|
|
SCAN_FAILED = 0x00,
|
|
|
|
SCAN_SUCCEED = 0x01,
|
|
|
|
SCAN_ESCAPE = 0x10,
|
|
|
|
};
|
|
|
|
|
|
|
|
CDirectInput(HINSTANCE hinst);
|
|
|
|
~CDirectInput();
|
|
|
|
|
|
|
|
void Initiate(CONTROL_INFO * ControlInfo);
|
2020-07-01 03:37:55 +00:00
|
|
|
void MapControllerDevice(N64CONTROLLER & Controller);
|
2020-06-23 07:47:46 +00:00
|
|
|
ScanResult ScanDevices(BUTTON & Button);
|
|
|
|
std::wstring ButtonAssignment(BUTTON & Button);
|
|
|
|
|
|
|
|
private:
|
|
|
|
CDirectInput();
|
|
|
|
CDirectInput(const CDirectInput&);
|
|
|
|
CDirectInput& operator=(const CDirectInput&);
|
|
|
|
|
|
|
|
static BOOL CALLBACK stEnumMakeDeviceList(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef);
|
|
|
|
BOOL EnumMakeDeviceList(LPCDIDEVICEINSTANCE lpddi);
|
|
|
|
ScanResult ScanKeyboard(LPDIRECTINPUTDEVICE8 didHandle, BUTTON & pButton);
|
|
|
|
void LoadConfig(void);
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
LPDIRECTINPUTDEVICE8 didHandle;
|
|
|
|
uint32_t dwDevType;
|
|
|
|
std::string InstanceName;
|
|
|
|
std::string ProductName;
|
|
|
|
} DEVICE;
|
|
|
|
|
|
|
|
struct GUIDComparer
|
|
|
|
{
|
|
|
|
bool operator()(const GUID & Left, const GUID & Right) const
|
|
|
|
{
|
|
|
|
return memcmp(&Left, &Right, sizeof(Right)) < 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
typedef std::map<GUID, DEVICE, GUIDComparer> DEVICE_MAP;
|
|
|
|
|
|
|
|
DEVICE_MAP m_Devices;
|
|
|
|
HMODULE m_hDirectInputDLL;
|
|
|
|
LPDIRECTINPUT8 m_pDIHandle;
|
|
|
|
HINSTANCE m_hinst;
|
|
|
|
HWND m_hWnd;
|
|
|
|
};
|