mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-09 08:41:31 +00:00
[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:
400
idd/LGInput/CHIDDevice.cpp
Normal file
400
idd/LGInput/CHIDDevice.cpp
Normal 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
33
idd/LGInput/CHIDDevice.h
Normal 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
95
idd/LGInput/Driver.cpp
Normal 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
33
idd/LGInput/Driver.h
Normal 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
151
idd/LGInput/HIDReports.cpp
Normal 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
75
idd/LGInput/HIDReports.h
Normal 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
75
idd/LGInput/LGInput.inf
Normal 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
104
idd/LGInput/LGInput.vcxproj
Normal 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>
|
||||
54
idd/LGInput/LGInput.vcxproj.filters
Normal file
54
idd/LGInput/LGInput.vcxproj.filters
Normal 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
50
idd/LGInput/Trace.h
Normal 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
|
||||
Reference in New Issue
Block a user