[idd] input: add virtual HID driver

Build LGInput as an independent UMDF driver with its own entry point,
service, tracing, and binary.

Expose absolute pointer, relative mouse, and keyboard collections with a
guarded report queue.

Keep LGIdd as the startup and deployment project. Give it a non-linking
build/package dependency on LGInput so F5 stages both driver stacks and
installs them together through LGIddInstall, while the two UMDF binaries
remain independent for future IPC.

Stage both DLLs for the NSIS installer, retain the WDK UMDF remote-debug
startup attachment, and move CSRWLock into LGCommon for the input
driver's report queue.
This commit is contained in:
Geoffrey McRae
2026-08-08 11:36:16 +10:00
parent d3fff4eb57
commit 214665bedd
20 changed files with 1372 additions and 98 deletions

View File

@@ -6,9 +6,12 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LGIdd", "LGIdd\LGIdd.vcxproj", "{1CBF3DAA-0726-4F5F-88A2-04D95FB6591A}"
ProjectSection(ProjectDependencies) = postProject
{0045D7AD-3F26-4B87-81CB-78D18839596D} = {0045D7AD-3F26-4B87-81CB-78D18839596D}
{23EC8370-5F3B-4D18-8C31-E89A154F3666} = {23EC8370-5F3B-4D18-8C31-E89A154F3666}
{FFCC376C-4D98-4B50-B431-E1BBC9C67E65} = {FFCC376C-4D98-4B50-B431-E1BBC9C67E65}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LGInput", "LGInput\LGInput.vcxproj", "{2477B25B-CB62-4AD9-A260-CE5F00D77EEB}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LGMP", "..\repos\LGMP\LGMP.vcxproj", "{FFCC376C-4D98-4B50-B431-E1BBC9C67E65}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LGIddHelper", "LGIddHelper\LGIddHelper.vcxproj", "{0045D7AD-3F26-4B87-81CB-78D18839596D}"
@@ -17,6 +20,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LGCommon", "LGCommon", "{AC
ProjectSection(SolutionItems) = preProject
LGCommon\CDebug.cpp = LGCommon\CDebug.cpp
LGCommon\CDebug.h = LGCommon\CDebug.h
LGCommon\CSRWLock.h = LGCommon\CSRWLock.h
LGCommon\DefaultDisplayModes.h = LGCommon\DefaultDisplayModes.h
LGCommon\PipeMsg.h = LGCommon\PipeMsg.h
EndProjectSection
@@ -26,49 +30,55 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Debug-LGInput|x64 = Debug-LGInput|x64
Release|x64 = Release|x64
Release|x86 = Release|x86
Release-LGInput|x64 = Release-LGInput|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1CBF3DAA-0726-4F5F-88A2-04D95FB6591A}.Debug|x64.ActiveCfg = Debug|x64
{1CBF3DAA-0726-4F5F-88A2-04D95FB6591A}.Debug|x64.Build.0 = Debug|x64
{1CBF3DAA-0726-4F5F-88A2-04D95FB6591A}.Debug|x64.Deploy.0 = Debug|x64
{1CBF3DAA-0726-4F5F-88A2-04D95FB6591A}.Debug|x86.ActiveCfg = Debug|Win32
{1CBF3DAA-0726-4F5F-88A2-04D95FB6591A}.Debug|x86.Build.0 = Debug|Win32
{1CBF3DAA-0726-4F5F-88A2-04D95FB6591A}.Debug|x86.Deploy.0 = Debug|Win32
{1CBF3DAA-0726-4F5F-88A2-04D95FB6591A}.Debug-LGInput|x64.ActiveCfg = Debug-LGInput|x64
{1CBF3DAA-0726-4F5F-88A2-04D95FB6591A}.Debug-LGInput|x64.Build.0 = Debug-LGInput|x64
{1CBF3DAA-0726-4F5F-88A2-04D95FB6591A}.Debug-LGInput|x64.Deploy.0 = Debug-LGInput|x64
{1CBF3DAA-0726-4F5F-88A2-04D95FB6591A}.Release|x64.ActiveCfg = Release|x64
{1CBF3DAA-0726-4F5F-88A2-04D95FB6591A}.Release|x64.Build.0 = Release|x64
{1CBF3DAA-0726-4F5F-88A2-04D95FB6591A}.Release|x64.Deploy.0 = Release|x64
{1CBF3DAA-0726-4F5F-88A2-04D95FB6591A}.Release|x86.ActiveCfg = Release|Win32
{1CBF3DAA-0726-4F5F-88A2-04D95FB6591A}.Release|x86.Build.0 = Release|Win32
{1CBF3DAA-0726-4F5F-88A2-04D95FB6591A}.Release|x86.Deploy.0 = Release|Win32
{1CBF3DAA-0726-4F5F-88A2-04D95FB6591A}.Release-LGInput|x64.ActiveCfg = Release-LGInput|x64
{1CBF3DAA-0726-4F5F-88A2-04D95FB6591A}.Release-LGInput|x64.Build.0 = Release-LGInput|x64
{1CBF3DAA-0726-4F5F-88A2-04D95FB6591A}.Release-LGInput|x64.Deploy.0 = Release-LGInput|x64
{2477B25B-CB62-4AD9-A260-CE5F00D77EEB}.Debug|x64.ActiveCfg = Debug|x64
{2477B25B-CB62-4AD9-A260-CE5F00D77EEB}.Debug|x64.Build.0 = Debug|x64
{2477B25B-CB62-4AD9-A260-CE5F00D77EEB}.Debug-LGInput|x64.ActiveCfg = Debug|x64
{2477B25B-CB62-4AD9-A260-CE5F00D77EEB}.Debug-LGInput|x64.Build.0 = Debug|x64
{2477B25B-CB62-4AD9-A260-CE5F00D77EEB}.Release|x64.ActiveCfg = Release|x64
{2477B25B-CB62-4AD9-A260-CE5F00D77EEB}.Release|x64.Build.0 = Release|x64
{2477B25B-CB62-4AD9-A260-CE5F00D77EEB}.Release-LGInput|x64.ActiveCfg = Release|x64
{2477B25B-CB62-4AD9-A260-CE5F00D77EEB}.Release-LGInput|x64.Build.0 = Release|x64
{FFCC376C-4D98-4B50-B431-E1BBC9C67E65}.Debug|x64.ActiveCfg = Debug|x64
{FFCC376C-4D98-4B50-B431-E1BBC9C67E65}.Debug|x64.Build.0 = Debug|x64
{FFCC376C-4D98-4B50-B431-E1BBC9C67E65}.Debug|x86.ActiveCfg = Debug|Win32
{FFCC376C-4D98-4B50-B431-E1BBC9C67E65}.Debug|x86.Build.0 = Debug|Win32
{FFCC376C-4D98-4B50-B431-E1BBC9C67E65}.Debug|x86.Deploy.0 = Debug|Win32
{FFCC376C-4D98-4B50-B431-E1BBC9C67E65}.Debug-LGInput|x64.ActiveCfg = Debug|x64
{FFCC376C-4D98-4B50-B431-E1BBC9C67E65}.Debug-LGInput|x64.Build.0 = Debug|x64
{FFCC376C-4D98-4B50-B431-E1BBC9C67E65}.Release|x64.ActiveCfg = Release|x64
{FFCC376C-4D98-4B50-B431-E1BBC9C67E65}.Release|x64.Build.0 = Release|x64
{FFCC376C-4D98-4B50-B431-E1BBC9C67E65}.Release|x86.ActiveCfg = Release|Win32
{FFCC376C-4D98-4B50-B431-E1BBC9C67E65}.Release|x86.Build.0 = Release|Win32
{FFCC376C-4D98-4B50-B431-E1BBC9C67E65}.Release|x86.Deploy.0 = Release|Win32
{FFCC376C-4D98-4B50-B431-E1BBC9C67E65}.Release-LGInput|x64.ActiveCfg = Release|x64
{FFCC376C-4D98-4B50-B431-E1BBC9C67E65}.Release-LGInput|x64.Build.0 = Release|x64
{0045D7AD-3F26-4B87-81CB-78D18839596D}.Debug|x64.ActiveCfg = Debug|x64
{0045D7AD-3F26-4B87-81CB-78D18839596D}.Debug|x64.Build.0 = Debug|x64
{0045D7AD-3F26-4B87-81CB-78D18839596D}.Debug|x86.ActiveCfg = Debug|Win32
{0045D7AD-3F26-4B87-81CB-78D18839596D}.Debug|x86.Build.0 = Debug|Win32
{0045D7AD-3F26-4B87-81CB-78D18839596D}.Debug-LGInput|x64.ActiveCfg = Debug|x64
{0045D7AD-3F26-4B87-81CB-78D18839596D}.Debug-LGInput|x64.Build.0 = Debug|x64
{0045D7AD-3F26-4B87-81CB-78D18839596D}.Release|x64.ActiveCfg = Release|x64
{0045D7AD-3F26-4B87-81CB-78D18839596D}.Release|x64.Build.0 = Release|x64
{0045D7AD-3F26-4B87-81CB-78D18839596D}.Release|x86.ActiveCfg = Release|Win32
{0045D7AD-3F26-4B87-81CB-78D18839596D}.Release|x86.Build.0 = Release|Win32
{0045D7AD-3F26-4B87-81CB-78D18839596D}.Release-LGInput|x64.ActiveCfg = Release|x64
{0045D7AD-3F26-4B87-81CB-78D18839596D}.Release-LGInput|x64.Build.0 = Release|x64
{23EC8370-5F3B-4D18-8C31-E89A154F3666}.Debug|x64.ActiveCfg = Debug|x64
{23EC8370-5F3B-4D18-8C31-E89A154F3666}.Debug|x64.Build.0 = Debug|x64
{23EC8370-5F3B-4D18-8C31-E89A154F3666}.Debug|x86.ActiveCfg = Debug|Win32
{23EC8370-5F3B-4D18-8C31-E89A154F3666}.Debug|x86.Build.0 = Debug|Win32
{23EC8370-5F3B-4D18-8C31-E89A154F3666}.Debug-LGInput|x64.ActiveCfg = Debug|x64
{23EC8370-5F3B-4D18-8C31-E89A154F3666}.Debug-LGInput|x64.Build.0 = Debug|x64
{23EC8370-5F3B-4D18-8C31-E89A154F3666}.Release|x64.ActiveCfg = Release|x64
{23EC8370-5F3B-4D18-8C31-E89A154F3666}.Release|x64.Build.0 = Release|x64
{23EC8370-5F3B-4D18-8C31-E89A154F3666}.Release|x86.ActiveCfg = Release|Win32
{23EC8370-5F3B-4D18-8C31-E89A154F3666}.Release|x86.Build.0 = Release|Win32
{23EC8370-5F3B-4D18-8C31-E89A154F3666}.Release-LGInput|x64.ActiveCfg = Release|x64
{23EC8370-5F3B-4D18-8C31-E89A154F3666}.Release-LGInput|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -18,6 +18,14 @@
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug-LGInput|x64">
<Configuration>Debug-LGInput</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release-LGInput|x64">
<Configuration>Release-LGInput</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />
@@ -109,7 +117,6 @@
<ClInclude Include="transport\lgmp\CLGMPTransport.h" />
<ClInclude Include="config\CSettings.h" />
<ClInclude Include="platform\CPlatformInfo.h" />
<ClInclude Include="util\CSRWLock.h" />
</ItemGroup>
<ItemGroup>
<Inf Include="LGIdd.inf" />
@@ -121,8 +128,14 @@
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
<Configuration>Debug</Configuration>
<Platform Condition="'$(Platform)' == ''">Win32</Platform>
<LGBaseConfiguration Condition="'$(Configuration)'=='Debug-LGInput'">Debug</LGBaseConfiguration>
<LGBaseConfiguration Condition="'$(Configuration)'=='Release-LGInput'">Release</LGBaseConfiguration>
<LGBaseConfiguration Condition="'$(LGBaseConfiguration)'==''">$(Configuration)</LGBaseConfiguration>
<LGInputDeployPackage Condition="'$(Configuration)'=='Debug-LGInput' or '$(Configuration)'=='Release-LGInput'">true</LGInputDeployPackage>
<RootNamespace>LGIdd</RootNamespace>
<WindowsTargetPlatformVersion>10.0.26100.0</WindowsTargetPlatformVersion>
<LGDriverSolutionDir>$([MSBuild]::NormalizeDirectory('$(MSBuildProjectDirectory)\..'))</LGDriverSolutionDir>
<SolutionDir Condition="'$(SolutionDir)'==''">$(LGDriverSolutionDir)</SolutionDir>
</PropertyGroup>
<PropertyGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<PlatformToolset>WindowsUserModeDriver10.0</PlatformToolset>
@@ -134,11 +147,11 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<DriverTargetPlatform>Universal</DriverTargetPlatform>
</PropertyGroup>
<PropertyGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PropertyGroup Label="PropertySheets" Condition="'$(LGBaseConfiguration)|$(Platform)'=='Debug|x64'">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<DriverTargetPlatform>Universal</DriverTargetPlatform>
</PropertyGroup>
<PropertyGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<PropertyGroup Label="PropertySheets" Condition="'$(LGBaseConfiguration)|$(Platform)'=='Release|x64'">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<DriverTargetPlatform>Universal</DriverTargetPlatform>
</PropertyGroup>
@@ -167,7 +180,7 @@
<UMDF_MINIMUM_VERSION_REQUIRED>25</UMDF_MINIMUM_VERSION_REQUIRED>
<_NT_TARGET_VERSION>0xA000005</_NT_TARGET_VERSION>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<PropertyGroup Condition="'$(LGBaseConfiguration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>true</UseDebugLibraries>
<UMDF_VERSION_MAJOR>2</UMDF_VERSION_MAJOR>
@@ -180,7 +193,7 @@
<_NT_TARGET_VERSION>0xA000005</_NT_TARGET_VERSION>
<PlatformToolset>WindowsUserModeDriver10.0</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<PropertyGroup Condition="'$(LGBaseConfiguration)|$(Platform)'=='Release|x64'" Label="Configuration">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>false</UseDebugLibraries>
<UMDF_VERSION_MAJOR>2</UMDF_VERSION_MAJOR>
@@ -208,14 +221,18 @@
<DebuggerFlavor>DbgengRemoteDebugger</DebuggerFlavor>
<Inf2CatUseLocalTime>true</Inf2CatUseLocalTime>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PropertyGroup Condition="'$(LGBaseConfiguration)|$(Platform)'=='Debug|x64'">
<DebuggerFlavor>DbgengRemoteDebugger</DebuggerFlavor>
<Inf2CatUseLocalTime>true</Inf2CatUseLocalTime>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<PropertyGroup Condition="'$(LGBaseConfiguration)|$(Platform)'=='Release|x64'">
<DebuggerFlavor>DbgengRemoteDebugger</DebuggerFlavor>
<Inf2CatUseLocalTime>true</Inf2CatUseLocalTime>
</PropertyGroup>
<PropertyGroup>
<LGPackageToolOutDir Condition="'$(Platform)'=='x64'">$([MSBuild]::NormalizeDirectory('$(LGDriverSolutionDir)$(Platform)\$(LGBaseConfiguration)'))</LGPackageToolOutDir>
<LGPackageToolOutDir Condition="'$(Platform)'=='Win32'">$([MSBuild]::NormalizeDirectory('$(LGDriverSolutionDir)$(LGBaseConfiguration)'))</LGPackageToolOutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WppEnabled>true</WppEnabled>
@@ -246,7 +263,7 @@
<FileDigestAlgorithm>SHA1</FileDigestAlgorithm>
</DriverSign>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ItemDefinitionGroup Condition="'$(LGBaseConfiguration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WppEnabled>true</WppEnabled>
<WppRecorderEnabled>true</WppRecorderEnabled>
@@ -261,7 +278,7 @@
<FileDigestAlgorithm>SHA1</FileDigestAlgorithm>
</DriverSign>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ItemDefinitionGroup Condition="'$(LGBaseConfiguration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WppEnabled>true</WppEnabled>
<WppRecorderEnabled>true</WppRecorderEnabled>
@@ -278,13 +295,58 @@
</ItemDefinitionGroup>
<ItemGroup>
<FilesToPackage Include="$(TargetPath)" />
<FilesToPackage Include="$(LGPackageToolOutDir)LGIddHelper.exe" />
<FilesToPackage Include="$(LGPackageToolOutDir)LGIddInstall.exe" />
<FilesToPackage Include="$(ProjectDir)..\installer.nsi" />
<FilesToPackage Include="$(ProjectDir)..\..\resources\icon.ico" />
<FilesToPackage Include="$(ProjectDir)..\..\LICENSE" />
<FilesToPackage Include="$(ProjectDir)..\LGIddHelper\VERSION" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LGInput\LGInput.vcxproj">
<Project>{2477b25b-cb62-4ad9-a260-ce5f00d77eeb}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<LinkLibraryDependencies>false</LinkLibraryDependencies>
<PackageRelativeDirectory>LGInput</PackageRelativeDirectory>
<AdditionalProperties Condition="'$(CurrentSolutionConfigurationContents)'==''">Configuration=$(LGBaseConfiguration);Platform=$(Platform);SolutionDir=$(LGDriverSolutionDir)</AdditionalProperties>
</ProjectReference>
<ProjectReference Include="..\..\repos\LGMP\LGMP.vcxproj">
<Project>{ffcc376c-4d98-4b50-b431-e1bbc9c67e65}</Project>
<AdditionalProperties Condition="'$(CurrentSolutionConfigurationContents)'==''">Configuration=$(LGBaseConfiguration);Platform=$(Platform);SolutionDir=$(LGDriverSolutionDir)</AdditionalProperties>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<PropertyGroup>
<RemoveDriver>false</RemoveDriver>
<InstallMode>CustomCommand</InstallMode>
<CommandLine Condition="'$(LGInputDeployPackage)'!='true'">%ComSpec% /d /s /c LGIddInstall.exe install LGIdd LGInput</CommandLine>
<CommandLine Condition="'$(LGInputDeployPackage)'=='true'">%ComSpec% /d /s /c LGIddInstall.exe install LGInput LGIdd</CommandLine>
<DeployFiles>$(PackageDir)LGIddInstall.exe</DeployFiles>
</PropertyGroup>
<Target Name="BuildLGIddPackageTools"
BeforeTargets="DriverPackageTarget"
Condition="'$(CurrentSolutionConfigurationContents)'==''">
<MSBuild
Projects="$(ProjectDir)..\LGIddHelper\LGIddHelper.vcxproj;$(ProjectDir)..\LGIddInstall\LGIddInstall.vcxproj"
Targets="Build"
BuildInParallel="false"
StopOnFirstFailure="true"
Properties="Configuration=$(LGBaseConfiguration);Platform=$(Platform);SolutionDir=$(LGDriverSolutionDir)" />
</Target>
<Target Name="CleanDriverPackageDirectory" BeforeTargets="DriverPackageTarget">
<RemoveDir Directories="$(PackageDir)" />
</Target>
<PropertyGroup>
<LGPeerPackageStageAfterTargets Condition="'$(SignMode)'=='TestSign'">PackageTestSign</LGPeerPackageStageAfterTargets>
<LGPeerPackageStageAfterTargets Condition="'$(SignMode)'=='ProductionSign'">PackageProductionSign</LGPeerPackageStageAfterTargets>
<LGPeerPackageStageAfterTargets Condition="'$(LGPeerPackageStageAfterTargets)'==''">Inf2Cat</LGPeerPackageStageAfterTargets>
</PropertyGroup>
<Target Name="StageLGInputDeployPackage" AfterTargets="$(LGPeerPackageStageAfterTargets)">
<Error
Condition="!Exists('$(PackageDir)LGInput\LGInput.inf') or !Exists('$(PackageDir)LGInput\LGInput.dll') or !Exists('$(PackageDir)LGInput\LGInput.cat')"
Text="The deployment package is missing one or more signed LGInput files." />
<Copy SourceFiles="$(PackageDir)LGInput\LGInput.inf;$(PackageDir)LGInput\LGInput.dll;$(PackageDir)LGInput\LGInput.cat" DestinationFolder="$(PackageDir)" />
</Target>
<ImportGroup Label="ExtensionTargets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>

