diff --git a/sys/Ds4Pdo.cpp b/sys/Ds4Pdo.cpp index 52b7740..f4523b7 100644 --- a/sys/Ds4Pdo.cpp +++ b/sys/Ds4Pdo.cpp @@ -384,7 +384,7 @@ VOID ViGEm::Bus::Targets::EmulationTargetDS4::GetConfigurationDescriptorType(PUC RtlCopyBytes(Buffer, Ds4DescriptorData, Length); } -VOID ViGEm::Bus::Targets::EmulationTargetDS4::UsbGetDeviceDescriptorType(PUSB_DEVICE_DESCRIPTOR pDescriptor) +NTSTATUS ViGEm::Bus::Targets::EmulationTargetDS4::UsbGetDeviceDescriptorType(PUSB_DEVICE_DESCRIPTOR pDescriptor) { pDescriptor->bLength = 0x12; pDescriptor->bDescriptorType = USB_DEVICE_DESCRIPTOR_TYPE; @@ -400,6 +400,8 @@ VOID ViGEm::Bus::Targets::EmulationTargetDS4::UsbGetDeviceDescriptorType(PUSB_DE pDescriptor->iProduct = 0x02; pDescriptor->iSerialNumber = 0x00; pDescriptor->bNumConfigurations = 0x01; + + return STATUS_SUCCESS; } NTSTATUS ViGEm::Bus::Targets::EmulationTargetDS4::SelectConfiguration(PURB Urb) diff --git a/sys/Ds4Pdo.hpp b/sys/Ds4Pdo.hpp index dcabf9a..6519a16 100644 --- a/sys/Ds4Pdo.hpp +++ b/sys/Ds4Pdo.hpp @@ -34,7 +34,7 @@ namespace ViGEm::Bus::Targets VOID GetConfigurationDescriptorType(PUCHAR Buffer, ULONG Length) override; - VOID UsbGetDeviceDescriptorType(PUSB_DEVICE_DESCRIPTOR pDescriptor) override; + NTSTATUS UsbGetDeviceDescriptorType(PUSB_DEVICE_DESCRIPTOR pDescriptor) override; NTSTATUS SelectConfiguration(PURB Urb) override; diff --git a/sys/EmulationTargetPDO.cpp b/sys/EmulationTargetPDO.cpp index 4b3c1c7..7856ca5 100644 --- a/sys/EmulationTargetPDO.cpp +++ b/sys/EmulationTargetPDO.cpp @@ -6,6 +6,7 @@ #include #include #include +#include PCWSTR ViGEm::Bus::Core::EmulationTargetPDO::_deviceLocation = L"Virtual Gamepad Emulation Bus"; @@ -25,6 +26,8 @@ NTSTATUS ViGEm::Bus::Core::EmulationTargetPDO::PdoCreateDevice(WDFDEVICE ParentD WDF_IO_QUEUE_CONFIG notificationsQueueConfig; PEMULATION_TARGET_PDO_CONTEXT pPdoContext; + TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_BUSPDO, "%!FUNC! Entry"); + DECLARE_CONST_UNICODE_STRING(deviceLocation, L"Virtual Gamepad Emulation Bus"); DECLARE_UNICODE_STRING_SIZE(buffer, MAX_INSTANCE_ID_LEN); // reserve space for device id @@ -487,12 +490,18 @@ NTSTATUS ViGEm::Bus::Core::EmulationTargetPDO::EvtDevicePrepareHardware( _In_ WDFCMRESLIST ResourcesTranslated ) { + TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_BUSPDO, "%!FUNC! Entry"); + UNREFERENCED_PARAMETER(ResourcesRaw); UNREFERENCED_PARAMETER(ResourcesTranslated); const auto ctx = EmulationTargetPdoGetContext(Device); - return ctx->Target->PdoPrepareHardware(); + NTSTATUS status = ctx->Target->PdoPrepareHardware(); + + TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_BUSPDO, "%!FUNC! Exit with status %!STATUS!", status); + + return status; } VOID ViGEm::Bus::Core::EmulationTargetPDO::EvtIoInternalDeviceControl( @@ -595,7 +604,7 @@ VOID ViGEm::Bus::Core::EmulationTargetPDO::EvtIoInternalDeviceControl( TRACE_BUSPDO, ">> >> >> USB_DEVICE_DESCRIPTOR_TYPE"); - ctx->Target->UsbGetDeviceDescriptorType( + status = ctx->Target->UsbGetDeviceDescriptorType( static_cast(urb->UrbControlDescriptorRequest.TransferBuffer)); break; diff --git a/sys/EmulationTargetPDO.hpp b/sys/EmulationTargetPDO.hpp index 2ceffe9..4b8021f 100644 --- a/sys/EmulationTargetPDO.hpp +++ b/sys/EmulationTargetPDO.hpp @@ -19,10 +19,6 @@ namespace ViGEm::Bus::Core { - // {A8BA2D1F-894F-464A-B0CE-7A0C8FD65DF1} - DEFINE_GUID(GUID_DEVCLASS_VIGEM_RAWPDO, - 0xA8BA2D1F, 0x894F, 0x464A, 0xB0, 0xCE, 0x7A, 0x0C, 0x8F, 0xD6, 0x5D, 0xF1); - typedef struct _PDO_IDENTIFICATION_DESCRIPTION* PPDO_IDENTIFICATION_DESCRIPTION; class EmulationTargetPDO @@ -54,7 +50,7 @@ namespace ViGEm::Bus::Core return (other._SerialNo == this->_SerialNo); } - virtual VOID UsbGetDeviceDescriptorType(PUSB_DEVICE_DESCRIPTOR pDescriptor) = 0; + virtual NTSTATUS UsbGetDeviceDescriptorType(PUSB_DEVICE_DESCRIPTOR pDescriptor) = 0; NTSTATUS UsbSelectConfiguration(PURB Urb); diff --git a/sys/XusbPdo.cpp b/sys/XusbPdo.cpp index 465a2e5..210a979 100644 --- a/sys/XusbPdo.cpp +++ b/sys/XusbPdo.cpp @@ -451,7 +451,7 @@ VOID ViGEm::Bus::Targets::EmulationTargetXUSB::GetConfigurationDescriptorType(PU RtlCopyBytes(Buffer, XusbDescriptorData, Length); } -VOID ViGEm::Bus::Targets::EmulationTargetXUSB::UsbGetDeviceDescriptorType(PUSB_DEVICE_DESCRIPTOR pDescriptor) +NTSTATUS ViGEm::Bus::Targets::EmulationTargetXUSB::UsbGetDeviceDescriptorType(PUSB_DEVICE_DESCRIPTOR pDescriptor) { pDescriptor->bLength = 0x12; pDescriptor->bDescriptorType = USB_DEVICE_DESCRIPTOR_TYPE; @@ -467,6 +467,8 @@ VOID ViGEm::Bus::Targets::EmulationTargetXUSB::UsbGetDeviceDescriptorType(PUSB_D pDescriptor->iProduct = 0x02; pDescriptor->iSerialNumber = 0x03; pDescriptor->bNumConfigurations = 0x01; + + return STATUS_SUCCESS; } NTSTATUS ViGEm::Bus::Targets::EmulationTargetXUSB::SelectConfiguration(PURB Urb) @@ -481,7 +483,7 @@ NTSTATUS ViGEm::Bus::Targets::EmulationTargetXUSB::SelectConfiguration(PURB Urb) PUSBD_INTERFACE_INFORMATION pInfo = &Urb->UrbSelectConfiguration.Interface; - TraceEvents(TRACE_LEVEL_VERBOSE, + TraceDbg( TRACE_XUSB, ">> >> >> URB_FUNCTION_SELECT_CONFIGURATION: Length %d, Interface %d, Alternate %d, Pipes %d", (int)pInfo->Length, @@ -513,7 +515,7 @@ NTSTATUS ViGEm::Bus::Targets::EmulationTargetXUSB::SelectConfiguration(PURB Urb) pInfo = (PUSBD_INTERFACE_INFORMATION)((PCHAR)pInfo + pInfo->Length); - TraceEvents(TRACE_LEVEL_VERBOSE, + TraceDbg( TRACE_XUSB, ">> >> >> URB_FUNCTION_SELECT_CONFIGURATION: Length %d, Interface %d, Alternate %d, Pipes %d", (int)pInfo->Length, @@ -561,7 +563,7 @@ NTSTATUS ViGEm::Bus::Targets::EmulationTargetXUSB::SelectConfiguration(PURB Urb) pInfo = (PUSBD_INTERFACE_INFORMATION)((PCHAR)pInfo + pInfo->Length); - TraceEvents(TRACE_LEVEL_VERBOSE, + TraceDbg( TRACE_XUSB, ">> >> >> URB_FUNCTION_SELECT_CONFIGURATION: Length %d, Interface %d, Alternate %d, Pipes %d", (int)pInfo->Length, @@ -585,7 +587,7 @@ NTSTATUS ViGEm::Bus::Targets::EmulationTargetXUSB::SelectConfiguration(PURB Urb) pInfo = (PUSBD_INTERFACE_INFORMATION)((PCHAR)pInfo + pInfo->Length); - TraceEvents(TRACE_LEVEL_VERBOSE, + TraceDbg( TRACE_XUSB, ">> >> >> URB_FUNCTION_SELECT_CONFIGURATION: Length %d, Interface %d, Alternate %d, Pipes %d", (int)pInfo->Length, @@ -624,7 +626,7 @@ NTSTATUS ViGEm::Bus::Targets::EmulationTargetXUSB::UsbSelectInterface(PURB Urb) { PUSBD_INTERFACE_INFORMATION pInfo = &Urb->UrbSelectInterface.Interface; - TraceEvents(TRACE_LEVEL_VERBOSE, + TraceDbg( TRACE_USBPDO, ">> >> >> URB_FUNCTION_SELECT_INTERFACE: Length %d, Interface %d, Alternate %d, Pipes %d", (int)pInfo->Length, @@ -632,7 +634,7 @@ NTSTATUS ViGEm::Bus::Targets::EmulationTargetXUSB::UsbSelectInterface(PURB Urb) (int)pInfo->AlternateSetting, pInfo->NumberOfPipes); - TraceEvents(TRACE_LEVEL_VERBOSE, + TraceDbg( TRACE_USBPDO, ">> >> >> URB_FUNCTION_SELECT_INTERFACE: Class %d, SubClass %d, Protocol %d", (int)pInfo->Class, @@ -965,6 +967,8 @@ NTSTATUS ViGEm::Bus::Targets::EmulationTargetXUSB::UsbControlTransfer(PURB Urb) NTSTATUS ViGEm::Bus::Targets::EmulationTargetXUSB::SubmitReport(PVOID NewReport) { + TraceDbg(TRACE_BUSENUM, "%!FUNC! Entry"); + NTSTATUS status = STATUS_SUCCESS; BOOLEAN changed; WDFREQUEST usbRequest; @@ -1010,6 +1014,8 @@ NTSTATUS ViGEm::Bus::Targets::EmulationTargetXUSB::SubmitReport(PVOID NewReport) // Complete pending request WdfRequestComplete(usbRequest, status); + + TraceDbg(TRACE_BUSENUM, "%!FUNC! Exit with status %!STATUS!", status); return status; } diff --git a/sys/XusbPdo.hpp b/sys/XusbPdo.hpp index e6addea..4de8add 100644 --- a/sys/XusbPdo.hpp +++ b/sys/XusbPdo.hpp @@ -41,7 +41,7 @@ namespace ViGEm::Bus::Targets VOID GetConfigurationDescriptorType(PUCHAR Buffer, ULONG Length) override; - VOID UsbGetDeviceDescriptorType(PUSB_DEVICE_DESCRIPTOR pDescriptor) override; + NTSTATUS UsbGetDeviceDescriptorType(PUSB_DEVICE_DESCRIPTOR pDescriptor) override; NTSTATUS SelectConfiguration(PURB Urb) override; diff --git a/sys/buspdo.cpp b/sys/buspdo.cpp index 89a83ea..1d60973 100644 --- a/sys/buspdo.cpp +++ b/sys/buspdo.cpp @@ -64,5 +64,5 @@ EXTERN_C BOOLEAN Bus_EvtChildListIdentificationDescriptionCompare( ViGEm::Bus::Core::PDO_IDENTIFICATION_DESCRIPTION, Header); - return (lhs->Target == rhs->Target) ? TRUE : FALSE; + return (lhs->SerialNo == rhs->SerialNo) ? TRUE : FALSE; }