Skip to content

Commit

Permalink
Merge pull request #69 from MiroKaku/main
Browse files Browse the repository at this point in the history
fix(core): distinguish the error states of VddAddDisplay.
  • Loading branch information
nomi-san authored Nov 4, 2024
2 parents 80bd3c4 + ad6c25a commit a9de6bb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
17 changes: 11 additions & 6 deletions core/parsec-vdd.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,22 @@ static const int VDD_MAX_DISPLAYS = 8;

// Core IoControl codes, see usage below.
typedef enum {
VDD_IOCTL_ADD = 0x0022e004,
VDD_IOCTL_REMOVE = 0x0022a008,
VDD_IOCTL_UPDATE = 0x0022a00c,
VDD_IOCTL_VERSION = 0x0022e010,
VDD_IOCTL_ADD = 0x0022e004, // CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800 + 1, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
VDD_IOCTL_REMOVE = 0x0022a008, // CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800 + 2, METHOD_BUFFERED, FILE_WRITE_ACCESS)
VDD_IOCTL_UPDATE = 0x0022a00c, // CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800 + 3, METHOD_BUFFERED, FILE_WRITE_ACCESS)
VDD_IOCTL_VERSION = 0x0022e010, // CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800 + 4, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)

// new code in driver v0.45
// relates to IOCTL_UPDATE and per display state
// but unused in Parsec app
VDD_IOCTL_UNKONWN = 0x0022a00c, // CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800 + 5, METHOD_BUFFERED, FILE_WRITE_ACCESS)
} VddCtlCode;

// Generic DeviceIoControl for all IoControl codes.
static DWORD VddIoControl(HANDLE vdd, VddCtlCode code, const void *data, size_t size)
{
if (vdd == NULL || vdd == INVALID_HANDLE_VALUE)
return 0;
return -1;

BYTE InBuffer[32];
ZeroMemory(InBuffer, sizeof(InBuffer));
Expand All @@ -285,7 +290,7 @@ static DWORD VddIoControl(HANDLE vdd, VddCtlCode code, const void *data, size_t
if (!GetOverlappedResultEx(vdd, &Overlapped, &NumberOfBytesTransferred, 5000, FALSE))
{
CloseHandle(Overlapped.hEvent);
return 0;
return -1;
}

if (Overlapped.hEvent != NULL)
Expand Down
11 changes: 7 additions & 4 deletions core/vdd-demo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ int main()
}
});

updater.detach();

// Print out guide.
printf("Press A to add a virtual display.\n");
printf("Press R to remove the last added.\n");
Expand All @@ -53,8 +51,13 @@ int main()
case 'a':
if (displays.size() < VDD_MAX_DISPLAYS) {
int index = VddAddDisplay(vdd);
displays.push_back(index);
printf("Added a new virtual display, index: %d.\n", index);
if (index != -1) {
displays.push_back(index);
printf("Added a new virtual display, index: %d.\n", index);
}
else {
printf("Add virtual display failed.");
}
}
else {
printf("Limit exceeded (%d), could not add more virtual displays.\n", VDD_MAX_DISPLAYS);
Expand Down

0 comments on commit a9de6bb

Please sign in to comment.