Skip to content

Commit 976dd16

Browse files
author
bud3699
committed
Configurable Cursor Support
- This commit is for the people who need more advanced cursor configuration support
1 parent 5281cef commit 976dd16

File tree

2 files changed

+119
-5
lines changed

2 files changed

+119
-5
lines changed

Virtual Display Driver (HDR)/MttVDD/Driver.cpp

Lines changed: 113 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ bool hardwareCursor = false;
9898
bool preventManufacturerSpoof = false;
9999
bool edidCeaOverride = false;
100100
bool sendLogsThroughPipe = true;
101+
102+
//Mouse settings
103+
bool alphaCursorSupport = true;
104+
int CursorMaxX = 128;
105+
int CursorMaxY = 128;
106+
107+
108+
//Rest
101109
IDDCX_BITS_PER_COMPONENT SDRCOLOUR = IDDCX_BITS_PER_COMPONENT_8;
102110
IDDCX_BITS_PER_COMPONENT HDRCOLOUR = IDDCX_BITS_PER_COMPONENT_10;
103111

@@ -111,6 +119,11 @@ std::map<std::wstring, std::pair<std::wstring, std::wstring>> SettingsQueryMap =
111119
{L"PreventMonitorSpoof", {L"PREVENTMONITORSPOOF", L"PreventSpoof"}},
112120
{L"EdidCeaOverride", {L"EDIDCEAOVERRIDE", L"EdidCeaOverride"}},
113121
{L"SendLogsThroughPipe", {L"SENDLOGSTHROUGHPIPE", L"SendLogsThroughPipe"}},
122+
//Cursor
123+
{L"AlphaCursorSupport", {L"ALPHACURSORSUPPORT", L"AlphaCursorSupport"}},
124+
{L"CursorMaxX", {L"CURSORMAXX", L"CursorMaxX"}},
125+
{L"CursorMaxY", {L"CURSORMAXY", L"CursorMaxY"}},
126+
114127
};
115128

116129
vector<unsigned char> Microsoft::IndirectDisp::IndirectDeviceContext::s_KnownMonitorEdid; //Changed to support static vector
@@ -230,6 +243,97 @@ bool EnabledQuery(const std::wstring& settingKey) {
230243
return xmlLoggingValue;
231244
}
232245