View File

@@ -193,9 +193,6 @@
<ClInclude Include="platform\CPlatformInfo.h">
<Filter>Platform</Filter>
</ClInclude>
<ClInclude Include="util\CSRWLock.h">
<Filter>Utilities</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(SolutionDir)LGCommon\*.cpp">

View File

@@ -21,7 +21,7 @@
#include "capture/CHardwareFrameProcessor.h"
#include "capture/CFrameProcessorUtil.h"
#include "transport/IFrameTransport.h"
#include "util/CSRWLock.h"
#include "CSRWLock.h"
#include "CDebug.h"
#include <cstring>

View File

@@ -21,8 +21,8 @@
#include "capture/CSoftwareFrameProcessor.h"
#include "capture/CFrameProcessorUtil.h"
#include "capture/FramePipeline.h"
#include "CSRWLock.h"
#include "transport/IFrameTransport.h"
#include "util/CSRWLock.h"
#include "CDebug.h"
#include <utility>

View File

@@ -20,13 +20,13 @@
#include "capture/CSwapChainProcessor.h"
#include "capture/CFrameProcessorUtil.h"
#include "CSRWLock.h"
#include "display/IddCxCompat.h"
#include "display/CDeviceContext.h"
#include "display/CMonitorContext.h"
#include "platform/CPlatformInfo.h"
#include "transport/IFrameTransport.h"
#include "transport/IControlTransport.h"
#include "util/CSRWLock.h"
#include <avrt.h>
#include <new>

