Skip to content

Commit

Permalink
Add ControllerInterface::Win32 to wrap XInput and DInput
Browse files Browse the repository at this point in the history
  • Loading branch information
ligfx authored and jordan-woyak committed Mar 29, 2019
1 parent 377615b commit 92ca6e1
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 30 deletions.
1 change: 1 addition & 0 deletions Source/Core/InputCommon/CMakeLists.txt
Expand Up @@ -35,6 +35,7 @@ if(WIN32)
ControllerInterface/DInput/DInputJoystick.cpp ControllerInterface/DInput/DInputJoystick.cpp
ControllerInterface/DInput/DInputKeyboardMouse.cpp ControllerInterface/DInput/DInputKeyboardMouse.cpp
ControllerInterface/DInput/XInputFilter.cpp ControllerInterface/DInput/XInputFilter.cpp
ControllerInterface/Win32/Win32.cpp
ControllerInterface/XInput/XInput.cpp ControllerInterface/XInput/XInput.cpp
ControllerInterface/ForceFeedback/ForceFeedbackDevice.cpp ControllerInterface/ForceFeedback/ForceFeedbackDevice.cpp
) )
Expand Down
Expand Up @@ -8,11 +8,8 @@


#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"


#ifdef CIFACE_USE_XINPUT #ifdef CIFACE_USE_WIN32
#include "InputCommon/ControllerInterface/XInput/XInput.h" #include "InputCommon/ControllerInterface/Win32/Win32.h"
#endif
#ifdef CIFACE_USE_DINPUT
#include "InputCommon/ControllerInterface/DInput/DInput.h"
#endif #endif
#ifdef CIFACE_USE_XLIB #ifdef CIFACE_USE_XLIB
#include "InputCommon/ControllerInterface/Xlib/XInput2.h" #include "InputCommon/ControllerInterface/Xlib/XInput2.h"
Expand Down Expand Up @@ -48,11 +45,8 @@ void ControllerInterface::Initialize(const WindowSystemInfo& wsi)


m_is_populating_devices = true; m_is_populating_devices = true;


#ifdef CIFACE_USE_DINPUT #ifdef CIFACE_USE_WIN32
// nothing needed ciface::Win32::Init();
#endif
#ifdef CIFACE_USE_XINPUT
ciface::XInput::Init();
#endif #endif
#ifdef CIFACE_USE_XLIB #ifdef CIFACE_USE_XLIB
// nothing needed // nothing needed
Expand Down Expand Up @@ -99,12 +93,8 @@ void ControllerInterface::RefreshDevices()


m_is_populating_devices = true; m_is_populating_devices = true;


#ifdef CIFACE_USE_DINPUT #ifdef CIFACE_USE_WIN32
if (m_wsi.type == WindowSystemType::Windows) ciface::Win32::PopulateDevices(m_wsi.render_surface);
ciface::DInput::PopulateDevices(reinterpret_cast<HWND>(m_wsi.render_surface));
#endif
#ifdef CIFACE_USE_XINPUT
ciface::XInput::PopulateDevices();
#endif #endif
#ifdef CIFACE_USE_XLIB #ifdef CIFACE_USE_XLIB
if (m_wsi.type == WindowSystemType::X11) if (m_wsi.type == WindowSystemType::X11)
Expand Down Expand Up @@ -160,14 +150,11 @@ void ControllerInterface::Shutdown()
// BEFORE we shutdown the backends. // BEFORE we shutdown the backends.
InvokeDevicesChangedCallbacks(); InvokeDevicesChangedCallbacks();


#ifdef CIFACE_USE_XINPUT #ifdef CIFACE_USE_WIN32
ciface::XInput::DeInit(); ciface::Win32::DeInit();
#endif
#ifdef CIFACE_USE_DINPUT
// nothing needed
#endif #endif
#ifdef CIFACE_USE_XLIB #ifdef CIFACE_USE_XLIB
// nothing needed // nothing needed
#endif #endif
#ifdef CIFACE_USE_OSX #ifdef CIFACE_USE_OSX
ciface::OSX::DeInit(); ciface::OSX::DeInit();
Expand Down
Expand Up @@ -15,8 +15,7 @@


// enable disable sources // enable disable sources
#ifdef _WIN32 #ifdef _WIN32
#define CIFACE_USE_XINPUT #define CIFACE_USE_WIN32
#define CIFACE_USE_DINPUT
#endif #endif
#if defined(HAVE_X11) && HAVE_X11 #if defined(HAVE_X11) && HAVE_X11
#define CIFACE_USE_XLIB #define CIFACE_USE_XLIB
Expand Down
26 changes: 26 additions & 0 deletions Source/Core/InputCommon/ControllerInterface/Win32/Win32.cpp
@@ -0,0 +1,26 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "InputCommon/ControllerInterface/Win32/Win32.h"

#include "InputCommon/ControllerInterface/DInput/DInput.h"
#include "InputCommon/ControllerInterface/XInput/XInput.h"

void ciface::Win32::Init()
{
// DInput::Init();
XInput::Init();
}

void ciface::Win32::PopulateDevices(void* hwnd)
{
DInput::PopulateDevices(static_cast<HWND>(hwnd));
XInput::PopulateDevices();
}

void ciface::Win32::DeInit()
{
// DInput::DeInit();
XInput::DeInit();
}
15 changes: 15 additions & 0 deletions Source/Core/InputCommon/ControllerInterface/Win32/Win32.h
@@ -0,0 +1,15 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

