2014-02-10 18:54:46 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
#include "DInput.h"
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2013-02-28 00:01:48 +00:00
|
|
|
#include "StringUtil.h"
|
2010-06-21 03:12:16 +00:00
|
|
|
|
2013-06-17 00:07:10 +00:00
|
|
|
#include "DInputJoystick.h"
|
|
|
|
#include "DInputKeyboardMouse.h"
|
2010-06-21 03:12:16 +00:00
|
|
|
|
2010-04-02 02:48:24 +00:00
|
|
|
#pragma comment(lib, "Dinput8.lib")
|
|
|
|
#pragma comment(lib, "dxguid.lib")
|
|
|
|
|
|
|
|
namespace ciface
|
|
|
|
{
|
2010-07-03 08:04:10 +00:00
|
|
|
namespace DInput
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2010-06-21 03:12:16 +00:00
|
|
|
|
|
|
|
BOOL CALLBACK DIEnumDeviceObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef)
|
|
|
|
{
|
|
|
|
((std::list<DIDEVICEOBJECTINSTANCE>*)pvRef)->push_back(*lpddoi);
|
|
|
|
return DIENUM_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL CALLBACK DIEnumDevicesCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef)
|
|
|
|
{
|
|
|
|
((std::list<DIDEVICEINSTANCE>*)pvRef)->push_back(*lpddi);
|
|
|
|
return DIENUM_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device)
|
|
|
|
{
|
2013-02-28 00:01:48 +00:00
|
|
|
DIPROPSTRING str = {};
|
2010-06-21 03:12:16 +00:00
|
|
|
str.diph.dwSize = sizeof(str);
|
|
|
|
str.diph.dwHeaderSize = sizeof(str.diph);
|
|
|
|
str.diph.dwHow = DIPH_DEVICE;
|
|
|
|
|
2013-02-28 00:01:48 +00:00
|
|
|
std::string result;
|
2010-06-21 03:12:16 +00:00
|
|
|
if (SUCCEEDED(device->GetProperty(DIPROP_PRODUCTNAME, &str.diph)))
|
|
|
|
{
|
2013-02-28 00:01:48 +00:00
|
|
|
result = StripSpaces(UTF16ToUTF8(str.wsz));
|
2010-06-21 03:12:16 +00:00
|
|
|
}
|
|
|
|
|
2013-02-28 00:01:48 +00:00
|
|
|
return result;
|
2010-06-21 03:12:16 +00:00
|
|
|
}
|
|
|
|
|
2013-06-17 00:07:10 +00:00
|
|
|
void Init(std::vector<Core::Device*>& devices, HWND hwnd)
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
|
|
|
IDirectInput8* idi8;
|
2010-06-12 02:08:01 +00:00
|
|
|
if (FAILED(DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (LPVOID*)&idi8, NULL)))
|
2010-04-02 02:48:24 +00:00
|
|
|
return;
|
|
|
|
|
2010-07-10 06:48:24 +00:00
|
|
|
InitKeyboardMouse(idi8, devices, hwnd);
|
2010-10-11 22:19:47 +00:00
|
|
|
InitJoystick(idi8, devices, hwnd);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
idi8->Release();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|