View File

@@ -21,7 +21,7 @@
#include "display/CDisplayConfiguration.h"
#include "CDebug.h"
#include "util/CSRWLock.h"
#include "CSRWLock.h"
#include <d3d12.h>
#include <iterator>

View File

@@ -36,17 +36,76 @@
#define LGIDD_CLASS_GUID GUID_DEVCLASS_DISPLAY
#define LGIDD_CLASS_NAME L"Display"
#define LGIDD_NAME L"LGIdd"
#define LGIDD_HWID L"Root\\LGIdd"
#define LGIDD_HWID_MULTI_SZ (LGIDD_HWID "\0")
#define LGIDD_INF_NAME L"LGIdd.inf"
#define LGIDD_PACKAGE_DIR L"LGIdd"
#define LGINPUT_CLASS_GUID GUID_DEVCLASS_HIDCLASS
#define LGINPUT_CLASS_NAME L"HIDClass"
#define LGINPUT_NAME L"LGInput"
#define LGINPUT_HWID L"Root\\LGInput"
#define LGINPUT_HWID_MULTI_SZ (LGINPUT_HWID "\0")
#define LGINPUT_INF_NAME L"LGInput.inf"
#define LGINPUT_PACKAGE_DIR L"LGInput"
#define LGIDD_REGKEY L"Software\\LookingGlass\\IDD"
#define DEVICE_COUNT 2
typedef struct DeviceDesc
{
const GUID *classGuid;
LPCWSTR className;
LPCWSTR name;
LPCWSTR hardwareId;
LPCWSTR hardwareIdMultiSz;
DWORD hardwareIdMultiSzSize;
LPCWSTR infName;
LPCWSTR packageDir;
}
DeviceDesc;
static const DeviceDesc LGIDD_DEVICE =
{
.classGuid = &LGIDD_CLASS_GUID,
.className = LGIDD_CLASS_NAME,
.name = LGIDD_NAME,
.hardwareId = LGIDD_HWID,
.hardwareIdMultiSz = LGIDD_HWID_MULTI_SZ,
.hardwareIdMultiSzSize = sizeof LGIDD_HWID_MULTI_SZ,
.infName = LGIDD_INF_NAME,
.packageDir = LGIDD_PACKAGE_DIR,
};
static const DeviceDesc LGINPUT_DEVICE =
{
.classGuid = &LGINPUT_CLASS_GUID,
.className = LGINPUT_CLASS_NAME,
.name = LGINPUT_NAME,
.hardwareId = LGINPUT_HWID,
.hardwareIdMultiSz = LGINPUT_HWID_MULTI_SZ,
.hardwareIdMultiSzSize = sizeof LGINPUT_HWID_MULTI_SZ,
.infName = LGINPUT_INF_NAME,
.packageDir = LGINPUT_PACKAGE_DIR,
};
void usage(wchar_t *program)
{
wprintf(L"Usage: %s <install|uninstall>\n", program);
wprintf(L"Usage: %s install [LGIdd LGInput|LGInput LGIdd]\n", program);
wprintf(L" %s uninstall\n", program);
exit(2);
}
const DeviceDesc *getDeviceByName(LPCWSTR name)
{
if (!_wcsicmp(name, LGIDD_DEVICE.name))
return &LGIDD_DEVICE;
if (!_wcsicmp(name, LGINPUT_DEVICE.name))
return &LGINPUT_DEVICE;
return NULL;
}
void debugWinError(const wchar_t *desc, HRESULT status)
{
wchar_t *buffer;
@@ -154,11 +213,18 @@ DWORD deleteKeyTreeHKLM()
return ec;
}
typedef bool (*IDD_FOUND_PROC)(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDevInfo, void *pContext);
typedef bool (*DEVICE_FOUND_PROC)(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDevInfo, void *pContext);
bool findIddDevice(IDD_FOUND_PROC procFound, void *pContext)
typedef struct DeviceRemovalContext
{
HDEVINFO hDevInfo = SetupDiGetClassDevsW(&LGIDD_CLASS_GUID, NULL, NULL, DIGCF_ALLCLASSES | DIGCF_PRESENT);
LPBOOL pbNeedRestart;
bool success;
}
DeviceRemovalContext;
bool findDevice(const DeviceDesc *device, DEVICE_FOUND_PROC procFound, void *pContext)
{
HDEVINFO hDevInfo = SetupDiGetClassDevsW(device->classGuid, NULL, NULL, DIGCF_ALLCLASSES | DIGCF_PRESENT);
if (hDevInfo == INVALID_HANDLE_VALUE)
{
debugWinError(L"SetupDiGetClassDevsW", GetLastError());
@@ -205,7 +271,7 @@ bool findIddDevice(IDD_FOUND_PROC procFound, void *pContext)
for (LPWSTR lpHwId = lpBuffer; *lpHwId; lpHwId += wcslen(lpBuffer) + 1)
{
if (!lstrcmpiW(lpHwId, LGIDD_HWID))
if (!lstrcmpiW(lpHwId, device->hardwareId))
{
found = true;
break;
@@ -232,24 +298,24 @@ enum DeviceCreated {
DEVICE_UNKNOWN,
};
bool isIddDeviceCreatedEnum(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDevInfo, void *pContext)
bool isDeviceCreatedEnum(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDevInfo, void *pContext)
{
enum DeviceCreated *result = pContext;
*result = DEVICE_CREATED;
return false;
}
enum DeviceCreated isIddDeviceCreated()
enum DeviceCreated isDeviceCreated(const DeviceDesc *device)
{
enum DeviceCreated result = DEVICE_UNKNOWN;
if (findIddDevice(isIddDeviceCreatedEnum, &result) && result == DEVICE_UNKNOWN)
if (findDevice(device, isDeviceCreatedEnum, &result) && result == DEVICE_UNKNOWN)
result = DEVICE_NOT_CREATED;
return result;
}
bool createIddDevice(void)
bool createDevice(const DeviceDesc *device)
{
HDEVINFO hDevInfo = SetupDiCreateDeviceInfoList(&LGIDD_CLASS_GUID, NULL);
HDEVINFO hDevInfo = SetupDiCreateDeviceInfoList(device->classGuid, NULL);
if (hDevInfo == INVALID_HANDLE_VALUE)
{
debugWinError(L"SetupDiCreateDeviceInfoList", GetLastError());
@@ -257,13 +323,14 @@ bool createIddDevice(void)
}
SP_DEVINFO_DATA devInfo = { .cbSize = sizeof devInfo, 0 };
if (!SetupDiCreateDeviceInfoW(hDevInfo, LGIDD_CLASS_NAME, &LGIDD_CLASS_GUID, NULL, NULL, DICD_GENERATE_ID, &devInfo))
if (!SetupDiCreateDeviceInfoW(hDevInfo, device->className, device->classGuid, NULL, NULL, DICD_GENERATE_ID, &devInfo))
{
debugWinError(L"SetupDiCreateDeviceInfoW", GetLastError());
goto fail;
}
if (!SetupDiSetDeviceRegistryPropertyW(hDevInfo, &devInfo, SPDRP_HARDWAREID, (PBYTE) LGIDD_HWID_MULTI_SZ, sizeof LGIDD_HWID_MULTI_SZ))
if (!SetupDiSetDeviceRegistryPropertyW(hDevInfo, &devInfo, SPDRP_HARDWAREID,
(PBYTE) device->hardwareIdMultiSz, device->hardwareIdMultiSzSize))
{
debugWinError(L"SetupDiSetDeviceRegistryPropertyW", GetLastError());
goto fail;
@@ -282,9 +349,9 @@ fail:
return false;
}
bool destroyIddDeviceEnum(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDevInfo, void* pContext)
bool destroyDeviceEnum(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDevInfo, void *pContext)
{
LPBOOL pbNeedRestart = pContext;
DeviceRemovalContext *context = pContext;
BOOL bNeedRestart;
WCHAR szInfPath[MAX_PATH] = { 0 };
@@ -312,40 +379,39 @@ bool destroyIddDeviceEnum(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDevInfo, void* pC
uninstall:
if (DiUninstallDevice(NULL, hDevInfo, pDevInfo, 0, &bNeedRestart))
*pbNeedRestart |= bNeedRestart;
*context->pbNeedRestart |= bNeedRestart;
else
{
debugWinError(L"DiUninstallDevice", GetLastError());
context->success = false;
return true;
}
if (*szInfPath)
{
if (DiUninstallDriverW(NULL, szInfPath, 0, &bNeedRestart))
*pbNeedRestart |= bNeedRestart;
*context->pbNeedRestart |= bNeedRestart;
else
debugWinError(L"DiUninstallDriverW", GetLastError());
}
DWORD ec = deleteKeyTreeHKLM();
if (ec != ERROR_SUCCESS)
{
debugWinError(L"deleteKeyTreeHKLM failed", ec);
// this is non-fatal
debugWinError(L"DiUninstallDriverW", GetLastError());
context->success = false;
}
}
return true;
}
void destroyIddDevice(LPBOOL pbNeedRestart)
bool destroyDevice(const DeviceDesc *device, LPBOOL pbNeedRestart)
{
findIddDevice(destroyIddDeviceEnum, pbNeedRestart);
DeviceRemovalContext context = { pbNeedRestart, true };
return findDevice(device, destroyDeviceEnum, &context) && context.success;
}
bool getIddInfPath(LPWSTR lpszInf)
bool getInfPath(const DeviceDesc *device, LPWSTR lpszInf)
{
WCHAR szDir[MAX_PATH];
WCHAR szInf[MAX_PATH];
WCHAR szPackageDir[MAX_PATH];
if (!GetModuleFileNameW(NULL, szDir, MAX_PATH))
{
@@ -354,7 +420,7 @@ bool getIddInfPath(LPWSTR lpszInf)
}
*PathFindFileNameW(szDir) = 0;
if (!PathCombineW(lpszInf, szDir, LGIDD_INF_NAME))
if (!PathCombineW(lpszInf, szDir, device->infName))
{
debugWinError(L"PathCombineW", GetLastError());
return false;
@@ -362,18 +428,28 @@ bool getIddInfPath(LPWSTR lpszInf)
if (!PathFileExistsW(lpszInf))
{
fwprintf(stderr, L"INF file does not exist: %s\n", szInf);
if (!PathCombineW(szPackageDir, szDir, device->packageDir) ||
!PathCombineW(lpszInf, szPackageDir, device->infName))
{
debugWinError(L"PathCombineW", GetLastError());
return false;
}
if (!PathFileExistsW(lpszInf))
{
fwprintf(stderr, L"INF file does not exist: %s\n", lpszInf);
return false;
}
}
return true;
}
bool installIddInf(PBOOL pbNeedRestart)
bool installInf(const DeviceDesc *device, PBOOL pbNeedRestart)
{
WCHAR szInf[MAX_PATH];
if (!getIddInfPath(szInf))
if (!getInfPath(device, szInf))
return false;
if (!DiInstallDriverW(NULL, szInf, DIIRFLAG_FORCE_INF, pbNeedRestart))
@@ -385,41 +461,75 @@ bool installIddInf(PBOOL pbNeedRestart)
return true;
}
void install()
void install(const DeviceDesc *const devices[DEVICE_COUNT])
{
switch (isIddDeviceCreated())
{
case DEVICE_NOT_CREATED:
wprintf(L"Creating LGIdd device: %s...\n", LGIDD_HWID);
if (!createIddDevice())
exit(1);
enum DeviceCreated created[DEVICE_COUNT];
for (size_t i = 0; i < DEVICE_COUNT; ++i)
{
created[i] = isDeviceCreated(devices[i]);
if (created[i] == DEVICE_UNKNOWN)
exit(1);
}
// fallthrough
case DEVICE_CREATED:
_putws(L"Preparing registry key...");
if (!ensureKeyWithAce())
exit(1);
_putws(L"Installing INF...");
BOOL bNeedRestart;
if (!installIddInf(&bNeedRestart))
BOOL bNeedRestart = FALSE;
BOOL bInfNeedRestart = FALSE;
for (size_t i = 0; i < DEVICE_COUNT; ++i)
{
const DeviceDesc *device = devices[i];
if (created[i] == DEVICE_NOT_CREATED)
{
wprintf(L"Preinstalling %s INF...\n", device->name);
bInfNeedRestart = FALSE;
if (!installInf(device, &bInfNeedRestart))
exit(1);
bNeedRestart |= bInfNeedRestart;
wprintf(L"Creating %s device: %s...\n", device->name, device->hardwareId);
if (!createDevice(device))
exit(1);
}
wprintf(L"Installing %s INF...\n", device->name);
bInfNeedRestart = FALSE;
if (!installInf(device, &bInfNeedRestart))
exit(1);
bNeedRestart |= bInfNeedRestart;
}
if (bNeedRestart)
{
_putws(L"Restart required to complete installation");
exit(12);
}
break;
case DEVICE_UNKNOWN:
exit(1);
}
}
void uninstall()
{
BOOL bNeedRestart = 0;
destroyIddDevice(&bNeedRestart);
bool success = true;
_putws(L"Uninstalling LGInput...");
success &= destroyDevice(&LGINPUT_DEVICE, &bNeedRestart);
_putws(L"Uninstalling LGIdd...");
success &= destroyDevice(&LGIDD_DEVICE, &bNeedRestart);
DWORD ec = deleteKeyTreeHKLM();
if (ec != ERROR_SUCCESS)
{
debugWinError(L"deleteKeyTreeHKLM failed", ec);
// this is non-fatal
}
if (!success)
exit(1);
if (bNeedRestart)
{
@@ -432,13 +542,32 @@ int wmain(int argc, wchar_t **argv)
{
_setmode(_fileno(stderr), _O_U16TEXT);
if (argc != 2)
if (argc < 2)
usage(argv[0]);
if (!wcscmp(argv[1], L"install"))
install();
{
const DeviceDesc *devices[DEVICE_COUNT] = { &LGIDD_DEVICE, &LGINPUT_DEVICE };
if (argc != 2)
{
if (argc != 4)
usage(argv[0]);
devices[0] = getDeviceByName(argv[2]);
devices[1] = getDeviceByName(argv[3]);
if (!devices[0] || !devices[1] || devices[0] == devices[1])
usage(argv[0]);
}
install(devices);
}
else if (!wcscmp(argv[1], L"uninstall"))
{
if (argc != 2)
usage(argv[0]);
uninstall();
}
else
usage(argv[0]);
}

400
idd/LGInput/CHIDDevice.cpp Normal file
View File

@@ -0,0 +1,400 @@
/**
* Looking Glass
* Copyright © 2017-2026 The Looking Glass Authors
* https://looking-glass.io
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "CHIDDevice.h"
#include "CSRWLock.h"
#include "HIDReports.h"
#include <hidport.h>
static constexpr USHORT LG_INPUT_VENDOR_ID = 0x0000;
static constexpr USHORT LG_INPUT_PRODUCT_ID = 0x0000;
static constexpr USHORT LG_INPUT_VERSION = 0x0001;
static constexpr size_t REPORT_QUEUE_LENGTH = 64;
struct HIDQueuedReport
{
UCHAR data[sizeof(HIDKeyboardReport)];
size_t size;
};
struct HIDDeviceContext
{
WDFQUEUE reportQueue;
HID_DEVICE_ATTRIBUTES attributes;
HID_DESCRIPTOR descriptor;
UCHAR keyboardLeds;
SRWLOCK reportLock;
bool active;
bool stopping;
size_t reportHead;
size_t reportCount;
HIDQueuedReport reports[REPORT_QUEUE_LENGTH];
};
WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(HIDDeviceContext, HIDGetDeviceContext);
static SRWLOCK s_deviceLock = SRWLOCK_INIT;
static HIDDeviceContext * s_device = nullptr;
EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL HIDEvtIoDeviceControl;
EVT_WDF_OBJECT_CONTEXT_CLEANUP HIDEvtReportQueueCleanup;
static NTSTATUS CopyToRequest(
_In_ WDFREQUEST request,
_In_reads_bytes_(size) const void * buffer,
_In_ size_t size)
{
WDFMEMORY memory;
NTSTATUS status = WdfRequestRetrieveOutputMemory(request, &memory);
if (!NT_SUCCESS(status))
return status;
size_t bufferSize;
WdfMemoryGetBuffer(memory, &bufferSize);
if (bufferSize < size)
return STATUS_BUFFER_TOO_SMALL;
status = WdfMemoryCopyFromBuffer(
memory, 0, const_cast<void *>(buffer), size);
if (NT_SUCCESS(status))
WdfRequestSetInformation(request, size);
return status;
}
static NTSTATUS GetOutputReport(
_In_ WDFREQUEST request,
_Out_ HID_XFER_PACKET * packet)
{
WDFMEMORY memory;
NTSTATUS status = WdfRequestRetrieveOutputMemory(request, &memory);
if (!NT_SUCCESS(status))
return status;
// mshidumdf carries the report ID in the output buffer length.
size_t outputBufferLength;
WdfMemoryGetBuffer(memory, &outputBufferLength);
packet->reportId = static_cast<UCHAR>(outputBufferLength);
status = WdfRequestRetrieveInputMemory(request, &memory);
if (!NT_SUCCESS(status))
return status;
size_t reportSize;
packet->reportBuffer =
static_cast<PUCHAR>(WdfMemoryGetBuffer(memory, &reportSize));
packet->reportBufferLen = static_cast<ULONG>(reportSize);
return STATUS_SUCCESS;
}
static NTSTATUS SetOutputReport(
_In_ WDFQUEUE queue,
_In_ WDFREQUEST request)
{
HID_XFER_PACKET packet = {};
NTSTATUS status = GetOutputReport(request, &packet);
if (!NT_SUCCESS(status))
return status;
if (packet.reportId != HID_REPORT_ID_KEYBOARD ||
packet.reportBufferLen < sizeof(HIDKeyboardLedsReport))
return STATUS_INVALID_PARAMETER;
const HIDKeyboardLedsReport * report =
reinterpret_cast<const HIDKeyboardLedsReport *>(packet.reportBuffer);
if (report->reportId != HID_REPORT_ID_KEYBOARD)
return STATUS_INVALID_PARAMETER;
WDFDEVICE device = WdfIoQueueGetDevice(queue);
HIDGetDeviceContext(device)->keyboardLeds = report->leds;
WdfRequestSetInformation(request, sizeof(*report));
return STATUS_SUCCESS;
}
static void PopReport(
_Inout_ HIDDeviceContext * context,
_Out_ HIDQueuedReport * report)
{
*report = context->reports[context->reportHead];
context->reportHead =
(context->reportHead + 1) % REPORT_QUEUE_LENGTH;
--context->reportCount;
}
static NTSTATUS QueueReport(
_Inout_ HIDDeviceContext * context,
_In_reads_bytes_(size) const void * data,
_In_ size_t size)
{
if (context->reportCount == REPORT_QUEUE_LENGTH)
return STATUS_BUFFER_OVERFLOW;
const size_t index =
(context->reportHead + context->reportCount) % REPORT_QUEUE_LENGTH;
HIDQueuedReport * report = &context->reports[index];
CopyMemory(report->data, data, size);
report->size = size;
++context->reportCount;
return STATUS_SUCCESS;
}
static NTSTATUS ReadReport(
_In_ HIDDeviceContext * context,
_In_ WDFREQUEST request,
_Out_ bool * complete)
{
HIDQueuedReport report = {};
bool haveReport = false;
*complete = true;
NTSTATUS status;
{
CSRWExclusiveLock lock(&context->reportLock);
if (context->stopping || !context->active)
status = STATUS_DEVICE_NOT_READY;
else if (context->reportCount)
{
PopReport(context, &report);
haveReport = true;
status = STATUS_SUCCESS;
}
else
{
status = WdfRequestForwardToIoQueue(request, context->reportQueue);
*complete = !NT_SUCCESS(status);
}
}
if (haveReport)
status = CopyToRequest(request, report.data, report.size);
return status;
}
static NTSTATUS ActivateDevice(_Inout_ HIDDeviceContext * context)
{
CSRWExclusiveLock lock(&context->reportLock);
if (context->stopping)
return STATUS_DEVICE_NOT_READY;
WdfIoQueueStart(context->reportQueue);
context->active = true;
return STATUS_SUCCESS;
}
static NTSTATUS DeactivateDevice(_Inout_ HIDDeviceContext * context)
{
CSRWExclusiveLock lock(&context->reportLock);
if (context->stopping)
return STATUS_DEVICE_NOT_READY;
context->active = false;
context->reportHead = 0;
context->reportCount = 0;
WdfIoQueuePurgeSynchronously(context->reportQueue);
return STATUS_SUCCESS;
}
static NTSTATUS CreateQueues(_In_ WDFDEVICE device)
{
WDF_IO_QUEUE_CONFIG queueConfig;
WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(
&queueConfig, WdfIoQueueDispatchParallel);
queueConfig.EvtIoDeviceControl = HIDEvtIoDeviceControl;
NTSTATUS status = WdfIoQueueCreate(
device, &queueConfig, WDF_NO_OBJECT_ATTRIBUTES, WDF_NO_HANDLE);
if (!NT_SUCCESS(status))
return status;
WDF_IO_QUEUE_CONFIG_INIT(&queueConfig, WdfIoQueueDispatchManual);
WDF_OBJECT_ATTRIBUTES queueAttributes;
WDF_OBJECT_ATTRIBUTES_INIT(&queueAttributes);
queueAttributes.EvtCleanupCallback = HIDEvtReportQueueCleanup;
return WdfIoQueueCreate(
device,
&queueConfig,
&queueAttributes,
&HIDGetDeviceContext(device)->reportQueue);
}
NTSTATUS CHIDDevice::Create(_Inout_ PWDFDEVICE_INIT deviceInit)
{
WdfFdoInitSetFilter(deviceInit);
WDF_OBJECT_ATTRIBUTES attributes;
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, HIDDeviceContext);
WDFDEVICE device;
NTSTATUS status = WdfDeviceCreate(&deviceInit, &attributes, &device);
if (!NT_SUCCESS(status))
return status;
HIDDeviceContext * context = HIDGetDeviceContext(device);
RtlZeroMemory(context, sizeof(*context));
InitializeSRWLock(&context->reportLock);
context->active = true;
context->attributes.Size =
static_cast<ULONG>(sizeof(context->attributes));
context->attributes.VendorID = LG_INPUT_VENDOR_ID;
context->attributes.ProductID = LG_INPUT_PRODUCT_ID;
context->attributes.VersionNumber = LG_INPUT_VERSION;
context->descriptor.bLength =
static_cast<UCHAR>(sizeof(context->descriptor));
context->descriptor.bDescriptorType = HID_HID_DESCRIPTOR_TYPE;
context->descriptor.bcdHID = 0x0111;
context->descriptor.bCountry = 0;
context->descriptor.bNumDescriptors = 1;
auto & reportDescriptor = context->descriptor.DescriptorList[0];
reportDescriptor.bReportType = HID_REPORT_DESCRIPTOR_TYPE;
reportDescriptor.wReportLength =
static_cast<USHORT>(HIDGetReportDescriptorSize());
status = CreateQueues(device);
if (!NT_SUCCESS(status))
return status;
{
CSRWExclusiveLock lock(&s_deviceLock);
s_device = context;
}
return STATUS_SUCCESS;
}
NTSTATUS CHIDDevice::SubmitReport(
_In_reads_bytes_(size) const void * report,
_In_ size_t size)
{
if (!report || !size)
return STATUS_INVALID_PARAMETER;
const UCHAR reportId = *static_cast<const UCHAR *>(report);
if (HIDGetInputReportSize(reportId) != size)
return STATUS_INVALID_PARAMETER;
CSRWSharedLock deviceLock(&s_deviceLock);
HIDDeviceContext * context = s_device;
if (!context)
return STATUS_DEVICE_NOT_READY;
WDFREQUEST request = nullptr;
NTSTATUS status;
{
CSRWExclusiveLock reportLock(&context->reportLock);
if (context->stopping || !context->active)
status = STATUS_DEVICE_NOT_READY;
else
{
status = WdfIoQueueRetrieveNextRequest(context->reportQueue, &request);
if (status == STATUS_NO_MORE_ENTRIES)
{
request = nullptr;
status = QueueReport(context, report, size);
}
}
}
if (request)
{
status = CopyToRequest(request, report, size);
WdfRequestComplete(request, status);
}
return status;
}
VOID HIDEvtIoDeviceControl(
_In_ WDFQUEUE queue,
_In_ WDFREQUEST request,
_In_ size_t outputBufferLength,
_In_ size_t inputBufferLength,
_In_ ULONG ioControlCode)
{
UNREFERENCED_PARAMETER(outputBufferLength);
UNREFERENCED_PARAMETER(inputBufferLength);
HIDDeviceContext * context =
HIDGetDeviceContext(WdfIoQueueGetDevice(queue));
NTSTATUS status;
bool complete = true;
switch (ioControlCode)
{
case IOCTL_HID_GET_DEVICE_DESCRIPTOR:
status = CopyToRequest(
request, &context->descriptor, context->descriptor.bLength);
break;
case IOCTL_HID_GET_DEVICE_ATTRIBUTES:
status = CopyToRequest(
request, &context->attributes, sizeof(context->attributes));
break;
case IOCTL_HID_GET_REPORT_DESCRIPTOR:
status = CopyToRequest(
request, HIDGetReportDescriptor(), HIDGetReportDescriptorSize());
break;
case IOCTL_HID_READ_REPORT:
status = ReadReport(context, request, &complete);
break;
case IOCTL_HID_WRITE_REPORT:
case IOCTL_UMDF_HID_SET_OUTPUT_REPORT:
status = SetOutputReport(queue, request);
break;
case IOCTL_HID_ACTIVATE_DEVICE:
status = ActivateDevice(context);
break;
case IOCTL_HID_DEACTIVATE_DEVICE:
status = DeactivateDevice(context);
break;
default:
status = STATUS_NOT_SUPPORTED;
break;
}
if (complete)
WdfRequestComplete(request, status);
}
VOID HIDEvtReportQueueCleanup(_In_ WDFOBJECT object)
{
HIDDeviceContext * context =
HIDGetDeviceContext(WdfIoQueueGetDevice((WDFQUEUE)object));
CSRWExclusiveLock deviceLock(&s_deviceLock);
if (s_device == context)
s_device = nullptr;
{
CSRWExclusiveLock reportLock(&context->reportLock);
context->stopping = true;
context->reportHead = 0;
context->reportCount = 0;
}
}

33
idd/LGInput/CHIDDevice.h Normal file
View File

@@ -0,0 +1,33 @@
/**
* Looking Glass
* Copyright © 2017-2026 The Looking Glass Authors
* https://looking-glass.io
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#pragma once
#include <windows.h>
#include <wdf.h>
class CHIDDevice
{
public:
static NTSTATUS Create(_Inout_ PWDFDEVICE_INIT deviceInit);
static NTSTATUS SubmitReport(
_In_reads_bytes_(size) const void * report,
_In_ size_t size);
};

95
idd/LGInput/Driver.cpp Normal file
View File

@@ -0,0 +1,95 @@
/**
* Looking Glass
* Copyright © 2017-2026 The Looking Glass Authors
* https://looking-glass.io
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "Driver.h"
#include "Driver.tmh"
#include "CDebug.h"
#include "CHIDDevice.h"
NTSTATUS DriverEntry(
_In_ PDRIVER_OBJECT DriverObject,
_In_ PUNICODE_STRING RegistryPath)
{
g_debug.Init(L"looking-glass-input");
DEBUG_INFO("Looking Glass Input Driver");
#if UMDF_VERSION_MAJOR == 2 && UMDF_VERSION_MINOR == 0
WPP_INIT_TRACING(MYDRIVER_TRACING_ID);
#else
WPP_INIT_TRACING(DriverObject, RegistryPath);
#endif
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry");
WDF_DRIVER_CONFIG config;
WDF_DRIVER_CONFIG_INIT(&config, LGInputEvtDeviceAdd);
WDF_OBJECT_ATTRIBUTES attributes;
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
attributes.EvtCleanupCallback = LGInputEvtDriverContextCleanup;
const NTSTATUS status = WdfDriverCreate(
DriverObject, RegistryPath, &attributes, &config, WDF_NO_HANDLE);
if (!NT_SUCCESS(status))
{
TraceEvents(
TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"WdfDriverCreate failed %!STATUS!",
status);
#if UMDF_VERSION_MAJOR == 2 && UMDF_VERSION_MINOR == 0
WPP_CLEANUP();
#else
WPP_CLEANUP(DriverObject);
#endif
return status;
}
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Exit");
return status;
}
NTSTATUS LGInputEvtDeviceAdd(
_In_ WDFDRIVER Driver,
_Inout_ PWDFDEVICE_INIT DeviceInit)
{
UNREFERENCED_PARAMETER(Driver);
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry");
const NTSTATUS status = CHIDDevice::Create(DeviceInit);
if (!NT_SUCCESS(status))
DEBUG_ERROR_HR(status, "Failed to create the HID input device");
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Exit");
return status;
}
VOID LGInputEvtDriverContextCleanup(_In_ WDFOBJECT DriverObject)
{
UNREFERENCED_PARAMETER(DriverObject);
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry");
#if UMDF_VERSION_MAJOR == 2 && UMDF_VERSION_MINOR == 0
WPP_CLEANUP();
#else
WPP_CLEANUP(WdfDriverWdmGetDriverObject((WDFDRIVER)DriverObject));
#endif
}

33
idd/LGInput/Driver.h Normal file
View File

@@ -0,0 +1,33 @@
/**
* Looking Glass
* Copyright © 2017-2026 The Looking Glass Authors
* https://looking-glass.io
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#pragma once
#include <windows.h>
#include <wdf.h>
#include "Trace.h"
EXTERN_C_START
DRIVER_INITIALIZE DriverEntry;
EXTERN_C_END
EVT_WDF_DRIVER_DEVICE_ADD LGInputEvtDeviceAdd;
EVT_WDF_OBJECT_CONTEXT_CLEANUP LGInputEvtDriverContextCleanup;

151
idd/LGInput/HIDReports.cpp Normal file
View File

@@ -0,0 +1,151 @@
/**
* Looking Glass
* Copyright © 2017-2026 The Looking Glass Authors
* https://looking-glass.io
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "HIDReports.h"
static const uint8_t REPORT_DESCRIPTOR[] =
{
// Absolute tablet, report ID 1.
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x02, // Usage (Mouse)
0xA1, 0x01, // Collection (Application)
0x85, HID_REPORT_ID_TABLET,
0x09, 0x01, // Usage (Pointer)
0xA1, 0x00, // Collection (Physical)
0x05, 0x09, // Usage Page (Button)
0x19, 0x01, // Usage Minimum (Button 1)
0x29, 0x05, // Usage Maximum (Button 5)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x75, 0x01, // Report Size (1)
0x95, 0x05, // Report Count (5)
0x81, 0x02, // Input (Data, Variable, Absolute)
0x75, 0x03, // Report Size (3)
0x95, 0x01, // Report Count (1)
0x81, 0x03, // Input (Constant)
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x30, // Usage (X)
0x09, 0x31, // Usage (Y)
0x15, 0x00, // Logical Minimum (0)
0x26, 0xFF, 0x7F, // Logical Maximum (32767)
0x75, 0x10, // Report Size (16)
0x95, 0x02, // Report Count (2)
0x81, 0x02, // Input (Data, Variable, Absolute)
0xC0, // End Collection
0xC0, // End Collection
// Relative mouse, report ID 2.
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x02, // Usage (Mouse)
0xA1, 0x01, // Collection (Application)
0x85, HID_REPORT_ID_MOUSE,
0x09, 0x01, // Usage (Pointer)
0xA1, 0x00, // Collection (Physical)
0x05, 0x09, // Usage Page (Button)
0x19, 0x01, // Usage Minimum (Button 1)
0x29, 0x05, // Usage Maximum (Button 5)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x75, 0x01, // Report Size (1)
0x95, 0x05, // Report Count (5)
0x81, 0x02, // Input (Data, Variable, Absolute)
0x75, 0x03, // Report Size (3)
0x95, 0x01, // Report Count (1)
0x81, 0x03, // Input (Constant)
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x30, // Usage (X)
0x09, 0x31, // Usage (Y)
0x16, 0x00, 0x80, // Logical Minimum (-32768)
0x26, 0xFF, 0x7F, // Logical Maximum (32767)
0x75, 0x10, // Report Size (16)
0x95, 0x02, // Report Count (2)
0x81, 0x06, // Input (Data, Variable, Relative)
0x09, 0x38, // Usage (Wheel)
0x15, 0x81, // Logical Minimum (-127)
0x25, 0x7F, // Logical Maximum (127)
0x75, 0x08, // Report Size (8)
0x95, 0x01, // Report Count (1)
0x81, 0x06, // Input (Data, Variable, Relative)
0xC0, // End Collection
0xC0, // End Collection
// Keyboard, report ID 3.
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x06, // Usage (Keyboard)
0xA1, 0x01, // Collection (Application)
0x85, HID_REPORT_ID_KEYBOARD,
0x05, 0x07, // Usage Page (Keyboard)
0x19, 0xE0, // Usage Minimum (Left Control)
0x29, 0xE7, // Usage Maximum (Right GUI)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x75, 0x01, // Report Size (1)
0x95, 0x08, // Report Count (8)
0x81, 0x02, // Input (Data, Variable, Absolute)
0x95, 0x01, // Report Count (1)
0x75, 0x08, // Report Size (8)
0x81, 0x03, // Input (Constant)
0x05, 0x08, // Usage Page (LEDs)
0x19, 0x01, // Usage Minimum (Num Lock)
0x29, 0x05, // Usage Maximum (Kana)
0x95, 0x05, // Report Count (5)
0x75, 0x01, // Report Size (1)
0x91, 0x02, // Output (Data, Variable, Absolute)
0x95, 0x01, // Report Count (1)
0x75, 0x03, // Report Size (3)
0x91, 0x03, // Output (Constant)
0x05, 0x07, // Usage Page (Keyboard)
0x19, 0x00, // Usage Minimum (0)
0x2A, 0xE7, 0x00, // Usage Maximum (231)
0x15, 0x00, // Logical Minimum (0)
0x26, 0xE7, 0x00, // Logical Maximum (231)
0x75, 0x08, // Report Size (8)
0x95, 0x06, // Report Count (6)
0x81, 0x00, // Input (Data, Array, Absolute)
0xC0, // End Collection
};
const uint8_t * HIDGetReportDescriptor()
{
return REPORT_DESCRIPTOR;
}
size_t HIDGetReportDescriptorSize()
{
return sizeof(REPORT_DESCRIPTOR);
}
size_t HIDGetInputReportSize(uint8_t reportId)
{
switch (reportId)
{
case HID_REPORT_ID_TABLET:
return sizeof(HIDTabletReport);
case HID_REPORT_ID_MOUSE:
return sizeof(HIDMouseReport);
case HID_REPORT_ID_KEYBOARD:
return sizeof(HIDKeyboardReport);
default:
return 0;
}
}

75
idd/LGInput/HIDReports.h Normal file
View File

@@ -0,0 +1,75 @@
/**
* Looking Glass
* Copyright © 2017-2026 The Looking Glass Authors
* https://looking-glass.io
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#pragma once
#include <stddef.h>
#include <stdint.h>
enum HIDReportId : uint8_t
{
HID_REPORT_ID_TABLET = 1,
HID_REPORT_ID_MOUSE = 2,
HID_REPORT_ID_KEYBOARD = 3,
};
#pragma pack(push, 1)
struct HIDTabletReport
{
uint8_t reportId;
uint8_t buttons;
uint16_t x;
uint16_t y;
};
struct HIDMouseReport
{
uint8_t reportId;
uint8_t buttons;
int16_t x;
int16_t y;
int8_t wheel;
};
struct HIDKeyboardReport
{
uint8_t reportId;
uint8_t modifiers;
uint8_t reserved;
uint8_t keys[6];
};
struct HIDKeyboardLedsReport
{
uint8_t reportId;
uint8_t leds;
};
#pragma pack(pop)
static_assert(sizeof(HIDTabletReport) == 6);
static_assert(sizeof(HIDMouseReport) == 7);
static_assert(sizeof(HIDKeyboardReport) == 9);
static_assert(sizeof(HIDKeyboardLedsReport) == 2);
const uint8_t * HIDGetReportDescriptor();
size_t HIDGetReportDescriptorSize();
size_t HIDGetInputReportSize(uint8_t reportId);

75
idd/LGInput/LGInput.inf Normal file
View File

@@ -0,0 +1,75 @@
;
; LGInput.inf
;
[Version]
Signature="$Windows NT$"
Class=HIDClass
ClassGuid={745A17A0-74D3-11D0-B6FE-00A0C90F57DA}
Provider=%ManufacturerName%
CatalogFile=LGInput.cat
DriverVer=0.1
PnpLockdown=1
[Manufacturer]
%ManufacturerName%=Standard,NT$ARCH$.10.0
[Standard.NT$ARCH$.10.0]
%DeviceName%=LGInput_Install,Root\LGInput
[LGInput_Install.NT]
CopyFiles=UMDriverCopy
[LGInput_Install.NT.hw]
AddReg=LGInput_HardwareSettings
[LGInput_HardwareSettings]
HKR,,"LowerFilters",0x00010008,"WUDFRd"
[LGInput_Install.NT.Services]
AddService=WUDFRd,0x000001f8,WUDFRD_ServiceInstall
AddService=mshidumdf,0x000001fa,mshidumdf_ServiceInstall
[mshidumdf_ServiceInstall]
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\mshidumdf.sys
[WUDFRD_ServiceInstall]
DisplayName=%WudfRdDisplayName%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\WUDFRd.sys
[LGInput_Install.NT.Wdf]
UmdfService=LGInput,LGInput_ServiceInstall
UmdfServiceOrder=LGInput
UmdfKernelModeClientPolicy=AllowKernelModeClients
UmdfFileObjectPolicy=AllowNullAndUnknownFileObjects
UmdfMethodNeitherAction=Copy
UmdfFsContextUsePolicy=CanUseFsContext2
UmdfHostProcessSharing=ProcessSharingDisabled
[LGInput_ServiceInstall]
UmdfLibraryVersion=$UMDFVERSION$
ServiceBinary=%12%\UMDF\LGInput.dll
[DestinationDirs]
UMDriverCopy=12,UMDF
[UMDriverCopy]
LGInput.dll
[SourceDisksNames]
1=%DiskName%
[SourceDisksFiles]
LGInput.dll=1
[Strings]
ManufacturerName="Looking Glass"
DiskName="LGInput Installation Disk"
DeviceName="Looking Glass"
WudfRdDisplayName="Windows Driver Foundation - User-mode Driver Framework Reflector"

104
idd/LGInput/LGInput.vcxproj Normal file
View File

@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(ProjectDir)..\LGCommon\CDebug.cpp">
<Link>Common\CDebug.cpp</Link>
</ClCompile>
<ClCompile Include="CHIDDevice.cpp" />
<ClCompile Include="Driver.cpp" />
<ClCompile Include="HIDReports.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(ProjectDir)..\LGCommon\CDebug.h">
<Link>Common\CDebug.h</Link>
</ClInclude>
<ClInclude Include="$(ProjectDir)..\LGCommon\CSRWLock.h">
<Link>Common\CSRWLock.h</Link>
</ClInclude>
<ClInclude Include="CHIDDevice.h" />
<ClInclude Include="Driver.h" />
<ClInclude Include="HIDReports.h" />
<ClInclude Include="Trace.h" />
</ItemGroup>
<ItemGroup>
<Inf Include="LGInput.inf" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{2477B25B-CB62-4AD9-A260-CE5F00D77EEB}</ProjectGuid>
<RootNamespace>LGInput</RootNamespace>
<WindowsTargetPlatformVersion>10.0.26100.0</WindowsTargetPlatformVersion>
<UMDF_VERSION_MAJOR>2</UMDF_VERSION_MAJOR>
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
<Platform Condition="'$(Platform)' == ''">Win32</Platform>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<TargetVersion>Windows10</TargetVersion>
<DriverTargetPlatform>Universal</DriverTargetPlatform>
<DriverType>UMDF</DriverType>
<PlatformToolset>WindowsUserModeDriver10.0</PlatformToolset>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UMDF_VERSION_MINOR>25</UMDF_VERSION_MINOR>
<UMDF_MINIMUM_VERSION_REQUIRED>25</UMDF_MINIMUM_VERSION_REQUIRED>
<_NT_TARGET_VERSION>0xA000005</_NT_TARGET_VERSION>
<Driver_SpectreMitigation>Spectre</Driver_SpectreMitigation>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'" Label="Configuration">
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'" Label="Configuration">
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings" />
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<TargetName>LGInput</TargetName>
<DebuggerFlavor>DbgengRemoteDebugger</DebuggerFlavor>
<Inf2CatUseLocalTime>true</Inf2CatUseLocalTime>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<WppEnabled>true</WppEnabled>
<WppRecorderEnabled>true</WppRecorderEnabled>
<WppScanConfigurationData Condition="'%(ClCompile.ScanConfigurationData)' == ''">Trace.h</WppScanConfigurationData>
<AdditionalOptions>/EHsc /D_ATL_NO_WIN_SUPPORT %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>$(ProjectDir)..\LGCommon;$(DDK_INC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);OneCoreUAP.lib</AdditionalDependencies>
</Link>
<DriverSign>
<FileDigestAlgorithm>SHA1</FileDigestAlgorithm>
</DriverSign>
</ItemDefinitionGroup>
<ItemGroup>
<FilesToPackage Include="$(TargetPath)" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
</Project>

View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Driver">
<UniqueIdentifier>{B48E885A-BB8C-4DD5-8145-587B360AAB3B}</UniqueIdentifier>
</Filter>
<Filter Include="HID">
<UniqueIdentifier>{D9688549-A0BE-46E6-8FAB-AE454D90E0FA}</UniqueIdentifier>
</Filter>
<Filter Include="Common">
<UniqueIdentifier>{938E49D6-F954-4EBE-80AB-E0F67E677F27}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<Inf Include="LGInput.inf">
<Filter>Driver</Filter>
</Inf>
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(ProjectDir)..\LGCommon\CDebug.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="$(ProjectDir)..\LGCommon\CSRWLock.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="CHIDDevice.h">
<Filter>Driver</Filter>
</ClInclude>
<ClInclude Include="Driver.h">
<Filter>Driver</Filter>
</ClInclude>
<ClInclude Include="HIDReports.h">
<Filter>HID</Filter>
</ClInclude>
<ClInclude Include="Trace.h">
<Filter>Driver</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(ProjectDir)..\LGCommon\CDebug.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="CHIDDevice.cpp">
<Filter>Driver</Filter>
</ClCompile>
<ClCompile Include="Driver.cpp">
<Filter>Driver</Filter>
</ClCompile>
<ClCompile Include="HIDReports.cpp">
<Filter>HID</Filter>
</ClCompile>
</ItemGroup>
</Project>

50
idd/LGInput/Trace.h Normal file
View File

@@ -0,0 +1,50 @@
/**
* Looking Glass
* Copyright © 2017-2026 The Looking Glass Authors
* https://looking-glass.io
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#pragma once
#define WPP_CONTROL_GUIDS \
WPP_DEFINE_CONTROL_GUID( \
LGInputTraceGuid, (1d279434,7f85,42cd,b4b9,9a3d6f5cb774), \
\
WPP_DEFINE_BIT(MYDRIVER_ALL_INFO) \
WPP_DEFINE_BIT(TRACE_DRIVER))
#define WPP_FLAG_LEVEL_LOGGER(flag, level) \
WPP_LEVEL_LOGGER(flag)
#define WPP_FLAG_LEVEL_ENABLED(flag, level) \
(WPP_LEVEL_ENABLED(flag) && \
WPP_CONTROL(WPP_BIT_ ## flag).Level >= level)
#define WPP_LEVEL_FLAGS_LOGGER(lvl, flags) \
WPP_LEVEL_LOGGER(flags)
#define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) \
(WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl)
// begin_wpp config
// FUNC Trace{FLAG=MYDRIVER_ALL_INFO}(LEVEL, MSG, ...);
// FUNC TraceEvents(LEVEL, FLAGS, MSG, ...);
// end_wpp
#if UMDF_VERSION_MAJOR == 2 && UMDF_VERSION_MINOR == 0
#define MYDRIVER_TRACING_ID L"Microsoft\\UMDF2.0\\LGInput V1.0"
#endif

View File

@@ -59,7 +59,7 @@ InstallDir "$PROGRAMFILES64\Looking Glass (IDD)"
;Install and uninstall pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "LICENSE.txt"
!insertmacro MUI_PAGE_LICENSE "LICENSE"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
@@ -172,13 +172,16 @@ Section "!Indirect Display Driver (IDD)" Section1
DetailPrint "Extracting IDD"
SetOutPath $INSTDIR
File lgidd.cat
File /oname=LGInput.cat "LGInput\LGInput.cat"
File LGIdd.dll
File /oname=LGInput.dll "LGInput\LGInput.dll"
File LGIdd.inf
File /oname=LGInput.inf "LGInput\LGInput.inf"
File LGIddHelper.exe
File LGIddInstall.exe
DetailPrint "Extracting support files"
File LICENSE.txt
File /oname=LICENSE.txt LICENSE
WriteUninstaller $INSTDIR\uninstaller.exe
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
@@ -232,8 +235,11 @@ Section "Uninstall" Section6
Delete "$INSTDIR\ivshmem.sys"
Delete "$INSTDIR\ivshmem.pdb"
Delete "$INSTDIR\lgidd.cat"
Delete "$INSTDIR\LGInput.cat"
Delete "$INSTDIR\LGIdd.dll"
Delete "$INSTDIR\LGInput.dll"
Delete "$INSTDIR\LGIdd.inf"
Delete "$INSTDIR\LGInput.inf"
Delete "$INSTDIR\LGIddHelper.exe"
Delete "$INSTDIR\LGIddInstall.exe"
Delete "$INSTDIR\LICENSE.txt"