246+
int GetIntegerSetting(const std::wstring& settingKey) {
247+
auto it = SettingsQueryMap.find(settingKey);
248+
if (it == SettingsQueryMap.end()) {
249+
vddlog("e", "requested data not found in xml, consider updating xml!");
250+
return -1;
251+
}
252+
253+
std::wstring regName = it->second.first;
254+
std::wstring xmlName = it->second.second;
255+
256+
std::wstring settingsname = confpath + L"\\vdd_settings.xml";
257+
HKEY hKey;
258+
DWORD dwValue;
259+
DWORD dwBufferSize = sizeof(dwValue);
260+
LONG lResult = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\MikeTheTech\\VirtualDisplayDriver", 0, KEY_READ, &hKey);
261+
262+
if (lResult == ERROR_SUCCESS) {
263+
lResult = RegQueryValueExW(hKey, regName.c_str(), NULL, NULL, (LPBYTE)&dwValue, &dwBufferSize);
264+
if (lResult == ERROR_SUCCESS) {
265+
RegCloseKey(hKey);
266+
LogQueries("d", xmlName + L" - Retrieved integer value: " + std::to_wstring(dwValue));
267+
return static_cast<int>(dwValue);
268+
}
269+
else {
270+
LogQueries("d", xmlName + L" - Failed to retrieve integer value from registry. Attempting to read as string.");
271+
wchar_t path[MAX_PATH];
272+
dwBufferSize = sizeof(path);
273+
lResult = RegQueryValueExW(hKey, regName.c_str(), NULL, NULL, (LPBYTE)path, &dwBufferSize);
274+
RegCloseKey(hKey);
275+
if (lResult == ERROR_SUCCESS) {
276+
try {
277+
int logValue = std::stoi(path);
278+
LogQueries("d", xmlName + L" - Retrieved string value: " + std::to_wstring(logValue));
279+
return logValue;
280+
}
281+
catch (const std::exception&) {
282+
LogQueries("d", xmlName + L" - Failed to convert registry string value to integer.");
283+
}
284+
}
285+
}
286+
}
287+
288+
CComPtr<IStream> pFileStream;
289+
HRESULT hr = SHCreateStreamOnFileEx(settingsname.c_str(), STGM_READ, FILE_ATTRIBUTE_NORMAL, FALSE, nullptr, &pFileStream);
290+
if (FAILED(hr)) {
291+
LogQueries("d", xmlName + L" - Failed to create file stream for XML settings.");
292+
return -1;
293+
}
294+
295+
CComPtr<IXmlReader> pReader;
296+
hr = CreateXmlReader(__uuidof(IXmlReader), (void**)&pReader, nullptr);
297+
if (FAILED(hr)) {
298+
LogQueries("d", xmlName + L" - Failed to create XML reader.");
299+
return -1;
300+
}
301+
302+
hr = pReader->SetInput(pFileStream);
303+
if (FAILED(hr)) {
304+
LogQueries("d", xmlName + L" - Failed to set input for XML reader.");
305+
return -1;
306+
}
307+
308+
XmlNodeType nodeType;
309+
const wchar_t* pwszLocalName;
310+
int xmlLoggingValue = -1;
311+
312+
while (S_OK == pReader->Read(&nodeType)) {
313+
if (nodeType == XmlNodeType_Element) {
314+
pReader->GetLocalName(&pwszLocalName, nullptr);
315+
if (wcscmp(pwszLocalName, xmlName.c_str()) == 0) {
316+
pReader->Read(&nodeType);
317+
if (nodeType == XmlNodeType_Text) {
318+
const wchar_t* pwszValue;
319+
pReader->GetValue(&pwszValue, nullptr);
320+
try {
321+
xmlLoggingValue = std::stoi(pwszValue);
322+
LogQueries("i", xmlName + L" - Retrieved from XML: " + std::to_wstring(xmlLoggingValue));
323+
}
324+
catch (const std::exception&) {
325+
LogQueries("d", xmlName + L" - Failed to convert XML string value to integer.");
326+
}
327+
break;
328+
}
329+
}
330+
}
331+
}
332+
333+
return xmlLoggingValue;
334+
}
335+
336+
233337
string WStringToString(const wstring& wstr) { //basically just a function for converting strings since codecvt is depricated in c++ 17
234338
if (wstr.empty()) return "";
235339

@@ -1230,11 +1334,16 @@ extern "C" NTSTATUS DriverEntry(
12301334
SDRCOLOUR = SDR10 ? IDDCX_BITS_PER_COMPONENT_10 : IDDCX_BITS_PER_COMPONENT_8;
12311335

12321336
customEdid = EnabledQuery(L"CustomEdidEnabled");
1233-
hardwareCursor = EnabledQuery(L"HardwareCursorEnabled");
12341337
preventManufacturerSpoof = EnabledQuery(L"PreventMonitorSpoof");
12351338
edidCeaOverride = EnabledQuery(L"EdidCeaOverride");
12361339
sendLogsThroughPipe = EnabledQuery(L"SendLogsThroughPipe");
12371340

1341+
//Cursor
1342+
hardwareCursor = EnabledQuery(L"HardwareCursorEnabled");
1343+
alphaCursorSupport = EnabledQuery(L"AlphaCursorSupport");
1344+
CursorMaxX = GetIntegerSetting(L"CursorMaxX");
1345+
CursorMaxY = GetIntegerSetting(L"CursorMaxY");
1346+
12381347
vddlog("i", "Driver Starting");
12391348
string utf8_confpath = WStringToString(confpath);
12401349
string logtext = "VDD Path: " + utf8_confpath;
@@ -2476,10 +2585,10 @@ void IndirectDeviceContext::AssignSwapChain(IDDCX_MONITOR& Monitor, IDDCX_SWAPCH
24762585
IDDCX_CURSOR_CAPS cursorInfo = {};
24772586
cursorInfo.Size = sizeof(cursorInfo);
24782587
cursorInfo.ColorXorCursorSupport = IDDCX_XOR_CURSOR_SUPPORT_FULL;
2479-
cursorInfo.AlphaCursorSupport = true;
2588+
cursorInfo.AlphaCursorSupport = alphaCursorSupport;
24802589

2481-
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
2482-
cursorInfo.MaxY = 512;
2590+
cursorInfo.MaxX = CursorMaxX; //Apparently in most cases 128 is fine but for safe guarding we will go 512, older intel cpus may be limited to 64x64
2591+
cursorInfo.MaxY = CursorMaxY;
24832592

24842593
//DirectXDevice->QueryMaxCursorSize(&cursorInfo.MaxX, &cursorInfo.MaxY); Experimental to get max cursor size - THIS IS NTO WORKING CODE
24852594

Virtual Display Driver (HDR)/vdd_settings.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
<CustomEdid>false</CustomEdid> <!-- Custom Edid should be named "user_edid.bin"! This does not support emulating resolutions!-->
4949
<PreventSpoof>false</PreventSpoof> <!--Enable this to prevent manufacturer spoofing when using custom edid. Please only do so if you need to!-->
5050
<EdidCeaOverride>false</EdidCeaOverride> <!--Enable this to override or add hard coded cea-extension block to custom Edid support allowing you to enable HDR-->
51-
<HardwareCursor>true</HardwareCursor>
5251
<SDR10bit>false</SDR10bit>
5352
<HDRPlus>false</HDRPlus> <!-- If you have SDR10 bit enabled, HDRPlus wont work - there’s a conflict because the display system cannot simultaneously handle both high dynamic range 12-bit and standard dynamic range 10-bit settings. -->
5453
<logging>false</logging>
@@ -60,4 +59,10 @@
6059
<!-- Debug Logging: Logs local system information with every driver function/event/process. Useful for GitHub Help Tickets.-->
6160
<SendLogsThroughPipe>true</SendLogsThroughPipe>
6261
</options>
62+
<cursor>
63+
<HardwareCursor>true</HardwareCursor> <!--Whether to display a hardware cursor in the buffer (If disabled streaming apps will use client cursor)-->
64+
<CursorMaxY>128</CursorMaxY> <!--The maximum height support for all cursor types. Older intel cpus may be limited to 64x64 -->
65+
<CursorMaxX>128</CursorMaxX> <!--The maximum width supported for all supported cursor types.-->
66+
<AlphaCursorSupport>true</AlphaCursorSupport> <!--Indicates if the adapter supports the 32-bit alpha cursor format. Most cursors are alpha format.-->
67+
</cursor>
6368
</vdd_settings>

0 commit comments

Comments
 (0)