diff options
| author | Ryan Houdek <Sonicadvance1@gmail.com> | 2013-11-13 16:17:42 -0600 |
|---|---|---|
| committer | Ryan Houdek <Sonicadvance1@gmail.com> | 2013-11-13 16:17:42 -0600 |
| commit | 2a23bdde6f76c0bff0906bbbee298480b52ba0c2 (patch) | |
| tree | 22a7bccfb1cb25d4c9f247ca3d43904a4a6d79dc /Source/Core/InputCommon | |
| parent | 3c7613fc83981f9ef8efa2e4ac478af9fe23bdec (diff) | |
| parent | 63a9dff3bb8c88cdc5b941db1f3813843c7a8564 (diff) | |
Merge branch 'master' into android-new-control-input-overlay
Conflicts:
Source/Core/DolphinWX/Src/Android/ButtonManager.h
Diffstat (limited to 'Source/Core/InputCommon')
24 files changed, 320 insertions, 368 deletions
diff --git a/Source/Core/InputCommon/InputCommon.vcxproj b/Source/Core/InputCommon/InputCommon.vcxproj index 03aaf1b3ea..4b2cd7cfeb 100644 --- a/Source/Core/InputCommon/InputCommon.vcxproj +++ b/Source/Core/InputCommon/InputCommon.vcxproj @@ -1,14 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="DebugFast|Win32"> - <Configuration>DebugFast</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="DebugFast|x64"> - <Configuration>DebugFast</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> <Platform>Win32</Platform> @@ -27,153 +19,43 @@ </ProjectConfiguration> </ItemGroup> <PropertyGroup Label="Globals"> - <ProjectGuid>{B39AC394-5DB5-4DA9-9D98-09D46CA3701F}</ProjectGuid> - <RootNamespace>InputCommon</RootNamespace> + <ProjectGuid>{6BBD47CF-91FD-4077-B676-8B76980178A9}</ProjectGuid> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <PropertyGroup Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v120</PlatformToolset> <CharacterSet>Unicode</CharacterSet> </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> - <ConfigurationType>StaticLibrary</ConfigurationType> + <PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <CharacterSet>Unicode</CharacterSet> </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>StaticLibrary</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|Win32'" Label="Configuration"> - <ConfigurationType>StaticLibrary</ConfigurationType> + <PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> - <ConfigurationType>StaticLibrary</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|x64'" Label="Configuration"> - <ConfigurationType>StaticLibrary</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="..\..\VSProps\Base.props" /> - <Import Project="..\..\VSProps\CodeGen_Debug.props" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <ImportGroup Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="..\..\VSProps\Base.props" /> - <Import Project="..\..\VSProps\CodeGen_Debug.props" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="..\..\VSProps\Base.props" /> - <Import Project="..\..\VSProps\CodeGen_Release.props" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="..\..\VSProps\Base.props" /> - <Import Project="..\..\VSProps\CodeGen_DebugFast.props" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="..\..\VSProps\Base.props" /> - <Import Project="..\..\VSProps\CodeGen_Release.props" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|x64'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="..\..\VSProps\Base.props" /> - <Import Project="..\..\VSProps\CodeGen_DebugFast.props" /> + <Import Project="..\..\VSProps\PrecompiledHeader.props" /> </ImportGroup> <PropertyGroup Label="UserMacros" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|Win32'" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|x64'" /> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <AdditionalIncludeDirectories>..\Common\Src;..\..\..\Externals\SDL\Include_1.2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <GenerateDebugInformation>true</GenerateDebugInformation> - </Link> - <Lib /> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <ClCompile> - <AdditionalIncludeDirectories>..\Common\Src;..\..\..\Externals\SDL\Include_1.2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <GenerateDebugInformation>true</GenerateDebugInformation> - </Link> - <Lib /> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <AdditionalIncludeDirectories>..\Common\Src;..\..\..\Externals\SDL\Include_1.2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <GenerateDebugInformation>true</GenerateDebugInformation> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - </Link> - <Lib /> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|Win32'"> - <ClCompile> - <AdditionalIncludeDirectories>..\Common\Src;..\..\..\Externals\SDL\Include_1.2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <GenerateDebugInformation>true</GenerateDebugInformation> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - </Link> - <Lib /> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <ClCompile> - <AdditionalIncludeDirectories>..\Common\Src;..\..\..\Externals\SDL\Include_1.2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <GenerateDebugInformation>true</GenerateDebugInformation> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - </Link> - <Lib /> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|x64'"> - <ClCompile> - <AdditionalIncludeDirectories>..\Common\Src;..\..\..\Externals\SDL\Include_1.2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <GenerateDebugInformation>true</GenerateDebugInformation> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - </Link> - <Lib /> - </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="Src\ControllerEmu.cpp" /> <ClCompile Include="Src\ControllerInterface\ControllerInterface.cpp" /> <ClCompile Include="Src\ControllerInterface\Device.cpp" /> - <ClCompile Include="Src\ControllerInterface\ExpressionParser.cpp" /> <ClCompile Include="Src\ControllerInterface\DInput\DInput.cpp" /> <ClCompile Include="Src\ControllerInterface\DInput\DInputJoystick.cpp" /> <ClCompile Include="Src\ControllerInterface\DInput\DInputKeyboardMouse.cpp" /> + <ClCompile Include="Src\ControllerInterface\ExpressionParser.cpp" /> <ClCompile Include="Src\ControllerInterface\SDL\SDL.cpp" /> <ClCompile Include="Src\ControllerInterface\XInput\XInput.cpp" /> <ClCompile Include="Src\InputConfig.cpp" /> + <ClCompile Include="Src\stdafx.cpp"> + <PrecompiledHeader>Create</PrecompiledHeader> + </ClCompile> <ClCompile Include="Src\UDPWiimote.cpp" /> <ClCompile Include="Src\UDPWrapper.cpp" /> </ItemGroup> @@ -181,22 +63,27 @@ <ClInclude Include="Src\ControllerEmu.h" /> <ClInclude Include="Src\ControllerInterface\ControllerInterface.h" /> <ClInclude Include="Src\ControllerInterface\Device.h" /> - <ClInclude Include="Src\ControllerInterface\ExpressionParser.h" /> <ClInclude Include="Src\ControllerInterface\DInput\DInput.h" /> <ClInclude Include="Src\ControllerInterface\DInput\DInputJoystick.h" /> <ClInclude Include="Src\ControllerInterface\DInput\DInputKeyboardMouse.h" /> - <ClInclude Include="Src\ControllerInterface\DInput\NamedKeys.h" /> + <ClInclude Include="Src\ControllerInterface\ExpressionParser.h" /> <ClInclude Include="Src\ControllerInterface\SDL\SDL.h" /> <ClInclude Include="Src\ControllerInterface\XInput\XInput.h" /> <ClInclude Include="Src\GCPadStatus.h" /> <ClInclude Include="Src\InputConfig.h" /> + <ClInclude Include="Src\stdafx.h" /> <ClInclude Include="Src\UDPWiimote.h" /> <ClInclude Include="Src\UDPWrapper.h" /> </ItemGroup> <ItemGroup> - <None Include="CMakeLists.txt" /> + <Text Include="CMakeLists.txt" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Common\Common.vcxproj"> + <Project>{2e6c348c-c75c-4d94-8d1e-9c1fcbf3efe4}</Project> + </ProjectReference> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> -</Project> +</Project>
\ No newline at end of file diff --git a/Source/Core/InputCommon/InputCommon.vcxproj.filters b/Source/Core/InputCommon/InputCommon.vcxproj.filters index c93a9289f4..0f28bafa56 100644 --- a/Source/Core/InputCommon/InputCommon.vcxproj.filters +++ b/Source/Core/InputCommon/InputCommon.vcxproj.filters @@ -1,34 +1,49 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> + <Filter Include="ControllerInterface"> + <UniqueIdentifier>{3a755a86-0efa-4396-bf79-bb3a1910764d}</UniqueIdentifier> + </Filter> + <Filter Include="ControllerInterface\DInput"> + <UniqueIdentifier>{0289ef91-50f5-4c16-9fa4-ff4c4d8208e7}</UniqueIdentifier> + </Filter> + <Filter Include="ControllerInterface\SDL"> + <UniqueIdentifier>{770bf6f3-b0c3-4731-be52-46f54b4cb319}</UniqueIdentifier> + </Filter> + <Filter Include="ControllerInterface\XInput"> + <UniqueIdentifier>{07bad1aa-7e03-4f5c-ade2-a44857c5cbc3}</UniqueIdentifier> + </Filter> + </ItemGroup> + <ItemGroup> <ClCompile Include="Src\ControllerEmu.cpp" /> <ClCompile Include="Src\InputConfig.cpp" /> <ClCompile Include="Src\UDPWiimote.cpp" /> <ClCompile Include="Src\UDPWrapper.cpp" /> - <ClCompile Include="Src\ControllerInterface\SDL\SDL.cpp"> - <Filter>ControllerInterface\SDL</Filter> - </ClCompile> - <ClCompile Include="Src\ControllerInterface\XInput\XInput.cpp"> - <Filter>ControllerInterface\XInput</Filter> - </ClCompile> - <ClCompile Include="Src\ControllerInterface\ControllerInterface.cpp"> - <Filter>ControllerInterface</Filter> - </ClCompile> - <ClCompile Include="Src\ControllerInterface\DInput\DInputKeyboardMouse.cpp"> + <ClCompile Include="Src\ControllerInterface\DInput\DInput.cpp"> <Filter>ControllerInterface\DInput</Filter> </ClCompile> <ClCompile Include="Src\ControllerInterface\DInput\DInputJoystick.cpp"> <Filter>ControllerInterface\DInput</Filter> </ClCompile> - <ClCompile Include="Src\ControllerInterface\DInput\DInput.cpp"> + <ClCompile Include="Src\ControllerInterface\DInput\DInputKeyboardMouse.cpp"> <Filter>ControllerInterface\DInput</Filter> </ClCompile> - <ClCompile Include="Src\ControllerInterface\ExpressionParser.cpp"> - <Filter>ControllerInterface</Filter> + <ClCompile Include="Src\ControllerInterface\XInput\XInput.cpp"> + <Filter>ControllerInterface\XInput</Filter> + </ClCompile> + <ClCompile Include="Src\ControllerInterface\SDL\SDL.cpp"> + <Filter>ControllerInterface\SDL</Filter> </ClCompile> <ClCompile Include="Src\ControllerInterface\Device.cpp"> <Filter>ControllerInterface</Filter> </ClCompile> + <ClCompile Include="Src\ControllerInterface\ControllerInterface.cpp"> + <Filter>ControllerInterface</Filter> + </ClCompile> + <ClCompile Include="Src\ControllerInterface\ExpressionParser.cpp"> + <Filter>ControllerInterface</Filter> + </ClCompile> + <ClCompile Include="Src\stdafx.cpp" /> </ItemGroup> <ItemGroup> <ClInclude Include="Src\ControllerEmu.h" /> @@ -36,12 +51,21 @@ <ClInclude Include="Src\InputConfig.h" /> <ClInclude Include="Src\UDPWiimote.h" /> <ClInclude Include="Src\UDPWrapper.h" /> - <ClInclude Include="Src\ControllerInterface\SDL\SDL.h"> - <Filter>ControllerInterface\SDL</Filter> + <ClInclude Include="Src\ControllerInterface\DInput\DInput.h"> + <Filter>ControllerInterface\DInput</Filter> + </ClInclude> + <ClInclude Include="Src\ControllerInterface\DInput\DInputJoystick.h"> + <Filter>ControllerInterface\DInput</Filter> + </ClInclude> + <ClInclude Include="Src\ControllerInterface\DInput\DInputKeyboardMouse.h"> + <Filter>ControllerInterface\DInput</Filter> </ClInclude> <ClInclude Include="Src\ControllerInterface\XInput\XInput.h"> <Filter>ControllerInterface\XInput</Filter> </ClInclude> + <ClInclude Include="Src\ControllerInterface\SDL\SDL.h"> + <Filter>ControllerInterface\SDL</Filter> + </ClInclude> <ClInclude Include="Src\ControllerInterface\ControllerInterface.h"> <Filter>ControllerInterface</Filter> </ClInclude> @@ -51,34 +75,9 @@ <ClInclude Include="Src\ControllerInterface\ExpressionParser.h"> <Filter>ControllerInterface</Filter> </ClInclude> - <ClInclude Include="Src\ControllerInterface\DInput\NamedKeys.h"> - <Filter>ControllerInterface\DInput</Filter> - </ClInclude> - <ClInclude Include="Src\ControllerInterface\DInput\DInputKeyboardMouse.h"> - <Filter>ControllerInterface\DInput</Filter> - </ClInclude> - <ClInclude Include="Src\ControllerInterface\DInput\DInputJoystick.h"> - <Filter>ControllerInterface\DInput</Filter> - </ClInclude> - <ClInclude Include="Src\ControllerInterface\DInput\DInput.h"> - <Filter>ControllerInterface\DInput</Filter> - </ClInclude> - </ItemGroup> - <ItemGroup> - <None Include="CMakeLists.txt" /> + <ClInclude Include="Src\stdafx.h" /> </ItemGroup> <ItemGroup> - <Filter Include="ControllerInterface"> - <UniqueIdentifier>{63655b75-3fd6-4cd0-814a-eb9f3505f91d}</UniqueIdentifier> - </Filter> - <Filter Include="ControllerInterface\DInput"> - <UniqueIdentifier>{64f2ab35-5cce-40a5-a4d3-232710267e05}</UniqueIdentifier> - </Filter> - <Filter Include="ControllerInterface\SDL"> - <UniqueIdentifier>{08565cb5-f959-45dc-90b1-93a9c0135478}</UniqueIdentifier> - </Filter> - <Filter Include="ControllerInterface\XInput"> - <UniqueIdentifier>{5a9c1b94-2eab-4357-b44f-87d5db50da3d}</UniqueIdentifier> - </Filter> + <Text Include="CMakeLists.txt" /> </ItemGroup> -</Project> +</Project>
\ No newline at end of file diff --git a/Source/Core/InputCommon/Src/ControllerEmu.cpp b/Source/Core/InputCommon/Src/ControllerEmu.cpp index 328fcb8c2f..e2e37789c7 100644 --- a/Source/Core/InputCommon/Src/ControllerEmu.cpp +++ b/Source/Core/InputCommon/Src/ControllerEmu.cpp @@ -221,8 +221,8 @@ void ControllerEmu::SaveConfig(IniFile::Section *sec, const std::string& base) ControllerEmu::AnalogStick::AnalogStick(const char* const _name) : ControlGroup(_name, GROUP_TYPE_STICK) { - for (unsigned int i = 0; i < 4; ++i) - controls.push_back(new Input(named_directions[i])); + for (auto& named_direction : named_directions) + controls.push_back(new Input(named_direction)); controls.push_back(new Input(_trans("Modifier"))); @@ -290,8 +290,8 @@ ControllerEmu::Cursor::Cursor(const char* const _name) : ControlGroup(_name, GROUP_TYPE_CURSOR) , m_z(0) { - for (unsigned int i = 0; i < 4; ++i) - controls.push_back(new Input(named_directions[i])); + for (auto& named_direction : named_directions) + controls.push_back(new Input(named_direction)); controls.push_back(new Input("Forward")); controls.push_back(new Input("Backward")); controls.push_back(new Input(_trans("Hide"))); diff --git a/Source/Core/InputCommon/Src/ControllerEmu.h b/Source/Core/InputCommon/Src/ControllerEmu.h index 5dc54b463f..750aa692c4 100644 --- a/Source/Core/InputCommon/Src/ControllerEmu.h +++ b/Source/Core/InputCommon/Src/ControllerEmu.h @@ -42,7 +42,7 @@ enum SETTING_SQUARE, }; -const char * const named_directions[] = +const char * const named_directions[] = { "Up", "Down", @@ -109,7 +109,7 @@ public: ControlGroup(const char* const _name, const unsigned int _type = GROUP_TYPE_OTHER) : name(_name), type(_type) {} virtual ~ControlGroup(); - + virtual void LoadConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "" ); virtual void SaveConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "" ); @@ -325,7 +325,7 @@ public: { // this section might be all wrong, but its working good enough, I think - ControlState ang = atan2(yy, xx); + ControlState ang = atan2(yy, xx); ControlState ang_sin = sin(ang); ControlState ang_cos = cos(ang); @@ -352,7 +352,7 @@ public: // this is kinda silly here // gui being open will make this happen 2x as fast, o well - + // silly if (step) { @@ -391,7 +391,7 @@ public: m_z = std::max(m_z - 0.1f, zz); *z = m_z; - + // hide if (controls[6]->control_ref->State() > 0.5f) { diff --git a/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp index bc1e115c17..7287c380d5 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp @@ -99,7 +99,7 @@ void ControllerInterface::Shutdown() m_devices.clear(); #ifdef CIFACE_USE_XINPUT - // nothing needed + ciface::XInput::DeInit(); #endif #ifdef CIFACE_USE_DINPUT // nothing needed @@ -249,7 +249,7 @@ Device::Control* ControllerInterface::InputReference::Detect(const unsigned int if (device->Inputs().size() == 0) return NULL; - // get starting state of all inputs, + // get starting state of all inputs, // so we can ignore those that were activated at time of Detect start std::vector<Device::Input*>::const_iterator i = device->Inputs().begin(), @@ -308,7 +308,7 @@ Device::Control* ControllerInterface::OutputReference::Detect(const unsigned int device->UpdateOutput(); Common::SleepCurrentThread(10); } - + State(0); device->UpdateOutput(); } diff --git a/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.h index 00b4b2c07d..4efb8941b7 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.h +++ b/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.h @@ -109,7 +109,7 @@ public: }; ControllerInterface() : m_is_init(false), m_hwnd(NULL) {} - + void SetHwnd(void* const hwnd); void Initialize(); void Shutdown(); diff --git a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp index fa33595ee8..7211559e93 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp @@ -76,17 +76,17 @@ void GetXInputGUIDS( std::vector<DWORD>& guids ) bstrNamespace = SysAllocString( L"\\\\.\\root\\cimv2" );if( bstrNamespace == NULL ) goto LCleanup; bstrClassName = SysAllocString( L"Win32_PNPEntity" ); if( bstrClassName == NULL ) goto LCleanup; bstrDeviceID = SysAllocString( L"DeviceID" ); if( bstrDeviceID == NULL ) goto LCleanup; - - // Connect to WMI + + // Connect to WMI hr = pIWbemLocator->ConnectServer( bstrNamespace, NULL, NULL, 0L, 0L, NULL, NULL, &pIWbemServices ); if( FAILED(hr) || pIWbemServices == NULL ) goto LCleanup; - // Switch security level to IMPERSONATE. - CoSetProxyBlanket( pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, + // Switch security level to IMPERSONATE. + CoSetProxyBlanket( pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE ); - hr = pIWbemServices->CreateInstanceEnum( bstrClassName, 0, NULL, &pEnumDevices ); + hr = pIWbemServices->CreateInstanceEnum( bstrClassName, 0, NULL, &pEnumDevices ); if( FAILED(hr) || pEnumDevices == NULL ) goto LCleanup; @@ -105,7 +105,7 @@ void GetXInputGUIDS( std::vector<DWORD>& guids ) if( SUCCEEDED( hr ) && var.vt == VT_BSTR && var.bstrVal != NULL ) { // Check if the device ID contains "IG_". If it does, then it's an XInput device - // This information can not be found from DirectInput + // This information can not be found from DirectInput if( wcsstr( var.bstrVal, L"IG_" ) ) { // If it does, then get the VID/PID from var.bstrVal @@ -122,7 +122,7 @@ void GetXInputGUIDS( std::vector<DWORD>& guids ) guids.push_back( dwVidPid ); //bIsXinputDevice = true; } - } + } SAFE_RELEASE( pDevices[iDevice] ); } } @@ -324,7 +324,7 @@ Joystick::Joystick( /*const LPCDIDEVICEINSTANCE lpddi, */const LPDIRECTINPUTDEVI { eff.cbTypeSpecificParams = sizeof(DIPERIODIC); } - + LPDIRECTINPUTEFFECT pEffect; if (SUCCEEDED(m_device->CreateEffect(force_type_names[f].guid, &eff, &pEffect, NULL))) { diff --git a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.h b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.h index ad383bd764..20b38c8a69 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.h +++ b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.h @@ -88,7 +88,7 @@ public: Joystick(const LPDIRECTINPUTDEVICE8 device, const unsigned int index); ~Joystick(); - + std::string GetName() const; int GetId() const; std::string GetSource() const; diff --git a/Source/Core/InputCommon/Src/ControllerInterface/ExpressionParser.cpp b/Source/Core/InputCommon/Src/ControllerInterface/ExpressionParser.cpp index d91fbc587c..b313559907 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/ExpressionParser.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/ExpressionParser.cpp @@ -222,22 +222,22 @@ public: ControlExpression(ControlQualifier qualifier_, Device::Control *control_) : qualifier(qualifier_), control(control_) {} - virtual ControlState GetValue() + virtual ControlState GetValue() override { return control->ToInput()->GetState(); } - virtual void SetValue(ControlState value) + virtual void SetValue(ControlState value) override { control->ToOutput()->SetState(value); } - virtual int CountNumControls() + virtual int CountNumControls() override { return 1; } - virtual operator std::string() + virtual operator std::string() override { return "`" + (std::string)qualifier + "`"; } @@ -257,7 +257,7 @@ public: delete rhs; } - virtual ControlState GetValue() + virtual ControlState GetValue() override { ControlState lhsValue = lhs->GetValue(); ControlState rhsValue = rhs->GetValue(); @@ -275,7 +275,7 @@ public: } } - virtual void SetValue(ControlState value) + virtual void SetValue(ControlState value) override { // Don't do anything special with the op we have. // Treat "A & B" the same as "A | B". @@ -283,12 +283,12 @@ public: rhs->SetValue(value); } - virtual int CountNumControls() + virtual int CountNumControls() override { return lhs->CountNumControls() + rhs->CountNumControls(); } - virtual operator std::string() + virtual operator std::string() override { return OpName(op) + "(" + (std::string)(*lhs) + ", " + (std::string)(*rhs) + ")"; } @@ -306,7 +306,7 @@ public: delete inner; } - virtual ControlState GetValue() + virtual ControlState GetValue() override { ControlState value = inner->GetValue(); switch (op) @@ -319,7 +319,7 @@ public: } } - virtual void SetValue(ControlState value) + virtual void SetValue(ControlState value) override { switch (op) { @@ -330,12 +330,12 @@ public: } } - virtual int CountNumControls() + virtual int CountNumControls() override { return inner->CountNumControls(); } - virtual operator std::string() + virtual operator std::string() override { return OpName(op) + "(" + (std::string)(*inner) + ")"; } diff --git a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXKeyboard.mm b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXKeyboard.mm index 6473f00e77..93de15daa4 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXKeyboard.mm +++ b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXKeyboard.mm @@ -222,9 +222,9 @@ Keyboard::Key::Key(IOHIDElementRef element, IOHIDDeviceRef device) }; const uint32_t keycode = IOHIDElementGetUsage(m_element); - for (uint32_t i = 0; i < sizeof named_keys / sizeof *named_keys; i++) - if (named_keys[i].code == keycode) { - m_name = named_keys[i].name; + for (auto & named_key : named_keys) + if (named_key.code == keycode) { + m_name = named_key.name; return; } diff --git a/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp b/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp index 40c822c577..bcd3586dc6 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp @@ -7,18 +7,14 @@ #include <algorithm> #ifdef _WIN32 - #if SDL_VERSION_ATLEAST(1, 3, 0) - #pragma comment(lib, "SDL.1.3.lib") - #else - #pragma comment(lib, "SDL.lib") - #endif +#pragma comment(lib, "SDL2.lib") #endif namespace ciface { namespace SDL { - + std::string GetJoystickName(int index) { #if SDL_VERSION_ATLEAST(2, 0, 0) @@ -29,7 +25,7 @@ std::string GetJoystickName(int index) } void Init( std::vector<Core::Device*>& devices ) -{ +{ // this is used to number the joysticks // multiple joysticks with the same name shall get unique ids starting at 0 std::map<std::string, int> name_counts; @@ -83,7 +79,7 @@ Joystick::Joystick(SDL_Joystick* const joystick, const int sdl_index, const unsi // get buttons for (u8 i = 0; i != SDL_JoystickNumButtons(m_joystick); ++i) AddInput(new Button(i, m_joystick)); - + // get hats for (u8 i = 0; i != SDL_JoystickNumHats(m_joystick); ++i) { @@ -155,7 +151,7 @@ Joystick::~Joystick() { #ifdef USE_SDL_HAPTIC if (m_haptic) - { + { // stop/destroy all effects SDL_HapticStopAll(m_haptic); std::list<EffectIDState>::iterator @@ -201,7 +197,7 @@ std::string Joystick::TriangleEffect::GetName() const return "Triangle"; } -void Joystick::ConstantEffect::SetState(const ControlState state) +void Joystick::ConstantEffect::SetState(ControlState state) { if (state) { @@ -219,7 +215,7 @@ void Joystick::ConstantEffect::SetState(const ControlState state) m_effect.changed = true; } -void Joystick::RampEffect::SetState(const ControlState state) +void Joystick::RampEffect::SetState(ControlState state) { if (state) { @@ -237,7 +233,7 @@ void Joystick::RampEffect::SetState(const ControlState state) m_effect.changed = true; } -void Joystick::SineEffect::SetState(const ControlState state) +void Joystick::SineEffect::SetState(ControlState state) { if (state) { @@ -260,7 +256,7 @@ void Joystick::SineEffect::SetState(const ControlState state) } #ifdef SDL_HAPTIC_SQUARE -void Joystick::SquareEffect::SetState(const ControlState state) +void Joystick::SquareEffect::SetState(ControlState state) { if (state) { @@ -283,7 +279,7 @@ void Joystick::SquareEffect::SetState(const ControlState state) } #endif // defined(SDL_HAPTIC_SQUARE) -void Joystick::TriangleEffect::SetState(const ControlState state) +void Joystick::TriangleEffect::SetState(ControlState state) { if (state) { @@ -310,7 +306,7 @@ bool Joystick::UpdateInput() { // each joystick is doin this, o well SDL_JoystickUpdate(); - + return true; } diff --git a/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.h b/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.h index 9b9794c481..f1714b253e 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.h +++ b/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.h @@ -43,9 +43,9 @@ private: class Button : public Core::Device::Input { public: - std::string GetName() const; + std::string GetName() const override; Button(u8 index, SDL_Joystick* js) : m_js(js), m_index(index) {} - ControlState GetState() const; + ControlState GetState() const override; private: SDL_Joystick* const m_js; const u8 m_index; @@ -54,9 +54,9 @@ private: class Axis : public Core::Device::Input { public: - std::string GetName() const; + std::string GetName() const override; Axis(u8 index, SDL_Joystick* js, Sint16 range) : m_js(js), m_range(range), m_index(index) {} - ControlState GetState() const; + ControlState GetState() const override; private: SDL_Joystick* const m_js; const Sint16 m_range; @@ -66,9 +66,9 @@ private: class Hat : public Input { public: - std::string GetName() const; + std::string GetName() const override; Hat(u8 index, SDL_Joystick* js, u8 direction) : m_js(js), m_direction(direction), m_index(index) {} - ControlState GetState() const; + ControlState GetState() const override; private: SDL_Joystick* const m_js; const u8 m_direction; @@ -81,7 +81,7 @@ private: public: std::string GetName() const; ConstantEffect(EffectIDState& effect) : m_effect(effect) {} - void SetState(const ControlState state); + void SetState(ControlState state); private: EffectIDState& m_effect; }; @@ -91,7 +91,7 @@ private: public: std::string GetName() const; RampEffect(EffectIDState& effect) : m_effect(effect) {} - void SetState(const ControlState state); + void SetState(ControlState state); private: EffectIDState& m_effect; }; @@ -101,7 +101,7 @@ private: public: std::string GetName() const; SineEffect(EffectIDState& effect) : m_effect(effect) {} - void SetState(const ControlState state); + void SetState(ControlState state); private: EffectIDState& m_effect; }; @@ -112,7 +112,7 @@ private: public: std::string GetName() const; SquareEffect(EffectIDState& effect) : m_effect(effect) {} - void SetState(const ControlState state); + void SetState(ControlState state); private: EffectIDState& m_effect; }; @@ -123,22 +123,22 @@ private: public: std::string GetName() const; TriangleEffect(EffectIDState& effect) : m_effect(effect) {} - void SetState(const ControlState state); + void SetState(ControlState state); private: EffectIDState& m_effect; }; #endif public: - bool UpdateInput(); - bool UpdateOutput(); + bool UpdateInput() override; + bool UpdateOutput() override; Joystick(SDL_Joystick* const joystick, const int sdl_index, const unsigned int index); ~Joystick(); - std::string GetName() const; - int GetId() const; - std::string GetSource() const; + std::string GetName() const override; + int GetId() const override; + std::string GetSource() const override; private: SDL_Joystick* const m_joystick; diff --git a/Source/Core/InputCommon/Src/ControllerInterface/XInput/XInput.cpp b/Source/Core/InputCommon/Src/ControllerInterface/XInput/XInput.cpp index c687bef856..0aa639aae8 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/XInput/XInput.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/XInput/XInput.cpp @@ -10,7 +10,7 @@ static const struct { const char* const name; const WORD bitmask; -} named_buttons[] = +} named_buttons[] = { { "Button A", XINPUT_GAMEPAD_A }, { "Button B", XINPUT_GAMEPAD_B }, @@ -48,14 +48,60 @@ static const char* const named_motors[] = "Motor R" }; +static HMODULE hXInput = nullptr; + +typedef decltype(&XInputGetCapabilities) XInputGetCapabilities_t; +typedef decltype(&XInputSetState) XInputSetState_t; +typedef decltype(&XInputGetState) XInputGetState_t; + +static XInputGetCapabilities_t PXInputGetCapabilities = nullptr; +static XInputSetState_t PXInputSetState = nullptr; +static XInputGetState_t PXInputGetState = nullptr; + void Init(std::vector<Core::Device*>& devices) { + if (!hXInput) + { + // Try for the most recent version we were compiled against (will only work if running on Win8+) + hXInput = ::LoadLibrary(XINPUT_DLL); + if (!hXInput) + { + // Drop back to DXSDK June 2010 version. Requires DX June 2010 redist. + hXInput = ::LoadLibrary(TEXT("xinput1_3.dll")); + if (!hXInput) + { + return; + } + } + + PXInputGetCapabilities = (XInputGetCapabilities_t)::GetProcAddress(hXInput, "XInputGetCapabilities"); + PXInputSetState = (XInputSetState_t)::GetProcAddress(hXInput, "XInputSetState"); + PXInputGetState = (XInputGetState_t)::GetProcAddress(hXInput, "XInputGetState"); + if (!PXInputGetCapabilities || + !PXInputSetState || + !PXInputGetState) + { + ::FreeLibrary(hXInput); + hXInput = nullptr; + return; + } + } + XINPUT_CAPABILITIES caps; for (int i = 0; i != 4; ++i) - if (ERROR_SUCCESS == XInputGetCapabilities(i, 0, &caps)) + if (ERROR_SUCCESS == PXInputGetCapabilities(i, 0, &caps)) devices.push_back(new Device(caps, i)); } +void DeInit() +{ + if (hXInput) + { + ::FreeLibrary(hXInput); + hXInput = nullptr; + } +} + Device::Device(const XINPUT_CAPABILITIES& caps, u8 index) : m_index(index), m_subtype(caps.SubType) { @@ -107,25 +153,21 @@ Device::Device(const XINPUT_CAPABILITIES& caps, u8 index) void Device::ClearInputState() { - ZeroMemory(&m_state_in, sizeof(m_state_in)); + ZeroMemory(&m_state_in, sizeof(m_state_in)); } std::string Device::GetName() const { - // why aren't these defined - // subtype doesn't seem to work, I tested with 2 different arcade sticks, both were shown as gamepad - // I'll leave it in anyway, maybe m$ will fix it - switch (m_subtype) { - case XINPUT_DEVSUBTYPE_GAMEPAD : return "Gamepad"; break; - case 0x02 /*XINPUT_DEVSUBTYPE_WHEEL*/ : return "Wheel"; break; - case 0x03 /*XINPUT_DEVSUBTYPE_ARCADE_STICK*/ : return "Arcade Stick"; break; - case 0x04 /*XINPUT_DEVSUBTYPE_FLIGHT_STICK*/ : return "Flight Stick"; break; - case 0x05 /*XINPUT_DEVSUBTYPE_DANCE_PAD*/ : return "Dance Pad"; break; - case 0x06 /*XINPUT_DEVSUBTYPE_GUITAR*/ : return "Guitar"; break; - case 0x08 /*XINPUT_DEVSUBTYPE_DRUM_KIT*/ : return "Drum Kit"; break; - default : return "Device"; break; + case XINPUT_DEVSUBTYPE_GAMEPAD: return "Gamepad"; break; + case XINPUT_DEVSUBTYPE_WHEEL: return "Wheel"; break; + case XINPUT_DEVSUBTYPE_ARCADE_STICK: return "Arcade Stick"; break; + case XINPUT_DEVSUBTYPE_FLIGHT_STICK: return "Flight Stick"; break; + case XINPUT_DEVSUBTYPE_DANCE_PAD: return "Dance Pad"; break; + case XINPUT_DEVSUBTYPE_GUITAR: return "Guitar"; break; + case XINPUT_DEVSUBTYPE_DRUM_KIT: return "Drum Kit"; break; + default: return "Device"; break; } } @@ -143,7 +185,7 @@ std::string Device::GetSource() const bool Device::UpdateInput() { - return (ERROR_SUCCESS == XInputGetState(m_index, &m_state_in)); + return (ERROR_SUCCESS == PXInputGetState(m_index, &m_state_in)); } bool Device::UpdateOutput() @@ -153,7 +195,7 @@ bool Device::UpdateOutput() if (memcmp(&m_state_out, &m_current_state_out, sizeof(m_state_out))) { m_current_state_out = m_state_out; - return (ERROR_SUCCESS == XInputSetState(m_index, &m_state_out)); + return (ERROR_SUCCESS == PXInputSetState(m_index, &m_state_out)); } else { diff --git a/Source/Core/InputCommon/Src/ControllerInterface/XInput/XInput.h b/Source/Core/InputCommon/Src/ControllerInterface/XInput/XInput.h index 8fe6dd1dee..17e49e5e2b 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/XInput/XInput.h +++ b/Source/Core/InputCommon/Src/ControllerInterface/XInput/XInput.h @@ -1,3 +1,8 @@ +// XInput suffers a similar issue as XAudio2. Since Win8, it is part of the OS. +// However, unlike XAudio2 they have not made the API incompatible - so we just +// compile against the latest version and fall back to dynamically loading the +// old DLL. + #ifndef _CIFACE_XINPUT_H_ #define _CIFACE_XINPUT_H_ @@ -7,12 +12,17 @@ #include <Windows.h> #include <XInput.h> +#ifndef XINPUT_DEVSUBTYPE_FLIGHT_STICK +#error You are building this module against the wrong version of DirectX. You probably need to remove DXSDK_DIR from your include path and/or _WIN32_WINNT is wrong. +#endif + namespace ciface { namespace XInput { void Init(std::vector<Core::Device*>& devices); +void DeInit(); class Device : public Core::Device { diff --git a/Source/Core/InputCommon/Src/ControllerInterface/Xlib/XInput2.cpp b/Source/Core/InputCommon/Src/ControllerInterface/Xlib/XInput2.cpp index b42eda1f21..23cadd3ee6 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/Xlib/XInput2.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/Xlib/XInput2.cpp @@ -8,8 +8,8 @@ #include <cmath> // This is an input plugin using the XInput 2.0 extension to the X11 protocol, -// loosely based on the old XLib plugin. (Has nothing to do with the XInput -// API on Windows.) +// loosely based on the old XLib plugin. (Has nothing to do with the XInput +// API on Windows.) // This plugin creates one KeyboardMouse object for each master pointer/ // keyboard pair. Each KeyboardMouse object exports four types of controls: @@ -20,20 +20,20 @@ // center of the emulator window. // * Mouse axis controls: one for each cardinal direction. Calculated using // a running average of relative mouse motion on each axis. -// * Key controls: these correspond to a limited subset of the keyboard +// * Key controls: these correspond to a limited subset of the keyboard // keys. // Mouse axis control tuning. Unlike absolute mouse position, relative mouse // motion data needs to be tweaked and smoothed out a bit to be usable. -// Mouse axis control output is simply divided by this number. In practice, +// Mouse axis control output is simply divided by this number. In practice, // that just means you can use a smaller "dead zone" if you bind axis controls // to a joystick. No real need to make this customizable. #define MOUSE_AXIS_SENSITIVITY 8.0f // The mouse axis controls use a weighted running average. Each frame, the new -// value is the average of the old value and the amount of relative mouse +// value is the average of the old value and the amount of relative mouse // motion during that frame. The old value is weighted by a ratio of // MOUSE_AXIS_SMOOTHING:1 compared to the new value. Increasing // MOUSE_AXIS_SMOOTHING makes the controls smoother, decreasing it makes them @@ -49,31 +49,31 @@ namespace XInput2 void Init(std::vector<Core::Device*>& devices, void* const hwnd) { Display* dpy; - + dpy = XOpenDisplay(NULL); - - // xi_opcode is important; it will be used to identify XInput events by + + // xi_opcode is important; it will be used to identify XInput events by // the polling loop in UpdateInput. int xi_opcode, event, error; - + // verify that the XInput extension is available if (!XQueryExtension(dpy, "XInputExtension", &xi_opcode, &event, &error)) return; - + // verify that the XInput extension is at at least version 2.0 int major = 2, minor = 0; - + if (XIQueryVersion(dpy, &major, &minor) != Success) return; - + // register all master devices with Dolphin - + XIDeviceInfo* all_masters; XIDeviceInfo* current_master; int num_masters; - + all_masters = XIQueryDevice(dpy, XIAllMasterDevices, &num_masters); - + for (int i = 0; i < num_masters; i++) { current_master = &all_masters[i]; @@ -82,34 +82,34 @@ void Init(std::vector<Core::Device*>& devices, void* const hwnd) // be a master keyboard. devices.push_back(new KeyboardMouse((Window)hwnd, xi_opcode, current_master->deviceid, current_master->attachment)); } - + XCloseDisplay(dpy); - + XIFreeDeviceInfo(all_masters); } -// Apply the event mask to the device and all its slaves. Only used in the +// Apply the event mask to the device and all its slaves. Only used in the // constructor. Remember, each KeyboardMouse has its own copy of the event // stream, which is how multiple event masks can "coexist." void KeyboardMouse::SelectEventsForDevice(Window window, XIEventMask *mask, int deviceid) { // Set the event mask for the master device. - + mask->deviceid = deviceid; XISelectEvents(m_display, window, mask, 1); - + // Query all the master device's slaves and set the same event mask for // those too. There are two reasons we want to do this. For mouse devices, // we want the raw motion events, and only slaves (i.e. physical hardware // devices) emit those. For keyboard devices, selecting slaves avoids // dealing with key focus. - + XIDeviceInfo* all_slaves; XIDeviceInfo* current_slave; int num_slaves; - + all_slaves = XIQueryDevice(m_display, XIAllDevices, &num_slaves); - + for (int i = 0; i < num_slaves; i++) { current_slave = &all_slaves[i]; @@ -118,33 +118,33 @@ void KeyboardMouse::SelectEventsForDevice(Window window, XIEventMask *mask, int mask->deviceid = current_slave->deviceid; XISelectEvents(m_display, window, mask, 1); } - + XIFreeDeviceInfo(all_slaves); } -KeyboardMouse::KeyboardMouse(Window window, int opcode, int pointer, int keyboard) +KeyboardMouse::KeyboardMouse(Window window, int opcode, int pointer, int keyboard) : m_window(window), xi_opcode(opcode), pointer_deviceid(pointer), keyboard_deviceid(keyboard) { memset(&m_state, 0, sizeof(m_state)); - + // The cool thing about each KeyboardMouse object having its own Display // is that each one gets its own separate copy of the X11 event stream, // which it can individually filter to get just the events it's interested // in. So be aware that each KeyboardMouse object actually has its own X11 // "context." m_display = XOpenDisplay(NULL); - + int min_keycode, max_keycode; XDisplayKeycodes(m_display, &min_keycode, &max_keycode); - + int unused; // should always be 1 XIDeviceInfo* pointer_device = XIQueryDevice(m_display, pointer_deviceid, &unused); name = std::string(pointer_device->name); XIFreeDeviceInfo(pointer_device); - + XIEventMask mask; unsigned char mask_buf[(XI_LASTEVENT + 7)/8]; - + mask.mask_len = sizeof(mask_buf); mask.mask = mask_buf; memset(mask_buf, 0, sizeof(mask_buf)); @@ -155,9 +155,9 @@ KeyboardMouse::KeyboardMouse(Window window, int opcode, int pointer, int keyboar XISetMask(mask_buf, XI_KeyPress); XISetMask(mask_buf, XI_KeyRelease); - SelectEventsForDevice(DefaultRootWindow(m_display), &mask, pointer_deviceid); + SelectEventsForDevice(DefaultRootWindow(m_display), &mask, pointer_deviceid); SelectEventsForDevice(DefaultRootWindow(m_display), &mask, keyboard_deviceid); - + // Keyboard Keys for (int i = min_keycode; i <= max_keycode; ++i) { @@ -175,7 +175,7 @@ KeyboardMouse::KeyboardMouse(Window window, int opcode, int pointer, int keyboar // Mouse Cursor, X-/+ and Y-/+ for (int i = 0; i != 4; ++i) AddInput(new Cursor(!!(i & 2), !!(i & 1), (&m_state.cursor.x)[!!(i & 2)])); - + // Mouse Axis, X-/+ and Y-/+ for (int i = 0; i != 4; ++i) AddInput(new Axis(!!(i & 2), !!(i & 1), (&m_state.axis.x)[!!(i & 2)])); @@ -191,15 +191,15 @@ void KeyboardMouse::UpdateCursor() { double root_x, root_y, win_x, win_y; Window root, child; - - // unused-- we're not interested in button presses here, as those are + + // unused-- we're not interested in button presses here, as those are // updated using events XIButtonState button_state; XIModifierState mods; XIGroupState group; - + XIQueryPointer(m_display, pointer_deviceid, m_window, &root, &child, &root_x, &root_y, &win_x, &win_y, &button_state, &mods, &group); - + free (button_state.mask); XWindowAttributes win_attribs; @@ -213,32 +213,32 @@ void KeyboardMouse::UpdateCursor() bool KeyboardMouse::UpdateInput() { XFlush(m_display); - + // Get the absolute position of the mouse pointer UpdateCursor(); - + // for the axis controls float delta_x = 0.0f, delta_y = 0.0f; double delta_delta; - + // Iterate through the event queue - update the axis controls, mouse // button controls, and keyboard controls. XEvent event; - while (XPending(m_display)) + while (XPending(m_display)) { XNextEvent(m_display, &event); - + if (event.xcookie.type != GenericEvent) continue; if (event.xcookie.extension != xi_opcode) continue; if (!XGetEventData(m_display, &event.xcookie)) continue; - + // only one of these will get used XIDeviceEvent* dev_event = (XIDeviceEvent*)event.xcookie.data; XIRawEvent* raw_event = (XIRawEvent*)event.xcookie.data; - + switch (event.xcookie.evtype) { case XI_ButtonPress: @@ -254,7 +254,7 @@ bool KeyboardMouse::UpdateInput() m_state.keyboard[dev_event->detail / 8] &= ~(1<<(dev_event->detail % 8)); break; case XI_RawMotion: - // always safe because there is always at least one byte in + // always safe because there is always at least one byte in // raw_event->valuators.mask, and if a bit is set in the mask, // then the value in raw_values is also available. if (XIMaskIsSet(raw_event->valuators.mask, 0)) @@ -273,10 +273,10 @@ bool KeyboardMouse::UpdateInput() } break; } - + XFreeEventData(m_display, &event.xcookie); } - + // apply axis smoothing m_state.axis.x *= MOUSE_AXIS_SMOOTHING; m_state.axis.x += delta_x; @@ -284,7 +284,7 @@ bool KeyboardMouse::UpdateInput() m_state.axis.y *= MOUSE_AXIS_SMOOTHING; m_state.axis.y += delta_y; m_state.axis.y /= MOUSE_AXIS_SMOOTHING+1.0f; - + return true; } @@ -322,10 +322,10 @@ KeyboardMouse::Key::Key(Display* const display, KeyCode keycode, const char* key } while (keysym == NoSymbol && i < 8); - // Convert to upper case for the keyname + // Convert to upper case for the keyname if (keysym >= 97 && keysym <= 122) keysym -= 32; - + // 0x0110ffff is the top of the unicode character range according // to keysymdef.h although it is probably more than we need. if (keysym == NoSymbol || keysym > 0x0110ffff || diff --git a/Source/Core/InputCommon/Src/ControllerInterface/Xlib/XInput2.h b/Source/Core/InputCommon/Src/ControllerInterface/Xlib/XInput2.h index 58a1a38c8c..dfb8fa285d 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/Xlib/XInput2.h +++ b/Source/Core/InputCommon/Src/ControllerInterface/Xlib/XInput2.h @@ -35,7 +35,7 @@ private: float x, y; } cursor, axis; }; - + class Key : public Input { friend class KeyboardMouse; @@ -43,21 +43,21 @@ private: std::string GetName() const { return m_keyname; } Key(Display* display, KeyCode keycode, const char* keyboard); ControlState GetState() const; - + private: std::string m_keyname; Display* const m_display; const char* const m_keyboard; const KeyCode m_keycode; }; - + class Button : public Input { public: std::string GetName() const { return name; } Button(unsigned int index, unsigned int& buttons); ControlState GetState() const; - + private: const unsigned int& m_buttons; const unsigned int m_index; @@ -71,14 +71,14 @@ private: bool IsDetectable() { return false; } Cursor(u8 index, bool positive, const float& cursor); ControlState GetState() const; - + private: const float& m_cursor; const u8 m_index; const bool m_positive; std::string name; }; - + class Axis : public Input { public: @@ -93,22 +93,22 @@ private: const bool m_positive; std::string name; }; - + private: void SelectEventsForDevice(Window window, XIEventMask *mask, int deviceid); void UpdateCursor(); - + public: bool UpdateInput(); bool UpdateOutput(); - + KeyboardMouse(Window window, int opcode, int pointer_deviceid, int keyboard_deviceid); ~KeyboardMouse(); - + std::string GetName() const; std::string GetSource() const; int GetId() const; - + private: Window m_window; Display* m_display; diff --git a/Source/Core/InputCommon/Src/ControllerInterface/Xlib/Xlib.cpp b/Source/Core/InputCommon/Src/ControllerInterface/Xlib/Xlib.cpp index 7016c4908b..e507b88c9f 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/Xlib/Xlib.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/Xlib/Xlib.cpp @@ -20,7 +20,7 @@ KeyboardMouse::KeyboardMouse(Window window) : m_window(window) int min_keycode, max_keycode; XDisplayKeycodes(m_display, &min_keycode, &max_keycode); - + // Keyboard Keys for (int i = min_keycode; i <= max_keycode; ++i) { @@ -99,7 +99,7 @@ KeyboardMouse::Key::Key(Display* const display, KeyCode keycode, const char* key i++; } while (keysym == NoSymbol && i < 8); - + // Convert to upper case for the keyname if (keysym >= 97 && keysym <= 122) keysym -= 32; diff --git a/Source/Core/InputCommon/Src/ControllerInterface/Xlib/Xlib.h b/Source/Core/InputCommon/Src/ControllerInterface/Xlib/Xlib.h index c178f1e9b4..35b6100081 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/Xlib/Xlib.h +++ b/Source/Core/InputCommon/Src/ControllerInterface/Xlib/Xlib.h @@ -26,7 +26,7 @@ private: float x, y; } cursor; }; - + class Key : public Input { friend class KeyboardMouse; @@ -34,14 +34,14 @@ private: std::string GetName() const; Key(Display* display, KeyCode keycode, const char* keyboard); ControlState GetState() const; - + private: std::string m_keyname; Display* const m_display; const char* const m_keyboard; const KeyCode m_keycode; }; - + class Button : public Input { public: @@ -49,7 +49,7 @@ private: Button(unsigned int index, unsigned int& buttons) : m_buttons(buttons), m_index(index) {} ControlState GetState() const; - + private: const unsigned int& m_buttons; const unsigned int m_index; @@ -69,18 +69,18 @@ private: const u8 m_index; const bool m_positive; }; - + public: bool UpdateInput(); bool UpdateOutput(); - + KeyboardMouse(Window window); ~KeyboardMouse(); - + std::string GetName() const; std::string GetSource() const; int GetId() const; - + private: Window m_window; Display* m_display; diff --git a/Source/Core/InputCommon/Src/UDPWiimote.cpp b/Source/Core/InputCommon/Src/UDPWiimote.cpp index e0cf787e0f..5419cb61ce 100644 --- a/Source/Core/InputCommon/Src/UDPWiimote.cpp +++ b/Source/Core/InputCommon/Src/UDPWiimote.cpp @@ -59,12 +59,12 @@ struct UDPWiimote::_d int UDPWiimote::noinst = 0; -UDPWiimote::UDPWiimote(const char *_port, const char * name, int _index) : +UDPWiimote::UDPWiimote(const char *_port, const char * name, int _index) : port(_port), displayName(name), d(new _d) ,x(0),y(0),z(1.0f),naX(0),naY(0),naZ(-1.0f),nunX(0),nunY(0), pointerX(1001.0f/2),pointerY(0),nunMask(0),mask(0),index(_index), int_port(atoi(_port)) { - + static bool sranded=false; if (!sranded) { @@ -72,7 +72,7 @@ UDPWiimote::UDPWiimote(const char *_port, const char * name, int _index) : sranded=true; } bcastMagic=rand() & 0xFFFF; - + #ifdef _WIN32 u_long iMode = 1; #endif @@ -88,21 +88,21 @@ UDPWiimote::UDPWiimote(const char *_port, const char * name, int _index) : WSAStartup(sockVersion, &wsaData); } #endif - + noinst++; memset(&hints, 0, sizeof hints); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_DGRAM; hints.ai_flags = AI_PASSIVE; // use my IP - + if (!int_port) { cleanup; err=-1; return; } - + if ((rv = getaddrinfo(NULL, _port, &hints, &servinfo)) != 0) { cleanup; @@ -126,14 +126,14 @@ UDPWiimote::UDPWiimote(const char *_port, const char * name, int _index) : } d->sockfds.push_back(sock); } - + if (d->sockfds.empty()) { cleanup; err=-2; return; } - + freeaddrinfo(servinfo); err=0; d->exit=false; @@ -160,15 +160,15 @@ void UDPWiimote::mainThread() { int maxfd=0; FD_ZERO(&fds); - for (std::list<sock_t>::iterator i=d->sockfds.begin(); i!=d->sockfds.end(); i++) + for (auto& fd : d->sockfds) { - FD_SET(*i,&fds); + FD_SET(fd,&fds); #ifndef _WIN32 - if (*i>=maxfd) - maxfd=(*i)+1; + if (fd>=maxfd) + maxfd=(fd)+1; #endif } - + u64 tleft=timeout.tv_sec*1000+timeout.tv_usec/1000; u64 telapsed=time.GetTimeDifference(); time.Update(); @@ -184,29 +184,28 @@ void UDPWiimote::mainThread() timeout.tv_sec=(long)(tleft/1000); timeout.tv_usec=(tleft%1000)*1000; } - + lk.unlock(); //VERY hacky. don't like it - if (d->exit) return; + if (d->exit) return; int rt=select(maxfd,&fds,NULL,NULL,&timeout); if (d->exit) return; lk.lock(); if (d->exit) return; - + if (rt) { - for (std::list<sock_t>::iterator i=d->sockfds.begin(); i!=d->sockfds.end(); i++) + for (sock_t fd : d->sockfds) { - if (FD_ISSET(*i,&fds)) + if (FD_ISSET(fd,&fds)) { - sock_t fd=*i; u8 bf[64]; int size=60; size_t addr_len; struct sockaddr_storage their_addr; addr_len = sizeof their_addr; - if ((size = recvfrom(fd, - (dataz)bf, - size , 0,(struct sockaddr *)&their_addr, (socklen_t*)&addr_len)) == -1) + if ((size = recvfrom(fd, + (dataz)bf, + size , 0,(struct sockaddr *)&their_addr, (socklen_t*)&addr_len)) == -1) { ERROR_LOG(WIIMOTE,"UDPWii Packet error"); } @@ -235,8 +234,8 @@ UDPWiimote::~UDPWiimote() std::lock_guard<std::mutex> lk(d->termLock); d->thread.join(); } - for (std::list<sock_t>::iterator i=d->sockfds.begin(); i!=d->sockfds.end(); i++) - close(*i); + for (auto& elem : d->sockfds) + close(elem); close(d->bipv4_fd); close(d->bipv6_fd); cleanup; @@ -328,7 +327,7 @@ void UDPWiimote::initBroadcastIPv4() WARN_LOG(WIIMOTE,"socket() failed"); return; } - + int broad=1; if (setsockopt(d->bipv4_fd,SOL_SOCKET,SO_BROADCAST, (const dataz)(&broad), sizeof broad) == -1) { @@ -345,7 +344,7 @@ void UDPWiimote::broadcastIPv4(const void * data, size_t size) their_addr.sin_port = htons(4431); their_addr.sin_addr.s_addr = INADDR_BROADCAST; memset(their_addr.sin_zero, '\0', sizeof their_addr.sin_zero); - + int num; if ((num=sendto(d->bipv4_fd,(const dataz)data,(int)size,0,(struct sockaddr *) &their_addr, sizeof their_addr)) == -1) { diff --git a/Source/Core/InputCommon/Src/UDPWiimote.h b/Source/Core/InputCommon/Src/UDPWiimote.h index 01b9b11969..877cb87473 100644 --- a/Source/Core/InputCommon/Src/UDPWiimote.h +++ b/Source/Core/InputCommon/Src/UDPWiimote.h @@ -38,7 +38,7 @@ private: std::string port,displayName; int pharsePacket(u8 * data, size_t size); struct _d; //using pimpl because Winsock2.h doesn't have include guards -_- - _d *d; + _d *d; double x,y,z; double naX,naY,naZ; double nunX,nunY; diff --git a/Source/Core/InputCommon/Src/UDPWrapper.cpp b/Source/Core/InputCommon/Src/UDPWrapper.cpp index e176a2164d..7fc77c4f44 100644 --- a/Source/Core/InputCommon/Src/UDPWrapper.cpp +++ b/Source/Core/InputCommon/Src/UDPWrapper.cpp @@ -12,7 +12,7 @@ const char* DefaultPort(const int index) return s.c_str(); } -UDPWrapper::UDPWrapper(int indx, const char* const _name) : +UDPWrapper::UDPWrapper(int indx, const char* const _name) : ControllerEmu::ControlGroup(_name,GROUP_TYPE_UDPWII), inst(NULL), index(indx), updIR(false),updAccel(false), diff --git a/Source/Core/InputCommon/Src/X11InputBase.cpp b/Source/Core/InputCommon/Src/X11InputBase.cpp index d23d2d77c5..b555a21449 100644 --- a/Source/Core/InputCommon/Src/X11InputBase.cpp +++ b/Source/Core/InputCommon/Src/X11InputBase.cpp @@ -105,7 +105,7 @@ KeySym wxCharCodeWXToX(int id) if (id >= 65 && id <= 90) // Standard uppercase letter: return lowercase keycode keySym = (KeySym)id + 32; - else + else // All other keyboard characters keySym = id <= 255 ? (KeySym)id : 0; } @@ -126,7 +126,7 @@ int wxKeyModWXToX(int modstate) #endif void XKeyToString(unsigned int keycode, char *keyStr) { switch (keycode) - { + { case XK_Insert: sprintf(keyStr, "INSERT"); break; @@ -148,10 +148,10 @@ void XKeyToString(unsigned int keycode, char *keyStr) { case XK_Left: sprintf(keyStr, "LEFT"); break; - case XK_Up: + case XK_Up: sprintf(keyStr, "UP"); break; - case XK_Right: + case XK_Right: sprintf(keyStr, "RIGHT"); break; case XK_Down: @@ -178,10 +178,10 @@ void XKeyToString(unsigned int keycode, char *keyStr) { case XK_KP_Left: sprintf(keyStr, "KP LEFT"); break; - case XK_KP_Up: + case XK_KP_Up: sprintf(keyStr, "KP UP"); break; - case XK_KP_Right: + case XK_KP_Right: sprintf(keyStr, "KP RIGHT"); break; case XK_KP_Down: diff --git a/Source/Core/InputCommon/Src/stdafx.cpp b/Source/Core/InputCommon/Src/stdafx.cpp new file mode 100644 index 0000000000..b602b39925 --- /dev/null +++ b/Source/Core/InputCommon/Src/stdafx.cpp @@ -0,0 +1,5 @@ +// Copyright 2013 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#include "stdafx.h" diff --git a/Source/Core/InputCommon/Src/stdafx.h b/Source/Core/InputCommon/Src/stdafx.h new file mode 100644 index 0000000000..498a15a12f --- /dev/null +++ b/Source/Core/InputCommon/Src/stdafx.h @@ -0,0 +1,14 @@ +// Copyright 2013 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#pragma once +/* +#define _WIN32_WINNT 0x501 +#ifndef _WIN32_IE +#define _WIN32_IE 0x0500 // Default value is 0x0400 +#endif +*/ +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +#include <algorithm> |
