summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInput.cpp
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2010-06-21 03:12:16 +0000
committerJordan Woyak <jordan.woyak@gmail.com>2010-06-21 03:12:16 +0000
commit9e3b65368873fd26f21e2568b2c67d00ec96d6a5 (patch)
treeb5eff0d77ae7e4327069116f6440dcc2a70a1a5f /Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInput.cpp
parentfde15c1bc633792bead817b2f87faf54477765b5 (diff)
GCPad/New Wiimote Plugin: Individual keyboard and mouse devices are now listed on Windows(2 player with 2 keyboards possible). Improved the ability to map multiple inputs to the same control. Inputs from different devices can be mapped to the same button (example: Mouse Left and XInput A). More advanced mappings such as "Button 1 or 2 and NOT button 3" are possible. I hope the GUI after right clicking a button isn't too confusing(may change it to be a bit more user friendly). Hopefully, I didn't break OSX stuff by 'const'ing a few functions.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5757 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInput.cpp')
-rw-r--r--Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInput.cpp61
1 files changed, 58 insertions, 3 deletions
diff --git a/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInput.cpp b/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInput.cpp
index b1f4bb067a..d36e76b3c1 100644
--- a/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInput.cpp
+++ b/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInput.cpp
@@ -4,6 +4,18 @@
#include "DirectInput.h"
+#include <StringUtil.h>
+
+#ifdef CIFACE_USE_DIRECTINPUT_JOYSTICK
+ #include "DirectInputJoystick.h"
+#endif
+#ifdef CIFACE_USE_DIRECTINPUT_KEYBOARD
+ #include "DirectInputKeyboard.h"
+#endif
+#ifdef CIFACE_USE_DIRECTINPUT_MOUSE
+ #include "DirectInputMouse.h"
+#endif
+
#pragma comment(lib, "Dinput8.lib")
#pragma comment(lib, "dxguid.lib")
@@ -12,17 +24,60 @@ namespace ciface
namespace DirectInput
{
+//BOOL CALLBACK DIEnumEffectsCallback(LPCDIEFFECTINFO pdei, LPVOID pvRef)
+//{
+// ((std::list<DIEFFECTINFO>*)pvRef)->push_back(*pdei);
+// return DIENUM_CONTINUE;
+//}
+
+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)
+{
+ std::string out;
+
+ DIPROPSTRING str;
+ ZeroMemory(&str, sizeof(str));
+ str.diph.dwSize = sizeof(str);
+ str.diph.dwHeaderSize = sizeof(str.diph);
+ str.diph.dwHow = DIPH_DEVICE;
+
+ if (SUCCEEDED(device->GetProperty(DIPROP_PRODUCTNAME, &str.diph)))
+ {
+ const int size = WideCharToMultiByte(CP_ACP, 0, str.wsz, -1, NULL, 0, NULL, NULL);
+ char* const data = new char[size];
+ if (size == WideCharToMultiByte(CP_ACP, 0, str.wsz, -1, data, size, NULL, NULL))
+ out.assign(data);
+ delete[] data;
+ }
+
+ return StripSpaces(out);
+}
+
void Init( std::vector<ControllerInterface::Device*>& devices/*, HWND hwnd*/ )
{
IDirectInput8* idi8;
if (FAILED(DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (LPVOID*)&idi8, NULL)))
return;
-#ifdef CIFACE_USE_DIRECTINPUT_KBM
- InitKeyboardMouse( idi8, devices );
+#ifdef CIFACE_USE_DIRECTINPUT_KEYBOARD
+ InitKeyboard(idi8, devices);
+#endif
+#ifdef CIFACE_USE_DIRECTINPUT_MOUSE
+ InitMouse(idi8, devices);
#endif
#ifdef CIFACE_USE_DIRECTINPUT_JOYSTICK
- InitJoystick( idi8, devices/*, hwnd*/ );
+ InitJoystick(idi8, devices/*, hwnd*/);
#endif
idi8->Release();