namespace ciface
{
namespace Win32
{
void Init();
void PopulateDevices(void* hwnd);
void DeInit();
}
}
2 changes: 2 additions & 0 deletions Source/Core/InputCommon/InputCommon.vcxproj
Expand Up @@ -63,6 +63,7 @@
<ClCompile Include="ControlReference\ControlReference.cpp" /> <ClCompile Include="ControlReference\ControlReference.cpp" />
<ClCompile Include="ControlReference\ExpressionParser.cpp" /> <ClCompile Include="ControlReference\ExpressionParser.cpp" />
<ClCompile Include="ControllerInterface\ForceFeedback\ForceFeedbackDevice.cpp" /> <ClCompile Include="ControllerInterface\ForceFeedback\ForceFeedbackDevice.cpp" />
<ClCompile Include="ControllerInterface\Win32\Win32.cpp" />
<ClCompile Include="ControllerInterface\XInput\XInput.cpp" /> <ClCompile Include="ControllerInterface\XInput\XInput.cpp" />
<ClCompile Include="GCAdapter.cpp"> <ClCompile Include="GCAdapter.cpp">
<!-- <!--
Expand Down Expand Up @@ -104,6 +105,7 @@
<ClInclude Include="ControlReference\ControlReference.h" /> <ClInclude Include="ControlReference\ControlReference.h" />
<ClInclude Include="ControlReference\ExpressionParser.h" /> <ClInclude Include="ControlReference\ExpressionParser.h" />
<ClInclude Include="ControllerInterface\ForceFeedback\ForceFeedbackDevice.h" /> <ClInclude Include="ControllerInterface\ForceFeedback\ForceFeedbackDevice.h" />
<ClInclude Include="ControllerInterface\Win32\Win32.h" />
<ClInclude Include="ControllerInterface\XInput\XInput.h" /> <ClInclude Include="ControllerInterface\XInput\XInput.h" />
<ClInclude Include="GCAdapter.h" /> <ClInclude Include="GCAdapter.h" />
<ClInclude Include="GCPadStatus.h" /> <ClInclude Include="GCPadStatus.h" />
Expand Down
21 changes: 15 additions & 6 deletions Source/Core/InputCommon/InputCommon.vcxproj.filters
Expand Up @@ -4,12 +4,6 @@
<Filter Include="ControllerInterface"> <Filter Include="ControllerInterface">
<UniqueIdentifier>{3a755a86-0efa-4396-bf79-bb3a1910764d}</UniqueIdentifier> <UniqueIdentifier>{3a755a86-0efa-4396-bf79-bb3a1910764d}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="ControllerInterface\DInput">
<UniqueIdentifier>{0289ef91-50f5-4c16-9fa4-ff4c4d8208e7}</UniqueIdentifier>
</Filter>
<Filter Include="ControllerInterface\XInput">
<UniqueIdentifier>{07bad1aa-7e03-4f5c-ade2-a44857c5cbc3}</UniqueIdentifier>
</Filter>
<Filter Include="ControllerInterface\ForceFeedback"> <Filter Include="ControllerInterface\ForceFeedback">
<UniqueIdentifier>{e10ce316-283c-4be0-848d-578dec2b6404}</UniqueIdentifier> <UniqueIdentifier>{e10ce316-283c-4be0-848d-578dec2b6404}</UniqueIdentifier>
</Filter> </Filter>
Expand All @@ -25,6 +19,15 @@
<Filter Include="ControllerEmu\Setting"> <Filter Include="ControllerEmu\Setting">
<UniqueIdentifier>{ce661cb4-f23f-4ab2-952d-402d381735e5}</UniqueIdentifier> <UniqueIdentifier>{ce661cb4-f23f-4ab2-952d-402d381735e5}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="ControllerInterface\Win32">
<UniqueIdentifier>{6ca06b20-d8f6-4622-97ab-eefbc66edbd5}</UniqueIdentifier>
</Filter>
<Filter Include="ControllerInterface\DInput">
<UniqueIdentifier>{0289ef91-50f5-4c16-9fa4-ff4c4d8208e7}</UniqueIdentifier>
</Filter>
<Filter Include="ControllerInterface\XInput">
<UniqueIdentifier>{07bad1aa-7e03-4f5c-ade2-a44857c5cbc3}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="GCAdapter.cpp" /> <ClCompile Include="GCAdapter.cpp" />
Expand Down Expand Up @@ -104,6 +107,9 @@
<ClCompile Include="ControllerInterface\DInput\XInputFilter.cpp"> <ClCompile Include="ControllerInterface\DInput\XInputFilter.cpp">
<Filter>ControllerInterface\DInput</Filter> <Filter>ControllerInterface\DInput</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="ControllerInterface\Win32\Win32.cpp">
<Filter>ControllerInterface\Win32</Filter>
</ClCompile>
<ClCompile Include="ControlReference\ExpressionParser.cpp"> <ClCompile Include="ControlReference\ExpressionParser.cpp">
<Filter>ControllerInterface</Filter> <Filter>ControllerInterface</Filter>
</ClCompile> </ClCompile>
Expand Down Expand Up @@ -200,6 +206,9 @@
<ClInclude Include="ControllerInterface\DInput\XInputFilter.h"> <ClInclude Include="ControllerInterface\DInput\XInputFilter.h">
<Filter>ControllerInterface\DInput</Filter> <Filter>ControllerInterface\DInput</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="ControllerInterface\Win32\Win32.h">
<Filter>ControllerInterface\Win32</Filter>
</ClInclude>
<ClInclude Include="ControlReference\ExpressionParser.h"> <ClInclude Include="ControlReference\ExpressionParser.h">
<Filter>ControllerInterface</Filter> <Filter>ControllerInterface</Filter>
</ClInclude> </ClInclude>
Expand Down

0 comments on commit 92ca6e1

Please sign in to comment.