summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp
diff options
context:
space:
mode:
authorJules Blok <jules.blok@gmail.com>2015-06-10 00:00:12 +0200
committerJules Blok <jules.blok@gmail.com>2015-06-10 00:00:12 +0200
commit7dfced21a2e5aac7195e0e1ad76468e30306766b (patch)
treebd671b639d3d911460b767caabad8fc8a759a6bf /Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp
parentc25be031fc1031d795157d8344b87b7841145197 (diff)
parent7b0a65e295c784f9d573f2ef52d4e2a7b9bb2889 (diff)
Merge branch 'master' into stable
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp
new file mode 100644
index 0000000000..4a68474618
--- /dev/null
+++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp
@@ -0,0 +1,65 @@
+// Copyright 2010 Dolphin Emulator Project
+// Licensed under GPLv2+
+// Refer to the license.txt file included.
+
+#include "Common/StringUtil.h"
+
+#include "InputCommon/ControllerInterface/DInput/DInput.h"
+
+#include "InputCommon/ControllerInterface/DInput/DInputJoystick.h"
+#include "InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.h"
+
+#pragma comment(lib, "Dinput8.lib")
+#pragma comment(lib, "dxguid.lib")
+
+namespace ciface
+{
+namespace DInput
+{
+
+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)
+{
+ DIPROPSTRING str = {};
+ str.diph.dwSize = sizeof(str);
+ str.diph.dwHeaderSize = sizeof(str.diph);
+ str.diph.dwHow = DIPH_DEVICE;
+
+ std::string result;
+ if (SUCCEEDED(device->GetProperty(DIPROP_PRODUCTNAME, &str.diph)))
+ {
+ result = StripSpaces(UTF16ToUTF8(str.wsz));
+ }
+
+ return result;
+}
+
+void Init(std::vector<Core::Device*>& devices, HWND hwnd)
+{
+ IDirectInput8* idi8;
+ if (FAILED(DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION,
+ IID_IDirectInput8, (LPVOID*)&idi8, nullptr)))
+ {
+ return;
+ }
+
+ InitKeyboardMouse(idi8, devices, hwnd);
+ InitJoystick(idi8, devices, hwnd);
+
+ idi8->Release();
+
+}
+
+}
+}