@@ -86,7 +86,7 @@ vector<tuple<int, int, int>> monitorModes;
8686vector< DISPLAYCONFIG_VIDEO_SIGNAL_INFO > s_KnownMonitorModes2;
8787UINT numVirtualDisplays;
8888wstring gpuname;
89- wstring confpath = L" C:\\ IddSampleDriver " ;
89+ wstring confpath = L" C:\\ VirtualDisplayDriver " ;
9090bool logsEnabled = false ;
9191bool debugLogs;
9292
@@ -752,13 +752,12 @@ bool initpath() {
752752 wchar_t szPath[MAX_PATH ];
753753 DWORD dwBufferSize = sizeof (szPath);
754754 LONG lResult;
755- vddlog (" i" , " Reading reg: Computer\\ HKEY_LOCAL_MACHINE\\ SOFTWARE\\ MikeTheTech\\ VirtualDisplayDriver" );
755+ // vddlog("i", "Reading reg: Computer\\HKEY_LOCAL_MACHINE\\SOFTWARE\\MikeTheTech\\VirtualDisplayDriver"); Remove this due to the fact, if reg key exists, this is called before reading
756756 lResult = RegOpenKeyExW (HKEY_LOCAL_MACHINE , L" SOFTWARE\\ MikeTheTech\\ VirtualDisplayDriver" , 0 , KEY_READ , &hKey);
757757 if (lResult != ERROR_SUCCESS ) {
758758 ostringstream oss;
759759 oss << " Failed to open registry key for path. Error code: " << lResult;
760- vddlog (" w" , oss.str ().c_str ());
761- confpath = L" C:\\ IddSampleDriver" ;
760+ vddlog (" w" , oss.str ().c_str ()); // These are okay to call though since they're only called if the reg doesnt exist
762761 return false ;
763762 }
764763
@@ -767,7 +766,6 @@ bool initpath() {
767766 ostringstream oss;
768767 oss << " Failed to open registry key for path. Error code: " << lResult;
769768 vddlog (" w" , oss.str ().c_str ());
770- confpath = L" C:\\ IddSampleDriver" ;
771769 RegCloseKey (hKey);
772770 return false ;
773771 }
@@ -1673,9 +1671,9 @@ void IndirectDeviceContext::InitAdapter()
16731671 AdapterCaps.EndPointDiagnostics .TransmissionType = IDDCX_TRANSMISSION_TYPE_WIRED_OTHER ;
16741672
16751673 // Declare your device strings for telemetry (required)
1676- AdapterCaps.EndPointDiagnostics .pEndPointFriendlyName = L" IddSample Device" ;
1677- AdapterCaps.EndPointDiagnostics .pEndPointManufacturerName = L" Microsoft " ;
1678- AdapterCaps.EndPointDiagnostics .pEndPointModelName = L" IddSample Model" ;
1674+ AdapterCaps.EndPointDiagnostics .pEndPointFriendlyName = L" VirtualDisplayDriver Device" ;
1675+ AdapterCaps.EndPointDiagnostics .pEndPointManufacturerName = L" MikeTheTech " ;
1676+ AdapterCaps.EndPointDiagnostics .pEndPointModelName = L" VirtualDisplayDriver Model" ;
16791677
16801678 // Declare your hardware and firmware versions (required)
16811679 IDDCX_ENDPOINT_VERSION Version = {};
@@ -1815,26 +1813,69 @@ void IndirectDeviceContext::CreateMonitor(unsigned int index) {
18151813 }
18161814}
18171815
1818- void IndirectDeviceContext::AssignSwapChain (IDDCX_SWAPCHAIN SwapChain, LUID RenderAdapter, HANDLE NewFrameEvent)
1816+ void IndirectDeviceContext::AssignSwapChain (IDDCX_MONITOR & Monitor, IDDCX_SWAPCHAIN SwapChain, LUID RenderAdapter, HANDLE NewFrameEvent)
18191817{
18201818 m_ProcessingThread.reset ();
18211819
18221820 auto Device = make_shared<Direct3DDevice>(RenderAdapter);
18231821 if (FAILED (Device->Init ()))
18241822 {
1825- // It's important to delete the swap-chain if D3D initialization fails, so that the OS knows to generate a new
1826- // swap-chain and try again.
18271823 vddlog (" e" , " D3D Initialization failed, deleting existing swap-chain." );
18281824 WdfObjectDelete (SwapChain);
1825+ return ;
18291826 }
18301827 else
18311828 {
1832- // Create a new swap-chain processing thread
18331829 vddlog (" d" , " Creating a new swap-chain processing thread." );
18341830 m_ProcessingThread.reset (new SwapChainProcessor (SwapChain, Device, NewFrameEvent));
1831+
1832+ HANDLE mouseEvent = CreateEventA (
1833+ nullptr ,
1834+ false ,
1835+ false ,
1836+ " VirtualDisplayDriverMouse"
1837+ );
1838+
1839+ if (!mouseEvent)
1840+ {
1841+ vddlog (" e" , " Failed to create mouse event. No hardware cursor supported!" );
1842+ return ;
1843+ }
1844+
1845+ IDDCX_CURSOR_CAPS cursorInfo = {};
1846+ cursorInfo.Size = sizeof (cursorInfo);
1847+ cursorInfo.ColorXorCursorSupport = IDDCX_XOR_CURSOR_SUPPORT_FULL ;
1848+ cursorInfo.AlphaCursorSupport = true ;
1849+
1850+ cursorInfo.MaxX = 512 ; // Apparently in most cases 128 is fine but for safe guarding we will go 512, older intel cpus may be limited to 64x64
1851+ cursorInfo.MaxY = 512 ;
1852+
1853+ // DirectXDevice->QueryMaxCursorSize(&cursorInfo.MaxX, &cursorInfo.MaxY); Experimental to get max cursor size - THIS IS NTO WORKING CODE
1854+
1855+
1856+ IDARG_IN_SETUP_HWCURSOR hwCursor = {};
1857+ hwCursor.CursorInfo = cursorInfo;
1858+ hwCursor.hNewCursorDataAvailable = mouseEvent;
1859+
1860+ NTSTATUS Status = IddCxMonitorSetupHardwareCursor (
1861+ Monitor,
1862+ &hwCursor
1863+ );
1864+
1865+ if (FAILED (Status))
1866+ {
1867+ CloseHandle (mouseEvent);
1868+ return ;
1869+ }
1870+
1871+ vddlog (" d" , " Hardware cursor setup completed successfully." );
1872+
1873+ // At this point, the swap-chain is set up and the hardware cursor is enabled
1874+ // Further swap-chain and cursor processing will occur in the new processing thread.
18351875 }
18361876}
18371877
1878+
18381879void IndirectDeviceContext::UnassignSwapChain ()
18391880{
18401881 // Stop processing the last swap-chain
@@ -2066,7 +2107,7 @@ NTSTATUS IddSampleMonitorAssignSwapChain(IDDCX_MONITOR MonitorObject, const IDAR
20662107 << " \n hNextSurfaceAvailable: " << pInArgs->hNextSurfaceAvailable ;
20672108 vddlog (" d" , logStream.str ().c_str ());
20682109 auto * pContext = WdfObjectGet_IndirectDeviceContextWrapper (MonitorObject);
2069- pContext->pContext ->AssignSwapChain (pInArgs->hSwapChain , pInArgs->RenderAdapterLuid , pInArgs->hNextSurfaceAvailable );
2110+ pContext->pContext ->AssignSwapChain (MonitorObject, pInArgs->hSwapChain , pInArgs->RenderAdapterLuid , pInArgs->hNextSurfaceAvailable );
20702111 vddlog (" d" , " Swap chain assigned successfully." );
20712112 return STATUS_SUCCESS ;
20722113}
0 commit comments