mirror of
https://github.com/VirtualDrivers/Virtual-Display-Driver.git
synced 2026-10-20 05:40:03 -05:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
165de3f949 | ||
|
|
549d5950a9 | ||
|
|
fdec6edc36 | ||
|
|
b6d5618b76 | ||
|
|
6fe70e6f66 | ||
|
|
17d7208774 | ||
|
|
f85b484bcd | ||
|
|
c4f715bd15 | ||
|
|
73a9cde142 | ||
|
|
1c049756ec |
No files matched your search
+139
-40
@@ -22,6 +22,8 @@ Environment:
|
||||
#include<string>
|
||||
#include<tuple>
|
||||
#include<vector>
|
||||
// jocke added for comming dynamic edid loading
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace Microsoft::IndirectDisp;
|
||||
@@ -54,6 +56,10 @@ vector<tuple<int, int, int>> monitorModes;
|
||||
vector< DISPLAYCONFIG_VIDEO_SIGNAL_INFO> s_KnownMonitorModes2;
|
||||
UINT numVirtualDisplays;
|
||||
|
||||
|
||||
std::vector<unsigned char>
|
||||
Microsoft::IndirectDisp::IndirectDeviceContext::s_knownMonitorEdidData;
|
||||
|
||||
struct IndirectDeviceContextWrapper
|
||||
{
|
||||
IndirectDeviceContext* pContext;
|
||||
@@ -115,6 +121,7 @@ vector<string> split(string& input, char delimiter)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void loadOptions(string filepath) {
|
||||
ifstream ifs(filepath);
|
||||
|
||||
@@ -429,40 +436,102 @@ constexpr DISPLAYCONFIG_VIDEO_SIGNAL_INFO dispinfo(UINT32 h, UINT32 v, UINT32 r)
|
||||
};
|
||||
}
|
||||
|
||||
// This is a sample monitor EDID - FOR SAMPLE PURPOSES ONLY
|
||||
const BYTE IndirectDeviceContext::s_KnownMonitorEdid[] =
|
||||
{
|
||||
/* 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x79,0x5E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xA6,0x01,0x03,0x80,0x28,
|
||||
0x1E,0x78,0x0A,0xEE,0x91,0xA3,0x54,0x4C,0x99,0x26,0x0F,0x50,0x54,0x20,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,
|
||||
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xA0,0x0F,0x20,0x00,0x31,0x58,0x1C,0x20,0x28,0x80,0x14,0x00,
|
||||
0x90,0x2C,0x11,0x00,0x00,0x1E,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6E */
|
||||
|
||||
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x31, 0xD8, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x18, 0x1F, 0x01, 0x04, 0xB5, 0x77, 0x22, 0x78,
|
||||
0x3A, 0xC7, 0x25, 0xB1, 0x4B, 0x46, 0xA8, 0x26, 0x0E, 0x50, 0x54, 0x2F,
|
||||
0xCF, 0x00, 0x71, 0x4F, 0x81, 0x00, 0x81, 0xC0, 0x81, 0x80, 0xA9, 0xC0,
|
||||
0xB3, 0x00, 0x95, 0x00, 0xD1, 0xC0, 0x74, 0xD6, 0x00, 0xA0, 0xF0, 0x38,
|
||||
0x40, 0x40, 0x30, 0x20, 0x3A, 0x00, 0xC0, 0x0E, 0x31, 0x00, 0x00, 0x1A,
|
||||
0x00, 0x00, 0x00, 0xFC, 0x00, 0x49, 0x44, 0x44, 0x20, 0x48, 0x44, 0x52,
|
||||
0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x85, 0x02, 0x03, 0x15, 0x00,
|
||||
0xE3, 0x05, 0xC0, 0x00, 0xE6, 0x06, 0x05, 0x01, 0x8B, 0x73, 0x02, 0xE5,
|
||||
0x01, 0x8B, 0x84, 0x90, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xC6
|
||||
// Jocke, createing a 512 byte array filled with 0 values (largest edid bin without breaking standards)
|
||||
|
||||
std::vector<BYTE> s_knownMonitorEdidData;
|
||||
|
||||
static void edidLoad(const std::string& filename) {
|
||||
std::wofstream logFile("C:\\IddSampleDriver\\lddlog.txt", std::ios::app);
|
||||
logFile << L"Entered EDIDLoad" << std::endl;
|
||||
|
||||
std::ifstream file(filename, std::ios::binary);
|
||||
if (file.is_open()) {
|
||||
logFile << L"Filename found for custom edid" << std::endl;
|
||||
// Read file into vector
|
||||
s_knownMonitorEdidData = std::vector<BYTE>(std::istreambuf_iterator<char>(file), {});
|
||||
logFile << L"Replacing edid data in custom bin" << std::endl;
|
||||
// Modify bytes at positions 8, 9, 10, and 11
|
||||
s_knownMonitorEdidData[8] = 0x36;
|
||||
s_knownMonitorEdidData[9] = 0x94;
|
||||
s_knownMonitorEdidData[10] = 0x37;
|
||||
s_knownMonitorEdidData[11] = 0x13;
|
||||
logFile << L"calculating new checksum" << std::endl;
|
||||
|
||||
// Calculate checksum
|
||||
int checksum = 0;
|
||||
for (int i = 0; i < 128; ++i) {
|
||||
checksum += s_knownMonitorEdidData[i];
|
||||
}
|
||||
checksum %= 256;
|
||||
uint8_t bytesum = static_cast<BYTE>(checksum);
|
||||
s_knownMonitorEdidData[127] = bytesum; // Store checksum as a byte, all byte number might be off by 1 (don't knwo how c++ handles array/vector position 0, if it's resereved or filed with data
|
||||
logFile << L"Checksum calculated and placed on last byte of edid data" << std::endl;
|
||||
}
|
||||
else {
|
||||
logFile << L"CustomEdid not found, checking default" << std::endl;
|
||||
std::ifstream filedef("default.bin", std::ios::binary);
|
||||
if (filedef.is_open()) {
|
||||
// Read file into vector this is our pre patched default edid
|
||||
s_knownMonitorEdidData = std::vector<BYTE>(std::istreambuf_iterator<char>(filedef), {});
|
||||
logFile << L"Default.bin loaded into edid data" << std::endl;
|
||||
}
|
||||
else { // if all files are gone from install folder then use our minimal hardcoded edid
|
||||
logFile << L"Defaulting to hardcoded edid" << std::endl;
|
||||
string incode = " {\
|
||||
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x36,0x94,0x37,0x13,0x00,0x00,0x00,0x00,\
|
||||
0x05,0x16,0x01,0x03,0x6D,0x32,0x1C,0x78,0xEA,0x5E,0xC0,0xA4,0x59,0x4A,0x98,0x25,\
|
||||
0x20,0x50,0x54,0x00,0x00,0x00,0xD1,0xC0,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,\
|
||||
0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x3A,0x80,0x18,0x71,0x38,0x2D,0x40,0x58,0x2C,\
|
||||
0x45,0x00,0xF4,0x19,0x11,0x00,0x00,0x1E,0x00,0x00,0x00,0xFF,0x00,0x4D,0x54,0x54,\
|
||||
0x31,0x33,0x33,0x37,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0xFD,0x00,0x3B,\
|
||||
0x3D,0x42,0x44,0x0F,0x00,0x0A,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0xFC,\
|
||||
0x00,0x4D,0x54,0x54,0x31,0x33,0x33,0x37,0x0A,0x20,0x20,0x20,0x20,0x20,0x00,0x83}";
|
||||
|
||||
s_knownMonitorEdidData = std::vector<BYTE>(incode.begin(), incode.end());
|
||||
}
|
||||
}
|
||||
logFile << L"Exiting EDID Load and closing log" << std::endl;
|
||||
logFile.close();
|
||||
|
||||
};
|
||||
|
||||
|
||||
// This is a sample monitor EDID - FOR SAMPLE PURPOSES ONLY
|
||||
/*
|
||||
const BYTE IndirectDeviceContext::s_KnownMonitorEdid[] = {
|
||||
0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x36,0x94,0x37,0x13,0x37,0x13,0x37,0x13,
|
||||
0x0d,0x22,0x01,0x03,0x80,0x32,0x1f,0x78,0x07,0xee,0x95,0xa3,0x54,0x4c,0x99,0x26,
|
||||
0x0f,0x50,0x54,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
|
||||
0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x3a,0x80,0x18,0x71,0x38,0x2d,0x40,0x58,0x2c,
|
||||
0x45,0x00,0x63,0xc8,0x10,0x00,0x00,0x06,0x00,0x00,0x00,0xfd,0x00,0x17,0xf0,0x0f,
|
||||
0xff,0x37,0x00,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0xfc,0x00,0x4d,
|
||||
0x54,0x54,0x31,0x33,0x33,0x37,0x0a,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x10,
|
||||
0x00,0x13,0x37,0x13,0x37,0x13,0x37,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x33,
|
||||
0x02,0x03,0x23,0x40,0x23,0x09,0x00,0x00,0xe6,0x06,0x0d,0x01,0xb4,0x78,0x01,0x67,
|
||||
0x03,0x0c,0x00,0x00,0x00,0x10,0x6e,0xe3,0x05,0x80,0x00,0x67,0xd8,0x5d,0xc4,0x01,
|
||||
0x6e,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9a,
|
||||
0x70,0x13,0x79,0x00,0x00,0x00,0x00,0x1e,0x4d,0x54,0x54,0x0d,0x00,0x39,0x05,0x00,
|
||||
0x00,0x0e,0x18,0x12,0x56,0x44,0x44,0x20,0x62,0x79,0x20,0x4d,0x69,0x6b,0x65,0x54,
|
||||
0x68,0x65,0x54,0x65,0x63,0x68,0x03,0x01,0x14,0x72,0xd6,0x00,0x84,0xff,0x1d,0x9f,
|
||||
0x00,0x2f,0x80,0x1f,0x00,0xdf,0x10,0x18,0x02,0x02,0x00,0x04,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x90
|
||||
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
IndirectDeviceContext::IndirectDeviceContext(_In_ WDFDEVICE WdfDevice) :
|
||||
m_WdfDevice(WdfDevice)
|
||||
{
|
||||
@@ -478,6 +547,7 @@ IndirectDeviceContext::~IndirectDeviceContext()
|
||||
|
||||
void IndirectDeviceContext::InitAdapter()
|
||||
{
|
||||
edidLoad("C:\\IddSampleDriver\\user_edid.bin");
|
||||
// ==============================
|
||||
// TODO: Update the below diagnostic information in accordance with the target hardware. The strings and version
|
||||
// numbers are used for telemetry and may be displayed to the user in some situations.
|
||||
@@ -541,6 +611,7 @@ void IndirectDeviceContext::FinishInit()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IndirectDeviceContext::CreateMonitor(unsigned int index) {
|
||||
// ==============================
|
||||
// TODO: In a real driver, the EDID should be retrieved dynamically from a connected physical monitor. The EDID
|
||||
@@ -549,18 +620,24 @@ void IndirectDeviceContext::CreateMonitor(unsigned int index) {
|
||||
// settings like viewing distance and scale factor. Manufacturers should also use a unique serial number every
|
||||
// single device to ensure the OS can tell the monitors apart.
|
||||
// ==============================
|
||||
std::wofstream logFile("C:\\IddSampleDriver\\lddlog.txt", std::ios::app);
|
||||
|
||||
logFile << L"Creating a monitor start at " << std::endl;
|
||||
|
||||
WDF_OBJECT_ATTRIBUTES Attr;
|
||||
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&Attr, IndirectDeviceContextWrapper);
|
||||
|
||||
logFile << L"Initialized WDF object attributes at " << std::endl;
|
||||
|
||||
IDDCX_MONITOR_INFO MonitorInfo = {};
|
||||
MonitorInfo.Size = sizeof(MonitorInfo);
|
||||
MonitorInfo.MonitorType = DISPLAYCONFIG_OUTPUT_TECHNOLOGY_HDMI;
|
||||
MonitorInfo.ConnectorIndex = index;
|
||||
MonitorInfo.MonitorDescription.Size = sizeof(MonitorInfo.MonitorDescription);
|
||||
MonitorInfo.MonitorDescription.Type = IDDCX_MONITOR_DESCRIPTION_TYPE_EDID;
|
||||
MonitorInfo.MonitorDescription.DataSize = sizeof(s_KnownMonitorEdid);
|
||||
MonitorInfo.MonitorDescription.pData = const_cast<BYTE*>(s_KnownMonitorEdid);
|
||||
MonitorInfo.MonitorDescription.DataSize = sizeof(s_knownMonitorEdidData);
|
||||
MonitorInfo.MonitorDescription.pData = s_knownMonitorEdidData.data();
|
||||
|
||||
|
||||
// ==============================
|
||||
// TODO: The monitor's container ID should be distinct from "this" device's container ID if the monitor is not
|
||||
@@ -570,31 +647,53 @@ void IndirectDeviceContext::CreateMonitor(unsigned int index) {
|
||||
// unique monitor or to use "this" device's container ID for a permanent/integrated monitor.
|
||||
// ==============================
|
||||
|
||||
// Create a container ID
|
||||
|
||||
logFile << L"Initialized monitor info at " << std::endl;
|
||||
|
||||
CoCreateGuid(&MonitorInfo.MonitorContainerId);
|
||||
|
||||
logFile << L"Created container ID at " << std::endl;
|
||||
|
||||
IDARG_IN_MONITORCREATE MonitorCreate = {};
|
||||
MonitorCreate.ObjectAttributes = &Attr;
|
||||
MonitorCreate.pMonitorInfo = &MonitorInfo;
|
||||
|
||||
// Create a monitor object with the specified monitor descriptor
|
||||
IDARG_OUT_MONITORCREATE MonitorCreateOut;
|
||||
NTSTATUS Status = IddCxMonitorCreate(m_Adapter, &MonitorCreate, &MonitorCreateOut);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
logFile << L"Failed to create monitor object. Status code: " << Status << std::endl;
|
||||
}
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
m_Monitor = MonitorCreateOut.MonitorObject;
|
||||
|
||||
// Associate the monitor with this device context
|
||||
auto* pContext = WdfObjectGet_IndirectDeviceContextWrapper(MonitorCreateOut.MonitorObject);
|
||||
pContext->pContext = this;
|
||||
|
||||
// Tell the OS that the monitor has been plugged in
|
||||
logFile << L"Created monitor object and associated it with this device context at " << std::endl;
|
||||
|
||||
IDARG_OUT_MONITORARRIVAL ArrivalOut;
|
||||
Status = IddCxMonitorArrival(m_Monitor, &ArrivalOut);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
logFile << L"Failed to plug in monitor. Status code: " << Status << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
logFile << L"Monitor has been plugged in at " << std::endl;
|
||||
}
|
||||
}
|
||||
else {
|
||||
logFile << L"Weird " << std::endl;
|
||||
}
|
||||
|
||||
|
||||
logFile << L"Creating a monitor end at " << std::endl;
|
||||
logFile.close();
|
||||
}
|
||||
|
||||
void IndirectDeviceContext::AssignSwapChain(IDDCX_SWAPCHAIN SwapChain, LUID RenderAdapter, HANDLE NewFrameEvent)
|
||||
|
||||
void IndirectDeviceContext::AssignSwapChain(IDDCX_SWAPCHAIN SwapChain, LUID RenderAdapter, HANDLE NewFrameEvent) // Jocke, is it here we could assign rendering gpu?
|
||||
{
|
||||
m_ProcessingThread.reset();
|
||||
|
||||
@@ -710,7 +809,7 @@ NTSTATUS IddSampleMonitorGetDefaultModes(IDDCX_MONITOR MonitorObject, const IDAR
|
||||
/// <summary>
|
||||
/// Creates a target mode from the fundamental mode attributes.
|
||||
/// </summary>
|
||||
void CreateTargetMode(DISPLAYCONFIG_VIDEO_SIGNAL_INFO& Mode, UINT Width, UINT Height, UINT VSync)
|
||||
void CreateTargetMode(DISPLAYCONFIG_VIDEO_SIGNAL_INFO& Mode, UINT Width, UINT Height, UINT VSync) // Jocke, is it her we have the issue with 640*480 init when multiple vdds are chosen
|
||||
{
|
||||
Mode.totalSize.cx = Mode.activeSize.cx = Width;
|
||||
Mode.totalSize.cy = Mode.activeSize.cy = Height;
|
||||
|
||||
@@ -80,6 +80,7 @@ namespace Microsoft
|
||||
public:
|
||||
IndirectDeviceContext(_In_ WDFDEVICE WdfDevice);
|
||||
virtual ~IndirectDeviceContext();
|
||||
static std::vector<BYTE> s_knownMonitorEdidData;
|
||||
|
||||
void InitAdapter();
|
||||
void FinishInit();
|
||||
@@ -100,7 +101,8 @@ namespace Microsoft
|
||||
|
||||
public:
|
||||
static const DISPLAYCONFIG_VIDEO_SIGNAL_INFO s_KnownMonitorModes[];
|
||||
static const BYTE s_KnownMonitorEdid[];
|
||||
static BYTE* s_KnownMonitorEdid();
|
||||
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
# THIS IS A DEVELOPMENT BRANCH. THIS BRANCH MAY BE UNSTABLE AND CAUSE ISSUES. WE ARE NOT LIABLE FOR ANY ISSUES IF YOU CHOOSE TO ATTEMPT TO BUILD THIS BRANCH
|
||||
|
||||
# Virtual Display Driver
|
||||
based on Microsoft Indirect Display Driver Sample. This creates a virtual display in Windows that acts and functions just like a real one. It's useful for streaming, virtual reality applications, recording, headless servers, etc. The benefit over a physical display is the ability to adjust resolutions and refresh rates beyond the physical displays capabilities. For example, this would enable the ability to stream a game from your home PC using game streaming software at 240hz at 8K while owning a 60hz 1080p monitor (unrealistic, but explains the abilities well). For servers without displays, this enabled remote desktop and screen streaming to other systems as if there were a display installed.
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
|
||||
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
Exit
|
||||
}
|
||||
}
|
||||
|
||||
$repoName = "PSGallery"
|
||||
$moduleName1 = "DisplayConfig"
|
||||
$moduleName2 = "MonitorConfig"
|
||||
if (!(Get-PSRepository -Name $repoName) -OR !(Find-Module -Name $moduleName1 | Where-Object {$_.Name -eq $moduleName1}) -OR !(Find-Module -Name $moduleName2 | Where-Object {$_.Name -eq $moduleName2})) {
|
||||
& .\dep_fix.ps1
|
||||
}
|
||||
|
||||
# Import the local module
|
||||
$dpth = Get-Module -ListAvailable $moduleName1 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $dpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue
|
||||
|
||||
# Import the other localmodule
|
||||
$mpth = Get-Module -ListAvailable $moduleName2 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $mpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue
|
||||
|
||||
$disp = Get-Monitor | Select-String -Pattern "MTT1337" | Select-Object LineNumber | Select-Object -ExpandProperty LineNumber
|
||||
$bpcc = Get-DisplayColorInfo -DisplayId $disp | Select-Object BitsPerColorChannel | Select-Object -ExpandProperty BitsPerColorChannel
|
||||
|
||||
if ( $bpcc -is [int] ) {
|
||||
if ( $bpcc -gt 8 ) {
|
||||
Disable-DisplayAdvancedColor -DisplayId $disp
|
||||
break
|
||||
}
|
||||
if ( $bpcc -lt 10 ) {
|
||||
Enable-DisplayAdvancedColor -DisplayId $disp
|
||||
break
|
||||
}
|
||||
}
|
||||
else { write-error "Something went wrong in identifying the Colormode of the display." ; break }
|
||||
@@ -0,0 +1,39 @@
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
|
||||
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
Exit
|
||||
}
|
||||
}
|
||||
|
||||
$repoName = "PSGallery"
|
||||
$moduleName1 = "DisplayConfig"
|
||||
$moduleName2 = "MonitorConfig"
|
||||
if (!(Get-PSRepository -Name $repoName) -OR !(Find-Module -Name $moduleName1 | Where-Object {$_.Name -eq $moduleName1}) -OR !(Find-Module -Name $moduleName2 | Where-Object {$_.Name -eq $moduleName2})) {
|
||||
& .\dep_fix.ps1
|
||||
}
|
||||
|
||||
|
||||
# Import the local module
|
||||
$dpth = Get-Module -ListAvailable $moduleName1 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $dpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
|
||||
|
||||
# Import the other localmodule
|
||||
$mpth = Get-Module -ListAvailable $moduleName2 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $mpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
|
||||
|
||||
# Check if there are enough arguments
|
||||
$numArgs = $args.Count
|
||||
switch ($numArgs) {
|
||||
0 { Write-Error "This script requires at least 2 arguments Xres Yres."; break }
|
||||
1 { Write-Error "This script requires at least 2 arguments Xres Yres."; break }
|
||||
2 { $disp = Get-Monitor | Select-String -Pattern "MTT1337" | Select-Object LineNumber | Select-Object -ExpandProperty LineNumber
|
||||
$vres = $args[0]
|
||||
$hres = $args[1]
|
||||
continue
|
||||
}
|
||||
default { Write-Error "Invalid number of arguments: $numArgs"; break }
|
||||
}
|
||||
# Setting the resolution on the correct display.
|
||||
Get-DisplayConfig | Set-DisplayResolution -DisplayId $disp -Width $vres -Height $hres | Use-DisplayConfig
|
||||
@@ -0,0 +1,32 @@
|
||||
# Define the repository name and URL
|
||||
$repoName = "PSGallery"
|
||||
$repoUrl = "https://www.powershellgallery.com/api/v2"
|
||||
|
||||
# Check if the repository is registered
|
||||
if (-not (Get-PSRepository -Name $repoName)) {
|
||||
# Register the repository
|
||||
Register-PSRepository -Name $repoName -SourceLocation $repoUrl -Confirm:$false -InformationAction:Ignore -WarningAction:SilentlyContinue
|
||||
}
|
||||
#Trust the repo, either its allready installed or newly added
|
||||
Set-PSRepository -Name $repoName -InstallationPolicy Trusted -InformationAction:Ignore -WarningAction:SilentlyContinue
|
||||
|
||||
# Define the module name and version
|
||||
$moduleName1 = "DisplayConfig"
|
||||
$version1 = "1.0.5"
|
||||
|
||||
# Define the module name and version
|
||||
$moduleName2 = "MonitorConfig"
|
||||
$version2 = "1.0.3"
|
||||
|
||||
# Check if the module1 is installed
|
||||
if (-not (Get-InstalledModule -Name $moduleName1 -MinimumVersion $version1)) {
|
||||
# Save the module
|
||||
Save-Module -Name $moduleName1 -Repository $repoName -RequiredVersion $version1 -Confirm:$false -InformationAction:Ignore -WarningAction:SilentlyContinue
|
||||
}
|
||||
|
||||
# Check if the module2 is installed
|
||||
if (-not (Get-InstalledModule -Name $moduleName2 -MinimumVersion $version2)) {
|
||||
# Save the module
|
||||
Save-Module -Name $moduleName2 -Repository $repoName -RequiredVersion $version2 -Confirm:$false -InformationAction:Ignore -WarningAction:SilentlyContinue
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
|
||||
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
Exit
|
||||
}
|
||||
}
|
||||
|
||||
$repoName = "PSGallery"
|
||||
$moduleName1 = "DisplayConfig"
|
||||
$moduleName2 = "MonitorConfig"
|
||||
if (!(Get-PSRepository -Name $repoName) -OR !(Find-Module -Name $moduleName1 | Where-Object {$_.Name -eq $moduleName1}) -OR !(Find-Module -Name $moduleName2 | Where-Object {$_.Name -eq $moduleName2})) {
|
||||
& .\dep_fix.ps1
|
||||
}
|
||||
|
||||
|
||||
# Import the local module
|
||||
$dpth = Get-Module -ListAvailable $moduleName1 | select path | Select-Object -ExpandProperty path; import-module -name $dpth
|
||||
|
||||
# Import the other localmodule
|
||||
$mpth = Get-Module -ListAvailable $moduleName2 | select path | Select-Object -ExpandProperty path; import-module -name $mpth
|
||||
|
||||
|
||||
$disp = Get-Monitor | Select-String -Pattern "MTT1337" | Select-Object LineNumber | Select-Object -ExpandProperty LineNumber
|
||||
Set-DisplayPrimary -DisplayId $disp
|
||||
@@ -0,0 +1,39 @@
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
|
||||
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
Exit
|
||||
}
|
||||
}
|
||||
|
||||
$repoName = "PSGallery"
|
||||
$moduleName1 = "DisplayConfig"
|
||||
$moduleName2 = "MonitorConfig"
|
||||
if (!(Get-PSRepository -Name $repoName) -OR !(Find-Module -Name $moduleName1 | Where-Object {$_.Name -eq $moduleName1}) -OR !(Find-Module -Name $moduleName2 | Where-Object {$_.Name -eq $moduleName2})) {
|
||||
& .\dep_fix.ps1
|
||||
}
|
||||
|
||||
|
||||
# Import the local module
|
||||
$dpth = Get-Module -ListAvailable $moduleName1 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $dpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
|
||||
|
||||
# Import the other localmodule
|
||||
$mpth = Get-Module -ListAvailable $moduleName2 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $mpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
|
||||
|
||||
|
||||
# Use the module's functions and cmdlets in your script
|
||||
# Check if there are enough arguments
|
||||
$numArgs = $args.Count
|
||||
switch ($numArgs) {
|
||||
0 { Write-Error "This script requires a refreshrate above 59 or reset"; break }
|
||||
1 { $disp = Get-Monitor | Select-String -Pattern "MTT1337" | Select-Object LineNumber | Select-Object -ExpandProperty LineNumber
|
||||
$rate = $args[0]
|
||||
continue
|
||||
}
|
||||
default { Write-Error "Invalid number of arguments: $numArgs"; break }
|
||||
}
|
||||
# Setting the resolution on the correct display.
|
||||
Get-DisplayConfig | Set-DisplayRefreshRate -DisplayId $disp -RefreshRate $rate | Use-DisplayConfig
|
||||
@@ -0,0 +1,46 @@
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
|
||||
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
Exit
|
||||
}
|
||||
}
|
||||
|
||||
$repoName = "PSGallery"
|
||||
$moduleName1 = "DisplayConfig"
|
||||
$moduleName2 = "MonitorConfig"
|
||||
if (!(Get-PSRepository -Name $repoName) -OR !(Find-Module -Name $moduleName1 | Where-Object {$_.Name -eq $moduleName1}) -OR !(Find-Module -Name $moduleName2 | Where-Object {$_.Name -eq $moduleName2})) {
|
||||
& .\dep_fix.ps1
|
||||
}
|
||||
|
||||
|
||||
# Import the local module
|
||||
$dpth = Get-Module -ListAvailable $moduleName1 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $dpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
|
||||
|
||||
# Import the other localmodule
|
||||
$mpth = Get-Module -ListAvailable $moduleName2 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $mpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
|
||||
|
||||
# Check if there are enough arguments
|
||||
$numArgs = $args.Count
|
||||
switch ($numArgs) {
|
||||
0 { Write-Error "This script requires at least 1, rotation in degrees ex. 90/180/270."; break }
|
||||
1 { $disp = Get-Monitor | Select-String -Pattern "MTT1337" | Select-Object LineNumber | Select-Object -ExpandProperty LineNumber
|
||||
switch ($args[0]) {
|
||||
90 { $degree = "Rotate90"
|
||||
continue
|
||||
}
|
||||
180 { $degree = "Rotate180"
|
||||
continue
|
||||
}
|
||||
270 { $degree = "Rotate270"
|
||||
continue
|
||||
}
|
||||
default { Write-Error "Invalid rotation angle(valid 90,180,270)."; break }
|
||||
}
|
||||
default { Write-Error "Invalid number of arguments: $numArgs"; break }
|
||||
}
|
||||
# Setting the resolution on the correct display.
|
||||
Get-DisplayConfig | Set-DisplayRotation -DisplayId $disp -Rotation $degree | Use-DisplayConfig
|
||||
@@ -0,0 +1,54 @@
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
|
||||
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
Exit
|
||||
}
|
||||
}
|
||||
|
||||
$repoName = "PSGallery"
|
||||
$moduleName1 = "DisplayConfig"
|
||||
$moduleName2 = "MonitorConfig"
|
||||
if (!(Get-PSRepository -Name $repoName) -OR !(Find-Module -Name $moduleName1 | Where-Object {$_.Name -eq $moduleName1}) -OR !(Find-Module -Name $moduleName2 | Where-Object {$_.Name -eq $moduleName2})) {
|
||||
& .\dep_fix.ps1
|
||||
}
|
||||
|
||||
|
||||
# Import the local module
|
||||
$dpth = Get-Module -ListAvailable $moduleName1 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $dpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
|
||||
|
||||
# Import the other localmodule
|
||||
$mpth = Get-Module -ListAvailable $moduleName2 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $mpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
|
||||
|
||||
# Check if there are enough arguments
|
||||
$numArgs = $args.Count
|
||||
switch ($numArgs) {
|
||||
0 { Write-Error "This script requires a scale 'reset' or an accepted percfentage value (100, 125, 150, 175, 200, 225, 250, 300, 350, 400, 450, 500) limited by the device max scale."; break }
|
||||
1 { $disp = Get-Monitor | Select-String -Pattern "MTT1337" | Select-Object LineNumber | Select-Object -ExpandProperty LineNumber
|
||||
$maxscale = Get-DisplayScale -DisplayId $disp | Select-Object -ExpandProperty MaxScale
|
||||
if ( $args[0] -is [int] ) {
|
||||
if ( $args[0] -le $maxscale -And $args[0] -ge 100 ) {
|
||||
Set-DisplayScale -DisplayId $disp -Scale $args[0]
|
||||
break
|
||||
}
|
||||
else {
|
||||
Write-Error "Invalid scale percentage."
|
||||
break
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( $args[0] -eq "reset" ) {
|
||||
Set-DisplayScale -DisplayId $disp -Recommended
|
||||
break
|
||||
}
|
||||
else {
|
||||
Write-Error "Invalid arguments: 'reset' or a valid percentage value like 150 is acceptable."
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
default { Write-Error "Invalid number of arguments: $numArgs"; break }
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
$device = get-pnpdevice -class Display -FriendlyName 'IddSampleDriver Device HDR' -ErrorAction SilentlyContinue
|
||||
$device = get-pnpdevice -class Display -FriendlyName 'Virtual Display' -ErrorAction SilentlyContinue
|
||||
|
||||
if ($device) {
|
||||
if ($device.Status -eq 'OK') {
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
|
||||
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
Exit
|
||||
}
|
||||
}
|
||||
|
||||
$repoName = "PSGallery"
|
||||
$moduleName1 = "DisplayConfig"
|
||||
$moduleName2 = "MonitorConfig"
|
||||
if (!(Get-PSRepository -Name $repoName) -OR !(Find-Module -Name $moduleName1 | Where-Object {$_.Name -eq $moduleName1}) -OR !(Find-Module -Name $moduleName2 | Where-Object {$_.Name -eq $moduleName2})) {
|
||||
& .\dep_fix.ps1
|
||||
}
|
||||
|
||||
|
||||
# Import the local module
|
||||
$dpth = Get-Module -ListAvailable $moduleName1 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $dpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
|
||||
|
||||
# Import the other localmodule
|
||||
$mpth = Get-Module -ListAvailable $moduleName2 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $mpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
|
||||
|
||||
|
||||
$profi = Get-DisplayProfile
|
||||
|
||||
if ( $profi -eq "Extend" ) {
|
||||
Set-DisplayProfile Clone
|
||||
break
|
||||
}
|
||||
if ( $profi -eq "Clone" ) {
|
||||
Set-DisplayProfile Extend
|
||||
break
|
||||
}
|
||||
Reference in new issue
Block a user