mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d2cece4f2 | ||
|
|
265611009c | ||
|
|
2714b6dca7 | ||
|
|
f6de5eba64 | ||
|
|
13f7c81689 | ||
|
|
8c0d84b65b |
@@ -42,6 +42,15 @@ public class ASUSWmi
|
|||||||
public const int GPUModeUltimate = 2;
|
public const int GPUModeUltimate = 2;
|
||||||
|
|
||||||
|
|
||||||
|
public const int MaxTotal = 150;
|
||||||
|
public const int MinTotal = 15;
|
||||||
|
public const int DefaultTotal = 125;
|
||||||
|
|
||||||
|
public const int MaxCPU = 90;
|
||||||
|
public const int MinCPU = 15;
|
||||||
|
public const int DefaultCPU = 80;
|
||||||
|
|
||||||
|
|
||||||
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||||
private static extern IntPtr CreateFile(
|
private static extern IntPtr CreateFile(
|
||||||
string lpFileName,
|
string lpFileName,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
using Starlight.Communication;
|
using Starlight.Communication;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Management;
|
||||||
|
|
||||||
namespace Starlight.AnimeMatrix
|
namespace Starlight.AnimeMatrix
|
||||||
{
|
{
|
||||||
@@ -70,16 +71,45 @@ namespace Starlight.AnimeMatrix
|
|||||||
private const int UpdatePageLength = 0x0278;
|
private const int UpdatePageLength = 0x0278;
|
||||||
|
|
||||||
public int LedCount => 1450;
|
public int LedCount => 1450;
|
||||||
public int Rows => 61;
|
|
||||||
|
|
||||||
private byte[] _displayBuffer = new byte[UpdatePageLength * 3];
|
private byte[] _displayBuffer = new byte[UpdatePageLength * 3];
|
||||||
private List<byte[]> frames = new List<byte[]>();
|
private List<byte[]> frames = new List<byte[]>();
|
||||||
|
|
||||||
|
private int pages = 3;
|
||||||
|
|
||||||
|
public int MaxColumns = 34;
|
||||||
|
public int MaxRows = 61;
|
||||||
|
|
||||||
|
public int FullRows = 11;
|
||||||
|
|
||||||
private int frameIndex = 0;
|
private int frameIndex = 0;
|
||||||
|
|
||||||
public AnimeMatrixDevice()
|
public AnimeMatrixDevice()
|
||||||
: base(0x0B05, 0x193B, 640)
|
: base(0x0B05, 0x193B, 640)
|
||||||
{
|
{
|
||||||
|
string model = GetModel();
|
||||||
|
Debug.WriteLine(model);
|
||||||
|
if (model is not null && model.Contains("401"))
|
||||||
|
{
|
||||||
|
pages = 2;
|
||||||
|
|
||||||
|
FullRows = 6;
|
||||||
|
MaxColumns = 33;
|
||||||
|
MaxRows = 55;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string GetModel()
|
||||||
|
{
|
||||||
|
using (var searcher = new ManagementObjectSearcher(@"Select * from Win32_ComputerSystem"))
|
||||||
|
{
|
||||||
|
foreach (var process in searcher.Get())
|
||||||
|
return process["Model"].ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] GetBuffer()
|
public byte[] GetBuffer()
|
||||||
@@ -115,12 +145,12 @@ namespace Starlight.AnimeMatrix
|
|||||||
|
|
||||||
public int EmptyColumns(int row)
|
public int EmptyColumns(int row)
|
||||||
{
|
{
|
||||||
return (int)Math.Ceiling(Math.Max(0, row - 11) / 2.0);
|
return (int)Math.Ceiling(Math.Max(0, row - FullRows) / 2.0);
|
||||||
}
|
}
|
||||||
public int Columns(int row)
|
public int Columns(int row)
|
||||||
{
|
{
|
||||||
EnsureRowInRange(row);
|
EnsureRowInRange(row);
|
||||||
return 34 - EmptyColumns(row);
|
return MaxColumns - EmptyColumns(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int RowToLinearAddress(int row)
|
public int RowToLinearAddress(int row)
|
||||||
@@ -183,6 +213,7 @@ namespace Starlight.AnimeMatrix
|
|||||||
|
|
||||||
public void Present()
|
public void Present()
|
||||||
{
|
{
|
||||||
|
|
||||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
||||||
.AppendData(BitConverter.GetBytes((ushort)(UpdatePageLength * 0 + 1)))
|
.AppendData(BitConverter.GetBytes((ushort)(UpdatePageLength * 0 + 1)))
|
||||||
.AppendData(BitConverter.GetBytes((ushort)UpdatePageLength))
|
.AppendData(BitConverter.GetBytes((ushort)UpdatePageLength))
|
||||||
@@ -195,12 +226,13 @@ namespace Starlight.AnimeMatrix
|
|||||||
.AppendData(_displayBuffer[(UpdatePageLength * 1)..(UpdatePageLength * 2)])
|
.AppendData(_displayBuffer[(UpdatePageLength * 1)..(UpdatePageLength * 2)])
|
||||||
);
|
);
|
||||||
|
|
||||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
if (pages > 2)
|
||||||
.AppendData(BitConverter.GetBytes((ushort)(UpdatePageLength * 2 + 1)))
|
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
||||||
.AppendData(BitConverter.GetBytes((ushort)(LedCount - UpdatePageLength * 2)))
|
.AppendData(BitConverter.GetBytes((ushort)(UpdatePageLength * 2 + 1)))
|
||||||
.AppendData(
|
.AppendData(BitConverter.GetBytes((ushort)(LedCount - UpdatePageLength * 2)))
|
||||||
_displayBuffer[(UpdatePageLength * 2)..(UpdatePageLength * 2 + (LedCount - UpdatePageLength * 2))])
|
.AppendData(
|
||||||
);
|
_displayBuffer[(UpdatePageLength * 2)..(UpdatePageLength * 2 + (LedCount - UpdatePageLength * 2))])
|
||||||
|
);
|
||||||
|
|
||||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x03));
|
Set(Packet<AnimeMatrixPacket>(0xC0, 0x03));
|
||||||
}
|
}
|
||||||
@@ -241,8 +273,8 @@ namespace Starlight.AnimeMatrix
|
|||||||
public void GenerateFrame(Image image)
|
public void GenerateFrame(Image image)
|
||||||
{
|
{
|
||||||
|
|
||||||
int width = 34 * 3;
|
int width = MaxColumns * 3;
|
||||||
int height = 61;
|
int height = MaxRows;
|
||||||
float scale;
|
float scale;
|
||||||
|
|
||||||
Bitmap canvas = new Bitmap(width, height);
|
Bitmap canvas = new Bitmap(width, height);
|
||||||
@@ -259,7 +291,7 @@ namespace Starlight.AnimeMatrix
|
|||||||
|
|
||||||
graph.DrawImage(image, ((int)width - scaleWidth), ((int)height - scaleHeight) / 2, scaleWidth, scaleHeight);
|
graph.DrawImage(image, ((int)width - scaleWidth), ((int)height - scaleHeight) / 2, scaleWidth, scaleHeight);
|
||||||
|
|
||||||
Bitmap bmp = new Bitmap(canvas, 34, 61);
|
Bitmap bmp = new Bitmap(canvas, MaxColumns, MaxRows);
|
||||||
|
|
||||||
for (int y = 0; y < bmp.Height; y++)
|
for (int y = 0; y < bmp.Height; y++)
|
||||||
{
|
{
|
||||||
@@ -275,9 +307,9 @@ namespace Starlight.AnimeMatrix
|
|||||||
|
|
||||||
private void EnsureRowInRange(int row)
|
private void EnsureRowInRange(int row)
|
||||||
{
|
{
|
||||||
if (row < 0 || row >= Rows)
|
if (row < 0 || row >= MaxRows)
|
||||||
{
|
{
|
||||||
throw new IndexOutOfRangeException($"Y-coordinate should fall in range of [0, {Rows - 1}].");
|
throw new IndexOutOfRangeException($"Y-coordinate should fall in range of [0, {MaxRows - 1}].");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
28
Fans.cs
28
Fans.cs
@@ -11,14 +11,6 @@ namespace GHelper
|
|||||||
Series seriesCPU;
|
Series seriesCPU;
|
||||||
Series seriesGPU;
|
Series seriesGPU;
|
||||||
|
|
||||||
const int MaxTotal = 150;
|
|
||||||
const int MinTotal = 15;
|
|
||||||
const int DefaultTotal = 125;
|
|
||||||
|
|
||||||
const int MaxCPU = 90;
|
|
||||||
const int MinCPU = 15;
|
|
||||||
const int DefaultCPU = 80;
|
|
||||||
|
|
||||||
void SetChart(Chart chart, int device)
|
void SetChart(Chart chart, int device)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -91,11 +83,11 @@ namespace GHelper
|
|||||||
buttonReset.Click += ButtonReset_Click;
|
buttonReset.Click += ButtonReset_Click;
|
||||||
buttonApply.Click += ButtonApply_Click;
|
buttonApply.Click += ButtonApply_Click;
|
||||||
|
|
||||||
trackTotal.Maximum = MaxTotal;
|
trackTotal.Maximum = ASUSWmi.MaxTotal;
|
||||||
trackTotal.Minimum = MinTotal;
|
trackTotal.Minimum = ASUSWmi.MinTotal;
|
||||||
|
|
||||||
trackCPU.Maximum = MaxCPU;
|
trackCPU.Maximum = ASUSWmi.MaxCPU;
|
||||||
trackCPU.Minimum = MinCPU;
|
trackCPU.Minimum = ASUSWmi.MinCPU;
|
||||||
|
|
||||||
trackCPU.Scroll += TrackCPU_Scroll;
|
trackCPU.Scroll += TrackCPU_Scroll;
|
||||||
trackTotal.Scroll += TrackTotal_Scroll;
|
trackTotal.Scroll += TrackTotal_Scroll;
|
||||||
@@ -167,13 +159,13 @@ namespace GHelper
|
|||||||
ApplyLabel(apply);
|
ApplyLabel(apply);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (limit_total < 0) limit_total = DefaultTotal;
|
if (limit_total < 0) limit_total = ASUSWmi.DefaultTotal;
|
||||||
if (limit_total > MaxTotal) limit_total = MaxTotal;
|
if (limit_total > ASUSWmi.MaxTotal) limit_total = ASUSWmi.MaxTotal;
|
||||||
if (limit_total < MinTotal) limit_total = MinTotal;
|
if (limit_total < ASUSWmi.MinTotal) limit_total = ASUSWmi.MinTotal;
|
||||||
|
|
||||||
if (limit_cpu < 0) limit_cpu = DefaultCPU;
|
if (limit_cpu < 0) limit_cpu = ASUSWmi.DefaultCPU;
|
||||||
if (limit_cpu > MaxCPU) limit_cpu = MaxCPU;
|
if (limit_cpu > ASUSWmi.MaxCPU) limit_cpu = ASUSWmi.MaxCPU;
|
||||||
if (limit_cpu < MinCPU) limit_cpu = MinCPU;
|
if (limit_cpu < ASUSWmi.MinCPU) limit_cpu = ASUSWmi.MinCPU;
|
||||||
if (limit_cpu > limit_total) limit_cpu = limit_total;
|
if (limit_cpu > limit_total) limit_cpu = limit_total;
|
||||||
|
|
||||||
trackTotal.Value = limit_total;
|
trackTotal.Value = limit_total;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<AssemblyName>GHelper</AssemblyName>
|
<AssemblyName>GHelper</AssemblyName>
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||||
<AssemblyVersion>0.18</AssemblyVersion>
|
<AssemblyVersion>0.18.1</AssemblyVersion>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
413
NativeMethods.cs
413
NativeMethods.cs
@@ -1,7 +1,311 @@
|
|||||||
using System.Diagnostics;
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Management;
|
using System.Management;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Tools;
|
||||||
|
using static Tools.ScreenInterrogatory;
|
||||||
|
|
||||||
|
namespace Tools
|
||||||
|
{
|
||||||
|
public static class ScreenInterrogatory
|
||||||
|
{
|
||||||
|
public const int ERROR_SUCCESS = 0;
|
||||||
|
|
||||||
|
#region enums
|
||||||
|
|
||||||
|
public enum QUERY_DEVICE_CONFIG_FLAGS : uint
|
||||||
|
{
|
||||||
|
QDC_ALL_PATHS = 0x00000001,
|
||||||
|
QDC_ONLY_ACTIVE_PATHS = 0x00000002,
|
||||||
|
QDC_DATABASE_CURRENT = 0x00000004
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY : uint
|
||||||
|
{
|
||||||
|
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_OTHER = 0xFFFFFFFF,
|
||||||
|
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_HD15 = 0,
|
||||||
|
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_SVIDEO = 1,
|
||||||
|
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_COMPOSITE_VIDEO = 2,
|
||||||
|
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_COMPONENT_VIDEO = 3,
|
||||||
|
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DVI = 4,
|
||||||
|
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_HDMI = 5,
|
||||||
|
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_LVDS = 6,
|
||||||
|
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_D_JPN = 8,
|
||||||
|
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_SDI = 9,
|
||||||
|
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EXTERNAL = 10,
|
||||||
|
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED = 11,
|
||||||
|
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_UDI_EXTERNAL = 12,
|
||||||
|
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_UDI_EMBEDDED = 13,
|
||||||
|
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_SDTVDONGLE = 14,
|
||||||
|
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_MIRACAST = 15,
|
||||||
|
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL = 0x80000000,
|
||||||
|
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_FORCE_UINT32 = 0xFFFFFFFF
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum DISPLAYCONFIG_SCANLINE_ORDERING : uint
|
||||||
|
{
|
||||||
|
DISPLAYCONFIG_SCANLINE_ORDERING_UNSPECIFIED = 0,
|
||||||
|
DISPLAYCONFIG_SCANLINE_ORDERING_PROGRESSIVE = 1,
|
||||||
|
DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED = 2,
|
||||||
|
DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED_UPPERFIELDFIRST = DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED,
|
||||||
|
DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED_LOWERFIELDFIRST = 3,
|
||||||
|
DISPLAYCONFIG_SCANLINE_ORDERING_FORCE_UINT32 = 0xFFFFFFFF
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum DISPLAYCONFIG_ROTATION : uint
|
||||||
|
{
|
||||||
|
DISPLAYCONFIG_ROTATION_IDENTITY = 1,
|
||||||
|
DISPLAYCONFIG_ROTATION_ROTATE90 = 2,
|
||||||
|
DISPLAYCONFIG_ROTATION_ROTATE180 = 3,
|
||||||
|
DISPLAYCONFIG_ROTATION_ROTATE270 = 4,
|
||||||
|
DISPLAYCONFIG_ROTATION_FORCE_UINT32 = 0xFFFFFFFF
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum DISPLAYCONFIG_SCALING : uint
|
||||||
|
{
|
||||||
|
DISPLAYCONFIG_SCALING_IDENTITY = 1,
|
||||||
|
DISPLAYCONFIG_SCALING_CENTERED = 2,
|
||||||
|
DISPLAYCONFIG_SCALING_STRETCHED = 3,
|
||||||
|
DISPLAYCONFIG_SCALING_ASPECTRATIOCENTEREDMAX = 4,
|
||||||
|
DISPLAYCONFIG_SCALING_CUSTOM = 5,
|
||||||
|
DISPLAYCONFIG_SCALING_PREFERRED = 128,
|
||||||
|
DISPLAYCONFIG_SCALING_FORCE_UINT32 = 0xFFFFFFFF
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum DISPLAYCONFIG_PIXELFORMAT : uint
|
||||||
|
{
|
||||||
|
DISPLAYCONFIG_PIXELFORMAT_8BPP = 1,
|
||||||
|
DISPLAYCONFIG_PIXELFORMAT_16BPP = 2,
|
||||||
|
DISPLAYCONFIG_PIXELFORMAT_24BPP = 3,
|
||||||
|
DISPLAYCONFIG_PIXELFORMAT_32BPP = 4,
|
||||||
|
DISPLAYCONFIG_PIXELFORMAT_NONGDI = 5,
|
||||||
|
DISPLAYCONFIG_PIXELFORMAT_FORCE_UINT32 = 0xffffffff
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum DISPLAYCONFIG_MODE_INFO_TYPE : uint
|
||||||
|
{
|
||||||
|
DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE = 1,
|
||||||
|
DISPLAYCONFIG_MODE_INFO_TYPE_TARGET = 2,
|
||||||
|
DISPLAYCONFIG_MODE_INFO_TYPE_FORCE_UINT32 = 0xFFFFFFFF
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum DISPLAYCONFIG_DEVICE_INFO_TYPE : uint
|
||||||
|
{
|
||||||
|
DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME = 1,
|
||||||
|
DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME = 2,
|
||||||
|
DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_PREFERRED_MODE = 3,
|
||||||
|
DISPLAYCONFIG_DEVICE_INFO_GET_ADAPTER_NAME = 4,
|
||||||
|
DISPLAYCONFIG_DEVICE_INFO_SET_TARGET_PERSISTENCE = 5,
|
||||||
|
DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_BASE_TYPE = 6,
|
||||||
|
DISPLAYCONFIG_DEVICE_INFO_FORCE_UINT32 = 0xFFFFFFFF
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region structs
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct LUID
|
||||||
|
{
|
||||||
|
public uint LowPart;
|
||||||
|
public int HighPart;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct DISPLAYCONFIG_PATH_SOURCE_INFO
|
||||||
|
{
|
||||||
|
public LUID adapterId;
|
||||||
|
public uint id;
|
||||||
|
public uint modeInfoIdx;
|
||||||
|
public uint statusFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct DISPLAYCONFIG_PATH_TARGET_INFO
|
||||||
|
{
|
||||||
|
public LUID adapterId;
|
||||||
|
public uint id;
|
||||||
|
public uint modeInfoIdx;
|
||||||
|
private DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY outputTechnology;
|
||||||
|
private DISPLAYCONFIG_ROTATION rotation;
|
||||||
|
private DISPLAYCONFIG_SCALING scaling;
|
||||||
|
private DISPLAYCONFIG_RATIONAL refreshRate;
|
||||||
|
private DISPLAYCONFIG_SCANLINE_ORDERING scanLineOrdering;
|
||||||
|
public bool targetAvailable;
|
||||||
|
public uint statusFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct DISPLAYCONFIG_RATIONAL
|
||||||
|
{
|
||||||
|
public uint Numerator;
|
||||||
|
public uint Denominator;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct DISPLAYCONFIG_PATH_INFO
|
||||||
|
{
|
||||||
|
public DISPLAYCONFIG_PATH_SOURCE_INFO sourceInfo;
|
||||||
|
public DISPLAYCONFIG_PATH_TARGET_INFO targetInfo;
|
||||||
|
public uint flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct DISPLAYCONFIG_2DREGION
|
||||||
|
{
|
||||||
|
public uint cx;
|
||||||
|
public uint cy;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct DISPLAYCONFIG_VIDEO_SIGNAL_INFO
|
||||||
|
{
|
||||||
|
public ulong pixelRate;
|
||||||
|
public DISPLAYCONFIG_RATIONAL hSyncFreq;
|
||||||
|
public DISPLAYCONFIG_RATIONAL vSyncFreq;
|
||||||
|
public DISPLAYCONFIG_2DREGION activeSize;
|
||||||
|
public DISPLAYCONFIG_2DREGION totalSize;
|
||||||
|
public uint videoStandard;
|
||||||
|
public DISPLAYCONFIG_SCANLINE_ORDERING scanLineOrdering;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct DISPLAYCONFIG_TARGET_MODE
|
||||||
|
{
|
||||||
|
public DISPLAYCONFIG_VIDEO_SIGNAL_INFO targetVideoSignalInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct POINTL
|
||||||
|
{
|
||||||
|
private int x;
|
||||||
|
private int y;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct DISPLAYCONFIG_SOURCE_MODE
|
||||||
|
{
|
||||||
|
public uint width;
|
||||||
|
public uint height;
|
||||||
|
public DISPLAYCONFIG_PIXELFORMAT pixelFormat;
|
||||||
|
public POINTL position;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
|
public struct DISPLAYCONFIG_MODE_INFO_UNION
|
||||||
|
{
|
||||||
|
[FieldOffset(0)]
|
||||||
|
public DISPLAYCONFIG_TARGET_MODE targetMode;
|
||||||
|
|
||||||
|
[FieldOffset(0)]
|
||||||
|
public DISPLAYCONFIG_SOURCE_MODE sourceMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct DISPLAYCONFIG_MODE_INFO
|
||||||
|
{
|
||||||
|
public DISPLAYCONFIG_MODE_INFO_TYPE infoType;
|
||||||
|
public uint id;
|
||||||
|
public LUID adapterId;
|
||||||
|
public DISPLAYCONFIG_MODE_INFO_UNION modeInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct DISPLAYCONFIG_TARGET_DEVICE_NAME_FLAGS
|
||||||
|
{
|
||||||
|
public uint value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct DISPLAYCONFIG_DEVICE_INFO_HEADER
|
||||||
|
{
|
||||||
|
public DISPLAYCONFIG_DEVICE_INFO_TYPE type;
|
||||||
|
public uint size;
|
||||||
|
public LUID adapterId;
|
||||||
|
public uint id;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||||
|
public struct DISPLAYCONFIG_TARGET_DEVICE_NAME
|
||||||
|
{
|
||||||
|
public DISPLAYCONFIG_DEVICE_INFO_HEADER header;
|
||||||
|
public DISPLAYCONFIG_TARGET_DEVICE_NAME_FLAGS flags;
|
||||||
|
public DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY outputTechnology;
|
||||||
|
public ushort edidManufactureId;
|
||||||
|
public ushort edidProductCodeId;
|
||||||
|
public uint connectorInstance;
|
||||||
|
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
|
||||||
|
public string monitorFriendlyDeviceName;
|
||||||
|
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
||||||
|
public string monitorDevicePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region DLL-Imports
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern int GetDisplayConfigBufferSizes(
|
||||||
|
QUERY_DEVICE_CONFIG_FLAGS flags, out uint numPathArrayElements, out uint numModeInfoArrayElements);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern int QueryDisplayConfig(
|
||||||
|
QUERY_DEVICE_CONFIG_FLAGS flags,
|
||||||
|
ref uint numPathArrayElements, [Out] DISPLAYCONFIG_PATH_INFO[] PathInfoArray,
|
||||||
|
ref uint numModeInfoArrayElements, [Out] DISPLAYCONFIG_MODE_INFO[] ModeInfoArray,
|
||||||
|
IntPtr currentTopologyId
|
||||||
|
);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern int DisplayConfigGetDeviceInfo(ref DISPLAYCONFIG_TARGET_DEVICE_NAME deviceName);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private static DISPLAYCONFIG_TARGET_DEVICE_NAME DeviceName(LUID adapterId, uint targetId)
|
||||||
|
{
|
||||||
|
var deviceName = new DISPLAYCONFIG_TARGET_DEVICE_NAME
|
||||||
|
{
|
||||||
|
header =
|
||||||
|
{
|
||||||
|
size = (uint)Marshal.SizeOf(typeof (DISPLAYCONFIG_TARGET_DEVICE_NAME)),
|
||||||
|
adapterId = adapterId,
|
||||||
|
id = targetId,
|
||||||
|
type = DISPLAYCONFIG_DEVICE_INFO_TYPE.DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var error = DisplayConfigGetDeviceInfo(ref deviceName);
|
||||||
|
if (error != ERROR_SUCCESS)
|
||||||
|
throw new Win32Exception(error);
|
||||||
|
|
||||||
|
return deviceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<DISPLAYCONFIG_TARGET_DEVICE_NAME> GetAllDevices()
|
||||||
|
{
|
||||||
|
uint pathCount, modeCount;
|
||||||
|
var error = GetDisplayConfigBufferSizes(QUERY_DEVICE_CONFIG_FLAGS.QDC_ONLY_ACTIVE_PATHS, out pathCount, out modeCount);
|
||||||
|
if (error != ERROR_SUCCESS)
|
||||||
|
throw new Win32Exception(error);
|
||||||
|
|
||||||
|
var displayPaths = new DISPLAYCONFIG_PATH_INFO[pathCount];
|
||||||
|
var displayModes = new DISPLAYCONFIG_MODE_INFO[modeCount];
|
||||||
|
error = QueryDisplayConfig(QUERY_DEVICE_CONFIG_FLAGS.QDC_ONLY_ACTIVE_PATHS,
|
||||||
|
ref pathCount, displayPaths, ref modeCount, displayModes, IntPtr.Zero);
|
||||||
|
if (error != ERROR_SUCCESS)
|
||||||
|
throw new Win32Exception(error);
|
||||||
|
|
||||||
|
for (var i = 0; i < modeCount; i++)
|
||||||
|
if (displayModes[i].infoType == DISPLAYCONFIG_MODE_INFO_TYPE.DISPLAYCONFIG_MODE_INFO_TYPE_TARGET)
|
||||||
|
yield return DeviceName(displayModes[i].adapterId, displayModes[i].id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public class NativeMethods
|
public class NativeMethods
|
||||||
{
|
{
|
||||||
@@ -162,43 +466,6 @@ public class NativeMethods
|
|||||||
string lpszDeviceName, ref DEVMODE lpDevMode, IntPtr hwnd,
|
string lpszDeviceName, ref DEVMODE lpDevMode, IntPtr hwnd,
|
||||||
DisplaySettingsFlags dwflags, IntPtr lParam);
|
DisplaySettingsFlags dwflags, IntPtr lParam);
|
||||||
|
|
||||||
// ENUM DISPLAYS
|
|
||||||
[DllImport("user32.dll")]
|
|
||||||
static extern bool EnumDisplayDevicesA(string lpDevice, uint iDevNum, ref DISPLAY_DEVICE lpDisplayDevice, uint dwFlags);
|
|
||||||
|
|
||||||
[Flags()]
|
|
||||||
public enum DisplayDeviceStateFlags : int
|
|
||||||
{
|
|
||||||
AttachedToDesktop = 0x1,
|
|
||||||
MultiDriver = 0x2,
|
|
||||||
PrimaryDevice = 0x4,
|
|
||||||
MirroringDriver = 0x8,
|
|
||||||
VGACompatible = 0x10,
|
|
||||||
Removable = 0x20,
|
|
||||||
ModesPruned = 0x8000000,
|
|
||||||
Remote = 0x4000000,
|
|
||||||
Disconnect = 0x2000000
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
|
||||||
public struct DISPLAY_DEVICE
|
|
||||||
{
|
|
||||||
[MarshalAs(UnmanagedType.U4)]
|
|
||||||
public int cb;
|
|
||||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
|
|
||||||
public string DeviceName;
|
|
||||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
|
||||||
public string DeviceString;
|
|
||||||
[MarshalAs(UnmanagedType.U4)]
|
|
||||||
public DisplayDeviceStateFlags StateFlags;
|
|
||||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
|
||||||
public string DeviceID;
|
|
||||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
|
||||||
public string DeviceKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----
|
|
||||||
|
|
||||||
public static DEVMODE CreateDevmode()
|
public static DEVMODE CreateDevmode()
|
||||||
{
|
{
|
||||||
DEVMODE dm = new DEVMODE();
|
DEVMODE dm = new DEVMODE();
|
||||||
@@ -209,75 +476,39 @@ public class NativeMethods
|
|||||||
}
|
}
|
||||||
|
|
||||||
public const int ENUM_CURRENT_SETTINGS = -1;
|
public const int ENUM_CURRENT_SETTINGS = -1;
|
||||||
public const string laptopScreenName = "\\\\.\\DISPLAY1";
|
public const string defaultDevice = "\\\\.\\DISPLAY1";
|
||||||
|
|
||||||
public static string FindLaptopScreen()
|
public static string FindLaptopScreen()
|
||||||
{
|
{
|
||||||
string laptopScreen = null;
|
string laptopScreen = null;
|
||||||
|
|
||||||
DISPLAY_DEVICE d = new DISPLAY_DEVICE();
|
|
||||||
d.cb = Marshal.SizeOf(d);
|
|
||||||
|
|
||||||
List<string> activeScreens = new List<string>();
|
|
||||||
int counter = 0;
|
|
||||||
int deviceNum = -1;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var searcherActive = new ManagementObjectSearcher(@"\\.\root\wmi", "SELECT * FROM WmiMonitorBasicDisplayParams");
|
var devices = GetAllDevices();
|
||||||
var resultsActive = searcherActive.Get();
|
int count = 0, displayNum = -1;
|
||||||
foreach (var result in resultsActive)
|
|
||||||
|
foreach (var device in devices)
|
||||||
{
|
{
|
||||||
activeScreens.Add(result["InstanceName"].ToString());
|
if (device.outputTechnology == DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY.DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL)
|
||||||
|
displayNum = count;
|
||||||
|
count++;
|
||||||
|
//Debug.WriteLine(device.outputTechnology);
|
||||||
|
//Debug.WriteLine(device.monitorFriendlyDeviceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
var searcher = new ManagementObjectSearcher(@"\\.\root\wmi", "SELECT * FROM WmiMonitorConnectionParams");
|
count = 0;
|
||||||
var results = searcher.Get();
|
foreach (var screen in Screen.AllScreens)
|
||||||
|
|
||||||
|
|
||||||
foreach (var result in results)
|
|
||||||
{
|
{
|
||||||
long technology;
|
if (count == displayNum)
|
||||||
long.TryParse(result["VideoOutputTechnology"].ToString(), out technology);
|
laptopScreen = screen.DeviceName;
|
||||||
string instanceName = result["InstanceName"].ToString();
|
//Debug.WriteLine(screen.DeviceName);
|
||||||
|
count++;
|
||||||
if (technology == 0x80000000 && activeScreens.Contains(instanceName))
|
|
||||||
{
|
|
||||||
deviceNum = counter;
|
|
||||||
//Debug.WriteLine(result["InstanceName"]);
|
|
||||||
}
|
|
||||||
counter++;
|
|
||||||
}
|
}
|
||||||
} catch
|
} catch
|
||||||
{
|
{
|
||||||
Debug.WriteLine("Failed to detect built in display");
|
Debug.WriteLine("Can't find internal screen");
|
||||||
deviceNum = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
counter = 0;
|
|
||||||
for (uint id = 0; EnumDisplayDevicesA(null, id, ref d, 0); id++)
|
|
||||||
{
|
|
||||||
if ((d.StateFlags & DisplayDeviceStateFlags.AttachedToDesktop) != 0)
|
|
||||||
{
|
|
||||||
//Debug.WriteLine(d.DeviceID);
|
|
||||||
//Debug.WriteLine(d.DeviceName);
|
|
||||||
if (counter == deviceNum)
|
|
||||||
{
|
|
||||||
laptopScreen = d.DeviceName;
|
|
||||||
}
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mismatch between active screens and enumerated screens, fallback to old method
|
|
||||||
if (counter != activeScreens.Count)
|
|
||||||
{
|
|
||||||
laptopScreen = null;
|
|
||||||
foreach (var screen in Screen.AllScreens)
|
|
||||||
if (screen.DeviceName == laptopScreenName)
|
|
||||||
laptopScreen = screen.DeviceName;
|
|
||||||
}
|
|
||||||
|
|
||||||
return laptopScreen;
|
return laptopScreen;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# G-Helper (For Asus ROG Zephyrus G14, G15, Flow X13, Flow X16, and others)
|
# G-Helper / GHelper for Asus ROG Zephyrus G14, G15, Flow X13, Flow X16, and other models
|
||||||
|
|
||||||
A small utility that allows you do almost everyting you could do with Armory Crate but without extra bloat and unnecessary services.
|
A small utility that allows you do almost everyting you could do with Armory Crate but without extra bloat and unnecessary services.
|
||||||
|
|
||||||
|
|||||||
@@ -693,6 +693,12 @@ namespace GHelper
|
|||||||
int limit_total = Program.config.getConfigPerf("limit_total");
|
int limit_total = Program.config.getConfigPerf("limit_total");
|
||||||
int limit_cpu = Program.config.getConfigPerf("limit_cpu");
|
int limit_cpu = Program.config.getConfigPerf("limit_cpu");
|
||||||
|
|
||||||
|
if (limit_total > ASUSWmi.MaxTotal) return;
|
||||||
|
if (limit_total < ASUSWmi.MinTotal) return;
|
||||||
|
|
||||||
|
if (limit_cpu > ASUSWmi.MaxCPU) return;
|
||||||
|
if (limit_cpu < ASUSWmi.MinCPU) return;
|
||||||
|
|
||||||
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA0, limit_total);
|
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA0, limit_total);
|
||||||
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA1, limit_total);
|
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA1, limit_total);
|
||||||
Program.wmi.DeviceSet(ASUSWmi.PPT_CPUB0, limit_cpu);
|
Program.wmi.DeviceSet(ASUSWmi.PPT_CPUB0, limit_cpu);
|
||||||
|
|||||||
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
|
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 2.4 MiB |
Reference in New Issue
Block a user