mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Compare commits
248 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e923d82732 | ||
|
|
6558d66e8d | ||
|
|
ec8605dfe6 | ||
|
|
ac462b628f | ||
|
|
1cd9c30c4a | ||
|
|
c575b17aba | ||
|
|
d2e0e6f51e | ||
|
|
0dae1c9115 | ||
|
|
16e085d9f1 | ||
|
|
6b04ffa172 | ||
|
|
15e4310016 | ||
|
|
3abe924525 | ||
|
|
691f187b7d | ||
|
|
8e4c0dada7 | ||
|
|
f535818fb0 | ||
|
|
ce75d2c778 | ||
|
|
c755213472 | ||
|
|
60e8712131 | ||
|
|
2c817b46ef | ||
|
|
e16f612311 | ||
|
|
4ce4b4bbf7 | ||
|
|
f9303ced8a | ||
|
|
f000a03395 | ||
|
|
90205e9231 | ||
|
|
e65270c961 | ||
|
|
306dfe2bd7 | ||
|
|
ca7dfff357 | ||
|
|
59288b9422 | ||
|
|
46ff8deb44 | ||
|
|
e6e8877531 | ||
|
|
b13306b989 | ||
|
|
838dc039ac | ||
|
|
0702f95e0c | ||
|
|
f42fcf2f73 | ||
|
|
6a7e1ddaa3 | ||
|
|
57ffcb8c7f | ||
|
|
5425bd0128 | ||
|
|
328cd8f9f1 | ||
|
|
38739ca8f6 | ||
|
|
a3e235e886 | ||
|
|
678f4b0eb7 | ||
|
|
4bbfbd0382 | ||
|
|
4c8291c74b | ||
|
|
e9060ad8c0 | ||
|
|
f26585e73c | ||
|
|
9f7da4c20a | ||
|
|
eff45c1485 | ||
|
|
be6e5e8f23 | ||
|
|
17083eef21 | ||
|
|
d5b098335b | ||
|
|
acb2efdd00 | ||
|
|
92fa210898 | ||
|
|
6dd4e07efe | ||
|
|
ae6972db76 | ||
|
|
b3f7b1027f | ||
|
|
8929daa604 | ||
|
|
eb522214f0 | ||
|
|
1222377c33 | ||
|
|
933f07d666 | ||
|
|
8f95f6a1bb | ||
|
|
f2c32b2e9a | ||
|
|
ddb591b79a | ||
|
|
65b4192393 | ||
|
|
846cc6e867 | ||
|
|
ddac5a23be | ||
|
|
4f6db4ae0a | ||
|
|
14dd96dee3 | ||
|
|
79ff24bbb7 | ||
|
|
b715bd0391 | ||
|
|
b97a06eb56 | ||
|
|
e69845e858 | ||
|
|
b832ba6e8b | ||
|
|
314d25c751 | ||
|
|
b52163949c | ||
|
|
f0ee2b8aac | ||
|
|
1603f625ed | ||
|
|
8f66006791 | ||
|
|
39387041fe | ||
|
|
400b2cd6cb | ||
|
|
b20442e61f | ||
|
|
6d219511fc | ||
|
|
2282820453 | ||
|
|
d4fcfe8895 | ||
|
|
8eb923a703 | ||
|
|
59548be543 | ||
|
|
1596ce84e8 | ||
|
|
f670b9e0dc | ||
|
|
52c2987c88 | ||
|
|
c9aa910035 | ||
|
|
22f648a23f | ||
|
|
9255a8554d | ||
|
|
859f4f55c3 | ||
|
|
7e3872939b | ||
|
|
2556583451 | ||
|
|
20e7d220e5 | ||
|
|
2f5543ce84 | ||
|
|
4c55e16f2e | ||
|
|
30544e74d7 | ||
|
|
f5925accb3 | ||
|
|
842ea2a92d | ||
|
|
1ca97bd3f4 | ||
|
|
8a1dd9f137 | ||
|
|
325f16cf55 | ||
|
|
42cc1bdb98 | ||
|
|
83a2d1dc9f | ||
|
|
3aae223b15 | ||
|
|
b22d2f8ceb | ||
|
|
2041861a14 | ||
|
|
dfc3c0e515 | ||
|
|
796ec34284 | ||
|
|
50894a59d3 | ||
|
|
1472004d4b | ||
|
|
36c42ed05f | ||
|
|
66220351f1 | ||
|
|
8f2c8842e0 | ||
|
|
1cda822820 | ||
|
|
2afba74dd5 | ||
|
|
e69f9d1014 | ||
|
|
47d96aca61 | ||
|
|
f36fb6ca55 | ||
|
|
e765b4f037 | ||
|
|
f395c706f6 | ||
|
|
444fdcdd97 | ||
|
|
b874900393 | ||
|
|
05aad0f1ad | ||
|
|
a34cc1cb03 | ||
|
|
8c557344db | ||
|
|
5b2a4cb065 | ||
|
|
51bcad8bbe | ||
|
|
125aa44e6c | ||
|
|
9e6ca7c2e2 | ||
|
|
252cc9d868 | ||
|
|
0b03b62a2d | ||
|
|
ff7a5463d6 | ||
|
|
5134aaca9d | ||
|
|
2a5c2e02ac | ||
|
|
80e3971dad | ||
|
|
ac60986646 | ||
|
|
1e0169a71d | ||
|
|
e0346a8af8 | ||
|
|
4ee97fdbc4 | ||
|
|
34075b67d4 | ||
|
|
4ed9675d99 | ||
|
|
af3538e105 | ||
|
|
d818405e04 | ||
|
|
9794229f3f | ||
|
|
9f56959c67 | ||
|
|
09e6676b7c | ||
|
|
6adb2e2fcf | ||
|
|
08cc4409a9 | ||
|
|
1ac0f2be08 | ||
|
|
05e66d3b95 | ||
|
|
0f8f1e9ce5 | ||
|
|
d37b46c588 | ||
|
|
020a7d074f | ||
|
|
7eb7cc9f78 | ||
|
|
38d60e88ea | ||
|
|
0cc16765b6 | ||
|
|
96f705806b | ||
|
|
d1cceda2ab | ||
|
|
381b4dd3e8 | ||
|
|
a99dcbf445 | ||
|
|
4751383a3a | ||
|
|
06320afcb3 | ||
|
|
0eb6209eda | ||
|
|
a342cab9a6 | ||
|
|
12c6482f61 | ||
|
|
20933bfd8d | ||
|
|
c66c8e9030 | ||
|
|
14b677514b | ||
|
|
ce266ffe07 | ||
|
|
f29410fa2a | ||
|
|
7117b58746 | ||
|
|
0456fa013c | ||
|
|
6a4aa4e138 | ||
|
|
d75067b40c | ||
|
|
de45038911 | ||
|
|
e23c727e79 | ||
|
|
2f2c534278 | ||
|
|
bdbec79aba | ||
|
|
e3d0a04fa4 | ||
|
|
4dd7d41cf4 | ||
|
|
8370217cef | ||
|
|
63c1829edd | ||
|
|
69e5a0448e | ||
|
|
b74b9ae257 | ||
|
|
71e007d8ad | ||
|
|
6896166c3c | ||
|
|
fd89d9c13a | ||
|
|
8bec153da8 | ||
|
|
7d968f5f08 | ||
|
|
ac5fc3f96e | ||
|
|
8590d0301a | ||
|
|
8804d19567 | ||
|
|
57ce0631a3 | ||
|
|
b796f9f9d4 | ||
|
|
f39563fcdf | ||
|
|
853d0c231d | ||
|
|
df3324d641 | ||
|
|
75c90ee155 | ||
|
|
4015e0a7f7 | ||
|
|
2a82e41894 | ||
|
|
a5541dfe10 | ||
|
|
fd3a139c47 | ||
|
|
608b8571d4 | ||
|
|
82a39bcfa1 | ||
|
|
f9ccd92dc6 | ||
|
|
1fadc6c31e | ||
|
|
0b7dd42a5d | ||
|
|
51cd700e25 | ||
|
|
7484253007 | ||
|
|
f5cf768017 | ||
|
|
ca57669596 | ||
|
|
35f1a3a25b | ||
|
|
b7afe94b8d | ||
|
|
97c97e8e19 | ||
|
|
ffc5a6f641 | ||
|
|
f87e6c5c88 | ||
|
|
22f136fe9e | ||
|
|
6d85376734 | ||
|
|
62512a7c05 | ||
|
|
7a6301328c | ||
|
|
3c6c4d122d | ||
|
|
0142c25929 | ||
|
|
27bc7339d8 | ||
|
|
2985fe378c | ||
|
|
71daba25a8 | ||
|
|
16feeb05a1 | ||
|
|
c69bf65c84 | ||
|
|
56ea434626 | ||
|
|
432508cfc5 | ||
|
|
deb515066d | ||
|
|
ac19a822f7 | ||
|
|
41caaefc97 | ||
|
|
a4488fa93b | ||
|
|
57c893ef77 | ||
|
|
07020c3561 | ||
|
|
ea134b640b | ||
|
|
5c3f1259f6 | ||
|
|
09fd4e4a13 | ||
|
|
31c48eb998 | ||
|
|
0c1f216853 | ||
|
|
83dc491b64 | ||
|
|
a75d1ad604 | ||
|
|
88f466103e | ||
|
|
efb9b73ff5 | ||
|
|
2c4bdb87aa | ||
|
|
832f13d8e4 |
25
.github/workflows/build.yml
vendored
Normal file
25
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup dotnet
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: |
|
||||
7.0.x
|
||||
- name: Build
|
||||
run: |
|
||||
dotnet build app/GHelper.sln
|
||||
28
.github/workflows/codeql.yml
vendored
Normal file
28
.github/workflows/codeql.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
name: CodeQL
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
schedule:
|
||||
- cron: '34 18 * * 3'
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
jobs:
|
||||
codeql:
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: c#
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
- name: Analyze
|
||||
uses: github/codeql-action/analyze@v2
|
||||
28
.github/workflows/release.yml
vendored
Normal file
28
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [ published ]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup dotnet
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: |
|
||||
7.0.x
|
||||
- name: Publish
|
||||
run: |
|
||||
dotnet publish app/GHelper.sln --configuration Release --runtime win-x64 -p:PublishSingleFile=true --no-self-contained
|
||||
powershell Compress-Archive app/bin/x64/Release/net7.0-windows8.0/win-x64/publish/GHelper.exe GHelper.zip
|
||||
- name: Upload
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
gh release upload ${{ github.ref_name }} app/bin/x64/Release/net7.0-windows8.0/win-x64/publish/GHelper.exe GHelper.zip
|
||||
312
app/AnimeMatrix/AniMatrix.cs
Normal file
312
app/AnimeMatrix/AniMatrix.cs
Normal file
@@ -0,0 +1,312 @@
|
||||
using NAudio.CoreAudioApi;
|
||||
using NAudio.Wave;
|
||||
using Starlight.AnimeMatrix;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Timers;
|
||||
|
||||
namespace GHelper.AnimeMatrix
|
||||
{
|
||||
|
||||
public class AniMatrix
|
||||
{
|
||||
System.Timers.Timer matrixTimer = default!;
|
||||
AnimeMatrixDevice mat;
|
||||
|
||||
double[] AudioValues;
|
||||
WasapiCapture AudioDevice;
|
||||
|
||||
public bool IsValid => mat != null;
|
||||
|
||||
private long lastPresent;
|
||||
private List<double> maxes = new List<double>();
|
||||
|
||||
public AniMatrix()
|
||||
{
|
||||
try
|
||||
{
|
||||
mat = new AnimeMatrixDevice();
|
||||
Task.Run(mat.WakeUp);
|
||||
matrixTimer = new System.Timers.Timer(100);
|
||||
matrixTimer.Elapsed += MatrixTimer_Elapsed;
|
||||
}
|
||||
catch
|
||||
{
|
||||
mat = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void SetMatrix()
|
||||
{
|
||||
|
||||
if (!IsValid) return;
|
||||
|
||||
int brightness = AppConfig.Get("matrix_brightness");
|
||||
int running = AppConfig.Get("matrix_running");
|
||||
|
||||
bool auto = AppConfig.Is("matrix_auto");
|
||||
|
||||
if (brightness < 0) brightness = 0;
|
||||
if (running < 0) running = 0;
|
||||
|
||||
BuiltInAnimation animation = new BuiltInAnimation(
|
||||
(BuiltInAnimation.Running)running,
|
||||
BuiltInAnimation.Sleeping.Starfield,
|
||||
BuiltInAnimation.Shutdown.SeeYa,
|
||||
BuiltInAnimation.Startup.StaticEmergence
|
||||
);
|
||||
|
||||
StopMatrixTimer();
|
||||
StopMatrixAudio();
|
||||
|
||||
mat.SetProvider();
|
||||
|
||||
if (brightness == 0 || (auto && SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online))
|
||||
{
|
||||
mat.SetDisplayState(false);
|
||||
Logger.WriteLine("Matrix Off");
|
||||
}
|
||||
else
|
||||
{
|
||||
mat.SetDisplayState(true);
|
||||
mat.SetBrightness((BrightnessMode)brightness);
|
||||
|
||||
switch (running)
|
||||
{
|
||||
case 2:
|
||||
SetMatrixPicture(AppConfig.GetString("matrix_picture"));
|
||||
break;
|
||||
case 3:
|
||||
SetMatrixClock();
|
||||
break;
|
||||
case 4:
|
||||
SetMatrixAudio();
|
||||
break;
|
||||
default:
|
||||
mat.SetBuiltInAnimation(true, animation);
|
||||
Logger.WriteLine("Matrix builtin " + animation.AsByte);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
//mat.SetBrightness((BrightnessMode)brightness);
|
||||
}
|
||||
|
||||
}
|
||||
private void StartMatrixTimer(int interval = 100)
|
||||
{
|
||||
matrixTimer.Interval = interval;
|
||||
matrixTimer.Start();
|
||||
}
|
||||
|
||||
private void StopMatrixTimer()
|
||||
{
|
||||
matrixTimer.Stop();
|
||||
}
|
||||
|
||||
|
||||
private void MatrixTimer_Elapsed(object? sender, ElapsedEventArgs e)
|
||||
{
|
||||
//if (!IsValid) return;
|
||||
|
||||
switch (AppConfig.Get("matrix_running"))
|
||||
{
|
||||
case 2:
|
||||
mat.PresentNextFrame();
|
||||
break;
|
||||
case 3:
|
||||
mat.PresentClock();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void SetMatrixClock()
|
||||
{
|
||||
mat.SetBuiltInAnimation(false);
|
||||
StartMatrixTimer(1000);
|
||||
Logger.WriteLine("Matrix Clock");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
StopMatrixAudio();
|
||||
}
|
||||
|
||||
void StopMatrixAudio()
|
||||
{
|
||||
if (AudioDevice is not null)
|
||||
{
|
||||
try
|
||||
{
|
||||
AudioDevice.StopRecording();
|
||||
AudioDevice.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WriteLine(ex.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetMatrixAudio()
|
||||
{
|
||||
if (!IsValid) return;
|
||||
|
||||
mat.SetBuiltInAnimation(false);
|
||||
StopMatrixTimer();
|
||||
StopMatrixAudio();
|
||||
|
||||
try
|
||||
{
|
||||
using (var enumerator = new MMDeviceEnumerator())
|
||||
using (MMDevice device = enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console))
|
||||
{
|
||||
AudioDevice = new WasapiLoopbackCapture(device);
|
||||
WaveFormat fmt = AudioDevice.WaveFormat;
|
||||
|
||||
AudioValues = new double[fmt.SampleRate / 1000];
|
||||
AudioDevice.DataAvailable += WaveIn_DataAvailable;
|
||||
AudioDevice.StartRecording();
|
||||
Logger.WriteLine("Matrix Audio");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WriteLine(ex.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void WaveIn_DataAvailable(object? sender, WaveInEventArgs e)
|
||||
{
|
||||
int bytesPerSamplePerChannel = AudioDevice.WaveFormat.BitsPerSample / 8;
|
||||
int bytesPerSample = bytesPerSamplePerChannel * AudioDevice.WaveFormat.Channels;
|
||||
int bufferSampleCount = e.Buffer.Length / bytesPerSample;
|
||||
|
||||
if (bufferSampleCount >= AudioValues.Length)
|
||||
{
|
||||
bufferSampleCount = AudioValues.Length;
|
||||
}
|
||||
|
||||
if (bytesPerSamplePerChannel == 2 && AudioDevice.WaveFormat.Encoding == WaveFormatEncoding.Pcm)
|
||||
{
|
||||
for (int i = 0; i < bufferSampleCount; i++)
|
||||
AudioValues[i] = BitConverter.ToInt16(e.Buffer, i * bytesPerSample);
|
||||
}
|
||||
else if (bytesPerSamplePerChannel == 4 && AudioDevice.WaveFormat.Encoding == WaveFormatEncoding.Pcm)
|
||||
{
|
||||
for (int i = 0; i < bufferSampleCount; i++)
|
||||
AudioValues[i] = BitConverter.ToInt32(e.Buffer, i * bytesPerSample);
|
||||
}
|
||||
else if (bytesPerSamplePerChannel == 4 && AudioDevice.WaveFormat.Encoding == WaveFormatEncoding.IeeeFloat)
|
||||
{
|
||||
for (int i = 0; i < bufferSampleCount; i++)
|
||||
AudioValues[i] = BitConverter.ToSingle(e.Buffer, i * bytesPerSample);
|
||||
}
|
||||
|
||||
double[] paddedAudio = FftSharp.Pad.ZeroPad(AudioValues);
|
||||
double[] fftMag = FftSharp.Transform.FFTmagnitude(paddedAudio);
|
||||
|
||||
PresentAudio(fftMag);
|
||||
}
|
||||
|
||||
private void DrawBar(int pos, double h)
|
||||
{
|
||||
int dx = pos * 2;
|
||||
int dy = 20;
|
||||
|
||||
byte color;
|
||||
|
||||
for (int y = 0; y < h - (h % 2); y++)
|
||||
for (int x = 0; x < 2 - (y % 2); x++)
|
||||
{
|
||||
//color = (byte)(Math.Min(1,(h - y - 2)*2) * 255);
|
||||
mat.SetLedPlanar(x + dx, dy + y, (byte)(h * 255 / 30));
|
||||
mat.SetLedPlanar(x + dx, dy - y, 255);
|
||||
}
|
||||
}
|
||||
|
||||
void PresentAudio(double[] audio)
|
||||
{
|
||||
|
||||
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastPresent) < 70) return;
|
||||
lastPresent = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
|
||||
mat.Clear();
|
||||
|
||||
int size = 20;
|
||||
double[] bars = new double[size];
|
||||
double max = 2, maxAverage;
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
bars[i] = Math.Sqrt(audio[i] * 10000);
|
||||
if (bars[i] > max) max = bars[i];
|
||||
}
|
||||
|
||||
maxes.Add(max);
|
||||
if (maxes.Count > 20) maxes.RemoveAt(0);
|
||||
maxAverage = maxes.Average();
|
||||
|
||||
for (int i = 0; i < size; i++) DrawBar(20 - i, bars[i]*20/maxAverage);
|
||||
|
||||
mat.Present();
|
||||
}
|
||||
|
||||
|
||||
public void SetMatrixPicture(string fileName)
|
||||
{
|
||||
|
||||
if (!IsValid) return;
|
||||
StopMatrixTimer();
|
||||
|
||||
Image image;
|
||||
|
||||
try
|
||||
{
|
||||
using (var fs = new FileStream(fileName, FileMode.Open))
|
||||
{
|
||||
var ms = new MemoryStream();
|
||||
fs.CopyTo(ms);
|
||||
ms.Position = 0;
|
||||
image = Image.FromStream(ms);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.WriteLine("Error loading picture");
|
||||
return;
|
||||
}
|
||||
|
||||
mat.SetBuiltInAnimation(false);
|
||||
mat.ClearFrames();
|
||||
|
||||
FrameDimension dimension = new FrameDimension(image.FrameDimensionsList[0]);
|
||||
int frameCount = image.GetFrameCount(dimension);
|
||||
|
||||
if (frameCount > 1)
|
||||
{
|
||||
for (int i = 0; i < frameCount; i++)
|
||||
{
|
||||
image.SelectActiveFrame(dimension, i);
|
||||
mat.GenerateFrame(image);
|
||||
mat.AddFrame();
|
||||
}
|
||||
|
||||
StartMatrixTimer();
|
||||
Logger.WriteLine("Matrix GIF " + fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
mat.GenerateFrame(image);
|
||||
mat.Present();
|
||||
Logger.WriteLine("Matrix " + fileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
using Starlight.Communication;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Text;
|
||||
using System.Globalization;
|
||||
using System.Management;
|
||||
using System.Text;
|
||||
@@ -61,7 +62,8 @@ namespace Starlight.AnimeMatrix
|
||||
public enum AnimeType
|
||||
{
|
||||
GA401,
|
||||
GA402
|
||||
GA402,
|
||||
GU604
|
||||
}
|
||||
|
||||
|
||||
@@ -88,12 +90,15 @@ namespace Starlight.AnimeMatrix
|
||||
//public int FullEvenRows = -1;
|
||||
|
||||
public int dx = 0;
|
||||
//Shifts the whole frame to the left or right to align with the diagonal cut
|
||||
public int frameShiftX = 0;
|
||||
public int MaxColumns = 34;
|
||||
|
||||
private int frameIndex = 0;
|
||||
|
||||
private static AnimeType _model = AnimeType.GA402;
|
||||
|
||||
|
||||
public AnimeMatrixDevice()
|
||||
: base(0x0B05, 0x193B, 640)
|
||||
{
|
||||
@@ -112,6 +117,16 @@ namespace Starlight.AnimeMatrix
|
||||
UpdatePageLength = 410;
|
||||
}
|
||||
|
||||
if (model.Contains("GU604"))
|
||||
{
|
||||
_model = AnimeType.GU604;
|
||||
|
||||
MaxColumns = 39;
|
||||
MaxRows = 92;
|
||||
LedCount = 1711;
|
||||
frameShiftX = -5;
|
||||
UpdatePageLength = 630;
|
||||
}
|
||||
|
||||
_displayBuffer = new byte[LedCount];
|
||||
|
||||
@@ -173,6 +188,9 @@ namespace Starlight.AnimeMatrix
|
||||
{
|
||||
return (y + 1) / 2 - 3;
|
||||
}
|
||||
case AnimeType.GU604:
|
||||
return (int)Math.Ceiling(Math.Max(0, y - 9) / 2F);
|
||||
|
||||
default:
|
||||
return (int)Math.Ceiling(Math.Max(0, y - 11) / 2F);
|
||||
}
|
||||
@@ -184,6 +202,8 @@ namespace Starlight.AnimeMatrix
|
||||
{
|
||||
case AnimeType.GA401:
|
||||
return 33;
|
||||
case AnimeType.GU604:
|
||||
return 39;
|
||||
default:
|
||||
return 34;
|
||||
}
|
||||
@@ -226,7 +246,7 @@ namespace Starlight.AnimeMatrix
|
||||
if (!IsRowInRange(y)) return;
|
||||
|
||||
if (x >= FirstX(y) && x < Width(y))
|
||||
SetLedLinear(RowToLinearAddress(y) - FirstX(y) + x + dx, value);
|
||||
SetLedLinear(RowToLinearAddress(y) - FirstX(y) + x + dx + frameShiftX, value);
|
||||
}
|
||||
|
||||
public void WakeUp()
|
||||
@@ -325,13 +345,21 @@ namespace Starlight.AnimeMatrix
|
||||
public void PresentClock()
|
||||
{
|
||||
int second = DateTime.Now.Second;
|
||||
string time;
|
||||
|
||||
if (CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern.Contains("H"))
|
||||
PresentTextDiagonal(DateTime.Now.ToString("H" + ((second % 2 == 0) ? ":" : " ") + "mm"));
|
||||
time = DateTime.Now.ToString("H" + ((second % 2 == 0) ? ":" : " ") + "mm");
|
||||
else
|
||||
PresentTextDiagonal(DateTime.Now.ToString("h" + ((second % 2 == 0) ? ":" : " ") + "mmtt"));
|
||||
time = DateTime.Now.ToString("h" + ((second % 2 == 0) ? ":" : " ") + "mmtt");
|
||||
|
||||
if (_model == AnimeType.GA401)
|
||||
PresentText(time);
|
||||
else
|
||||
PresentTextDiagonal(time);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void PresentText(string text1, string text2 = "")
|
||||
{
|
||||
using (Bitmap bmp = new Bitmap(MaxColumns * 3, MaxRows))
|
||||
@@ -341,14 +369,14 @@ namespace Starlight.AnimeMatrix
|
||||
g.CompositingQuality = CompositingQuality.HighQuality;
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
|
||||
using (Font font = new Font("Arial", 24F, GraphicsUnit.Pixel))
|
||||
using (Font font = new Font("Consolas", 21F, FontStyle.Regular, GraphicsUnit.Pixel))
|
||||
{
|
||||
SizeF textSize = g.MeasureString(text1, font);
|
||||
g.DrawString(text1, font, Brushes.White, (MaxColumns * 3 - textSize.Width) + 3, -3);
|
||||
g.DrawString(text1, font, Brushes.White, (MaxColumns * 3 - textSize.Width) + 3, -4);
|
||||
}
|
||||
|
||||
if (text2.Length > 0)
|
||||
using (Font font = new Font("Arial", 18F, GraphicsUnit.Pixel))
|
||||
using (Font font = new Font("Consolas", 18F, GraphicsUnit.Pixel))
|
||||
{
|
||||
SizeF textSize = g.MeasureString(text2, font);
|
||||
g.DrawString(text2, font, Brushes.White, (MaxColumns * 3 - textSize.Width) + 1, 25);
|
||||
@@ -419,6 +447,24 @@ namespace Starlight.AnimeMatrix
|
||||
|
||||
Clear();
|
||||
|
||||
|
||||
InstalledFontCollection installedFontCollection = new InstalledFontCollection();
|
||||
|
||||
|
||||
string familyName;
|
||||
string familyList = "";
|
||||
FontFamily[] fontFamilies;
|
||||
// Get the array of FontFamily objects.
|
||||
fontFamilies = installedFontCollection.Families;
|
||||
|
||||
int count = fontFamilies.Length;
|
||||
for (int j = 0; j < count; ++j)
|
||||
{
|
||||
familyName = fontFamilies[j].Name;
|
||||
familyList = familyList + familyName;
|
||||
familyList = familyList + ", ";
|
||||
}
|
||||
|
||||
int maxX = (int)Math.Sqrt(MaxRows * MaxRows + MaxColumns * MaxColumns);
|
||||
|
||||
using (Bitmap bmp = new Bitmap(maxX, MaxRows))
|
||||
@@ -428,10 +474,10 @@ namespace Starlight.AnimeMatrix
|
||||
g.CompositingQuality = CompositingQuality.HighQuality;
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
|
||||
using (Font font = new Font("Calibri", 14F, GraphicsUnit.Pixel))
|
||||
using (Font font = new Font("Consolas", 13F, FontStyle.Regular, GraphicsUnit.Pixel))
|
||||
{
|
||||
SizeF textSize = g.MeasureString(text, font);
|
||||
g.DrawString(text, font, Brushes.White, 4, 0);
|
||||
g.DrawString(text, font, Brushes.White, 4, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
147
app/AppConfig.cs
147
app/AppConfig.cs
@@ -1,21 +1,20 @@
|
||||
using System.Diagnostics;
|
||||
using GHelper;
|
||||
using System.Diagnostics;
|
||||
using System.Management;
|
||||
using System.Text.Json;
|
||||
|
||||
public class AppConfig
|
||||
public static class AppConfig
|
||||
{
|
||||
|
||||
public string appPath;
|
||||
string configFile;
|
||||
private static string configFile;
|
||||
private static string? _model;
|
||||
|
||||
string _model;
|
||||
private static Dictionary<string, object> config = new Dictionary<string, object>();
|
||||
|
||||
public Dictionary<string, object> config = new Dictionary<string, object>();
|
||||
|
||||
public AppConfig()
|
||||
static AppConfig()
|
||||
{
|
||||
|
||||
appPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GHelper";
|
||||
string appPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GHelper";
|
||||
configFile = appPath + "\\config.json";
|
||||
|
||||
if (!System.IO.Directory.Exists(appPath))
|
||||
@@ -30,18 +29,18 @@ public class AppConfig
|
||||
}
|
||||
catch
|
||||
{
|
||||
initConfig();
|
||||
Init();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
initConfig();
|
||||
Init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public string GetModel()
|
||||
public static string GetModel()
|
||||
{
|
||||
if (_model is null)
|
||||
{
|
||||
@@ -58,14 +57,15 @@ public class AppConfig
|
||||
|
||||
return _model;
|
||||
}
|
||||
public bool ContainsModel(string contains)
|
||||
public static bool ContainsModel(string contains)
|
||||
{
|
||||
|
||||
GetModel();
|
||||
return (_model is not null && _model.Contains(contains));
|
||||
|
||||
return (_model is not null && _model.ToLower().Contains(contains.ToLower()));
|
||||
}
|
||||
private void initConfig()
|
||||
|
||||
|
||||
private static void Init()
|
||||
{
|
||||
config = new Dictionary<string, object>();
|
||||
config["performance_mode"] = 0;
|
||||
@@ -73,37 +73,27 @@ public class AppConfig
|
||||
File.WriteAllText(configFile, jsonString);
|
||||
}
|
||||
|
||||
public int getConfig(string name, bool performance = false)
|
||||
public static int Get(string name, int empty = -1)
|
||||
{
|
||||
|
||||
if (config.ContainsKey(name))
|
||||
return int.Parse(config[name].ToString());
|
||||
else return -1;
|
||||
else return empty;
|
||||
}
|
||||
|
||||
public string getConfigString(string name)
|
||||
public static bool Is(string name)
|
||||
{
|
||||
return Get(name) == 1;
|
||||
}
|
||||
|
||||
public static string GetString(string name, string empty = null)
|
||||
{
|
||||
if (config.ContainsKey(name))
|
||||
return config[name].ToString();
|
||||
else return null;
|
||||
else return empty;
|
||||
}
|
||||
|
||||
public void setConfig(string name, int value)
|
||||
private static void Write()
|
||||
{
|
||||
config[name] = value;
|
||||
string jsonString = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true });
|
||||
try
|
||||
{
|
||||
File.WriteAllText(configFile, jsonString);
|
||||
} catch (Exception e)
|
||||
{
|
||||
Debug.Write(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public void setConfig(string name, string value)
|
||||
{
|
||||
config[name] = value;
|
||||
string jsonString = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true });
|
||||
try
|
||||
{
|
||||
@@ -115,24 +105,51 @@ public class AppConfig
|
||||
}
|
||||
}
|
||||
|
||||
public string getParamName(int device, string paramName = "fan_profile")
|
||||
public static void Set(string name, int value)
|
||||
{
|
||||
int mode = getConfig("performance_mode");
|
||||
config[name] = value;
|
||||
Write();
|
||||
}
|
||||
|
||||
public static void Set(string name, string value)
|
||||
{
|
||||
config[name] = value;
|
||||
Write();
|
||||
}
|
||||
public static void Remove(string name)
|
||||
{
|
||||
config.Remove(name);
|
||||
Write();
|
||||
}
|
||||
|
||||
public static string GgetParamName(AsusFan device, string paramName = "fan_profile")
|
||||
{
|
||||
int mode = Modes.GetCurrent();
|
||||
string name;
|
||||
|
||||
if (device == 1)
|
||||
name = "gpu";
|
||||
else if (device == 2)
|
||||
name = "mid";
|
||||
else
|
||||
name = "cpu";
|
||||
switch (device)
|
||||
{
|
||||
case AsusFan.GPU:
|
||||
name = "gpu";
|
||||
break;
|
||||
case AsusFan.Mid:
|
||||
name = "mid";
|
||||
break;
|
||||
case AsusFan.XGM:
|
||||
name = "xgm";
|
||||
break;
|
||||
default:
|
||||
name = "cpu";
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return paramName + "_" + name + "_" + mode;
|
||||
}
|
||||
|
||||
public byte[] getFanConfig(int device)
|
||||
public static byte[] GetFanConfig(AsusFan device)
|
||||
{
|
||||
string curveString = getConfigString(getParamName(device));
|
||||
string curveString = GetString(GgetParamName(device));
|
||||
byte[] curve = { };
|
||||
|
||||
if (curveString is not null)
|
||||
@@ -141,10 +158,10 @@ public class AppConfig
|
||||
return curve;
|
||||
}
|
||||
|
||||
public void setFanConfig(int device, byte[] curve)
|
||||
public static void SetFanConfig(AsusFan device, byte[] curve)
|
||||
{
|
||||
string bitCurve = BitConverter.ToString(curve);
|
||||
setConfig(getParamName(device), bitCurve);
|
||||
Set(GgetParamName(device), bitCurve);
|
||||
}
|
||||
|
||||
|
||||
@@ -156,27 +173,27 @@ public class AppConfig
|
||||
return array;
|
||||
}
|
||||
|
||||
public byte[] getDefaultCurve(int device)
|
||||
public static byte[] GetDefaultCurve(AsusFan device)
|
||||
{
|
||||
int mode = getConfig("performance_mode");
|
||||
int mode = Modes.GetCurrentBase();
|
||||
byte[] curve;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case 1:
|
||||
if (device == 1)
|
||||
if (device == AsusFan.GPU)
|
||||
curve = StringToBytes("14-3F-44-48-4C-50-54-62-16-1F-26-2D-39-47-55-5F");
|
||||
else
|
||||
curve = StringToBytes("14-3F-44-48-4C-50-54-62-11-1A-22-29-34-43-51-5A");
|
||||
break;
|
||||
case 2:
|
||||
if (device == 1)
|
||||
if (device == AsusFan.GPU)
|
||||
curve = StringToBytes("3C-41-42-46-47-4B-4C-62-08-11-11-1D-1D-26-26-2D");
|
||||
else
|
||||
curve = StringToBytes("3C-41-42-46-47-4B-4C-62-03-0C-0C-16-16-22-22-29");
|
||||
break;
|
||||
default:
|
||||
if (device == 1)
|
||||
if (device == AsusFan.GPU)
|
||||
curve = StringToBytes("3A-3D-40-44-48-4D-51-62-0C-16-1D-1F-26-2D-34-4A");
|
||||
else
|
||||
curve = StringToBytes("3A-3D-40-44-48-4D-51-62-08-11-16-1A-22-29-30-45");
|
||||
@@ -186,23 +203,29 @@ public class AppConfig
|
||||
return curve;
|
||||
}
|
||||
|
||||
public string getConfigPerfString(string name)
|
||||
public static string GetModeString(string name)
|
||||
{
|
||||
int mode = getConfig("performance_mode");
|
||||
return getConfigString(name + "_" + mode);
|
||||
return GetString(name + "_" + Modes.GetCurrent());
|
||||
}
|
||||
|
||||
public int getConfigPerf(string name)
|
||||
public static int GetMode(string name)
|
||||
{
|
||||
int mode = getConfig("performance_mode");
|
||||
return getConfig(name + "_" + mode);
|
||||
return Get(name + "_" + Modes.GetCurrent());
|
||||
}
|
||||
|
||||
public void setConfigPerf(string name, int value)
|
||||
public static bool IsMode(string name)
|
||||
{
|
||||
int mode = getConfig("performance_mode");
|
||||
setConfig(name + "_" + mode, value);
|
||||
return Get(name + "_" + Modes.GetCurrent()) == 1;
|
||||
}
|
||||
|
||||
public static void SetMode(string name, int value)
|
||||
{
|
||||
Set(name + "_" + Modes.GetCurrent(), value);
|
||||
}
|
||||
|
||||
public static void SetMode(string name, string value)
|
||||
{
|
||||
Set(name + "_" + Modes.GetCurrent(), value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,29 @@
|
||||
using System.Management;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class ASUSWmi
|
||||
public enum AsusFan
|
||||
{
|
||||
CPU = 0,
|
||||
GPU = 1,
|
||||
Mid = 2,
|
||||
XGM = 3
|
||||
}
|
||||
|
||||
public enum AsusMode
|
||||
{
|
||||
Balanced = 0,
|
||||
Turbo = 1,
|
||||
Silent = 2
|
||||
}
|
||||
|
||||
public enum AsusGPU
|
||||
{
|
||||
Eco = 0,
|
||||
Standard = 1,
|
||||
Ultimate = 2
|
||||
}
|
||||
|
||||
public class AsusACPI
|
||||
{
|
||||
|
||||
const string FILE_NAME = @"\\.\\ATKACPI";
|
||||
@@ -9,10 +31,20 @@ public class ASUSWmi
|
||||
|
||||
const uint DSTS = 0x53545344;
|
||||
const uint DEVS = 0x53564544;
|
||||
const uint INIT = 0x54494E49;
|
||||
|
||||
public const uint UniversalControl = 0x00100021;
|
||||
|
||||
public const int KB_Light_Up = 0xc4;
|
||||
public const int KB_Light_Down = 0xc5;
|
||||
public const int Brightness_Down = 0x10;
|
||||
public const int Brightness_Up = 0x20;
|
||||
public const int KB_Sleep = 0x6c;
|
||||
public const int KB_DUO_PgUpDn = 0x4B;
|
||||
public const int KB_DUO_SecondDisplay = 0x6A;
|
||||
|
||||
|
||||
public const int Touchpad_Toggle = 0x6B;
|
||||
|
||||
public const int ChargerMode = 0x0012006C;
|
||||
|
||||
@@ -41,25 +73,34 @@ public class ASUSWmi
|
||||
public const int Temp_CPU = 0x00120094;
|
||||
public const int Temp_GPU = 0x00120097;
|
||||
|
||||
public const int PPT_TotalA0 = 0x001200A0; // Total PPT on 2022 (PPT_LIMIT_SLOW ) and CPU PPT on 2021
|
||||
public const int PPT_TotalA0 = 0x001200A0; // SPL (Total limit for all-AMD models) / PL1
|
||||
public const int PPT_EDCA1 = 0x001200A1; // CPU EDC
|
||||
public const int PPT_TDCA2 = 0x001200A2; // CPU TDC
|
||||
public const int PPT_APUA3 = 0x001200A3; // APU PPT ON 2021, doesn't work on 2022
|
||||
public const int PPT_APUA3 = 0x001200A3; // sPPT (long boost limit) / PL2
|
||||
|
||||
public const int PPT_CPUB0 = 0x001200B0; // CPU PPT on 2022 (PPT_LIMIT_APU)
|
||||
public const int PPT_CPUB1 = 0x001200B1; // Total PPT on 2022 (PPT_LIMIT_SLOW)
|
||||
|
||||
public const int PPT_GPUC0 = 0x001200C0; // NVIDIA GPU Boost
|
||||
public const int PPT_APUC1 = 0x001200C1; // Actual Power Limit (PPT_LIMIT_FAST) AND Sustained Power Limit (STAPM_LIMIT)
|
||||
public const int PPT_APUC1 = 0x001200C1; // fPPT (fast boost limit)
|
||||
public const int PPT_GPUC2 = 0x001200C2; // NVIDIA GPU Temp Target (75.. 87 C)
|
||||
|
||||
public const int TUF_KB_BRIGHTNESS = 0x00050021;
|
||||
public const int TUF_KB = 0x00100056;
|
||||
public const int TUF_KB_STATE = 0x00100057;
|
||||
|
||||
public const int TabletState = 0x00060077;
|
||||
public const int FnLock = 0x00100023;
|
||||
|
||||
public const int Tablet_Notebook = 0;
|
||||
public const int Tablet_Tablet = 1;
|
||||
public const int Tablet_Tent = 2;
|
||||
public const int Tablet_Rotated = 3;
|
||||
|
||||
public const int PerformanceBalanced = 0;
|
||||
public const int PerformanceTurbo = 1;
|
||||
public const int PerformanceSilent = 2;
|
||||
public const int PerformanceManual = 4;
|
||||
|
||||
public const int GPUModeEco = 0;
|
||||
public const int GPUModeStandard = 1;
|
||||
@@ -116,7 +157,43 @@ public class ASUSWmi
|
||||
|
||||
private IntPtr handle;
|
||||
|
||||
public ASUSWmi()
|
||||
// Event handling attempt
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern IntPtr CreateEvent(IntPtr lpEventAttributes, bool bManualReset, bool bInitialState, string lpName);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern bool WaitForSingleObject(IntPtr hHandle, int dwMilliseconds);
|
||||
|
||||
private IntPtr eventHandle;
|
||||
|
||||
// still works only with asus optimization service on , if someone knows how to get ACPI events from asus without that - let me know
|
||||
public void RunListener()
|
||||
{
|
||||
|
||||
eventHandle = CreateEvent(IntPtr.Zero, false, false, "ATK4001");
|
||||
|
||||
byte[] outBuffer = new byte[16];
|
||||
byte[] data = new byte[8];
|
||||
bool result;
|
||||
|
||||
data[0] = BitConverter.GetBytes(eventHandle.ToInt32())[0];
|
||||
data[1] = BitConverter.GetBytes(eventHandle.ToInt32())[1];
|
||||
|
||||
Control(0x222400, data, outBuffer);
|
||||
Logger.WriteLine("ACPI :" + BitConverter.ToString(data) + "|" + BitConverter.ToString(outBuffer));
|
||||
|
||||
while (true)
|
||||
{
|
||||
WaitForSingleObject(eventHandle, Timeout.Infinite);
|
||||
Control(0x222408, new byte[0], outBuffer);
|
||||
int code = BitConverter.ToInt32(outBuffer);
|
||||
Logger.WriteLine("ACPI Code: " + code);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public AsusACPI()
|
||||
{
|
||||
handle = CreateFile(
|
||||
FILE_NAME,
|
||||
@@ -127,16 +204,19 @@ public class ASUSWmi
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
IntPtr.Zero
|
||||
);
|
||||
|
||||
if (handle == new IntPtr(-1))
|
||||
{
|
||||
throw new Exception("Can't connect to ACPI");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Control(uint dwIoControlCode, byte[] lpInBuffer, byte[] lpOutBuffer)
|
||||
{
|
||||
|
||||
uint lpBytesReturned = 0;
|
||||
bool result = DeviceIoControl(
|
||||
DeviceIoControl(
|
||||
handle,
|
||||
dwIoControlCode,
|
||||
lpInBuffer,
|
||||
@@ -171,6 +251,13 @@ public class ASUSWmi
|
||||
|
||||
}
|
||||
|
||||
public byte[] DeviceInit()
|
||||
{
|
||||
byte[] args = new byte[8];
|
||||
return CallMethod(INIT, args);
|
||||
|
||||
}
|
||||
|
||||
public int DeviceSet(uint DeviceID, int Status, string logName)
|
||||
{
|
||||
byte[] args = new byte[8];
|
||||
@@ -204,7 +291,7 @@ public class ASUSWmi
|
||||
byte[] args = new byte[8];
|
||||
BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0);
|
||||
byte[] status = CallMethod(DSTS, args);
|
||||
|
||||
|
||||
return BitConverter.ToInt32(status, 0) - 65536;
|
||||
|
||||
}
|
||||
@@ -214,12 +301,26 @@ public class ASUSWmi
|
||||
byte[] args = new byte[8];
|
||||
BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0);
|
||||
BitConverter.GetBytes((uint)Status).CopyTo(args, 4);
|
||||
|
||||
|
||||
return CallMethod(DSTS, args);
|
||||
}
|
||||
|
||||
public int SetGPUEco(int eco)
|
||||
{
|
||||
int ecoFlag = DeviceGet(GPUEco);
|
||||
if (ecoFlag < 0) return -1;
|
||||
|
||||
public int SetFanCurve(int device, byte[] curve)
|
||||
if (ecoFlag == 1 && eco == 0)
|
||||
return DeviceSet(GPUEco, eco, "GPUEco");
|
||||
|
||||
if (ecoFlag == 0 && eco == 1)
|
||||
return DeviceSet(GPUEco, eco, "GPUEco");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
public int SetFanCurve(AsusFan device, byte[] curve)
|
||||
{
|
||||
|
||||
if (curve.Length != 16) return -1;
|
||||
@@ -228,16 +329,14 @@ public class ASUSWmi
|
||||
int result;
|
||||
|
||||
for (int i = 8; i < curve.Length; i++)
|
||||
{
|
||||
curve[i] = Math.Max((byte)0, Math.Min((byte)99, curve[i])); // it seems to be a bug, when some old model's bios can go nuts if fan is set to 100%
|
||||
}
|
||||
|
||||
switch (device)
|
||||
{
|
||||
case 1:
|
||||
case AsusFan.GPU:
|
||||
result = DeviceSet(DevsGPUFanCurve, curve, "FanGPU");
|
||||
break;
|
||||
case 2:
|
||||
case AsusFan.Mid:
|
||||
result = DeviceSet(DevsMidFanCurve, curve, "FanMid");
|
||||
break;
|
||||
default:
|
||||
@@ -248,7 +347,7 @@ public class ASUSWmi
|
||||
return result;
|
||||
}
|
||||
|
||||
public byte[] GetFanCurve(int device, int mode = 0)
|
||||
public byte[] GetFanCurve(AsusFan device, int mode = 0)
|
||||
{
|
||||
uint fan_mode;
|
||||
|
||||
@@ -262,9 +361,9 @@ public class ASUSWmi
|
||||
|
||||
switch (device)
|
||||
{
|
||||
case 1:
|
||||
case AsusFan.GPU:
|
||||
return DeviceGetBuffer(DevsGPUFanCurve, fan_mode);
|
||||
case 2:
|
||||
case AsusFan.Mid:
|
||||
return DeviceGetBuffer(DevsMidFanCurve, fan_mode);
|
||||
default:
|
||||
return DeviceGetBuffer(DevsCPUFanCurve, fan_mode);
|
||||
@@ -272,6 +371,83 @@ public class ASUSWmi
|
||||
|
||||
}
|
||||
|
||||
public static bool IsInvalidCurve(byte[] curve)
|
||||
{
|
||||
return curve.Length != 16 || IsEmptyCurve(curve);
|
||||
}
|
||||
|
||||
public static bool IsEmptyCurve(byte[] curve)
|
||||
{
|
||||
return curve.All(singleByte => singleByte == 0);
|
||||
}
|
||||
|
||||
public static byte[] FixFanCurve(byte[] curve)
|
||||
{
|
||||
if (curve.Length != 16) throw new Exception("Incorrect curve");
|
||||
|
||||
var points = new Dictionary<byte, byte>();
|
||||
for (int i = 0; i < 8; i++) points[curve[i]] = curve[i + 8];
|
||||
|
||||
var pointsFixed = new Dictionary<byte, byte>();
|
||||
bool fix = false;
|
||||
|
||||
int count = 0;
|
||||
foreach (var pair in points.OrderBy(x => x.Key))
|
||||
{
|
||||
if (count == 0 && pair.Key >= 40)
|
||||
{
|
||||
fix = true;
|
||||
pointsFixed.Add(20, 0);
|
||||
}
|
||||
|
||||
if (count != 3 || !fix)
|
||||
pointsFixed.Add(pair.Key, pair.Value);
|
||||
count++;
|
||||
}
|
||||
|
||||
count = 0;
|
||||
foreach (var pair in pointsFixed.OrderBy(x => x.Key))
|
||||
{
|
||||
curve[count] = pair.Key;
|
||||
curve[count + 8] = pair.Value;
|
||||
count++;
|
||||
}
|
||||
|
||||
return curve;
|
||||
|
||||
}
|
||||
|
||||
public bool IsXGConnected()
|
||||
{
|
||||
//return true;
|
||||
return DeviceGet(GPUXGConnected) == 1;
|
||||
}
|
||||
|
||||
public bool IsAllAmdPPT()
|
||||
{
|
||||
return DeviceGet(PPT_CPUB0) >= 0 && DeviceGet(PPT_GPUC0) < 0;
|
||||
}
|
||||
|
||||
/*
|
||||
public void ScanRange()
|
||||
{
|
||||
int value;
|
||||
string appPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GHelper";
|
||||
string logFile = appPath + "\\scan.txt";
|
||||
for (uint i = 0x00000000; i <= 0x00160000; i++)
|
||||
{
|
||||
value = DeviceGet(i);
|
||||
if (value >= 0)
|
||||
using (StreamWriter w = File.AppendText(logFile))
|
||||
{
|
||||
w.WriteLine(i.ToString("X8") + ": " + value.ToString("X4") + " (" + value + ")");
|
||||
w.Close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
public void TUFKeyboardBrightness(int brightness)
|
||||
{
|
||||
int param = 0x80 | (brightness & 0x7F);
|
||||
@@ -321,7 +497,8 @@ public class ASUSWmi
|
||||
watcher.Scope = new ManagementScope("root\\wmi");
|
||||
watcher.Query = new WqlEventQuery("SELECT * FROM AsusAtkWmiEvent");
|
||||
watcher.Start();
|
||||
} catch
|
||||
}
|
||||
catch
|
||||
{
|
||||
Logger.WriteLine("Can't connect to ASUS WMI events");
|
||||
}
|
||||
426
app/AsusUSB.cs
Normal file
426
app/AsusUSB.cs
Normal file
@@ -0,0 +1,426 @@
|
||||
using HidLibrary;
|
||||
using System.Text;
|
||||
|
||||
namespace GHelper
|
||||
{
|
||||
|
||||
[Flags]
|
||||
public enum AuraDev19b6 : uint
|
||||
{
|
||||
BootLogo = 1,
|
||||
BootKeyb = 1 << 1,
|
||||
AwakeLogo = 1 << 2,
|
||||
AwakeKeyb = 1 << 3,
|
||||
SleepLogo = 1 << 4,
|
||||
SleepKeyb = 1 << 5,
|
||||
ShutdownLogo = 1 << 6,
|
||||
ShutdownKeyb = 1 << 7,
|
||||
BootBar = 1u << (7 + 2),
|
||||
AwakeBar = 1u << (7 + 3),
|
||||
SleepBar = 1u << (7 + 4),
|
||||
ShutdownBar = 1u << (7 + 5),
|
||||
BootLid = 1u << (15 + 1),
|
||||
AwakeLid = 1u << (15 + 2),
|
||||
SleepLid = 1u << (15 + 3),
|
||||
ShutdownLid = 1u << (15 + 4)
|
||||
}
|
||||
|
||||
public static class AuraDev19b6Extensions
|
||||
{
|
||||
public static byte[] ToBytes(this AuraDev19b6[] controls)
|
||||
{
|
||||
uint a = 0;
|
||||
foreach (var n in controls)
|
||||
{
|
||||
a |= (uint)n;
|
||||
}
|
||||
return new byte[] { 0x5d, 0xbd, 0x01, (byte)(a & 0xff), (byte)((a & 0xff00) >> 8), (byte)((a & 0xff0000) >> 16) };
|
||||
}
|
||||
|
||||
public static ushort BitOr(this AuraDev19b6 self, AuraDev19b6 rhs)
|
||||
{
|
||||
return (ushort)(self | rhs);
|
||||
}
|
||||
|
||||
public static ushort BitAnd(this AuraDev19b6 self, AuraDev19b6 rhs)
|
||||
{
|
||||
return (ushort)(self & rhs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class AsusUSB
|
||||
{
|
||||
|
||||
public const int ASUS_ID = 0x0b05;
|
||||
|
||||
public const byte INPUT_HID_ID = 0x5a;
|
||||
public const byte AURA_HID_ID = 0x5d;
|
||||
|
||||
public static readonly byte[] LED_INIT1 = new byte[] { AURA_HID_ID, 0xb9 };
|
||||
public static readonly byte[] LED_INIT2 = Encoding.ASCII.GetBytes("]ASUS Tech.Inc.");
|
||||
public static readonly byte[] LED_INIT3 = new byte[] { AURA_HID_ID, 0x05, 0x20, 0x31, 0, 0x08 };
|
||||
public static readonly byte[] LED_INIT4 = Encoding.ASCII.GetBytes("^ASUS Tech.Inc.");
|
||||
public static readonly byte[] LED_INIT5 = new byte[] { 0x5e, 0x05, 0x20, 0x31, 0, 0x08 };
|
||||
|
||||
static byte[] MESSAGE_SET = { AURA_HID_ID, 0xb5, 0, 0, 0 };
|
||||
static byte[] MESSAGE_APPLY = { AURA_HID_ID, 0xb4 };
|
||||
|
||||
static int[] deviceIds = { 0x1a30, 0x1854, 0x1869, 0x1866, 0x19b6, 0x1822, 0x1837, 0x1854, 0x184a, 0x183d, 0x8502, 0x1807, 0x17e0, 0x18c6 };
|
||||
|
||||
private static int mode = 0;
|
||||
private static int speed = 1;
|
||||
public static Color Color1 = Color.White;
|
||||
public static Color Color2 = Color.Black;
|
||||
|
||||
|
||||
public static Dictionary<int, string> GetSpeeds()
|
||||
{
|
||||
return new Dictionary<int, string>
|
||||
{
|
||||
{ 0, Properties.Strings.AuraSlow },
|
||||
{ 1, Properties.Strings.AuraNormal },
|
||||
{ 2, Properties.Strings.AuraFast }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
static Dictionary<int, string> _modes = new Dictionary<int, string>
|
||||
{
|
||||
{ 0, Properties.Strings.AuraStatic },
|
||||
{ 1, Properties.Strings.AuraBreathe },
|
||||
{ 2, Properties.Strings.AuraColorCycle },
|
||||
{ 3, Properties.Strings.AuraRainbow },
|
||||
{ 10, Properties.Strings.AuraStrobe },
|
||||
};
|
||||
|
||||
static Dictionary<int, string> _modesStrix = new Dictionary<int, string>
|
||||
{
|
||||
{ 0, Properties.Strings.AuraStatic },
|
||||
{ 1, Properties.Strings.AuraBreathe },
|
||||
{ 2, Properties.Strings.AuraColorCycle },
|
||||
{ 3, Properties.Strings.AuraRainbow },
|
||||
{ 4, "Star" },
|
||||
{ 5, "Rain" },
|
||||
{ 6, "Highlight" },
|
||||
{ 7, "Laser" },
|
||||
{ 8, "Ripple" },
|
||||
{ 10, Properties.Strings.AuraStrobe},
|
||||
{ 11, "Comet" },
|
||||
{ 12, "Flash" },
|
||||
};
|
||||
|
||||
|
||||
public static Dictionary<int, string> GetModes()
|
||||
{
|
||||
if (AppConfig.ContainsModel("TUF"))
|
||||
{
|
||||
_modes.Remove(3);
|
||||
}
|
||||
|
||||
if (AppConfig.ContainsModel("401"))
|
||||
{
|
||||
_modes.Remove(2);
|
||||
_modes.Remove(3);
|
||||
}
|
||||
|
||||
if (AppConfig.ContainsModel("G513QY"))
|
||||
{
|
||||
return _modes;
|
||||
}
|
||||
|
||||
if (AppConfig.ContainsModel("Strix") || AppConfig.ContainsModel("Scar"))
|
||||
{
|
||||
return _modesStrix;
|
||||
}
|
||||
|
||||
return _modes;
|
||||
}
|
||||
|
||||
|
||||
public static int Mode
|
||||
{
|
||||
get { return mode; }
|
||||
set
|
||||
{
|
||||
if (GetModes().ContainsKey(value))
|
||||
mode = value;
|
||||
else
|
||||
mode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool HasSecondColor()
|
||||
{
|
||||
return (mode == 1 && !AppConfig.ContainsModel("TUF"));
|
||||
}
|
||||
|
||||
public static int Speed
|
||||
{
|
||||
get { return speed; }
|
||||
set
|
||||
{
|
||||
if (GetSpeeds().ContainsKey(value))
|
||||
speed = value;
|
||||
else
|
||||
speed = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void SetColor(int colorCode)
|
||||
{
|
||||
Color1 = Color.FromArgb(colorCode);
|
||||
}
|
||||
|
||||
public static void SetColor2(int colorCode)
|
||||
{
|
||||
Color2 = Color.FromArgb(colorCode);
|
||||
}
|
||||
|
||||
|
||||
private static IEnumerable<HidDevice> GetHidDevices(int[] deviceIds, int minInput = 18, int minFeatures = 1)
|
||||
{
|
||||
HidDevice[] HidDeviceList = HidDevices.Enumerate(ASUS_ID, deviceIds).ToArray();
|
||||
foreach (HidDevice device in HidDeviceList)
|
||||
if (device.IsConnected
|
||||
&& device.Capabilities.FeatureReportByteLength >= minFeatures
|
||||
&& device.Capabilities.InputReportByteLength >= minInput)
|
||||
yield return device;
|
||||
}
|
||||
|
||||
public static HidDevice? GetDevice(byte reportID = INPUT_HID_ID)
|
||||
{
|
||||
HidDevice[] HidDeviceList = HidDevices.Enumerate(ASUS_ID, deviceIds).ToArray();
|
||||
HidDevice input = null;
|
||||
|
||||
foreach (HidDevice device in HidDeviceList)
|
||||
if (device.ReadFeatureData(out byte[] data, reportID))
|
||||
{
|
||||
input = device;
|
||||
//Logger.WriteLine("HID Device("+ reportID + ")" + + device.Capabilities.FeatureReportByteLength + "|" + device.Capabilities.InputReportByteLength + device.DevicePath);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
public static bool TouchpadToggle()
|
||||
{
|
||||
HidDevice? input = GetDevice();
|
||||
if (input != null) return input.WriteFeatureData(new byte[] { INPUT_HID_ID, 0xf4, 0x6b });
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static byte[] AuraMessage(int mode, Color color, Color color2, int speed)
|
||||
{
|
||||
|
||||
byte[] msg = new byte[17];
|
||||
msg[0] = AURA_HID_ID;
|
||||
msg[1] = 0xb3;
|
||||
msg[2] = 0x00; // Zone
|
||||
msg[3] = (byte)mode; // Aura Mode
|
||||
msg[4] = (byte)(color.R); // R
|
||||
msg[5] = (byte)(color.G); // G
|
||||
msg[6] = (byte)(color.B); // B
|
||||
msg[7] = (byte)speed; // aura.speed as u8;
|
||||
msg[8] = 0; // aura.direction as u8;
|
||||
msg[10] = (byte)(color2.R); // R
|
||||
msg[11] = (byte)(color2.G); // G
|
||||
msg[12] = (byte)(color2.B); // B
|
||||
return msg;
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var devices = GetHidDevices(deviceIds, 0);
|
||||
foreach (HidDevice device in devices)
|
||||
{
|
||||
device.OpenDevice();
|
||||
device.WriteFeatureData(LED_INIT1);
|
||||
device.WriteFeatureData(LED_INIT2);
|
||||
device.WriteFeatureData(LED_INIT3);
|
||||
device.WriteFeatureData(LED_INIT4);
|
||||
device.WriteFeatureData(LED_INIT5);
|
||||
device.CloseDevice();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static void ApplyBrightness(int brightness, string log = "Backlight")
|
||||
{
|
||||
|
||||
if (AppConfig.ContainsModel("TUF"))
|
||||
Program.acpi.TUFKeyboardBrightness(brightness);
|
||||
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
|
||||
byte[] msg = { AURA_HID_ID, 0xba, 0xc5, 0xc4, (byte)brightness };
|
||||
byte[] msgBackup = { INPUT_HID_ID, 0xba, 0xc5, 0xc4, (byte)brightness };
|
||||
|
||||
var devices = GetHidDevices(deviceIds, 0);
|
||||
foreach (HidDevice device in devices)
|
||||
{
|
||||
device.OpenDevice();
|
||||
|
||||
if (device.ReadFeatureData(out byte[] data, AURA_HID_ID))
|
||||
{
|
||||
device.WriteFeatureData(msg);
|
||||
Logger.WriteLine(log + ":" + BitConverter.ToString(msg));
|
||||
}
|
||||
|
||||
if (AppConfig.ContainsModel("GA503") && device.ReadFeatureData(out byte[] dataBackkup, INPUT_HID_ID))
|
||||
{
|
||||
device.WriteFeatureData(msgBackup);
|
||||
Logger.WriteLine(log + ":" + BitConverter.ToString(msgBackup));
|
||||
}
|
||||
|
||||
device.CloseDevice();
|
||||
}
|
||||
|
||||
// Backup payload for old models
|
||||
/*
|
||||
if (AppConfig.ContainsModel("GA503RW"))
|
||||
{
|
||||
byte[] msgBackup = { INPUT_HID_ID, 0xba, 0xc5, 0xc4, (byte)brightness };
|
||||
|
||||
var devicesBackup = GetHidDevices(deviceIds, 0);
|
||||
foreach (HidDevice device in devicesBackup)
|
||||
{
|
||||
device.OpenDevice();
|
||||
device.WriteFeatureData(msgBackup);
|
||||
device.CloseDevice();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void ApplyAuraPower(List<AuraDev19b6> flags)
|
||||
{
|
||||
|
||||
byte[] msg = AuraDev19b6Extensions.ToBytes(flags.ToArray());
|
||||
|
||||
|
||||
var devices = GetHidDevices(deviceIds);
|
||||
//Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg));
|
||||
|
||||
foreach (HidDevice device in devices)
|
||||
{
|
||||
device.OpenDevice();
|
||||
device.WriteFeatureData(msg);
|
||||
Logger.WriteLine("USB-KB " + device.Attributes.ProductHexId + ":" + BitConverter.ToString(msg));
|
||||
device.CloseDevice();
|
||||
}
|
||||
|
||||
if (AppConfig.ContainsModel("TUF"))
|
||||
Program.acpi.TUFKeyboardPower(
|
||||
flags.Contains(AuraDev19b6.AwakeKeyb),
|
||||
flags.Contains(AuraDev19b6.BootKeyb),
|
||||
flags.Contains(AuraDev19b6.SleepKeyb),
|
||||
flags.Contains(AuraDev19b6.ShutdownKeyb));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void ApplyAura()
|
||||
{
|
||||
|
||||
int _speed;
|
||||
|
||||
switch (Speed)
|
||||
{
|
||||
case 1:
|
||||
_speed = 0xeb;
|
||||
break;
|
||||
case 2:
|
||||
_speed = 0xf5;
|
||||
break;
|
||||
default:
|
||||
_speed = 0xe1;
|
||||
break;
|
||||
}
|
||||
|
||||
byte[] msg = AuraMessage(Mode, Color1, Color2, _speed);
|
||||
|
||||
var devices = GetHidDevices(deviceIds);
|
||||
|
||||
if (devices.Count() == 0)
|
||||
{
|
||||
Logger.WriteLine("USB-KB : not found");
|
||||
devices = GetHidDevices(deviceIds, 1);
|
||||
}
|
||||
|
||||
foreach (HidDevice device in devices)
|
||||
{
|
||||
device.OpenDevice();
|
||||
device.WriteFeatureData(msg);
|
||||
device.WriteFeatureData(MESSAGE_SET);
|
||||
device.WriteFeatureData(MESSAGE_APPLY);
|
||||
device.CloseDevice();
|
||||
Logger.WriteLine("USB-KB " + device.Capabilities.FeatureReportByteLength + "|" + device.Capabilities.InputReportByteLength + device.Description + device.DevicePath + ":" + BitConverter.ToString(msg));
|
||||
}
|
||||
|
||||
if (AppConfig.ContainsModel("TUF"))
|
||||
Program.acpi.TUFKeyboardRGB(Mode, Color1, _speed);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Reference : thanks to https://github.com/RomanYazvinsky/ for initial discovery of XGM payloads
|
||||
public static int SetXGM(byte[] msg)
|
||||
{
|
||||
|
||||
//Logger.WriteLine("XGM Payload :" + BitConverter.ToString(msg));
|
||||
|
||||
var payload = new byte[300];
|
||||
Array.Copy(msg, payload, msg.Length);
|
||||
|
||||
foreach (HidDevice device in GetHidDevices(new int[] { 0x1970 }, 0, 300))
|
||||
{
|
||||
device.OpenDevice();
|
||||
Logger.WriteLine("XGM " + device.Attributes.ProductHexId + "|" + device.Capabilities.FeatureReportByteLength + ":" + BitConverter.ToString(msg));
|
||||
device.WriteFeatureData(payload);
|
||||
device.CloseDevice();
|
||||
//return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void ApplyXGMLight(bool status)
|
||||
{
|
||||
SetXGM(new byte[] { 0x5e, 0xc5, status ? (byte)0x50 : (byte)0 });
|
||||
}
|
||||
|
||||
|
||||
public static int ResetXGM()
|
||||
{
|
||||
return SetXGM(new byte[] { 0x5e, 0xd1, 0x02 });
|
||||
}
|
||||
|
||||
public static int SetXGMFan(byte[] curve)
|
||||
{
|
||||
|
||||
if (AsusACPI.IsInvalidCurve(curve)) return -1;
|
||||
|
||||
byte[] msg = new byte[19];
|
||||
Array.Copy(new byte[] { 0x5e, 0xd1, 0x01 }, msg, 3);
|
||||
Array.Copy(curve, 0, msg, 3, curve.Length);
|
||||
|
||||
return SetXGM(msg);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
300
app/Aura.cs
300
app/Aura.cs
@@ -1,300 +0,0 @@
|
||||
using HidLibrary;
|
||||
using System.Diagnostics;
|
||||
using static Starlight.AnimeMatrix.BuiltInAnimation;
|
||||
|
||||
namespace GHelper
|
||||
{
|
||||
|
||||
[Flags]
|
||||
public enum AuraDev19b6 : uint
|
||||
{
|
||||
BootLogo = 1,
|
||||
BootKeyb = 1 << 1,
|
||||
AwakeLogo = 1 << 2,
|
||||
AwakeKeyb = 1 << 3,
|
||||
SleepLogo = 1 << 4,
|
||||
SleepKeyb = 1 << 5,
|
||||
ShutdownLogo = 1 << 6,
|
||||
ShutdownKeyb = 1 << 7,
|
||||
BootBar = 1u << (7 + 2),
|
||||
AwakeBar = 1u << (7 + 3),
|
||||
SleepBar = 1u << (7 + 4),
|
||||
ShutdownBar = 1u << (7 + 5),
|
||||
BootLid = 1u << (15 + 1),
|
||||
AwakeLid = 1u << (15 + 2),
|
||||
SleepLid = 1u << (15 + 3),
|
||||
ShutdownLid = 1u << (15 + 4)
|
||||
}
|
||||
|
||||
public static class AuraDev19b6Extensions
|
||||
{
|
||||
public static byte[] ToBytes(this AuraDev19b6[] controls)
|
||||
{
|
||||
uint a = 0;
|
||||
foreach (var n in controls)
|
||||
{
|
||||
a |= (uint)n;
|
||||
}
|
||||
return new byte[] { 0x5d, 0xbd, 0x01, (byte)(a & 0xff), (byte)((a & 0xff00) >> 8), (byte)((a & 0xff0000) >> 16) };
|
||||
}
|
||||
|
||||
public static ushort BitOr(this AuraDev19b6 self, AuraDev19b6 rhs)
|
||||
{
|
||||
return (ushort)(self | rhs);
|
||||
}
|
||||
|
||||
public static ushort BitAnd(this AuraDev19b6 self, AuraDev19b6 rhs)
|
||||
{
|
||||
return (ushort)(self & rhs);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Aura
|
||||
{
|
||||
|
||||
static byte[] MESSAGE_SET = { 0x5d, 0xb5, 0, 0, 0 };
|
||||
static byte[] MESSAGE_APPLY = { 0x5d, 0xb4 };
|
||||
|
||||
static int[] deviceIds = { 0x1a30, 0x1854, 0x1869, 0x1866, 0x19b6, 0x1822, 0x1837, 0x1854, 0x184a, 0x183d, 0x8502, 0x1807, 0x17e0 };
|
||||
|
||||
private static int mode = 0;
|
||||
private static int speed = 1;
|
||||
public static Color Color1 = Color.White;
|
||||
public static Color Color2 = Color.Black;
|
||||
|
||||
|
||||
public static Dictionary<int, string> GetSpeeds()
|
||||
{
|
||||
return new Dictionary<int, string>
|
||||
{
|
||||
{ 0, Properties.Strings.AuraSlow },
|
||||
{ 1, Properties.Strings.AuraNormal },
|
||||
{ 2, Properties.Strings.AuraFast }
|
||||
};
|
||||
}
|
||||
|
||||
static Dictionary<int, string> _modes = new Dictionary<int, string>
|
||||
{
|
||||
{ 0, Properties.Strings.AuraStatic },
|
||||
{ 1, Properties.Strings.AuraBreathe },
|
||||
{ 2, Properties.Strings.AuraColorCycle },
|
||||
{ 3, Properties.Strings.AuraRainbow },
|
||||
{ 10, Properties.Strings.AuraStrobe },
|
||||
};
|
||||
|
||||
static Dictionary<int, string> _modesStrix = new Dictionary<int, string>
|
||||
{
|
||||
{ 0, Properties.Strings.AuraStatic },
|
||||
{ 1, Properties.Strings.AuraBreathe },
|
||||
{ 2, Properties.Strings.AuraColorCycle },
|
||||
{ 3, Properties.Strings.AuraRainbow },
|
||||
{ 4, "Star" },
|
||||
{ 5, "Rain" },
|
||||
{ 6, "Highlight" },
|
||||
{ 7, "Laser" },
|
||||
{ 8, "Ripple" },
|
||||
{ 10, Properties.Strings.AuraStrobe},
|
||||
{ 11, "Comet" },
|
||||
{ 12, "Flash" },
|
||||
};
|
||||
|
||||
|
||||
public static Dictionary<int, string> GetModes()
|
||||
{
|
||||
if (Program.config.ContainsModel("TUF"))
|
||||
{
|
||||
_modes.Remove(3);
|
||||
}
|
||||
|
||||
if (Program.config.ContainsModel("401"))
|
||||
{
|
||||
_modes.Remove(2);
|
||||
_modes.Remove(3);
|
||||
}
|
||||
|
||||
if (Program.config.ContainsModel("Strix") || Program.config.ContainsModel("Scar"))
|
||||
{
|
||||
return _modesStrix;
|
||||
}
|
||||
|
||||
return _modes;
|
||||
}
|
||||
|
||||
|
||||
public static int Mode
|
||||
{
|
||||
get { return mode; }
|
||||
set
|
||||
{
|
||||
if (GetModes().ContainsKey(value))
|
||||
mode = value;
|
||||
else
|
||||
mode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool HasSecondColor()
|
||||
{
|
||||
return (mode == 1 && !Program.config.ContainsModel("TUF"));
|
||||
}
|
||||
|
||||
public static int Speed
|
||||
{
|
||||
get { return speed; }
|
||||
set
|
||||
{
|
||||
if (GetSpeeds().ContainsKey(value))
|
||||
speed = value;
|
||||
else
|
||||
speed = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void SetColor(int colorCode)
|
||||
{
|
||||
Color1 = Color.FromArgb(colorCode);
|
||||
}
|
||||
|
||||
public static void SetColor2(int colorCode)
|
||||
{
|
||||
Color2 = Color.FromArgb(colorCode);
|
||||
}
|
||||
|
||||
public static byte[] AuraMessage(int mode, Color color, Color color2, int speed)
|
||||
{
|
||||
|
||||
byte[] msg = new byte[17];
|
||||
msg[0] = 0x5d;
|
||||
msg[1] = 0xb3;
|
||||
msg[2] = 0x00; // Zone
|
||||
msg[3] = (byte)mode; // Aura Mode
|
||||
msg[4] = (byte)(color.R); // R
|
||||
msg[5] = (byte)(color.G); // G
|
||||
msg[6] = (byte)(color.B); // B
|
||||
msg[7] = (byte)speed; // aura.speed as u8;
|
||||
msg[8] = 0; // aura.direction as u8;
|
||||
msg[10] = (byte)(color2.R); // R
|
||||
msg[11] = (byte)(color2.G); // G
|
||||
msg[12] = (byte)(color2.B); // B
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
public static void ApplyBrightness(int brightness)
|
||||
{
|
||||
HidDevice[] HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray();
|
||||
|
||||
byte[] msg = { 0x5d, 0xba, 0xc5, 0xc4, (byte)brightness };
|
||||
|
||||
foreach (HidDevice device in HidDeviceList)
|
||||
if (device.IsConnected && device.Description.Contains("HID"))
|
||||
{
|
||||
device.OpenDevice();
|
||||
device.Write(msg);
|
||||
device.CloseDevice();
|
||||
}
|
||||
|
||||
Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg));
|
||||
|
||||
if (Program.config.ContainsModel("TUF"))
|
||||
Program.wmi.TUFKeyboardBrightness(brightness);
|
||||
}
|
||||
|
||||
|
||||
public static void ApplyAuraPower(bool awake = true, bool boot = false, bool sleep = false, bool shutdown = false)
|
||||
{
|
||||
HidDevice[] HidDeviceList = HidDevices.Enumerate(0x0b05, 0x19b6).ToArray();
|
||||
|
||||
List<AuraDev19b6> flags = new List<AuraDev19b6>();
|
||||
|
||||
if (awake)
|
||||
{
|
||||
flags.Add(AuraDev19b6.AwakeKeyb);
|
||||
flags.Add(AuraDev19b6.AwakeBar);
|
||||
flags.Add(AuraDev19b6.AwakeLid);
|
||||
flags.Add(AuraDev19b6.AwakeLogo);
|
||||
}
|
||||
|
||||
if (boot)
|
||||
{
|
||||
flags.Add(AuraDev19b6.BootKeyb);
|
||||
flags.Add(AuraDev19b6.BootBar);
|
||||
flags.Add(AuraDev19b6.BootLid);
|
||||
flags.Add(AuraDev19b6.BootLogo);
|
||||
}
|
||||
|
||||
if (sleep)
|
||||
{
|
||||
flags.Add(AuraDev19b6.SleepKeyb);
|
||||
flags.Add(AuraDev19b6.SleepBar);
|
||||
flags.Add(AuraDev19b6.SleepLid);
|
||||
flags.Add(AuraDev19b6.SleepLogo);
|
||||
}
|
||||
|
||||
if (shutdown)
|
||||
{
|
||||
flags.Add(AuraDev19b6.ShutdownKeyb);
|
||||
flags.Add(AuraDev19b6.ShutdownBar);
|
||||
flags.Add(AuraDev19b6.ShutdownLid);
|
||||
flags.Add(AuraDev19b6.ShutdownLogo);
|
||||
}
|
||||
|
||||
byte[] msg = AuraDev19b6Extensions.ToBytes(flags.ToArray());
|
||||
|
||||
Debug.WriteLine(BitConverter.ToString(msg));
|
||||
|
||||
foreach (HidDevice device in HidDeviceList)
|
||||
if (device.IsConnected && device.Description.Contains("HID"))
|
||||
{
|
||||
device.OpenDevice();
|
||||
device.Write(msg);
|
||||
device.CloseDevice();
|
||||
}
|
||||
|
||||
Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg));
|
||||
|
||||
if (Program.config.ContainsModel("TUF"))
|
||||
Program.wmi.TUFKeyboardPower(awake, boot, sleep, shutdown);
|
||||
|
||||
}
|
||||
|
||||
public static void ApplyAura()
|
||||
{
|
||||
|
||||
HidDevice[] HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray();
|
||||
|
||||
int _speed;
|
||||
|
||||
switch (Speed)
|
||||
{
|
||||
case 1:
|
||||
_speed = 0xeb;
|
||||
break;
|
||||
case 2:
|
||||
_speed = 0xf5;
|
||||
break;
|
||||
default:
|
||||
_speed = 0xe1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
byte[] msg = AuraMessage(Mode, Color1, Color2, _speed);
|
||||
foreach (HidDevice device in HidDeviceList)
|
||||
if (device.IsConnected && device.Description.Contains("HID"))
|
||||
{
|
||||
device.OpenDevice();
|
||||
device.Write(msg);
|
||||
device.Write(MESSAGE_SET);
|
||||
device.Write(MESSAGE_APPLY);
|
||||
device.CloseDevice();
|
||||
}
|
||||
|
||||
if (Program.config.ContainsModel("TUF"))
|
||||
Program.wmi.TUFKeyboardRGB(Mode, Color1, _speed);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public static class ControlHelper
|
||||
}
|
||||
|
||||
var chk = control as CheckBox;
|
||||
if (chk != null && chk.Padding.Left > 5)
|
||||
if (chk != null && chk.Padding.Right > 5)
|
||||
{
|
||||
chk.BackColor = RForm.buttonSecond;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace CustomControls
|
||||
public static Color colorEco = Color.FromArgb(255, 6, 180, 138);
|
||||
public static Color colorStandard = Color.FromArgb(255, 58, 174, 239);
|
||||
public static Color colorTurbo = Color.FromArgb(255, 255, 32, 32);
|
||||
public static Color colorCustom = Color.FromArgb(255, 255, 128, 0);
|
||||
|
||||
|
||||
public static Color buttonMain;
|
||||
public static Color buttonSecond;
|
||||
@@ -30,11 +32,6 @@ namespace CustomControls
|
||||
|
||||
public bool darkTheme = false;
|
||||
|
||||
public RForm()
|
||||
{
|
||||
DoubleBuffered = true;
|
||||
}
|
||||
|
||||
public static void InitColors(bool darkTheme)
|
||||
{
|
||||
if (darkTheme)
|
||||
|
||||
1074
app/Extra.Designer.cs
generated
1074
app/Extra.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
360
app/Extra.cs
360
app/Extra.cs
@@ -1,4 +1,5 @@
|
||||
using CustomControls;
|
||||
using GHelper.Gpu;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace GHelper
|
||||
@@ -16,18 +17,37 @@ namespace GHelper
|
||||
{"performance", Properties.Strings.PerformanceMode},
|
||||
{"screen", Properties.Strings.ToggleScreen},
|
||||
{"miniled", Properties.Strings.ToggleMiniled},
|
||||
{"fnlock", Properties.Strings.ToggleFnLock},
|
||||
{"brightness_down", Properties.Strings.BrightnessDown},
|
||||
{"brightness_up", Properties.Strings.BrightnessUp},
|
||||
{"custom", Properties.Strings.Custom}
|
||||
};
|
||||
|
||||
private void SetKeyCombo(ComboBox combo, TextBox txbox, string name)
|
||||
{
|
||||
if (name == "m4")
|
||||
customActions[""] = Properties.Strings.OpenGHelper;
|
||||
|
||||
if (name == "fnf4")
|
||||
switch (name)
|
||||
{
|
||||
customActions[""] = Properties.Strings.ToggleAura;
|
||||
customActions.Remove("aura");
|
||||
case "m1":
|
||||
customActions[""] = Properties.Strings.VolumeDown;
|
||||
break;
|
||||
case "m2":
|
||||
customActions[""] = Properties.Strings.VolumeUp;
|
||||
break;
|
||||
case "m3":
|
||||
customActions[""] = Properties.Strings.MuteMic;
|
||||
break;
|
||||
case "m4":
|
||||
customActions[""] = Properties.Strings.OpenGHelper;
|
||||
break;
|
||||
case "fnf4":
|
||||
customActions[""] = Properties.Strings.ToggleAura;
|
||||
customActions.Remove("aura");
|
||||
break;
|
||||
case "fnc":
|
||||
customActions[""] = Properties.Strings.ToggleFnLock;
|
||||
customActions.Remove("fnlock");
|
||||
break;
|
||||
}
|
||||
|
||||
combo.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
@@ -35,7 +55,7 @@ namespace GHelper
|
||||
combo.DisplayMember = "Value";
|
||||
combo.ValueMember = "Key";
|
||||
|
||||
string action = Program.config.getConfigString(name);
|
||||
string action = AppConfig.GetString(name);
|
||||
|
||||
combo.SelectedValue = (action is not null) ? action : "";
|
||||
if (combo.SelectedValue is null) combo.SelectedValue = "";
|
||||
@@ -43,13 +63,17 @@ namespace GHelper
|
||||
combo.SelectedValueChanged += delegate
|
||||
{
|
||||
if (combo.SelectedValue is not null)
|
||||
Program.config.setConfig(name, combo.SelectedValue.ToString());
|
||||
AppConfig.Set(name, combo.SelectedValue.ToString());
|
||||
|
||||
if (name == "m1" || name == "m2")
|
||||
Program.inputDispatcher.RegisterKeys();
|
||||
|
||||
};
|
||||
|
||||
txbox.Text = Program.config.getConfigString(name + "_custom");
|
||||
txbox.Text = AppConfig.GetString(name + "_custom");
|
||||
txbox.TextChanged += delegate
|
||||
{
|
||||
Program.config.setConfig(name + "_custom", txbox.Text);
|
||||
AppConfig.Set(name + "_custom", txbox.Text);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -58,7 +82,7 @@ namespace GHelper
|
||||
InitializeComponent();
|
||||
|
||||
groupBindings.Text = Properties.Strings.KeyBindings;
|
||||
groupLight.Text = Properties.Strings.KeyboardBacklight;
|
||||
groupLight.Text = " " + Properties.Strings.LaptopBacklight;
|
||||
groupOther.Text = Properties.Strings.Other;
|
||||
|
||||
checkAwake.Text = Properties.Strings.Awake;
|
||||
@@ -69,67 +93,272 @@ namespace GHelper
|
||||
labelSpeed.Text = Properties.Strings.AnimationSpeed;
|
||||
labelBrightness.Text = Properties.Strings.Brightness;
|
||||
|
||||
checkKeyboardAuto.Text = Properties.Strings.KeyboardAuto;
|
||||
labelBacklightTimeout.Text = Properties.Strings.BacklightTimeout;
|
||||
labelBacklightTimeoutPlugged.Text = Properties.Strings.BacklightTimeoutPlugged;
|
||||
|
||||
checkNoOverdrive.Text = Properties.Strings.DisableOverdrive;
|
||||
checkTopmost.Text = Properties.Strings.WindowTop;
|
||||
checkUSBC.Text = Properties.Strings.OptimizedUSBC;
|
||||
checkAutoApplyWindowsPowerMode.Text = Properties.Strings.ApplyWindowsPowerPlan;
|
||||
checkFnLock.Text = Properties.Strings.FnLock;
|
||||
|
||||
labelBacklight.Text = Properties.Strings.Keyboard;
|
||||
labelBacklightBar.Text = Properties.Strings.Lightbar;
|
||||
labelBacklightLid.Text = Properties.Strings.Lid;
|
||||
labelBacklightLogo.Text = Properties.Strings.Logo;
|
||||
|
||||
checkGpuApps.Text = Properties.Strings.KillGpuApps;
|
||||
|
||||
Text = Properties.Strings.ExtraSettings;
|
||||
|
||||
InitTheme();
|
||||
|
||||
SetKeyCombo(comboM1, textM1, "m1");
|
||||
SetKeyCombo(comboM2, textM2, "m2");
|
||||
SetKeyCombo(comboM3, textM3, "m3");
|
||||
SetKeyCombo(comboM4, textM4, "m4");
|
||||
SetKeyCombo(comboFNF4, textFNF4, "fnf4");
|
||||
SetKeyCombo(comboFNC, textFNC, "fnc");
|
||||
|
||||
Shown += Keyboard_Shown;
|
||||
|
||||
comboKeyboardSpeed.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboKeyboardSpeed.DataSource = new BindingSource(Aura.GetSpeeds(), null);
|
||||
comboKeyboardSpeed.DataSource = new BindingSource(AsusUSB.GetSpeeds(), null);
|
||||
comboKeyboardSpeed.DisplayMember = "Value";
|
||||
comboKeyboardSpeed.ValueMember = "Key";
|
||||
comboKeyboardSpeed.SelectedValue = Aura.Speed;
|
||||
comboKeyboardSpeed.SelectedValue = AsusUSB.Speed;
|
||||
comboKeyboardSpeed.SelectedValueChanged += ComboKeyboardSpeed_SelectedValueChanged;
|
||||
|
||||
checkAwake.Checked = !(Program.config.getConfig("keyboard_awake") == 0);
|
||||
checkBoot.Checked = !(Program.config.getConfig("keyboard_boot") == 0);
|
||||
checkSleep.Checked = !(Program.config.getConfig("keyboard_sleep") == 0);
|
||||
checkShutdown.Checked = !(Program.config.getConfig("keyboard_shutdown") == 0);
|
||||
// Keyboard
|
||||
checkAwake.Checked = !(AppConfig.Get("keyboard_awake") == 0);
|
||||
checkBoot.Checked = !(AppConfig.Get("keyboard_boot") == 0);
|
||||
checkSleep.Checked = !(AppConfig.Get("keyboard_sleep") == 0);
|
||||
checkShutdown.Checked = !(AppConfig.Get("keyboard_shutdown") == 0);
|
||||
|
||||
// Lightbar
|
||||
checkAwakeBar.Checked = !(AppConfig.Get("keyboard_awake_bar") == 0);
|
||||
checkBootBar.Checked = !(AppConfig.Get("keyboard_boot_bar") == 0);
|
||||
checkSleepBar.Checked = !(AppConfig.Get("keyboard_sleep_bar") == 0);
|
||||
checkShutdownBar.Checked = !(AppConfig.Get("keyboard_shutdown_bar") == 0);
|
||||
|
||||
// Lid
|
||||
checkAwakeLid.Checked = !(AppConfig.Get("keyboard_awake_lid") == 0);
|
||||
checkBootLid.Checked = !(AppConfig.Get("keyboard_boot_lid") == 0);
|
||||
checkSleepLid.Checked = !(AppConfig.Get("keyboard_sleep_lid") == 0);
|
||||
checkShutdownLid.Checked = !(AppConfig.Get("keyboard_shutdown_lid") == 0);
|
||||
|
||||
// Logo
|
||||
checkAwakeLogo.Checked = !(AppConfig.Get("keyboard_awake_logo") == 0);
|
||||
checkBootLogo.Checked = !(AppConfig.Get("keyboard_boot_logo") == 0);
|
||||
checkSleepLogo.Checked = !(AppConfig.Get("keyboard_sleep_logo") == 0);
|
||||
checkShutdownLogo.Checked = !(AppConfig.Get("keyboard_shutdown_logo") == 0);
|
||||
|
||||
checkAwake.CheckedChanged += CheckPower_CheckedChanged;
|
||||
checkBoot.CheckedChanged += CheckPower_CheckedChanged;
|
||||
checkSleep.CheckedChanged += CheckPower_CheckedChanged;
|
||||
checkShutdown.CheckedChanged += CheckPower_CheckedChanged;
|
||||
|
||||
checkTopmost.Checked = (Program.config.getConfig("topmost") == 1);
|
||||
checkAwakeBar.CheckedChanged += CheckPower_CheckedChanged;
|
||||
checkBootBar.CheckedChanged += CheckPower_CheckedChanged;
|
||||
checkSleepBar.CheckedChanged += CheckPower_CheckedChanged;
|
||||
checkShutdownBar.CheckedChanged += CheckPower_CheckedChanged;
|
||||
|
||||
checkAwakeLid.CheckedChanged += CheckPower_CheckedChanged;
|
||||
checkBootLid.CheckedChanged += CheckPower_CheckedChanged;
|
||||
checkSleepLid.CheckedChanged += CheckPower_CheckedChanged;
|
||||
checkShutdownLid.CheckedChanged += CheckPower_CheckedChanged;
|
||||
|
||||
checkAwakeLogo.CheckedChanged += CheckPower_CheckedChanged;
|
||||
checkBootLogo.CheckedChanged += CheckPower_CheckedChanged;
|
||||
checkSleepLogo.CheckedChanged += CheckPower_CheckedChanged;
|
||||
checkShutdownLogo.CheckedChanged += CheckPower_CheckedChanged;
|
||||
|
||||
if (!AppConfig.ContainsModel("Strix"))
|
||||
{
|
||||
labelBacklightBar.Visible = false;
|
||||
checkAwakeBar.Visible = false;
|
||||
checkBootBar.Visible = false;
|
||||
checkSleepBar.Visible = false;
|
||||
checkShutdownBar.Visible = false;
|
||||
|
||||
if (!AppConfig.ContainsModel("Z13"))
|
||||
{
|
||||
labelBacklightLid.Visible = false;
|
||||
checkAwakeLid.Visible = false;
|
||||
checkBootLid.Visible = false;
|
||||
checkSleepLid.Visible = false;
|
||||
checkShutdownLid.Visible = false;
|
||||
|
||||
labelBacklightLogo.Visible = false;
|
||||
checkAwakeLogo.Visible = false;
|
||||
checkBootLogo.Visible = false;
|
||||
checkSleepLogo.Visible = false;
|
||||
checkShutdownLogo.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
checkTopmost.Checked = AppConfig.Is("topmost");
|
||||
checkTopmost.CheckedChanged += CheckTopmost_CheckedChanged; ;
|
||||
|
||||
checkKeyboardAuto.Checked = (Program.config.getConfig("keyboard_auto") == 1);
|
||||
checkKeyboardAuto.CheckedChanged += CheckKeyboardAuto_CheckedChanged;
|
||||
|
||||
checkNoOverdrive.Checked = (Program.config.getConfig("no_overdrive") == 1);
|
||||
checkNoOverdrive.Checked = AppConfig.Is("no_overdrive");
|
||||
checkNoOverdrive.CheckedChanged += CheckNoOverdrive_CheckedChanged;
|
||||
|
||||
checkUSBC.Checked = (Program.config.getConfig("optimized_usbc") == 1);
|
||||
checkUSBC.Checked = AppConfig.Is("optimized_usbc");
|
||||
checkUSBC.CheckedChanged += CheckUSBC_CheckedChanged;
|
||||
|
||||
int kb_brightness = Program.config.getConfig("keyboard_brightness");
|
||||
trackBrightness.Value = (kb_brightness >= 0 && kb_brightness <= 3) ? kb_brightness : 3;
|
||||
checkAutoApplyWindowsPowerMode.Checked = (AppConfig.Get("auto_apply_power_plan") != 0);
|
||||
checkAutoApplyWindowsPowerMode.CheckedChanged += checkAutoApplyWindowsPowerMode_CheckedChanged;
|
||||
|
||||
pictureHelp.Click += PictureHelp_Click;
|
||||
trackBrightness.Value = InputDispatcher.GetBacklight();
|
||||
trackBrightness.Scroll += TrackBrightness_Scroll;
|
||||
|
||||
panelXMG.Visible = (Program.acpi.DeviceGet(AsusACPI.GPUXGConnected) == 1);
|
||||
checkXMG.Checked = !(AppConfig.Get("xmg_light") == 0);
|
||||
checkXMG.CheckedChanged += CheckXMG_CheckedChanged;
|
||||
|
||||
numericBacklightTime.Value = AppConfig.Get("keyboard_timeout", 60);
|
||||
numericBacklightPluggedTime.Value = AppConfig.Get("keyboard_ac_timeout", 0);
|
||||
|
||||
numericBacklightTime.ValueChanged += NumericBacklightTime_ValueChanged;
|
||||
numericBacklightPluggedTime.ValueChanged += NumericBacklightTime_ValueChanged;
|
||||
|
||||
checkGpuApps.Checked = AppConfig.Is("kill_gpu_apps");
|
||||
checkGpuApps.CheckedChanged += CheckGpuApps_CheckedChanged;
|
||||
|
||||
checkFnLock.Checked = AppConfig.Is("fn_lock");
|
||||
checkFnLock.CheckedChanged += CheckFnLock_CheckedChanged; ;
|
||||
|
||||
pictureHelp.Click += PictureHelp_Click;
|
||||
|
||||
buttonServices.Click += ButtonServices_Click;
|
||||
|
||||
InitVariBright();
|
||||
InitServices();
|
||||
}
|
||||
|
||||
|
||||
private void InitServices()
|
||||
{
|
||||
if (OptimizationService.IsRunning()) buttonServices.Text = Properties.Strings.Stop;
|
||||
else buttonServices.Text = Properties.Strings.Start;
|
||||
|
||||
labelServices.Text = Properties.Strings.AsusServicesRunning + ": " + OptimizationService.GetRunningCount();
|
||||
buttonServices.Enabled = true;
|
||||
|
||||
}
|
||||
|
||||
public void ServiesToggle()
|
||||
{
|
||||
buttonServices.Enabled = false;
|
||||
|
||||
if (OptimizationService.IsRunning())
|
||||
{
|
||||
labelServices.Text = Properties.Strings.StoppingServices + " ...";
|
||||
Task.Run(() =>
|
||||
{
|
||||
OptimizationService.StopAsusServices();
|
||||
BeginInvoke(delegate
|
||||
{
|
||||
InitServices();
|
||||
});
|
||||
Program.inputDispatcher.Init();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
labelServices.Text = Properties.Strings.StartingServices + " ...";
|
||||
Task.Run(() =>
|
||||
{
|
||||
OptimizationService.StartAsusServices();
|
||||
BeginInvoke(delegate
|
||||
{
|
||||
InitServices();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonServices_Click(object? sender, EventArgs e)
|
||||
{
|
||||
if (ProcessHelper.IsUserAdministrator())
|
||||
ServiesToggle();
|
||||
else
|
||||
ProcessHelper.RunAsAdmin("services");
|
||||
}
|
||||
|
||||
private void InitVariBright()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var amdControl = new AmdGpuControl())
|
||||
{
|
||||
int variBrightSupported = 0, VariBrightEnabled;
|
||||
if (amdControl.GetVariBright(out variBrightSupported, out VariBrightEnabled))
|
||||
{
|
||||
Logger.WriteLine("Varibright: " + variBrightSupported + "," + VariBrightEnabled);
|
||||
checkVariBright.Checked = (VariBrightEnabled == 3);
|
||||
}
|
||||
|
||||
checkVariBright.Visible = (variBrightSupported > 0);
|
||||
checkVariBright.CheckedChanged += CheckVariBright_CheckedChanged;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.ToString());
|
||||
checkVariBright.Visible = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void CheckVariBright_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
using (var amdControl = new AmdGpuControl())
|
||||
{
|
||||
amdControl.SetVariBright(checkVariBright.Checked ? 1 : 0);
|
||||
ProcessHelper.KillByName("RadeonSoftware");
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckFnLock_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
int fnLock = checkFnLock.Checked ? 1 : 0;
|
||||
AppConfig.Set("fn_lock", fnLock);
|
||||
Program.acpi.DeviceSet(AsusACPI.FnLock, (fnLock == 1) ? 0 : 1, "FnLock");
|
||||
|
||||
Program.inputDispatcher.RegisterKeys();
|
||||
}
|
||||
|
||||
private void CheckGpuApps_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
AppConfig.Set("kill_gpu_apps", (checkGpuApps.Checked ? 1 : 0));
|
||||
}
|
||||
|
||||
private void NumericBacklightTime_ValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
AppConfig.Set("keyboard_timeout", (int)numericBacklightTime.Value);
|
||||
AppConfig.Set("keyboard_ac_timeout", (int)numericBacklightPluggedTime.Value);
|
||||
Program.inputDispatcher.InitBacklightTimer();
|
||||
}
|
||||
|
||||
private void CheckXMG_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
AppConfig.Set("xmg_light", (checkXMG.Checked ? 1 : 0));
|
||||
AsusUSB.ApplyXGMLight(checkXMG.Checked);
|
||||
}
|
||||
|
||||
private void CheckUSBC_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("optimized_usbc", (checkUSBC.Checked ? 1 : 0));
|
||||
AppConfig.Set("optimized_usbc", (checkUSBC.Checked ? 1 : 0));
|
||||
}
|
||||
|
||||
private void TrackBrightness_Scroll(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("keyboard_brightness", trackBrightness.Value);
|
||||
Aura.ApplyBrightness(trackBrightness.Value);
|
||||
AppConfig.Set("keyboard_brightness", trackBrightness.Value);
|
||||
AppConfig.Set("keyboard_brightness_ac", trackBrightness.Value);
|
||||
AsusUSB.ApplyBrightness(trackBrightness.Value, "Slider");
|
||||
}
|
||||
|
||||
private void PictureHelp_Click(object? sender, EventArgs e)
|
||||
@@ -139,42 +368,89 @@ namespace GHelper
|
||||
|
||||
private void CheckNoOverdrive_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("no_overdrive", (checkNoOverdrive.Checked ? 1 : 0));
|
||||
AppConfig.Set("no_overdrive", (checkNoOverdrive.Checked ? 1 : 0));
|
||||
Program.settingsForm.AutoScreen(true);
|
||||
}
|
||||
|
||||
private void CheckKeyboardAuto_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("keyboard_auto", (checkKeyboardAuto.Checked ? 1 : 0));
|
||||
}
|
||||
|
||||
private void CheckTopmost_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("topmost", (checkTopmost.Checked ? 1 : 0));
|
||||
AppConfig.Set("topmost", (checkTopmost.Checked ? 1 : 0));
|
||||
Program.settingsForm.TopMost = checkTopmost.Checked;
|
||||
}
|
||||
|
||||
private void CheckPower_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("keyboard_awake", (checkAwake.Checked ? 1 : 0));
|
||||
Program.config.setConfig("keyboard_boot", (checkBoot.Checked ? 1 : 0));
|
||||
Program.config.setConfig("keyboard_sleep", (checkSleep.Checked ? 1 : 0));
|
||||
Program.config.setConfig("keyboard_shutdown", (checkShutdown.Checked ? 1 : 0));
|
||||
AppConfig.Set("keyboard_awake", (checkAwake.Checked ? 1 : 0));
|
||||
AppConfig.Set("keyboard_boot", (checkBoot.Checked ? 1 : 0));
|
||||
AppConfig.Set("keyboard_sleep", (checkSleep.Checked ? 1 : 0));
|
||||
AppConfig.Set("keyboard_shutdown", (checkShutdown.Checked ? 1 : 0));
|
||||
|
||||
AppConfig.Set("keyboard_awake_bar", (checkAwakeBar.Checked ? 1 : 0));
|
||||
AppConfig.Set("keyboard_boot_bar", (checkBootBar.Checked ? 1 : 0));
|
||||
AppConfig.Set("keyboard_sleep_bar", (checkSleepBar.Checked ? 1 : 0));
|
||||
AppConfig.Set("keyboard_shutdown_bar", (checkShutdownBar.Checked ? 1 : 0));
|
||||
|
||||
AppConfig.Set("keyboard_awake_lid", (checkAwakeLid.Checked ? 1 : 0));
|
||||
AppConfig.Set("keyboard_boot_lid", (checkBootLid.Checked ? 1 : 0));
|
||||
AppConfig.Set("keyboard_sleep_lid", (checkSleepLid.Checked ? 1 : 0));
|
||||
AppConfig.Set("keyboard_shutdown_lid", (checkShutdownLid.Checked ? 1 : 0));
|
||||
|
||||
AppConfig.Set("keyboard_awake_logo", (checkAwakeLogo.Checked ? 1 : 0));
|
||||
AppConfig.Set("keyboard_boot_logo", (checkBootLogo.Checked ? 1 : 0));
|
||||
AppConfig.Set("keyboard_sleep_logo", (checkSleepLogo.Checked ? 1 : 0));
|
||||
AppConfig.Set("keyboard_shutdown_logo", (checkShutdownLogo.Checked ? 1 : 0));
|
||||
|
||||
List<AuraDev19b6> flags = new List<AuraDev19b6>();
|
||||
|
||||
if (checkAwake.Checked) flags.Add(AuraDev19b6.AwakeKeyb);
|
||||
if (checkBoot.Checked) flags.Add(AuraDev19b6.BootKeyb);
|
||||
if (checkSleep.Checked) flags.Add(AuraDev19b6.SleepKeyb);
|
||||
if (checkShutdown.Checked) flags.Add(AuraDev19b6.ShutdownKeyb);
|
||||
|
||||
if (checkAwakeBar.Checked) flags.Add(AuraDev19b6.AwakeBar);
|
||||
if (checkBootBar.Checked) flags.Add(AuraDev19b6.BootBar);
|
||||
if (checkSleepBar.Checked) flags.Add(AuraDev19b6.SleepBar);
|
||||
if (checkShutdownBar.Checked) flags.Add(AuraDev19b6.ShutdownBar);
|
||||
|
||||
if (checkAwakeLid.Checked) flags.Add(AuraDev19b6.AwakeLid);
|
||||
if (checkBootLid.Checked) flags.Add(AuraDev19b6.BootLid);
|
||||
if (checkSleepLid.Checked) flags.Add(AuraDev19b6.SleepLid);
|
||||
if (checkShutdownLid.Checked) flags.Add(AuraDev19b6.ShutdownLid);
|
||||
|
||||
if (checkAwakeLogo.Checked) flags.Add(AuraDev19b6.AwakeLogo);
|
||||
if (checkBootLogo.Checked) flags.Add(AuraDev19b6.BootLogo);
|
||||
if (checkSleepLogo.Checked) flags.Add(AuraDev19b6.SleepLogo);
|
||||
if (checkShutdownLogo.Checked) flags.Add(AuraDev19b6.ShutdownLogo);
|
||||
|
||||
AsusUSB.ApplyAuraPower(flags);
|
||||
|
||||
Aura.ApplyAuraPower(checkAwake.Checked, checkBoot.Checked, checkSleep.Checked, checkShutdown.Checked);
|
||||
}
|
||||
|
||||
private void ComboKeyboardSpeed_SelectedValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("aura_speed", (int)comboKeyboardSpeed.SelectedValue);
|
||||
AppConfig.Set("aura_speed", (int)comboKeyboardSpeed.SelectedValue);
|
||||
Program.settingsForm.SetAura();
|
||||
}
|
||||
|
||||
|
||||
private void Keyboard_Shown(object? sender, EventArgs e)
|
||||
{
|
||||
Top = Program.settingsForm.Top;
|
||||
if (Height > Program.settingsForm.Height)
|
||||
{
|
||||
Top = Program.settingsForm.Top + Program.settingsForm.Height - Height;
|
||||
}
|
||||
else
|
||||
{
|
||||
Top = Program.settingsForm.Top;
|
||||
}
|
||||
|
||||
Left = Program.settingsForm.Left - Width - 5;
|
||||
}
|
||||
|
||||
private void checkAutoApplyWindowsPowerMode_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
AppConfig.Set("auto_apply_power_plan", checkAutoApplyWindowsPowerMode.Checked ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,64 @@
|
||||
<root>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
||||
1036
app/Fans.Designer.cs
generated
1036
app/Fans.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
553
app/Fans.cs
553
app/Fans.cs
@@ -1,6 +1,8 @@
|
||||
using CustomControls;
|
||||
using GHelper.Gpu;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net.Sockets;
|
||||
using System.Windows.Forms.DataVisualization.Charting;
|
||||
|
||||
namespace GHelper
|
||||
@@ -8,13 +10,22 @@ namespace GHelper
|
||||
public partial class Fans : RForm
|
||||
{
|
||||
|
||||
int curIndex = -1;
|
||||
DataPoint curPoint = null;
|
||||
|
||||
Series seriesCPU;
|
||||
Series seriesGPU;
|
||||
Series seriesMid;
|
||||
Series seriesXGM;
|
||||
|
||||
static int MinRPM, MaxRPM;
|
||||
|
||||
static bool gpuVisible = true;
|
||||
|
||||
const int fansMax = 100;
|
||||
|
||||
NvidiaGpuControl? nvControl = null;
|
||||
|
||||
public Fans()
|
||||
{
|
||||
|
||||
@@ -30,10 +41,17 @@ namespace GHelper
|
||||
buttonReset.Text = Properties.Strings.FactoryDefaults;
|
||||
checkApplyFans.Text = Properties.Strings.ApplyFanCurve;
|
||||
|
||||
InitTheme();
|
||||
labelGPU.Text = Properties.Strings.GPUSettings;
|
||||
|
||||
labelGPUCoreTitle.Text = Properties.Strings.GPUCoreClockOffset;
|
||||
labelGPUMemoryTitle.Text = Properties.Strings.GPUMemoryClockOffset;
|
||||
labelGPUBoostTitle.Text = Properties.Strings.GPUBoost;
|
||||
labelGPUTempTitle.Text = Properties.Strings.GPUTempTarget;
|
||||
|
||||
InitTheme(true);
|
||||
|
||||
MinRPM = 18;
|
||||
MaxRPM = HardwareMonitor.GetFanMax();
|
||||
MaxRPM = HardwareControl.GetFanMax();
|
||||
labelTip.Visible = false;
|
||||
labelTip.BackColor = Color.Transparent;
|
||||
|
||||
@@ -42,10 +60,12 @@ namespace GHelper
|
||||
seriesCPU = chartCPU.Series.Add("CPU");
|
||||
seriesGPU = chartGPU.Series.Add("GPU");
|
||||
seriesMid = chartMid.Series.Add("Mid");
|
||||
seriesXGM = chartXGM.Series.Add("XGM");
|
||||
|
||||
seriesCPU.Color = colorStandard;
|
||||
seriesGPU.Color = colorTurbo;
|
||||
seriesMid.Color = colorEco;
|
||||
seriesXGM.Color = Color.Orange;
|
||||
|
||||
chartCPU.MouseMove += ChartCPU_MouseMove;
|
||||
chartCPU.MouseUp += ChartCPU_MouseUp;
|
||||
@@ -56,19 +76,27 @@ namespace GHelper
|
||||
chartMid.MouseMove += ChartCPU_MouseMove;
|
||||
chartMid.MouseUp += ChartCPU_MouseUp;
|
||||
|
||||
chartXGM.MouseMove += ChartCPU_MouseMove;
|
||||
chartXGM.MouseUp += ChartCPU_MouseUp;
|
||||
|
||||
buttonReset.Click += ButtonReset_Click;
|
||||
|
||||
trackTotal.Maximum = ASUSWmi.MaxTotal;
|
||||
trackTotal.Minimum = ASUSWmi.MinTotal;
|
||||
trackA0.Maximum = AsusACPI.MaxTotal;
|
||||
trackA0.Minimum = AsusACPI.MinTotal;
|
||||
|
||||
trackCPU.Maximum = ASUSWmi.MaxCPU;
|
||||
trackCPU.Minimum = ASUSWmi.MinCPU;
|
||||
trackB0.Maximum = AsusACPI.MaxCPU;
|
||||
trackB0.Minimum = AsusACPI.MinCPU;
|
||||
|
||||
trackCPU.Scroll += TrackPower_Scroll;
|
||||
trackTotal.Scroll += TrackPower_Scroll;
|
||||
trackC1.Maximum = AsusACPI.MaxTotal;
|
||||
trackC1.Minimum = AsusACPI.MinTotal;
|
||||
|
||||
trackCPU.MouseUp += TrackPower_MouseUp;
|
||||
trackTotal.MouseUp += TrackPower_MouseUp;
|
||||
trackC1.Scroll += TrackPower_Scroll;
|
||||
trackB0.Scroll += TrackPower_Scroll;
|
||||
trackA0.Scroll += TrackPower_Scroll;
|
||||
|
||||
trackC1.MouseUp += TrackPower_MouseUp;
|
||||
trackB0.MouseUp += TrackPower_MouseUp;
|
||||
trackA0.MouseUp += TrackPower_MouseUp;
|
||||
|
||||
checkApplyFans.Click += CheckApplyFans_Click;
|
||||
checkApplyPower.Click += CheckApplyPower_Click;
|
||||
@@ -79,88 +107,194 @@ namespace GHelper
|
||||
trackGPUMemory.Minimum = NvidiaGpuControl.MinMemoryOffset;
|
||||
trackGPUMemory.Maximum = NvidiaGpuControl.MaxMemoryOffset;
|
||||
|
||||
trackGPUBoost.Minimum = ASUSWmi.MinGPUBoost;
|
||||
trackGPUBoost.Maximum = ASUSWmi.MaxGPUBoost;
|
||||
trackGPUBoost.Minimum = AsusACPI.MinGPUBoost;
|
||||
trackGPUBoost.Maximum = AsusACPI.MaxGPUBoost;
|
||||
|
||||
trackGPUTemp.Minimum = ASUSWmi.MinGPUTemp;
|
||||
trackGPUTemp.Maximum = ASUSWmi.MaxGPUTemp;
|
||||
trackGPUTemp.Minimum = AsusACPI.MinGPUTemp;
|
||||
trackGPUTemp.Maximum = AsusACPI.MaxGPUTemp;
|
||||
|
||||
trackGPUCore.Scroll += trackGPU_Scroll;
|
||||
trackGPUMemory.Scroll += trackGPU_Scroll;
|
||||
trackGPUBoost.Scroll += trackGPU_Scroll;
|
||||
trackGPUTemp.Scroll += trackGPU_Scroll;
|
||||
|
||||
trackGPUBoost.Scroll += trackGPUPower_Scroll;
|
||||
trackGPUTemp.Scroll += trackGPUPower_Scroll;
|
||||
|
||||
trackGPUCore.MouseUp += TrackGPU_MouseUp;
|
||||
trackGPUMemory.MouseUp += TrackGPU_MouseUp;
|
||||
|
||||
trackGPUBoost.MouseUp += TrackGPUBoost_MouseUp;
|
||||
trackGPUTemp.MouseUp += TrackGPUBoost_MouseUp;
|
||||
trackGPUBoost.MouseUp += TrackGPU_MouseUp;
|
||||
trackGPUTemp.MouseUp += TrackGPU_MouseUp;
|
||||
|
||||
//labelInfo.MaximumSize = new Size(280, 0);
|
||||
labelInfo.Text = Properties.Strings.PPTExperimental;
|
||||
labelFansResult.Visible = false;
|
||||
|
||||
FillModes();
|
||||
|
||||
InitMode();
|
||||
InitFans();
|
||||
InitPower();
|
||||
InitBoost();
|
||||
InitGPU(true);
|
||||
|
||||
comboBoost.SelectedValueChanged += ComboBoost_Changed;
|
||||
|
||||
comboModes.SelectionChangeCommitted += ComboModes_SelectedValueChanged;
|
||||
comboModes.TextChanged += ComboModes_TextChanged;
|
||||
comboModes.KeyPress += ComboModes_KeyPress;
|
||||
|
||||
Shown += Fans_Shown;
|
||||
|
||||
InitGPUClocks();
|
||||
buttonAdd.Click += ButtonAdd_Click;
|
||||
buttonRemove.Click += ButtonRemove_Click;
|
||||
buttonRename.Click += ButtonRename_Click;
|
||||
|
||||
}
|
||||
|
||||
private void TrackGPUBoost_MouseUp(object? sender, MouseEventArgs e)
|
||||
private void ComboModes_KeyPress(object? sender, KeyPressEventArgs e)
|
||||
{
|
||||
Program.config.setConfig("gpu_boost", trackGPUBoost.Value);
|
||||
Program.config.setConfig("gpu_temp", trackGPUTemp.Value);
|
||||
Program.settingsForm.SetGPUPower();
|
||||
if (e.KeyChar == 13) RenameToggle();
|
||||
}
|
||||
|
||||
private void ComboModes_TextChanged(object? sender, EventArgs e)
|
||||
{
|
||||
if (comboModes.DropDownStyle == ComboBoxStyle.DropDownList) return;
|
||||
if (!Modes.IsCurrentCustom()) return;
|
||||
AppConfig.SetMode("mode_name", comboModes.Text);
|
||||
}
|
||||
|
||||
private void RenameToggle()
|
||||
{
|
||||
if (comboModes.DropDownStyle == ComboBoxStyle.DropDownList)
|
||||
comboModes.DropDownStyle = ComboBoxStyle.Simple;
|
||||
else
|
||||
{
|
||||
var mode = Modes.GetCurrent();
|
||||
FillModes();
|
||||
comboModes.SelectedValue = mode;
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRename_Click(object? sender, EventArgs e)
|
||||
{
|
||||
RenameToggle();
|
||||
}
|
||||
|
||||
private void ButtonRemove_Click(object? sender, EventArgs e)
|
||||
{
|
||||
int mode = Modes.GetCurrent();
|
||||
if (!Modes.IsCurrentCustom()) return;
|
||||
|
||||
Modes.Remove(mode);
|
||||
FillModes();
|
||||
|
||||
Program.settingsForm.SetPerformanceMode(AsusACPI.PerformanceBalanced);
|
||||
|
||||
}
|
||||
|
||||
private void FillModes()
|
||||
{
|
||||
comboModes.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboModes.DataSource = new BindingSource(Modes.GetDictonary(), null);
|
||||
comboModes.DisplayMember = "Value";
|
||||
comboModes.ValueMember = "Key";
|
||||
}
|
||||
|
||||
private void ButtonAdd_Click(object? sender, EventArgs e)
|
||||
{
|
||||
int mode = Modes.Add();
|
||||
FillModes();
|
||||
Program.settingsForm.SetPerformanceMode(mode);
|
||||
}
|
||||
|
||||
public void InitMode()
|
||||
{
|
||||
int mode = Modes.GetCurrent();
|
||||
comboModes.SelectedValue = mode;
|
||||
buttonRename.Visible = buttonRemove.Visible = Modes.IsCurrentCustom();
|
||||
}
|
||||
|
||||
private void ComboModes_SelectedValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
var selectedMode = comboModes.SelectedValue;
|
||||
|
||||
if (selectedMode == null) return;
|
||||
if ((int)selectedMode == Modes.GetCurrent()) return;
|
||||
|
||||
Debug.WriteLine(selectedMode);
|
||||
|
||||
Program.settingsForm.SetPerformanceMode((int)selectedMode);
|
||||
}
|
||||
|
||||
private void TrackGPU_MouseUp(object? sender, MouseEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Program.config.setConfig("gpu_core", trackGPUCore.Value);
|
||||
Program.config.setConfig("gpu_memory", trackGPUMemory.Value);
|
||||
|
||||
int status = Program.nvControl.SetClocks(trackGPUCore.Value, trackGPUMemory.Value);
|
||||
if (status == -1) Program.RunAsAdmin("gpu");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WriteLine("F:" + ex.ToString());
|
||||
}
|
||||
|
||||
InitGPUClocks();
|
||||
Program.settingsForm.SetGPUPower();
|
||||
Program.settingsForm.SetGPUClocks(true);
|
||||
}
|
||||
|
||||
private void InitGPUClocks()
|
||||
public void InitGPU(bool readClocks = false)
|
||||
{
|
||||
if (Program.nvControl is null || !Program.nvControl.IsValid)
|
||||
|
||||
if (Program.acpi.DeviceGet(AsusACPI.GPUEco) == 1)
|
||||
{
|
||||
panelGPU.Visible = false;
|
||||
gpuVisible = panelGPU.Visible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (HardwareControl.GpuControl is null) HardwareControl.RecreateGpuControl();
|
||||
|
||||
if (HardwareControl.GpuControl is not null && HardwareControl.GpuControl.IsNvidia)
|
||||
{
|
||||
nvControl = (NvidiaGpuControl)HardwareControl.GpuControl;
|
||||
}
|
||||
else
|
||||
{
|
||||
gpuVisible = panelGPU.Visible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
panelGPU.Visible = true;
|
||||
gpuVisible = panelGPU.Visible = true;
|
||||
|
||||
int gpu_boost = AppConfig.GetMode("gpu_boost");
|
||||
int gpu_temp = AppConfig.GetMode("gpu_temp");
|
||||
int core = AppConfig.GetMode("gpu_core");
|
||||
int memory = AppConfig.GetMode("gpu_memory");
|
||||
|
||||
if (gpu_boost < 0) gpu_boost = AsusACPI.MaxGPUBoost;
|
||||
if (gpu_temp < 0) gpu_temp = AsusACPI.MaxGPUTemp;
|
||||
|
||||
if (core == -1) core = 0;
|
||||
if (memory == -1) memory = 0;
|
||||
|
||||
//if (readClocks)
|
||||
//{
|
||||
int status = nvControl.GetClocks(out int current_core, out int current_memory);
|
||||
if (status != -1)
|
||||
{
|
||||
core = current_core;
|
||||
memory = current_memory;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
labelGPU.Text = nvControl.FullName;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//}
|
||||
|
||||
Program.nvControl.GetClocks(out int core, out int memory);
|
||||
trackGPUCore.Value = Math.Max(Math.Min(core, NvidiaGpuControl.MaxCoreOffset), NvidiaGpuControl.MinCoreOffset);
|
||||
trackGPUMemory.Value = Math.Max(Math.Min(memory, NvidiaGpuControl.MaxMemoryOffset), NvidiaGpuControl.MinMemoryOffset);
|
||||
|
||||
int gpu_boost = Program.config.getConfig("gpu_boost");
|
||||
int gpu_temp = Program.config.getConfig("gpu_temp");
|
||||
trackGPUBoost.Value = Math.Max(Math.Min(gpu_boost, AsusACPI.MaxGPUBoost), AsusACPI.MinGPUBoost);
|
||||
trackGPUTemp.Value = Math.Max(Math.Min(gpu_temp, AsusACPI.MaxGPUTemp), AsusACPI.MinGPUTemp);
|
||||
|
||||
if (gpu_boost < 0) gpu_boost = ASUSWmi.MaxGPUBoost;
|
||||
if (gpu_temp < 0) gpu_temp = ASUSWmi.MaxGPUTemp;
|
||||
|
||||
trackGPUBoost.Value = Math.Max(Math.Min(gpu_boost, ASUSWmi.MaxGPUBoost), ASUSWmi.MinGPUBoost);
|
||||
trackGPUTemp.Value = Math.Max(Math.Min(gpu_temp, ASUSWmi.MaxGPUTemp), ASUSWmi.MinGPUTemp);
|
||||
panelGPUBoost.Visible = (Program.acpi.DeviceGet(AsusACPI.PPT_GPUC0) >= 0);
|
||||
panelGPUTemp.Visible = (Program.acpi.DeviceGet(AsusACPI.PPT_GPUC2) >= 0);
|
||||
|
||||
VisualiseGPUSettings();
|
||||
|
||||
@@ -168,7 +302,7 @@ namespace GHelper
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WriteLine(ex.ToString());
|
||||
panelGPU.Visible = false;
|
||||
gpuVisible = panelGPU.Visible = false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -183,6 +317,22 @@ namespace GHelper
|
||||
|
||||
private void trackGPU_Scroll(object? sender, EventArgs e)
|
||||
{
|
||||
if (sender is null) return;
|
||||
TrackBar track = (TrackBar)sender;
|
||||
track.Value = (int)Math.Round((float)track.Value / 5) * 5;
|
||||
|
||||
AppConfig.SetMode("gpu_core", trackGPUCore.Value);
|
||||
AppConfig.SetMode("gpu_memory", trackGPUMemory.Value);
|
||||
|
||||
VisualiseGPUSettings();
|
||||
|
||||
}
|
||||
|
||||
private void trackGPUPower_Scroll(object? sender, EventArgs e)
|
||||
{
|
||||
AppConfig.SetMode("gpu_boost", trackGPUBoost.Value);
|
||||
AppConfig.SetMode("gpu_temp", trackGPUTemp.Value);
|
||||
|
||||
VisualiseGPUSettings();
|
||||
}
|
||||
|
||||
@@ -193,20 +343,26 @@ namespace GHelper
|
||||
return (200 * Math.Round((float)(MinRPM * 100 + (MaxRPM - MinRPM) * percentage) / 200)).ToString() + unit;
|
||||
}
|
||||
|
||||
void SetChart(Chart chart, int device)
|
||||
void SetChart(Chart chart, AsusFan device)
|
||||
{
|
||||
|
||||
string title;
|
||||
string title = "";
|
||||
|
||||
if (device == 1)
|
||||
title = Properties.Strings.FanProfileGPU;
|
||||
else if (device == 2)
|
||||
title = Properties.Strings.FanProfileMid;
|
||||
else
|
||||
title = Properties.Strings.FanProfileCPU;
|
||||
|
||||
if (Program.settingsForm.perfName.Length > 0)
|
||||
labelFans.Text = Properties.Strings.FanProfiles + ": " + Program.settingsForm.perfName;
|
||||
switch (device)
|
||||
{
|
||||
case AsusFan.CPU:
|
||||
title = Properties.Strings.FanProfileCPU;
|
||||
break;
|
||||
case AsusFan.GPU:
|
||||
title = Properties.Strings.FanProfileGPU;
|
||||
break;
|
||||
case AsusFan.Mid:
|
||||
title = Properties.Strings.FanProfileMid;
|
||||
break;
|
||||
case AsusFan.XGM:
|
||||
title = "XG Mobile";
|
||||
break;
|
||||
}
|
||||
|
||||
chart.Titles[0].Text = title;
|
||||
|
||||
@@ -215,7 +371,7 @@ namespace GHelper
|
||||
chart.ChartAreas[0].AxisX.Interval = 10;
|
||||
|
||||
chart.ChartAreas[0].AxisY.Minimum = 0;
|
||||
chart.ChartAreas[0].AxisY.Maximum = 100;
|
||||
chart.ChartAreas[0].AxisY.Maximum = fansMax;
|
||||
|
||||
chart.ChartAreas[0].AxisY.LabelStyle.Font = new Font("Arial", 7F);
|
||||
|
||||
@@ -224,10 +380,10 @@ namespace GHelper
|
||||
chart.ChartAreas[0].AxisX.LineColor = chartGrid;
|
||||
chart.ChartAreas[0].AxisY.LineColor = chartGrid;
|
||||
|
||||
for (int i = 0; i <= 90; i += 10)
|
||||
for (int i = 0; i <= fansMax - 10; i += 10)
|
||||
chart.ChartAreas[0].AxisY.CustomLabels.Add(i - 2, i + 2, ChartPercToRPM(i));
|
||||
|
||||
chart.ChartAreas[0].AxisY.CustomLabels.Add(98, 102, Properties.Strings.RPM);
|
||||
chart.ChartAreas[0].AxisY.CustomLabels.Add(fansMax - 2, fansMax + 2, Properties.Strings.RPM);
|
||||
|
||||
chart.ChartAreas[0].AxisY.Interval = 10;
|
||||
|
||||
@@ -236,7 +392,7 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
private void Fans_Shown(object? sender, EventArgs e)
|
||||
public void FormPosition()
|
||||
{
|
||||
if (Height > Program.settingsForm.Height)
|
||||
{
|
||||
@@ -244,15 +400,19 @@ namespace GHelper
|
||||
}
|
||||
else
|
||||
{
|
||||
MinimumSize = new Size(0, Program.settingsForm.Height);
|
||||
Size = MinimumSize = new Size(0, Program.settingsForm.Height);
|
||||
Height = Program.settingsForm.Height;
|
||||
Top = Program.settingsForm.Top;
|
||||
}
|
||||
|
||||
|
||||
Left = Program.settingsForm.Left - Width - 5;
|
||||
}
|
||||
|
||||
private void Fans_Shown(object? sender, EventArgs e)
|
||||
{
|
||||
FormPosition();
|
||||
}
|
||||
|
||||
|
||||
private void TrackPower_MouseUp(object? sender, MouseEventArgs e)
|
||||
{
|
||||
@@ -269,28 +429,20 @@ namespace GHelper
|
||||
|
||||
private void ComboBoost_Changed(object? sender, EventArgs e)
|
||||
{
|
||||
if (Program.config.getConfigPerf("auto_boost") != comboBoost.SelectedIndex)
|
||||
if (AppConfig.GetMode("auto_boost") != comboBoost.SelectedIndex)
|
||||
{
|
||||
NativeMethods.SetCPUBoost(comboBoost.SelectedIndex);
|
||||
Program.config.setConfigPerf("auto_boost", comboBoost.SelectedIndex);
|
||||
}
|
||||
AppConfig.SetMode("auto_boost", comboBoost.SelectedIndex);
|
||||
}
|
||||
|
||||
private void CheckApplyPower_Click(object? sender, EventArgs e)
|
||||
{
|
||||
if (sender is null) return;
|
||||
CheckBox chk = (CheckBox)sender;
|
||||
Program.config.setConfigPerf("auto_apply_power", chk.Checked ? 1 : 0);
|
||||
|
||||
if (chk.Checked)
|
||||
{
|
||||
Program.settingsForm.AutoPower();
|
||||
}
|
||||
else
|
||||
{
|
||||
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"), "PerfMode");
|
||||
Program.settingsForm.AutoFans();
|
||||
}
|
||||
AppConfig.SetMode("auto_apply_power", chk.Checked ? 1 : 0);
|
||||
Program.settingsForm.SetPerformanceMode();
|
||||
|
||||
}
|
||||
|
||||
@@ -299,17 +451,9 @@ namespace GHelper
|
||||
if (sender is null) return;
|
||||
CheckBox chk = (CheckBox)sender;
|
||||
|
||||
Program.config.setConfigPerf("auto_apply", chk.Checked ? 1 : 0);
|
||||
AppConfig.SetMode("auto_apply", chk.Checked ? 1 : 0);
|
||||
Program.settingsForm.SetPerformanceMode();
|
||||
|
||||
if (chk.Checked)
|
||||
{
|
||||
Program.settingsForm.AutoFans();
|
||||
}
|
||||
else
|
||||
{
|
||||
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"), "PerfMode");
|
||||
Program.settingsForm.AutoPower();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -334,51 +478,73 @@ namespace GHelper
|
||||
public void InitPower(bool changed = false)
|
||||
{
|
||||
|
||||
bool cpuBmode = (Program.wmi.DeviceGet(ASUSWmi.PPT_CPUB0) >= 0); // 2022 model +
|
||||
bool cpuAmode = (Program.wmi.DeviceGet(ASUSWmi.PPT_TotalA0) >= 0); // 2021 model +
|
||||
bool modeA0 = Program.acpi.DeviceGet(AsusACPI.PPT_TotalA0) >= 0;
|
||||
bool modeB0 = Program.acpi.IsAllAmdPPT();
|
||||
bool modeC1 = Program.acpi.DeviceGet(AsusACPI.PPT_APUC1) >= 0;
|
||||
|
||||
panelSliders.Visible = cpuAmode;
|
||||
panelCPU.Visible = cpuBmode;
|
||||
panelA0.Visible = modeA0;
|
||||
panelB0.Visible = modeB0;
|
||||
|
||||
// Yes, that's stupid, but Total slider on 2021 model actually adjusts CPU PPT
|
||||
if (!cpuBmode)
|
||||
|
||||
// All AMD version has B0 but doesn't have C0 (Nvidia GPU) settings
|
||||
if (modeB0)
|
||||
{
|
||||
labelPlatform.Text = "CPU SPPT";
|
||||
labelLeftA0.Text = "Platform (CPU + GPU)";
|
||||
labelLeftB0.Text = "CPU";
|
||||
panelC1.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
labelLeftA0.Text = "CPU Slow (SPL + sPPT)";
|
||||
labelLeftC1.Text = "CPU Fast (fPPT)";
|
||||
panelC1.Visible = modeC1;
|
||||
}
|
||||
|
||||
int limit_total;
|
||||
int limit_cpu;
|
||||
bool apply = Program.config.getConfigPerf("auto_apply_power") == 1;
|
||||
int limit_fast;
|
||||
|
||||
bool apply = AppConfig.IsMode("auto_apply_power");
|
||||
|
||||
if (changed)
|
||||
{
|
||||
limit_total = trackTotal.Value;
|
||||
limit_cpu = trackCPU.Value;
|
||||
limit_total = trackA0.Value;
|
||||
limit_cpu = trackB0.Value;
|
||||
limit_fast = trackC1.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
limit_total = Program.config.getConfigPerf("limit_total");
|
||||
limit_cpu = Program.config.getConfigPerf("limit_cpu");
|
||||
limit_total = AppConfig.GetMode("limit_total");
|
||||
limit_cpu = AppConfig.GetMode("limit_cpu");
|
||||
limit_fast = AppConfig.GetMode("limit_fast");
|
||||
}
|
||||
|
||||
if (limit_total < 0) limit_total = ASUSWmi.DefaultTotal;
|
||||
if (limit_total > ASUSWmi.MaxTotal) limit_total = ASUSWmi.MaxTotal;
|
||||
if (limit_total < ASUSWmi.MinTotal) limit_total = ASUSWmi.MinTotal;
|
||||
if (limit_total < 0) limit_total = AsusACPI.DefaultTotal;
|
||||
if (limit_total > AsusACPI.MaxTotal) limit_total = AsusACPI.MaxTotal;
|
||||
if (limit_total < AsusACPI.MinTotal) limit_total = AsusACPI.MinTotal;
|
||||
|
||||
if (limit_cpu < 0) limit_cpu = ASUSWmi.DefaultCPU;
|
||||
if (limit_cpu > ASUSWmi.MaxCPU) limit_cpu = ASUSWmi.MaxCPU;
|
||||
if (limit_cpu < ASUSWmi.MinCPU) limit_cpu = ASUSWmi.MinCPU;
|
||||
if (limit_cpu < 0) limit_cpu = AsusACPI.DefaultCPU;
|
||||
if (limit_cpu > AsusACPI.MaxCPU) limit_cpu = AsusACPI.MaxCPU;
|
||||
if (limit_cpu < AsusACPI.MinCPU) limit_cpu = AsusACPI.MinCPU;
|
||||
if (limit_cpu > limit_total) limit_cpu = limit_total;
|
||||
|
||||
trackTotal.Value = limit_total;
|
||||
trackCPU.Value = limit_cpu;
|
||||
if (limit_fast < 0) limit_fast = AsusACPI.DefaultTotal;
|
||||
if (limit_fast > AsusACPI.MaxTotal) limit_fast = AsusACPI.MaxTotal;
|
||||
if (limit_fast < AsusACPI.MinTotal) limit_fast = AsusACPI.MinTotal;
|
||||
|
||||
trackA0.Value = limit_total;
|
||||
trackB0.Value = limit_cpu;
|
||||
trackC1.Value = limit_fast;
|
||||
|
||||
checkApplyPower.Checked = apply;
|
||||
|
||||
labelTotal.Text = trackTotal.Value.ToString() + "W";
|
||||
labelCPU.Text = trackCPU.Value.ToString() + "W";
|
||||
labelA0.Text = trackA0.Value.ToString() + "W";
|
||||
labelB0.Text = trackB0.Value.ToString() + "W";
|
||||
labelC1.Text = trackC1.Value.ToString() + "W";
|
||||
|
||||
Program.config.setConfigPerf("limit_total", limit_total);
|
||||
Program.config.setConfigPerf("limit_cpu", limit_cpu);
|
||||
AppConfig.SetMode("limit_total", limit_total);
|
||||
AppConfig.SetMode("limit_cpu", limit_cpu);
|
||||
AppConfig.SetMode("limit_fast", limit_fast);
|
||||
|
||||
|
||||
}
|
||||
@@ -393,36 +559,59 @@ namespace GHelper
|
||||
public void InitFans()
|
||||
{
|
||||
|
||||
byte[] curve = Program.wmi.GetFanCurve(2);
|
||||
int chartCount = 2;
|
||||
|
||||
if (curve.All(singleByte => singleByte == 0))
|
||||
// Middle / system fan check
|
||||
if (!AsusACPI.IsEmptyCurve(Program.acpi.GetFanCurve(AsusFan.Mid)))
|
||||
{
|
||||
Program.config.setConfig("mid_fan", 0);
|
||||
|
||||
AppConfig.Set("mid_fan", 1);
|
||||
chartCount++;
|
||||
chartMid.Visible = true;
|
||||
SetChart(chartMid, AsusFan.Mid);
|
||||
LoadProfile(seriesMid, AsusFan.Mid);
|
||||
}
|
||||
else
|
||||
{
|
||||
Program.config.setConfig("mid_fan", 1);
|
||||
chartMid.Visible = true;
|
||||
SetChart(chartMid, 2);
|
||||
LoadProfile(seriesMid, 2);
|
||||
AppConfig.Set("mid_fan", 0);
|
||||
}
|
||||
|
||||
// XG Mobile Fan check
|
||||
if (Program.acpi.IsXGConnected())
|
||||
{
|
||||
AppConfig.Set("xgm_fan", 1);
|
||||
chartCount++;
|
||||
chartXGM.Visible = true;
|
||||
SetChart(chartXGM, AsusFan.XGM);
|
||||
LoadProfile(seriesXGM, AsusFan.XGM);
|
||||
}
|
||||
else
|
||||
{
|
||||
AppConfig.Set("xgm_fan", 0);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (chartCount > 2)
|
||||
Size = MinimumSize = new Size(0, (int)(ControlHelper.GetDpiScale(this).Value * (chartCount * 200 + 100)));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex);
|
||||
}
|
||||
|
||||
|
||||
SetChart(chartCPU, 0);
|
||||
SetChart(chartGPU, 1);
|
||||
SetChart(chartCPU, AsusFan.CPU);
|
||||
SetChart(chartGPU, AsusFan.GPU);
|
||||
|
||||
LoadProfile(seriesCPU, 0);
|
||||
LoadProfile(seriesGPU, 1);
|
||||
LoadProfile(seriesCPU, AsusFan.CPU);
|
||||
LoadProfile(seriesGPU, AsusFan.GPU);
|
||||
|
||||
int auto_apply = Program.config.getConfigPerf("auto_apply");
|
||||
|
||||
checkApplyFans.Checked = (auto_apply == 1);
|
||||
checkApplyFans.Checked = AppConfig.IsMode("auto_apply");
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LoadProfile(Series series, int device, int def = 0)
|
||||
void LoadProfile(Series series, AsusFan device, bool reset = false)
|
||||
{
|
||||
|
||||
series.ChartType = SeriesChartType.Line;
|
||||
@@ -431,14 +620,18 @@ namespace GHelper
|
||||
|
||||
series.Points.Clear();
|
||||
|
||||
int mode = Program.config.getConfig("performance_mode");
|
||||
byte[] curve = Program.config.getFanConfig(device);
|
||||
byte[] curve = AppConfig.GetFanConfig(device);
|
||||
|
||||
if (def == 1 || curve.Length != 16)
|
||||
curve = Program.wmi.GetFanCurve(device, mode);
|
||||
if (reset || AsusACPI.IsInvalidCurve(curve))
|
||||
{
|
||||
curve = Program.acpi.GetFanCurve(device, Modes.GetCurrentBase());
|
||||
|
||||
if (curve.Length != 16 || curve.All(singleByte => singleByte == 0))
|
||||
curve = Program.config.getDefaultCurve(device);
|
||||
if (AsusACPI.IsInvalidCurve(curve))
|
||||
curve = AppConfig.GetDefaultCurve(device);
|
||||
|
||||
curve = AsusACPI.FixFanCurve(curve);
|
||||
|
||||
}
|
||||
|
||||
//Debug.WriteLine(BitConverter.ToString(curve));
|
||||
|
||||
@@ -454,7 +647,7 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
void SaveProfile(Series series, int device)
|
||||
void SaveProfile(Series series, AsusFan device)
|
||||
{
|
||||
byte[] curve = new byte[16];
|
||||
int i = 0;
|
||||
@@ -465,7 +658,7 @@ namespace GHelper
|
||||
i++;
|
||||
}
|
||||
|
||||
Program.config.setFanConfig(device, curve);
|
||||
AppConfig.SetFanConfig(device, curve);
|
||||
//Program.wmi.SetFanCurve(device, curve);
|
||||
|
||||
}
|
||||
@@ -474,29 +667,60 @@ namespace GHelper
|
||||
private void ButtonReset_Click(object? sender, EventArgs e)
|
||||
{
|
||||
|
||||
LoadProfile(seriesCPU, 0, 1);
|
||||
LoadProfile(seriesGPU, 1, 1);
|
||||
if (Program.config.getConfig("mid_fan") == 1)
|
||||
LoadProfile(seriesMid, 2, 1);
|
||||
LoadProfile(seriesCPU, AsusFan.CPU, true);
|
||||
LoadProfile(seriesGPU, AsusFan.GPU, true);
|
||||
|
||||
if (AppConfig.Is("mid_fan"))
|
||||
LoadProfile(seriesMid, AsusFan.Mid, true);
|
||||
|
||||
if (AppConfig.Is("xgm_fan"))
|
||||
LoadProfile(seriesXGM, AsusFan.XGM, true);
|
||||
|
||||
checkApplyFans.Checked = false;
|
||||
checkApplyPower.Checked = false;
|
||||
|
||||
Program.config.setConfigPerf("auto_apply", 0);
|
||||
Program.config.setConfigPerf("auto_apply_power", 0);
|
||||
AppConfig.SetMode("auto_apply", 0);
|
||||
AppConfig.SetMode("auto_apply_power", 0);
|
||||
|
||||
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, Modes.GetCurrentBase(), "Mode");
|
||||
|
||||
if (Program.acpi.IsXGConnected())
|
||||
AsusUSB.ResetXGM();
|
||||
|
||||
if (gpuVisible)
|
||||
{
|
||||
trackGPUCore.Value = 0;
|
||||
trackGPUMemory.Value = 0;
|
||||
trackGPUBoost.Value = AsusACPI.MaxGPUBoost;
|
||||
trackGPUTemp.Value = AsusACPI.MaxGPUTemp;
|
||||
|
||||
AppConfig.SetMode("gpu_boost", trackGPUBoost.Value);
|
||||
AppConfig.SetMode("gpu_temp", trackGPUTemp.Value);
|
||||
AppConfig.SetMode("gpu_core", trackGPUCore.Value);
|
||||
AppConfig.SetMode("gpu_memory", trackGPUMemory.Value);
|
||||
|
||||
VisualiseGPUSettings();
|
||||
Program.settingsForm.SetGPUClocks(true);
|
||||
Program.settingsForm.SetGPUPower();
|
||||
}
|
||||
|
||||
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"), "PerfMode");
|
||||
}
|
||||
|
||||
private void ChartCPU_MouseUp(object? sender, MouseEventArgs e)
|
||||
{
|
||||
curPoint = null;
|
||||
curIndex = -1;
|
||||
|
||||
labelTip.Visible = false;
|
||||
|
||||
SaveProfile(seriesCPU, 0);
|
||||
SaveProfile(seriesGPU, 1);
|
||||
if (Program.config.getConfig("mid_fan") == 1)
|
||||
SaveProfile(seriesMid, 2);
|
||||
SaveProfile(seriesCPU, AsusFan.CPU);
|
||||
SaveProfile(seriesGPU, AsusFan.GPU);
|
||||
|
||||
if (AppConfig.Is("mid_fan"))
|
||||
SaveProfile(seriesMid, AsusFan.Mid);
|
||||
|
||||
if (AppConfig.Is("xgm_fan"))
|
||||
SaveProfile(seriesXGM, AsusFan.XGM);
|
||||
|
||||
Program.settingsForm.AutoFans();
|
||||
|
||||
@@ -516,9 +740,12 @@ namespace GHelper
|
||||
bool tip = false;
|
||||
|
||||
HitTestResult hit = chart.HitTest(e.X, e.Y);
|
||||
Series series = chart.Series[0];
|
||||
|
||||
if (hit.Series is not null && hit.PointIndex >= 0)
|
||||
{
|
||||
curPoint = hit.Series.Points[hit.PointIndex];
|
||||
curIndex = hit.PointIndex;
|
||||
curPoint = hit.Series.Points[curIndex];
|
||||
tip = true;
|
||||
}
|
||||
|
||||
@@ -537,7 +764,7 @@ namespace GHelper
|
||||
if (dx > 100) dx = 100;
|
||||
|
||||
if (dy < 0) dy = 0;
|
||||
if (dy > 100) dy = 100;
|
||||
if (dy > fansMax) dy = fansMax;
|
||||
|
||||
dymin = (dx - 65) * 1.2;
|
||||
|
||||
@@ -545,11 +772,18 @@ namespace GHelper
|
||||
|
||||
if (e.Button.HasFlag(MouseButtons.Left))
|
||||
{
|
||||
curPoint.XValue = dx;
|
||||
curPoint.YValues[0] = dy;
|
||||
double deltaY = dy - curPoint.YValues[0];
|
||||
double deltaX = dx - curPoint.XValue;
|
||||
|
||||
if (hit.Series is not null)
|
||||
AdjustAllLevels(hit.PointIndex, dx, dy, hit.Series);
|
||||
curPoint.XValue = dx;
|
||||
|
||||
if (Control.ModifierKeys == Keys.Shift)
|
||||
AdjustAll(0, deltaY, series);
|
||||
else
|
||||
{
|
||||
curPoint.YValues[0] = dy;
|
||||
AdjustAllLevels(curIndex, dx, dy, series);
|
||||
}
|
||||
|
||||
tip = true;
|
||||
}
|
||||
@@ -572,6 +806,15 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
private void AdjustAll(double deltaX, double deltaY, Series series)
|
||||
{
|
||||
for (int i = 0; i < series.Points.Count; i++)
|
||||
{
|
||||
series.Points[i].XValue = Math.Max(20, Math.Min(100, series.Points[i].XValue + deltaX));
|
||||
series.Points[i].YValues[0] = Math.Max(0, Math.Min(100, series.Points[i].YValues[0] + deltaY));
|
||||
}
|
||||
}
|
||||
|
||||
private void AdjustAllLevels(int index, double curXVal, double curYVal, Series series)
|
||||
{
|
||||
|
||||
|
||||
@@ -1,4 +1,64 @@
|
||||
<root>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<AssemblyVersion>0.58</AssemblyVersion>
|
||||
<AssemblyVersion>0.84</AssemblyVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
@@ -59,8 +59,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FftSharp" Version="2.0.0" />
|
||||
<PackageReference Include="hidlibrary" Version="3.3.40" />
|
||||
<PackageReference Include="HidSharpCore" Version="1.2.1.1" />
|
||||
<PackageReference Include="NAudio" Version="2.1.0" />
|
||||
<PackageReference Include="System.Management" Version="7.0.1" />
|
||||
<PackageReference Include="TaskScheduler" Version="2.10.1" />
|
||||
<PackageReference Include="WinForms.DataVisualization" Version="1.8.0" />
|
||||
|
||||
@@ -1,10 +1,37 @@
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using static AmdAdl2.Adl2.NativeMethods;
|
||||
|
||||
namespace AmdAdl2;
|
||||
|
||||
#region Export Struct
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
public struct ADLSGApplicationInfo
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public string strFileName;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public string strFilePath;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public string strVersion;
|
||||
|
||||
public long timeStamp;
|
||||
public uint iProfileExists;
|
||||
public uint iGPUAffinity;
|
||||
public ADLBdf GPUBdf;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct ADLBdf
|
||||
{
|
||||
public int iBus;
|
||||
public int iDevice;
|
||||
public int iFunction;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct ADLSingleSensorData {
|
||||
public int Supported;
|
||||
@@ -481,5 +508,71 @@ public class Adl2 {
|
||||
|
||||
[DllImport(Atiadlxx_FileName)]
|
||||
public static extern int ADL2_Adapter_ASICFamilyType_Get(IntPtr adlContextHandle, int adapterIndex, out ADLAsicFamilyType asicFamilyType, out int asicFamilyTypeValids);
|
||||
|
||||
[DllImport(Atiadlxx_FileName)]
|
||||
public static extern int ADL2_SwitchableGraphics_Applications_Get(
|
||||
IntPtr context,
|
||||
int iListType,
|
||||
out int lpNumApps,
|
||||
out IntPtr lppAppList);
|
||||
|
||||
[DllImport(Atiadlxx_FileName)]
|
||||
public static extern int ADL2_Adapter_VariBright_Caps(
|
||||
IntPtr context,
|
||||
int iAdapterIndex,
|
||||
out int iSupported,
|
||||
out int iEnabled,
|
||||
out int iVersion);
|
||||
|
||||
[DllImport(Atiadlxx_FileName)]
|
||||
public static extern int ADL2_Adapter_VariBrightEnable_Set(
|
||||
IntPtr context,
|
||||
int iAdapterIndex,
|
||||
int iEnabled);
|
||||
|
||||
// Clocks
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct ADLODNPerformanceLevel
|
||||
{
|
||||
public int iClock;
|
||||
public int iVddc;
|
||||
public int iEnabled;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct ADLODNPerformanceLevels
|
||||
{
|
||||
public int iSize;
|
||||
public int iMode;
|
||||
public int iNumberOfPerformanceLevels;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public ADLODNPerformanceLevel[] aLevels;
|
||||
}
|
||||
|
||||
|
||||
[DllImport(Atiadlxx_FileName)]
|
||||
public static extern int ADL2_OverdriveN_SystemClocks_Get(
|
||||
IntPtr context,
|
||||
int adapterIndex,
|
||||
ref ADLODNPerformanceLevels performanceLevels);
|
||||
|
||||
[DllImport(Atiadlxx_FileName)]
|
||||
public static extern int ADL2_OverdriveN_SystemClocks_Set(
|
||||
IntPtr context,
|
||||
int adapterIndex,
|
||||
ref ADLODNPerformanceLevels performanceLevels);
|
||||
|
||||
[DllImport(Atiadlxx_FileName)]
|
||||
public static extern int ADL2_OverdriveN_MemoryClocks_Get(
|
||||
IntPtr context,
|
||||
int adapterIndex,
|
||||
ref ADLODNPerformanceLevels performanceLevels);
|
||||
|
||||
[DllImport(Atiadlxx_FileName)]
|
||||
public static extern int ADL2_OverdriveN_MemoryClocks_Set(
|
||||
IntPtr context,
|
||||
int adapterIndex,
|
||||
ref ADLODNPerformanceLevels performanceLevels);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,75 +1,92 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using AmdAdl2;
|
||||
using System.Runtime.InteropServices;
|
||||
using static AmdAdl2.Adl2.NativeMethods;
|
||||
|
||||
namespace GHelper.Gpu;
|
||||
|
||||
// Reference: https://github.com/GPUOpen-LibrariesAndSDKs/display-library/blob/master/Sample-Managed/Program.cs
|
||||
public class AmdGpuControl : IGpuControl {
|
||||
public class AmdGpuControl : IGpuControl
|
||||
{
|
||||
private bool _isReady;
|
||||
private IntPtr _adlContextHandle;
|
||||
private readonly ADLAdapterInfo _internalDiscreteAdapter;
|
||||
|
||||
public bool IsNvidia => false;
|
||||
|
||||
public string FullName => _internalDiscreteAdapter!.AdapterName;
|
||||
|
||||
public AmdGpuControl() {
|
||||
private ADLAdapterInfo? FindByType(ADLAsicFamilyType type = ADLAsicFamilyType.Discrete)
|
||||
{
|
||||
ADL2_Adapter_NumberOfAdapters_Get(_adlContextHandle, out int numberOfAdapters);
|
||||
if (numberOfAdapters <= 0)
|
||||
return null;
|
||||
|
||||
ADLAdapterInfoArray osAdapterInfoData = new();
|
||||
int osAdapterInfoDataSize = Marshal.SizeOf(osAdapterInfoData);
|
||||
IntPtr AdapterBuffer = Marshal.AllocCoTaskMem(osAdapterInfoDataSize);
|
||||
Marshal.StructureToPtr(osAdapterInfoData, AdapterBuffer, false);
|
||||
if (ADL2_Adapter_AdapterInfo_Get(_adlContextHandle, AdapterBuffer, osAdapterInfoDataSize) != Adl2.ADL_SUCCESS)
|
||||
return null;
|
||||
|
||||
osAdapterInfoData = (ADLAdapterInfoArray)Marshal.PtrToStructure(AdapterBuffer, osAdapterInfoData.GetType())!;
|
||||
|
||||
const int amdVendorId = 1002;
|
||||
|
||||
// Determine which GPU is internal discrete AMD GPU
|
||||
ADLAdapterInfo internalDiscreteAdapter =
|
||||
osAdapterInfoData.ADLAdapterInfo
|
||||
.FirstOrDefault(adapter =>
|
||||
{
|
||||
if (adapter.Exist == 0 || adapter.Present == 0)
|
||||
return false;
|
||||
|
||||
if (adapter.VendorID != amdVendorId)
|
||||
return false;
|
||||
|
||||
if (ADL2_Adapter_ASICFamilyType_Get(_adlContextHandle, adapter.AdapterIndex, out ADLAsicFamilyType asicFamilyType, out int asicFamilyTypeValids) != Adl2.ADL_SUCCESS)
|
||||
return false;
|
||||
|
||||
asicFamilyType = (ADLAsicFamilyType)((int)asicFamilyType & asicFamilyTypeValids);
|
||||
|
||||
return (asicFamilyType & type) != 0;
|
||||
});
|
||||
|
||||
if (internalDiscreteAdapter.Exist == 0)
|
||||
return null;
|
||||
|
||||
return internalDiscreteAdapter;
|
||||
|
||||
}
|
||||
|
||||
public AmdGpuControl()
|
||||
{
|
||||
if (!Adl2.Load())
|
||||
return;
|
||||
|
||||
if (Adl2.ADL2_Main_Control_Create(1, out _adlContextHandle) != Adl2.ADL_SUCCESS)
|
||||
return;
|
||||
|
||||
Adl2.NativeMethods.ADL2_Adapter_NumberOfAdapters_Get(_adlContextHandle, out int numberOfAdapters);
|
||||
if (numberOfAdapters <= 0)
|
||||
return;
|
||||
ADLAdapterInfo? internalDiscreteAdapter = FindByType(ADLAsicFamilyType.Discrete);
|
||||
|
||||
ADLAdapterInfoArray osAdapterInfoData = new();
|
||||
int osAdapterInfoDataSize = Marshal.SizeOf(osAdapterInfoData);
|
||||
IntPtr AdapterBuffer = Marshal.AllocCoTaskMem(osAdapterInfoDataSize);
|
||||
Marshal.StructureToPtr(osAdapterInfoData, AdapterBuffer, false);
|
||||
if (Adl2.NativeMethods.ADL2_Adapter_AdapterInfo_Get(_adlContextHandle, AdapterBuffer, osAdapterInfoDataSize) != Adl2.ADL_SUCCESS)
|
||||
return;
|
||||
if (internalDiscreteAdapter is not null)
|
||||
{
|
||||
_internalDiscreteAdapter = (ADLAdapterInfo)internalDiscreteAdapter;
|
||||
_isReady = true;
|
||||
}
|
||||
|
||||
osAdapterInfoData = (ADLAdapterInfoArray) Marshal.PtrToStructure(AdapterBuffer, osAdapterInfoData.GetType())!;
|
||||
|
||||
const int amdVendorId = 1002;
|
||||
|
||||
// Determine which GPU is internal discrete AMD GPU
|
||||
ADLAdapterInfo internalDiscreteAdapter =
|
||||
osAdapterInfoData.ADLAdapterInfo
|
||||
.FirstOrDefault(adapter => {
|
||||
if (adapter.Exist == 0 || adapter.Present == 0)
|
||||
return false;
|
||||
|
||||
if (adapter.VendorID != amdVendorId)
|
||||
return false;
|
||||
|
||||
if (Adl2.NativeMethods.ADL2_Adapter_ASICFamilyType_Get(_adlContextHandle, adapter.AdapterIndex, out ADLAsicFamilyType asicFamilyType, out int asicFamilyTypeValids) != Adl2.ADL_SUCCESS)
|
||||
return false;
|
||||
|
||||
asicFamilyType = (ADLAsicFamilyType) ((int) asicFamilyType & asicFamilyTypeValids);
|
||||
|
||||
// FIXME: is this correct for G14 2022?
|
||||
return (asicFamilyType & ADLAsicFamilyType.Discrete) != 0;
|
||||
});
|
||||
|
||||
if (internalDiscreteAdapter.Exist == 0)
|
||||
return;
|
||||
|
||||
_internalDiscreteAdapter = internalDiscreteAdapter;
|
||||
_isReady = true;
|
||||
}
|
||||
|
||||
public bool IsValid => _isReady && _adlContextHandle != IntPtr.Zero;
|
||||
|
||||
public int? GetCurrentTemperature() {
|
||||
public int? GetCurrentTemperature()
|
||||
{
|
||||
if (!IsValid)
|
||||
return null;
|
||||
|
||||
if (Adl2.NativeMethods.ADL2_New_QueryPMLogData_Get(_adlContextHandle, _internalDiscreteAdapter.AdapterIndex, out ADLPMLogDataOutput adlpmLogDataOutput) != Adl2.ADL_SUCCESS)
|
||||
|
||||
if (ADL2_New_QueryPMLogData_Get(_adlContextHandle, _internalDiscreteAdapter.AdapterIndex, out ADLPMLogDataOutput adlpmLogDataOutput) != Adl2.ADL_SUCCESS)
|
||||
return null;
|
||||
|
||||
ADLSingleSensorData temperatureSensor = adlpmLogDataOutput.Sensors[(int) ADLSensorType.PMLOG_TEMPERATURE_EDGE];
|
||||
|
||||
ADLSingleSensorData temperatureSensor = adlpmLogDataOutput.Sensors[(int)ADLSensorType.PMLOG_TEMPERATURE_EDGE];
|
||||
if (temperatureSensor.Supported == 0)
|
||||
return null;
|
||||
|
||||
@@ -79,10 +96,9 @@ public class AmdGpuControl : IGpuControl {
|
||||
|
||||
public int? GetGpuUse()
|
||||
{
|
||||
if (!IsValid)
|
||||
return null;
|
||||
if (!IsValid) return null;
|
||||
|
||||
if (Adl2.NativeMethods.ADL2_New_QueryPMLogData_Get(_adlContextHandle, _internalDiscreteAdapter.AdapterIndex, out ADLPMLogDataOutput adlpmLogDataOutput) != Adl2.ADL_SUCCESS)
|
||||
if (ADL2_New_QueryPMLogData_Get(_adlContextHandle, _internalDiscreteAdapter.AdapterIndex, out ADLPMLogDataOutput adlpmLogDataOutput) != Adl2.ADL_SUCCESS)
|
||||
return null;
|
||||
|
||||
ADLSingleSensorData gpuUsage = adlpmLogDataOutput.Sensors[(int)ADLSensorType.PMLOG_INFO_ACTIVITY_GFX];
|
||||
@@ -94,20 +110,125 @@ public class AmdGpuControl : IGpuControl {
|
||||
}
|
||||
|
||||
|
||||
private void ReleaseUnmanagedResources() {
|
||||
if (_adlContextHandle != IntPtr.Zero) {
|
||||
Adl2.NativeMethods.ADL2_Main_Control_Destroy(_adlContextHandle);
|
||||
public bool SetVariBright(int enabled)
|
||||
{
|
||||
if (_adlContextHandle == IntPtr.Zero) return false;
|
||||
|
||||
ADLAdapterInfo? iGPU = FindByType(ADLAsicFamilyType.Integrated);
|
||||
if (iGPU is null) return false;
|
||||
|
||||
return ADL2_Adapter_VariBrightEnable_Set(_adlContextHandle, ((ADLAdapterInfo)iGPU).AdapterIndex, enabled) == Adl2.ADL_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
public bool GetVariBright(out int supported, out int enabled)
|
||||
{
|
||||
supported = enabled = -1;
|
||||
|
||||
if (_adlContextHandle == IntPtr.Zero) return false;
|
||||
|
||||
ADLAdapterInfo? iGPU = FindByType(ADLAsicFamilyType.Integrated);
|
||||
if (iGPU is null) return false;
|
||||
|
||||
if (ADL2_Adapter_VariBright_Caps(_adlContextHandle, ((ADLAdapterInfo)iGPU).AdapterIndex, out int supportedOut, out int enabledOut, out int version) != Adl2.ADL_SUCCESS)
|
||||
return false;
|
||||
|
||||
supported = supportedOut;
|
||||
enabled = enabledOut;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public ADLODNPerformanceLevels? GetGPUClocks()
|
||||
{
|
||||
if (!IsValid) return null;
|
||||
|
||||
ADLODNPerformanceLevels performanceLevels = new();
|
||||
ADL2_OverdriveN_SystemClocks_Get(_adlContextHandle, _internalDiscreteAdapter.AdapterIndex, ref performanceLevels);
|
||||
|
||||
return performanceLevels;
|
||||
}
|
||||
|
||||
public void KillGPUApps()
|
||||
{
|
||||
|
||||
if (!IsValid) return;
|
||||
|
||||
IntPtr appInfoPtr = IntPtr.Zero;
|
||||
int appCount = 0;
|
||||
|
||||
try
|
||||
{
|
||||
// Get switchable graphics applications information
|
||||
var result = ADL2_SwitchableGraphics_Applications_Get(_adlContextHandle, 2, out appCount, out appInfoPtr);
|
||||
if (result != 0)
|
||||
{
|
||||
throw new Exception("Failed to get switchable graphics applications. Error code: " + result);
|
||||
}
|
||||
|
||||
// Convert the application data pointers to an array of structs
|
||||
var appInfoArray = new ADLSGApplicationInfo[appCount];
|
||||
IntPtr currentPtr = appInfoPtr;
|
||||
|
||||
for (int i = 0; i < appCount; i++)
|
||||
{
|
||||
appInfoArray[i] = Marshal.PtrToStructure<ADLSGApplicationInfo>(currentPtr);
|
||||
currentPtr = IntPtr.Add(currentPtr, Marshal.SizeOf<ADLSGApplicationInfo>());
|
||||
}
|
||||
|
||||
var appNames = new List<string>();
|
||||
|
||||
for (int i = 0; i < appCount; i++)
|
||||
{
|
||||
if (appInfoArray[i].iGPUAffinity == 1)
|
||||
{
|
||||
Logger.WriteLine(appInfoArray[i].strFileName + ":" + appInfoArray[i].iGPUAffinity + "(" + appInfoArray[i].timeStamp + ")");
|
||||
appNames.Add(Path.GetFileNameWithoutExtension(appInfoArray[i].strFileName));
|
||||
}
|
||||
}
|
||||
|
||||
List<string> immune = new() { "svchost", "system", "ntoskrnl", "csrss", "winlogon", "wininit", "smss" };
|
||||
|
||||
foreach (string kill in appNames)
|
||||
if (!immune.Contains(kill.ToLower()))
|
||||
ProcessHelper.KillByName(kill);
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WriteLine(ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Clean up resources
|
||||
if (appInfoPtr != IntPtr.Zero)
|
||||
{
|
||||
Marshal.FreeCoTaskMem(appInfoPtr);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ReleaseUnmanagedResources()
|
||||
{
|
||||
if (_adlContextHandle != IntPtr.Zero)
|
||||
{
|
||||
ADL2_Main_Control_Destroy(_adlContextHandle);
|
||||
_adlContextHandle = IntPtr.Zero;
|
||||
_isReady = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
public void Dispose()
|
||||
{
|
||||
ReleaseUnmanagedResources();
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
~AmdGpuControl() {
|
||||
~AmdGpuControl()
|
||||
{
|
||||
ReleaseUnmanagedResources();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
namespace GHelper.Gpu;
|
||||
|
||||
public interface IGpuControl : IDisposable {
|
||||
public interface IGpuControl : IDisposable {
|
||||
bool IsNvidia { get; }
|
||||
bool IsValid { get; }
|
||||
public string FullName { get; }
|
||||
int? GetCurrentTemperature();
|
||||
int? GetGpuUse();
|
||||
void KillGPUApps();
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using NvAPIWrapper.Native;
|
||||
using NvAPIWrapper.Native.GPU;
|
||||
using NvAPIWrapper.Native.GPU.Structures;
|
||||
using NvAPIWrapper.Native.Interfaces.GPU;
|
||||
using System.Diagnostics;
|
||||
using static NvAPIWrapper.Native.GPU.Structures.PerformanceStates20InfoV1;
|
||||
|
||||
namespace GHelper.Gpu;
|
||||
@@ -16,7 +17,7 @@ public class NvidiaGpuControl : IGpuControl
|
||||
public const int MinCoreOffset = -250;
|
||||
public const int MinMemoryOffset = -250;
|
||||
|
||||
private readonly PhysicalGPU? _internalGpu;
|
||||
private static PhysicalGPU? _internalGpu;
|
||||
|
||||
public NvidiaGpuControl()
|
||||
{
|
||||
@@ -27,10 +28,11 @@ public class NvidiaGpuControl : IGpuControl
|
||||
|
||||
public bool IsNvidia => IsValid;
|
||||
|
||||
public string FullName => _internalGpu!.FullName;
|
||||
|
||||
public int? GetCurrentTemperature()
|
||||
{
|
||||
if (!IsValid)
|
||||
return null;
|
||||
if (!IsValid) return null;
|
||||
|
||||
PhysicalGPU internalGpu = _internalGpu!;
|
||||
IThermalSensor? gpuSensor =
|
||||
@@ -44,26 +46,73 @@ public class NvidiaGpuControl : IGpuControl
|
||||
{
|
||||
}
|
||||
|
||||
public void KillGPUApps()
|
||||
{
|
||||
|
||||
if (!IsValid) return;
|
||||
PhysicalGPU internalGpu = _internalGpu!;
|
||||
|
||||
try
|
||||
{
|
||||
Process[] processes = internalGpu.GetActiveApplications();
|
||||
foreach (Process process in processes) ProcessHelper.KillByProcess(process);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WriteLine(ex.Message);
|
||||
}
|
||||
|
||||
//NVIDIA.RestartDisplayDriver();
|
||||
}
|
||||
|
||||
|
||||
public void GetClocks(out int core, out int memory)
|
||||
public int GetClocks(out int core, out int memory)
|
||||
{
|
||||
PhysicalGPU internalGpu = _internalGpu!;
|
||||
Logger.WriteLine(internalGpu.FullName);
|
||||
Logger.WriteLine(internalGpu.ArchitectInformation.ToString());
|
||||
|
||||
IPerformanceStates20Info states = GPUApi.GetPerformanceStates20(internalGpu.Handle);
|
||||
//Logger.WriteLine(internalGpu.FullName);
|
||||
//Logger.WriteLine(internalGpu.ArchitectInformation.ToString());
|
||||
|
||||
Logger.WriteLine("IPerformanceStates20Info type : " + states.GetType());
|
||||
try
|
||||
{
|
||||
IPerformanceStates20Info states = GPUApi.GetPerformanceStates20(internalGpu.Handle);
|
||||
core = states.Clocks[PerformanceStateId.P0_3DPerformance][0].FrequencyDeltaInkHz.DeltaValue / 1000;
|
||||
memory = states.Clocks[PerformanceStateId.P0_3DPerformance][1].FrequencyDeltaInkHz.DeltaValue / 1000;
|
||||
Logger.WriteLine($"GET GPU CLOCKS: {core}, {memory}");
|
||||
return 0;
|
||||
|
||||
core = states.Clocks[PerformanceStateId.P0_3DPerformance][0].FrequencyDeltaInkHz.DeltaValue / 1000;
|
||||
memory = states.Clocks[PerformanceStateId.P0_3DPerformance][1].FrequencyDeltaInkHz.DeltaValue / 1000;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WriteLine("GET GPU CLOCKS:" + ex.Message);
|
||||
core = memory = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public bool RestartGPU()
|
||||
{
|
||||
try
|
||||
{
|
||||
string script = @"$device = Get-PnpDevice | Where-Object { $_.FriendlyName -imatch 'NVIDIA' -and $_.Class -eq 'Display' }; Disable-PnpDevice $device.InstanceId -Confirm:$false; Start-Sleep -Seconds 3; Enable-PnpDevice $device.InstanceId -Confirm:$false";
|
||||
Logger.WriteLine(script);
|
||||
ProcessHelper.RunCMD("powershell", script);
|
||||
//Thread.Sleep(2000);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WriteLine(ex.ToString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int SetClocksFromConfig()
|
||||
{
|
||||
int core = Program.config.getConfig("gpu_core");
|
||||
int memory = Program.config.getConfig("gpu_memory");
|
||||
int core = AppConfig.Get("gpu_core",0);
|
||||
int memory = AppConfig.Get("gpu_memory",0);
|
||||
int status = SetClocks(core, memory);
|
||||
return status;
|
||||
}
|
||||
@@ -79,7 +128,7 @@ public class NvidiaGpuControl : IGpuControl
|
||||
var coreClock = new PerformanceStates20ClockEntryV1(PublicClockDomain.Graphics, new PerformanceStates20ParameterDelta(core * 1000));
|
||||
var memoryClock = new PerformanceStates20ClockEntryV1(PublicClockDomain.Memory, new PerformanceStates20ParameterDelta(memory * 1000));
|
||||
|
||||
PerformanceStates20ClockEntryV1[] clocks = { coreClock , memoryClock};
|
||||
PerformanceStates20ClockEntryV1[] clocks = { coreClock, memoryClock };
|
||||
PerformanceStates20BaseVoltageEntryV1[] voltages = { };
|
||||
|
||||
PerformanceState20[] performanceStates = { new PerformanceState20(PerformanceStateId.P0_3DPerformance, clocks, voltages) };
|
||||
@@ -88,11 +137,12 @@ public class NvidiaGpuControl : IGpuControl
|
||||
|
||||
try
|
||||
{
|
||||
Logger.WriteLine($"SET GPU CLOCKS: {core}, {memory}");
|
||||
GPUApi.SetPerformanceStates20(internalGpu.Handle, overclock);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WriteLine(ex.ToString());
|
||||
Logger.WriteLine("SET GPU CLOCKS: " + ex.Message);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -111,7 +161,7 @@ public class NvidiaGpuControl : IGpuControl
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WriteLine(ex.ToString());
|
||||
Debug.WriteLine(ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using GHelper.Gpu;
|
||||
using System.Diagnostics;
|
||||
|
||||
public static class HardwareMonitor
|
||||
public static class HardwareControl
|
||||
{
|
||||
public static IGpuControl? GpuControl;
|
||||
|
||||
@@ -19,16 +19,19 @@ public static class HardwareMonitor
|
||||
public static int GetFanMax()
|
||||
{
|
||||
int max = 58;
|
||||
if (Program.config.ContainsModel("401")) max = 72;
|
||||
else if (Program.config.ContainsModel("503")) max = 68;
|
||||
return Math.Max(max, Program.config.getConfig("fan_max"));
|
||||
int configMax = AppConfig.Get("fan_max");
|
||||
if (configMax > 100) configMax = 0; // skipping inadvequate settings
|
||||
|
||||
if (AppConfig.ContainsModel("401")) max = 72;
|
||||
else if (AppConfig.ContainsModel("503")) max = 68;
|
||||
return Math.Max(max, configMax);
|
||||
}
|
||||
|
||||
public static void SetFanMax(int fan)
|
||||
{
|
||||
Program.config.setConfig("fan_max", fan);
|
||||
AppConfig.Set("fan_max", fan);
|
||||
}
|
||||
private static string FormatFan(int fan)
|
||||
public static string FormatFan(int fan)
|
||||
{
|
||||
// fix for old models
|
||||
if (fan < 0)
|
||||
@@ -38,12 +41,12 @@ public static class HardwareMonitor
|
||||
}
|
||||
|
||||
int fanMax = GetFanMax();
|
||||
if (fan > fanMax) SetFanMax(fan);
|
||||
if (fan > fanMax && fan < 110) SetFanMax(fan);
|
||||
|
||||
if (Program.config.getConfig("fan_rpm") == 1)
|
||||
return " Fan: " + (fan * 100).ToString() + "RPM";
|
||||
if (AppConfig.Is("fan_rpm"))
|
||||
return GHelper.Properties.Strings.FanSpeed + (fan * 100).ToString() + "RPM";
|
||||
else
|
||||
return " Fan: " + Math.Min(Math.Round((float)fan / fanMax * 100), 100).ToString() + "%"; // relatively to 6000 rpm
|
||||
return GHelper.Properties.Strings.FanSpeed + Math.Min(Math.Round((float)fan / fanMax * 100), 100).ToString() + "%"; // relatively to 6000 rpm
|
||||
}
|
||||
|
||||
private static int GetGpuUse()
|
||||
@@ -51,6 +54,7 @@ public static class HardwareMonitor
|
||||
try
|
||||
{
|
||||
int? gpuUse = GpuControl?.GetGpuUse();
|
||||
Logger.WriteLine("GPU usage: " + GpuControl?.FullName + " " + gpuUse + "%");
|
||||
if (gpuUse is not null) return (int)gpuUse;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -68,11 +72,11 @@ public static class HardwareMonitor
|
||||
gpuTemp = -1;
|
||||
gpuUse = -1;
|
||||
|
||||
cpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan));
|
||||
gpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.GPU_Fan));
|
||||
midFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.Mid_Fan));
|
||||
cpuFan = FormatFan(Program.acpi.DeviceGet(AsusACPI.CPU_Fan));
|
||||
gpuFan = FormatFan(Program.acpi.DeviceGet(AsusACPI.GPU_Fan));
|
||||
midFan = FormatFan(Program.acpi.DeviceGet(AsusACPI.Mid_Fan));
|
||||
|
||||
cpuTemp = Program.wmi.DeviceGet(ASUSWmi.Temp_CPU);
|
||||
cpuTemp = Program.acpi.DeviceGet(AsusACPI.Temp_CPU);
|
||||
|
||||
if (cpuTemp < 0) try
|
||||
{
|
||||
@@ -81,9 +85,9 @@ public static class HardwareMonitor
|
||||
cpuTemp = ct.NextValue() - 273;
|
||||
}
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("Failed reading CPU temp");
|
||||
Debug.WriteLine("Failed reading CPU temp :" + ex.Message);
|
||||
}
|
||||
|
||||
try
|
||||
@@ -94,12 +98,11 @@ public static class HardwareMonitor
|
||||
catch (Exception ex)
|
||||
{
|
||||
gpuTemp = -1;
|
||||
Debug.WriteLine("Failed reading GPU temp");
|
||||
Debug.WriteLine(ex.ToString());
|
||||
Debug.WriteLine("Failed reading GPU temp :" + ex.Message);
|
||||
}
|
||||
|
||||
if (gpuTemp is null || gpuTemp < 0)
|
||||
gpuTemp = Program.wmi.DeviceGet(ASUSWmi.Temp_GPU);
|
||||
gpuTemp = Program.acpi.DeviceGet(AsusACPI.Temp_GPU);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -114,7 +117,7 @@ public static class HardwareMonitor
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsUsedGPU(int threshold = 20)
|
||||
public static bool IsUsedGPU(int threshold = 10)
|
||||
{
|
||||
if (GetGpuUse() > threshold)
|
||||
{
|
||||
@@ -124,9 +127,17 @@ public static class HardwareMonitor
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static NvidiaGpuControl? GetNvidiaGpuControl()
|
||||
{
|
||||
if ((bool)GpuControl?.IsNvidia)
|
||||
return (NvidiaGpuControl)GpuControl;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void RecreateGpuControlWithDelay(int delay = 5)
|
||||
{
|
||||
|
||||
// Re-enabling the discrete GPU takes a bit of time,
|
||||
// so a simple workaround is to refresh again after that happens
|
||||
Task.Run(async () =>
|
||||
@@ -134,9 +145,6 @@ public static class HardwareMonitor
|
||||
await Task.Delay(TimeSpan.FromSeconds(delay));
|
||||
RecreateGpuControl();
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void RecreateGpuControl()
|
||||
@@ -145,32 +153,54 @@ public static class HardwareMonitor
|
||||
{
|
||||
GpuControl?.Dispose();
|
||||
|
||||
// Detect valid GPU temperature provider.
|
||||
// We start with NVIDIA because there's always at least an integrated AMD GPU
|
||||
IGpuControl _gpuControl = new NvidiaGpuControl();
|
||||
|
||||
if (_gpuControl.IsValid)
|
||||
{
|
||||
GpuControl = _gpuControl;
|
||||
Logger.WriteLine(GpuControl.FullName);
|
||||
return;
|
||||
}
|
||||
|
||||
_gpuControl.Dispose();
|
||||
|
||||
/*
|
||||
_gpuControl = new AmdGpuControl();
|
||||
if (_gpuControl.IsValid)
|
||||
{
|
||||
GpuControl = _gpuControl;
|
||||
Logger.WriteLine(GpuControl.FullName);
|
||||
return;
|
||||
}
|
||||
_gpuControl.Dispose();
|
||||
*/
|
||||
|
||||
GpuControl = null;
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void KillGPUApps()
|
||||
{
|
||||
|
||||
List<string> tokill = new() { "EADesktop", "RadeonSoftware", "epicgameslauncher", "ASUSSmartDisplayControl" };
|
||||
|
||||
if (AppConfig.Is("kill_gpu_apps"))
|
||||
{
|
||||
tokill.Add("nvdisplay.container");
|
||||
tokill.Add("nvcontainer");
|
||||
tokill.Add("nvcplui");
|
||||
}
|
||||
|
||||
foreach (string kill in tokill) ProcessHelper.KillByName(kill);
|
||||
|
||||
if (AppConfig.Is("kill_gpu_apps") && GpuControl is not null)
|
||||
{
|
||||
GpuControl.KillGPUApps();
|
||||
}
|
||||
}
|
||||
}
|
||||
539
app/InputDispatcher.cs
Normal file
539
app/InputDispatcher.cs
Normal file
@@ -0,0 +1,539 @@
|
||||
using HidLibrary;
|
||||
using Microsoft.Win32;
|
||||
using NAudio.CoreAudioApi;
|
||||
using System.Diagnostics;
|
||||
using System.Management;
|
||||
|
||||
namespace GHelper
|
||||
{
|
||||
public class KeyboardListener
|
||||
{
|
||||
|
||||
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
public KeyboardListener(Action<int> KeyHandler)
|
||||
{
|
||||
HidDevice? input = AsusUSB.GetDevice();
|
||||
if (input == null) return;
|
||||
|
||||
Logger.WriteLine($"Input: {input.DevicePath}");
|
||||
|
||||
var task = Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
while (!cancellationTokenSource.Token.IsCancellationRequested)
|
||||
{
|
||||
var data = input.Read().Data;
|
||||
if (data.Length > 1 && data[0] == AsusUSB.INPUT_HID_ID && data[1] > 0)
|
||||
{
|
||||
Logger.WriteLine($"Key: {data[1]}");
|
||||
KeyHandler(data[1]);
|
||||
}
|
||||
}
|
||||
Logger.WriteLine("Listener stopped");
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WriteLine(ex.ToString());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
cancellationTokenSource?.Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class InputDispatcher
|
||||
{
|
||||
System.Timers.Timer timer = new System.Timers.Timer(1000);
|
||||
public bool backlightActivity = true;
|
||||
|
||||
public static Keys keyProfile = Keys.F5;
|
||||
public static Keys keyApp = Keys.F12;
|
||||
|
||||
KeyboardListener listener;
|
||||
KeyboardHook hook = new KeyboardHook();
|
||||
|
||||
public InputDispatcher()
|
||||
{
|
||||
|
||||
byte[] result = Program.acpi.DeviceInit();
|
||||
Debug.WriteLine($"Init: {BitConverter.ToString(result)}");
|
||||
|
||||
Program.acpi.SubscribeToEvents(WatcherEventArrived);
|
||||
//Task.Run(Program.acpi.RunListener);
|
||||
|
||||
hook.KeyPressed += new EventHandler<KeyPressedEventArgs>(KeyPressed);
|
||||
|
||||
RegisterKeys();
|
||||
|
||||
timer.Elapsed += Timer_Elapsed;
|
||||
|
||||
}
|
||||
|
||||
private void Timer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
if (GetBacklight() == 0) return;
|
||||
|
||||
TimeSpan iddle = NativeMethods.GetIdleTime();
|
||||
int kb_timeout;
|
||||
|
||||
if (SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online)
|
||||
kb_timeout = AppConfig.Get("keyboard_ac_timeout", 0);
|
||||
else
|
||||
kb_timeout = AppConfig.Get("keyboard_timeout", 60);
|
||||
|
||||
if (kb_timeout == 0) return;
|
||||
|
||||
if (backlightActivity && iddle.TotalSeconds > kb_timeout)
|
||||
{
|
||||
backlightActivity = false;
|
||||
AsusUSB.ApplyBrightness(0, "Timeout");
|
||||
}
|
||||
|
||||
if (!backlightActivity && iddle.TotalSeconds < kb_timeout)
|
||||
{
|
||||
backlightActivity = true;
|
||||
SetBacklightAuto();
|
||||
}
|
||||
|
||||
//Debug.WriteLine(iddle.TotalSeconds);
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
if (listener is not null) listener.Dispose();
|
||||
|
||||
Program.acpi.DeviceInit();
|
||||
|
||||
if (!OptimizationService.IsRunning())
|
||||
listener = new KeyboardListener(HandleEvent);
|
||||
else
|
||||
Logger.WriteLine("Optimization service is running");
|
||||
|
||||
InitBacklightTimer();
|
||||
}
|
||||
|
||||
public void InitBacklightTimer()
|
||||
{
|
||||
timer.Enabled = (AppConfig.Get("keyboard_timeout") > 0 && SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online) ||
|
||||
(AppConfig.Get("keyboard_ac_timeout") > 0 && SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void RegisterKeys()
|
||||
{
|
||||
hook.UnregisterAll();
|
||||
|
||||
// CTRL + SHIFT + F5 to cycle profiles
|
||||
if (AppConfig.Get("keybind_profile") != -1) keyProfile = (Keys)AppConfig.Get("keybind_profile");
|
||||
if (AppConfig.Get("keybind_app") != -1) keyApp = (Keys)AppConfig.Get("keybind_app");
|
||||
|
||||
string actionM1 = AppConfig.GetString("m1");
|
||||
string actionM2 = AppConfig.GetString("m2");
|
||||
|
||||
if (keyProfile != Keys.None) hook.RegisterHotKey(ModifierKeys.Shift | ModifierKeys.Control, keyProfile);
|
||||
if (keyApp != Keys.None) hook.RegisterHotKey(ModifierKeys.Shift | ModifierKeys.Control, keyApp);
|
||||
|
||||
if (!AppConfig.ContainsModel("Z13"))
|
||||
if (actionM1 is not null && actionM1.Length > 0) hook.RegisterHotKey(ModifierKeys.None, Keys.VolumeDown);
|
||||
if (actionM2 is not null && actionM2.Length > 0) hook.RegisterHotKey(ModifierKeys.None, Keys.VolumeUp);
|
||||
|
||||
// FN-Lock group
|
||||
|
||||
if (AppConfig.Is("fn_lock") && !AppConfig.ContainsModel("VivoBook"))
|
||||
for (Keys i = Keys.F1; i <= Keys.F11; i++) hook.RegisterHotKey(ModifierKeys.None, i);
|
||||
|
||||
}
|
||||
|
||||
static void CustomKey(string configKey = "m3")
|
||||
{
|
||||
string command = AppConfig.GetString(configKey + "_custom");
|
||||
int intKey;
|
||||
|
||||
try
|
||||
{
|
||||
intKey = Convert.ToInt32(command, 16);
|
||||
}
|
||||
catch
|
||||
{
|
||||
intKey = -1;
|
||||
}
|
||||
|
||||
|
||||
if (intKey > 0)
|
||||
KeyboardHook.KeyPress((Keys)intKey);
|
||||
else
|
||||
LaunchProcess(command);
|
||||
|
||||
}
|
||||
|
||||
public void KeyPressed(object sender, KeyPressedEventArgs e)
|
||||
{
|
||||
|
||||
if (e.Modifier == ModifierKeys.None)
|
||||
{
|
||||
Logger.WriteLine(e.Key.ToString());
|
||||
|
||||
if (AppConfig.ContainsModel("Z13"))
|
||||
{
|
||||
switch (e.Key)
|
||||
{
|
||||
case Keys.F2:
|
||||
KeyboardHook.KeyPress(Keys.VolumeDown);
|
||||
return;
|
||||
case Keys.F3:
|
||||
KeyboardHook.KeyPress(Keys.VolumeUp);
|
||||
return;
|
||||
case Keys.F4:
|
||||
KeyProcess("m3");
|
||||
return;
|
||||
case Keys.F11:
|
||||
HandleEvent(199);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (AppConfig.ContainsModel("GA401I") && !AppConfig.ContainsModel("GA401IHR"))
|
||||
{
|
||||
switch (e.Key)
|
||||
{
|
||||
case Keys.F2:
|
||||
KeyboardHook.KeyPress(Keys.MediaPreviousTrack);
|
||||
return;
|
||||
case Keys.F3:
|
||||
KeyboardHook.KeyPress(Keys.MediaPlayPause);
|
||||
return;
|
||||
case Keys.F4:
|
||||
KeyboardHook.KeyPress(Keys.MediaNextTrack);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch (e.Key)
|
||||
{
|
||||
case Keys.F1:
|
||||
KeyboardHook.KeyPress(Keys.VolumeMute);
|
||||
break;
|
||||
case Keys.F2:
|
||||
HandleEvent(197);
|
||||
break;
|
||||
case Keys.F3:
|
||||
HandleEvent(196);
|
||||
break;
|
||||
case Keys.F4:
|
||||
KeyProcess("fnf4");
|
||||
break;
|
||||
case Keys.F5:
|
||||
KeyProcess("fnf5");
|
||||
break;
|
||||
case Keys.F6:
|
||||
KeyboardHook.KeyPress(Keys.Snapshot);
|
||||
break;
|
||||
case Keys.F7:
|
||||
if (AppConfig.ContainsModel("TUF"))
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, ScreenBrightness.Adjust(-10) + "%", ToastIcon.BrightnessDown);
|
||||
HandleOptimizationEvent(16);
|
||||
break;
|
||||
case Keys.F8:
|
||||
if (AppConfig.ContainsModel("TUF"))
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, ScreenBrightness.Adjust(+10) + "%", ToastIcon.BrightnessUp);
|
||||
HandleOptimizationEvent(32);
|
||||
break;
|
||||
case Keys.F9:
|
||||
KeyboardHook.KeyWinPress(Keys.P);
|
||||
break;
|
||||
case Keys.F10:
|
||||
HandleOptimizationEvent(107);
|
||||
break;
|
||||
case Keys.F11:
|
||||
HandleOptimizationEvent(108);
|
||||
break;
|
||||
case Keys.F12:
|
||||
KeyboardHook.KeyWinPress(Keys.A);
|
||||
break;
|
||||
case Keys.VolumeDown:
|
||||
KeyProcess("m1");
|
||||
break;
|
||||
case Keys.VolumeUp:
|
||||
KeyProcess("m2");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (e.Modifier == (ModifierKeys.Control | ModifierKeys.Shift))
|
||||
{
|
||||
if (e.Key == keyProfile) Program.settingsForm.CyclePerformanceMode();
|
||||
if (e.Key == keyApp) Program.SettingsToggle();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void KeyProcess(string name = "m3")
|
||||
{
|
||||
string action = AppConfig.GetString(name);
|
||||
|
||||
if (action is null || action.Length <= 1)
|
||||
{
|
||||
if (name == "m4")
|
||||
action = "ghelper";
|
||||
if (name == "fnf4")
|
||||
action = "aura";
|
||||
if (name == "fnf5")
|
||||
action = "performance";
|
||||
if (name == "m3" && !OptimizationService.IsRunning())
|
||||
action = "micmute";
|
||||
if (name == "fnc")
|
||||
action = "fnlock";
|
||||
}
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case "mute":
|
||||
KeyboardHook.KeyPress(Keys.VolumeMute);
|
||||
break;
|
||||
case "play":
|
||||
KeyboardHook.KeyPress(Keys.MediaPlayPause);
|
||||
break;
|
||||
case "screenshot":
|
||||
KeyboardHook.KeyPress(Keys.Snapshot);
|
||||
break;
|
||||
case "screen":
|
||||
Logger.WriteLine("Screen off toggle");
|
||||
NativeMethods.TurnOffScreen(Program.settingsForm.Handle);
|
||||
break;
|
||||
case "miniled":
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.ToogleMiniled);
|
||||
break;
|
||||
case "aura":
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.CycleAuraMode);
|
||||
break;
|
||||
case "performance":
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.CyclePerformanceMode);
|
||||
break;
|
||||
case "ghelper":
|
||||
Program.settingsForm.BeginInvoke(delegate
|
||||
{
|
||||
Program.SettingsToggle();
|
||||
});
|
||||
break;
|
||||
case "fnlock":
|
||||
ToggleFnLock();
|
||||
break;
|
||||
case "micmute":
|
||||
using (var enumerator = new MMDeviceEnumerator())
|
||||
{
|
||||
var commDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Communications);
|
||||
bool muteStatus = !commDevice.AudioEndpointVolume.Mute;
|
||||
commDevice.AudioEndpointVolume.Mute = muteStatus;
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, muteStatus ? "Muted" : "Unmuted", muteStatus ? ToastIcon.MicrophoneMute : ToastIcon.Microphone);
|
||||
}
|
||||
break;
|
||||
case "brightness_up":
|
||||
HandleOptimizationEvent(32);
|
||||
break;
|
||||
case "brightness_down":
|
||||
HandleOptimizationEvent(16);
|
||||
break;
|
||||
case "custom":
|
||||
CustomKey(name);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static bool GetTouchpadState()
|
||||
{
|
||||
using (var key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\PrecisionTouchPad\Status", false))
|
||||
{
|
||||
return (key?.GetValue("Enabled")?.ToString() == "1");
|
||||
}
|
||||
}
|
||||
|
||||
static void ToggleFnLock()
|
||||
{
|
||||
int fnLock = AppConfig.Is("fn_lock") ? 0 : 1;
|
||||
AppConfig.Set("fn_lock", fnLock);
|
||||
|
||||
if (AppConfig.ContainsModel("VivoBook"))
|
||||
Program.acpi.DeviceSet(AsusACPI.FnLock, (fnLock == 1) ? 0 : 1, "FnLock");
|
||||
else
|
||||
Program.settingsForm.BeginInvoke(Program.inputDispatcher.RegisterKeys);
|
||||
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, "Fn-Lock "+(fnLock==1?"On":"Off"), ToastIcon.FnLock);
|
||||
}
|
||||
|
||||
public static void TabletMode()
|
||||
{
|
||||
bool touchpadState = GetTouchpadState();
|
||||
bool tabletState = Program.acpi.DeviceGet(AsusACPI.TabletState) > 0;
|
||||
|
||||
Logger.WriteLine("Tablet: " + tabletState + " Touchpad: " + touchpadState);
|
||||
|
||||
if ((tabletState && touchpadState) || (!tabletState && !touchpadState)) AsusUSB.TouchpadToggle();
|
||||
|
||||
}
|
||||
|
||||
static void HandleEvent(int EventID)
|
||||
{
|
||||
switch (EventID)
|
||||
{
|
||||
case 124: // M3
|
||||
KeyProcess("m3");
|
||||
return;
|
||||
case 56: // M4 / Rog button
|
||||
KeyProcess("m4");
|
||||
return;
|
||||
case 174: // FN+F5
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.CyclePerformanceMode);
|
||||
return;
|
||||
case 179: // FN+F4
|
||||
case 178: // FN+F4
|
||||
KeyProcess("fnf4");
|
||||
return;
|
||||
case 158: // Fn + C
|
||||
KeyProcess("fnc");
|
||||
return;
|
||||
case 78: // Fn + ESC
|
||||
ToggleFnLock();
|
||||
return;
|
||||
case 189: // Tablet mode
|
||||
TabletMode();
|
||||
return;
|
||||
case 197: // FN+F2
|
||||
SetBacklight(-1);
|
||||
return;
|
||||
case 196: // FN+F3
|
||||
SetBacklight(1);
|
||||
return;
|
||||
case 199: // ON Z13 - FN+F11 - cycles backlight
|
||||
SetBacklight(4);
|
||||
return;
|
||||
case 53: // FN+F6 on GA-502DU model
|
||||
NativeMethods.TurnOffScreen(Program.settingsForm.Handle);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!OptimizationService.IsRunning())
|
||||
|
||||
HandleOptimizationEvent(EventID);
|
||||
|
||||
// Asus Optimization service Events
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void HandleOptimizationEvent(int EventID)
|
||||
{
|
||||
switch (EventID)
|
||||
{
|
||||
case 16: // FN+F7
|
||||
Program.acpi.DeviceSet(AsusACPI.UniversalControl, AsusACPI.Brightness_Down, "Brightness");
|
||||
break;
|
||||
case 32: // FN+F8
|
||||
Program.acpi.DeviceSet(AsusACPI.UniversalControl, AsusACPI.Brightness_Up, "Brightness");
|
||||
break;
|
||||
case 107: // FN+F10
|
||||
bool touchpadState = GetTouchpadState();
|
||||
AsusUSB.TouchpadToggle();
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, touchpadState ? "Off" : "On", ToastIcon.Touchpad);
|
||||
break;
|
||||
case 108: // FN+F11
|
||||
Program.acpi.DeviceSet(AsusACPI.UniversalControl, AsusACPI.KB_Sleep, "Sleep");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static int GetBacklight()
|
||||
{
|
||||
int backlight_power = AppConfig.Get("keyboard_brightness", 1);
|
||||
int backlight_battery = AppConfig.Get("keyboard_brightness_ac", 1);
|
||||
bool onBattery = SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online;
|
||||
|
||||
int backlight;
|
||||
|
||||
//backlight = onBattery ? Math.Min(backlight_battery, backlight_power) : Math.Max(backlight_battery, backlight_power);
|
||||
backlight = onBattery ? backlight_battery : backlight_power;
|
||||
|
||||
return Math.Max(Math.Min(3, backlight), 0);
|
||||
}
|
||||
|
||||
public static void SetBacklightAuto(bool init = false)
|
||||
{
|
||||
if (init) AsusUSB.Init();
|
||||
|
||||
//if (!OptimizationService.IsRunning())
|
||||
AsusUSB.ApplyBrightness(GetBacklight(), "Auto");
|
||||
}
|
||||
|
||||
public static void SetBacklight(int delta)
|
||||
{
|
||||
int backlight_power = AppConfig.Get("keyboard_brightness", 1);
|
||||
int backlight_battery = AppConfig.Get("keyboard_brightness_ac", 1);
|
||||
bool onBattery = SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online;
|
||||
|
||||
int backlight = onBattery ? backlight_battery : backlight_power;
|
||||
|
||||
if (delta >= 4)
|
||||
backlight = (++backlight % 4);
|
||||
else
|
||||
backlight = Math.Max(Math.Min(3, backlight + delta), 0);
|
||||
|
||||
if (onBattery)
|
||||
AppConfig.Set("keyboard_brightness_ac", backlight);
|
||||
else
|
||||
AppConfig.Set("keyboard_brightness", backlight);
|
||||
|
||||
if (!OptimizationService.IsRunning())
|
||||
{
|
||||
AsusUSB.ApplyBrightness(backlight, "HotKey");
|
||||
string[] backlightNames = new string[] { "Off", "Low", "Mid", "Max" };
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, backlightNames[backlight], delta > 0 ? ToastIcon.BacklightUp : ToastIcon.BacklightDown);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void LaunchProcess(string command = "")
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
string executable = command.Split(' ')[0];
|
||||
string arguments = command.Substring(executable.Length).Trim();
|
||||
Process proc = Process.Start(executable, arguments);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Logger.WriteLine("Failed to run " + command);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void WatcherEventArrived(object sender, EventArrivedEventArgs e)
|
||||
{
|
||||
if (e.NewEvent is null) return;
|
||||
int EventID = int.Parse(e.NewEvent["EventID"].ToString());
|
||||
Logger.WriteLine("WMI event " + EventID);
|
||||
HandleEvent(EventID);
|
||||
}
|
||||
}
|
||||
}
|
||||
173
app/KeyboardHook.cs
Normal file
173
app/KeyboardHook.cs
Normal file
@@ -0,0 +1,173 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public sealed class KeyboardHook : IDisposable
|
||||
{
|
||||
// Registers a hot key with Windows.
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);
|
||||
// Unregisters the hot key with Windows.
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern void keybd_event(byte virtualKey, byte scanCode, uint flags, IntPtr extraInfo);
|
||||
|
||||
public const int KEYEVENTF_EXTENDEDKEY = 1;
|
||||
public const int KEYEVENTF_KEYUP = 2;
|
||||
private const byte VK_LWIN = 0x5B;
|
||||
|
||||
public static void KeyPress(Keys key)
|
||||
{
|
||||
keybd_event((byte)key, 0, KEYEVENTF_EXTENDEDKEY, IntPtr.Zero);
|
||||
}
|
||||
|
||||
public static void KeyWinPress(Keys key)
|
||||
{
|
||||
keybd_event(VK_LWIN, 0, KEYEVENTF_EXTENDEDKEY, IntPtr.Zero);
|
||||
keybd_event((byte)key, 0, KEYEVENTF_EXTENDEDKEY, IntPtr.Zero);
|
||||
keybd_event((byte)key, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, IntPtr.Zero);
|
||||
keybd_event(VK_LWIN, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, IntPtr.Zero);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Represents the window that is used internally to get the messages.
|
||||
/// </summary>
|
||||
private class Window : NativeWindow, IDisposable
|
||||
{
|
||||
private static int WM_HOTKEY = 0x0312;
|
||||
public static Keys? fakeKey;
|
||||
|
||||
public Window()
|
||||
{
|
||||
// create the handle for the window.
|
||||
this.CreateHandle(new CreateParams());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overridden to get the notifications.
|
||||
/// </summary>
|
||||
/// <param name="m"></param>
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
base.WndProc(ref m);
|
||||
|
||||
// check if we got a hot key pressed.
|
||||
if (m.Msg == WM_HOTKEY)
|
||||
{
|
||||
// get the keys.
|
||||
Keys key = (Keys)(((int)m.LParam >> 16) & 0xFFFF);
|
||||
ModifierKeys modifier = (ModifierKeys)((int)m.LParam & 0xFFFF);
|
||||
|
||||
// invoke the event to notify the parent.
|
||||
if (KeyPressed != null)
|
||||
KeyPressed(this, new KeyPressedEventArgs(modifier, key));
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<KeyPressedEventArgs> KeyPressed;
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.DestroyHandle();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
private Window _window = new Window();
|
||||
private int _currentId;
|
||||
|
||||
public KeyboardHook()
|
||||
{
|
||||
// register the event of the inner native window.
|
||||
_window.KeyPressed += delegate (object sender, KeyPressedEventArgs args)
|
||||
{
|
||||
if (KeyPressed != null)
|
||||
KeyPressed(this, args);
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers a hot key in the system.
|
||||
/// </summary>
|
||||
/// <param name="modifier">The modifiers that are associated with the hot key.</param>
|
||||
/// <param name="key">The key itself that is associated with the hot key.</param>
|
||||
public void RegisterHotKey(ModifierKeys modifier, Keys key)
|
||||
{
|
||||
// increment the counter.
|
||||
_currentId = _currentId + 1;
|
||||
|
||||
// register the hot key.
|
||||
if (!RegisterHotKey(_window.Handle, _currentId, (uint)modifier, (uint)key))
|
||||
Logger.WriteLine("Couldn’t register " + key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A hot key has been pressed.
|
||||
/// </summary>
|
||||
public event EventHandler<KeyPressedEventArgs> KeyPressed;
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void UnregisterAll()
|
||||
{
|
||||
// unregister all the registered hot keys.
|
||||
for (int i = _currentId; i > 0; i--)
|
||||
{
|
||||
UnregisterHotKey(_window.Handle, i);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
UnregisterAll();
|
||||
// dispose the inner native window.
|
||||
_window.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event Args for the event that is fired after the hot key has been pressed.
|
||||
/// </summary>
|
||||
public class KeyPressedEventArgs : EventArgs
|
||||
{
|
||||
private ModifierKeys _modifier;
|
||||
private Keys _key;
|
||||
|
||||
internal KeyPressedEventArgs(ModifierKeys modifier, Keys key)
|
||||
{
|
||||
_modifier = modifier;
|
||||
_key = key;
|
||||
}
|
||||
|
||||
public ModifierKeys Modifier
|
||||
{
|
||||
get { return _modifier; }
|
||||
}
|
||||
|
||||
public Keys Key
|
||||
{
|
||||
get { return _key; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The enumeration of possible modifiers.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum ModifierKeys : uint
|
||||
{
|
||||
None = 0,
|
||||
Alt = 1,
|
||||
Control = 2,
|
||||
Shift = 4,
|
||||
Win = 8
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public static class Logger
|
||||
try
|
||||
{
|
||||
var file = File.ReadAllLines(logFile);
|
||||
int skip = Math.Max(0, file.Count() - 500);
|
||||
int skip = Math.Max(0, file.Count() - 1000);
|
||||
File.WriteAllLines(logFile, file.Skip(skip).ToArray());
|
||||
}
|
||||
catch { }
|
||||
|
||||
156
app/Modes.cs
Normal file
156
app/Modes.cs
Normal file
@@ -0,0 +1,156 @@
|
||||
using Microsoft.VisualBasic.Devices;
|
||||
|
||||
namespace GHelper
|
||||
{
|
||||
internal class Modes
|
||||
{
|
||||
|
||||
const int maxModes = 20;
|
||||
|
||||
public static Dictionary<int, string> GetDictonary()
|
||||
{
|
||||
Dictionary<int, string> modes = new Dictionary<int, string>
|
||||
{
|
||||
{2, Properties.Strings.Silent},
|
||||
{0, Properties.Strings.Balanced},
|
||||
{1, Properties.Strings.Turbo}
|
||||
};
|
||||
|
||||
for (int i = 3; i < maxModes; i++)
|
||||
{
|
||||
if (Exists(i)) modes.Add(i, GetName(i));
|
||||
}
|
||||
|
||||
return modes;
|
||||
}
|
||||
|
||||
public static List<int> GetList()
|
||||
{
|
||||
List<int> modes = new() { 2, 0, 1 };
|
||||
for (int i = 3; i < maxModes; i++)
|
||||
{
|
||||
if (Exists(i)) modes.Add(i);
|
||||
}
|
||||
|
||||
return modes;
|
||||
}
|
||||
|
||||
public static void Remove(int mode)
|
||||
{
|
||||
List<string> cleanup = new() {
|
||||
"mode_base",
|
||||
"mode_name",
|
||||
"limit_total",
|
||||
"limit_fast",
|
||||
"limit_cpu",
|
||||
"limit_total",
|
||||
"fan_profile_cpu",
|
||||
"fan_profile_gpu",
|
||||
"fan_profile_mid",
|
||||
"gpu_boost",
|
||||
"gpu_temp",
|
||||
"gpu_core",
|
||||
"gpu_memory",
|
||||
"auto_boost",
|
||||
"auto_apply",
|
||||
"auto_apply_power"
|
||||
};
|
||||
|
||||
foreach (string clean in cleanup)
|
||||
{
|
||||
AppConfig.Remove(clean + "_" + mode);
|
||||
}
|
||||
}
|
||||
|
||||
public static int Add()
|
||||
{
|
||||
for (int i = 3; i < maxModes; i++)
|
||||
{
|
||||
if (!Exists(i))
|
||||
{
|
||||
int modeBase = GetCurrentBase();
|
||||
string nameName = "Custom " + (i - 2);
|
||||
AppConfig.Set("mode_base_" + i, modeBase);
|
||||
AppConfig.Set("mode_name_" + i, nameName);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int GetCurrent()
|
||||
{
|
||||
return AppConfig.Get("performance_mode");
|
||||
}
|
||||
|
||||
public static bool IsCurrentCustom()
|
||||
{
|
||||
return GetCurrent() > 2;
|
||||
}
|
||||
|
||||
public static void SetCurrent(int mode)
|
||||
{
|
||||
AppConfig.Set("performance_" + (int)SystemInformation.PowerStatus.PowerLineStatus, mode);
|
||||
AppConfig.Set("performance_mode", mode);
|
||||
}
|
||||
|
||||
public static int GetCurrentBase()
|
||||
{
|
||||
return GetBase(GetCurrent());
|
||||
}
|
||||
|
||||
public static string GetCurrentName()
|
||||
{
|
||||
return GetName(GetCurrent());
|
||||
}
|
||||
|
||||
public static bool Exists(int mode)
|
||||
{
|
||||
return GetBase(mode) >= 0;
|
||||
}
|
||||
|
||||
public static int GetBase(int mode)
|
||||
{
|
||||
if (mode >= 0 && mode <= 2)
|
||||
return mode;
|
||||
else
|
||||
return AppConfig.Get("mode_base_" + mode);
|
||||
}
|
||||
|
||||
public static string GetName(int mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
return Properties.Strings.Balanced;
|
||||
case 1:
|
||||
return Properties.Strings.Turbo;
|
||||
case 2:
|
||||
return Properties.Strings.Silent;
|
||||
default:
|
||||
return AppConfig.GetString("mode_name_" + mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static int GetNext(bool back = false)
|
||||
{
|
||||
var modes = GetList();
|
||||
int index = modes.IndexOf(GetCurrent());
|
||||
|
||||
if (back)
|
||||
{
|
||||
index--;
|
||||
if (index < 0) index = modes.Count - 1;
|
||||
return modes[index];
|
||||
}
|
||||
else
|
||||
{
|
||||
index++;
|
||||
if (index > modes.Count - 1) index = 0;
|
||||
return modes[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using GHelper;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using static Tools.ScreenInterrogatory;
|
||||
@@ -7,47 +6,6 @@ using static Tools.ScreenInterrogatory;
|
||||
namespace Tools
|
||||
{
|
||||
|
||||
public class KeyHandler
|
||||
{
|
||||
|
||||
public const int NOMOD = 0x0000;
|
||||
public const int ALT = 0x0001;
|
||||
public const int CTRL = 0x0002;
|
||||
public const int SHIFT = 0x0004;
|
||||
public const int WIN = 0x0008;
|
||||
|
||||
public const int WM_HOTKEY_MSG_ID = 0x0312;
|
||||
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
|
||||
|
||||
private int modifier;
|
||||
private int key;
|
||||
private IntPtr hWnd;
|
||||
private int id;
|
||||
public KeyHandler(int modifier, Keys key, nint handle)
|
||||
{
|
||||
this.modifier = modifier;
|
||||
this.key = (int)key;
|
||||
this.hWnd = handle;
|
||||
id = this.GetHashCode();
|
||||
}
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return modifier ^ key ^ hWnd.ToInt32();
|
||||
}
|
||||
public bool Register()
|
||||
{
|
||||
return RegisterHotKey(hWnd, id, modifier, key);
|
||||
}
|
||||
public bool Unregiser()
|
||||
{
|
||||
return UnregisterHotKey(hWnd, id);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ScreenInterrogatory
|
||||
{
|
||||
@@ -351,6 +309,27 @@ namespace Tools
|
||||
public class NativeMethods
|
||||
{
|
||||
|
||||
internal struct LASTINPUTINFO
|
||||
{
|
||||
public uint cbSize;
|
||||
public uint dwTime;
|
||||
}
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
private static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
|
||||
|
||||
public static TimeSpan GetIdleTime()
|
||||
{
|
||||
LASTINPUTINFO lastInPut = new LASTINPUTINFO();
|
||||
lastInPut.cbSize = (uint)Marshal.SizeOf(lastInPut);
|
||||
GetLastInputInfo(ref lastInPut);
|
||||
return TimeSpan.FromMilliseconds((uint)Environment.TickCount - lastInPut.dwTime);
|
||||
|
||||
}
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
public static extern bool SetForegroundWindow(IntPtr handle);
|
||||
|
||||
private const int WM_SYSCOMMAND = 0x0112;
|
||||
private const int SC_MONITORPOWER = 0xF170;
|
||||
private const int MONITOR_OFF = 2;
|
||||
@@ -435,22 +414,8 @@ public class NativeMethods
|
||||
}
|
||||
|
||||
|
||||
public const int KEYEVENTF_EXTENDEDKEY = 1;
|
||||
public const int KEYEVENTF_KEYUP = 2;
|
||||
|
||||
public const int VK_MEDIA_NEXT_TRACK = 0xB0;
|
||||
public const int VK_MEDIA_PLAY_PAUSE = 0xB3;
|
||||
public const int VK_MEDIA_PREV_TRACK = 0xB1;
|
||||
public const int VK_VOLUME_MUTE = 0xAD;
|
||||
public const int VK_SNAPSHOT = 0x2C;
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern void keybd_event(byte virtualKey, byte scanCode, uint flags, IntPtr extraInfo);
|
||||
|
||||
public static void KeyPress(int key = VK_MEDIA_PLAY_PAUSE)
|
||||
{
|
||||
keybd_event((byte)key, 0, KEYEVENTF_EXTENDEDKEY, IntPtr.Zero);
|
||||
}
|
||||
[DllImport("Powrprof.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
|
||||
public static extern bool SetSuspendState(bool hiberate, bool forceCritical, bool disableWakeEvent);
|
||||
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
@@ -515,6 +480,17 @@ public class NativeMethods
|
||||
);
|
||||
|
||||
|
||||
[DllImport("powrprof.dll")]
|
||||
static extern uint PowerReadACValue(
|
||||
IntPtr RootPowerKey,
|
||||
Guid SchemeGuid,
|
||||
Guid SubGroupOfPowerSettingGuid,
|
||||
Guid PowerSettingGuid,
|
||||
ref int Type,
|
||||
ref IntPtr Buffer,
|
||||
ref uint BufferSize
|
||||
);
|
||||
|
||||
|
||||
[DllImport("PowrProf.dll", CharSet = CharSet.Unicode)]
|
||||
static extern UInt32 PowerSetActiveScheme(IntPtr RootPowerKey,
|
||||
@@ -526,6 +502,9 @@ public class NativeMethods
|
||||
static readonly Guid GUID_CPU = new Guid("54533251-82be-4824-96c1-47b60b740d00");
|
||||
static readonly Guid GUID_BOOST = new Guid("be337238-0d82-4146-a960-4f3749d470c7");
|
||||
|
||||
private static Guid GUID_SLEEP_SUBGROUP = new Guid("238c9fa8-0aad-41ed-83f4-97be242c8f20");
|
||||
private static Guid GUID_HIBERNATEIDLE = new Guid("9d7815a6-7ee4-497e-8888-515a05f02364");
|
||||
|
||||
[DllImportAttribute("powrprof.dll", EntryPoint = "PowerGetActualOverlayScheme")]
|
||||
public static extern uint PowerGetActualOverlayScheme(out Guid ActualOverlayGuid);
|
||||
|
||||
@@ -609,6 +588,42 @@ public class NativeMethods
|
||||
return dm;
|
||||
}
|
||||
|
||||
public enum COLORPROFILETYPE
|
||||
{
|
||||
CPT_ICC,
|
||||
CPT_DMP,
|
||||
CPT_CAMP,
|
||||
CPT_GMMP
|
||||
}
|
||||
public enum COLORPROFILESUBTYPE
|
||||
{
|
||||
CPST_PERCEPTUAL,
|
||||
CPST_RELATIVE_COLORIMETRIC,
|
||||
CPST_SATURATION,
|
||||
CPST_ABSOLUTE_COLORIMETRIC,
|
||||
CPST_NONE,
|
||||
CPST_RGB_WORKING_SPACE,
|
||||
CPST_CUSTOM_WORKING_SPACE,
|
||||
CPST_STANDARD_DISPLAY_COLOR_MODE,
|
||||
CPST_EXTENDED_DISPLAY_COLOR_MODE
|
||||
}
|
||||
public enum WCS_PROFILE_MANAGEMENT_SCOPE
|
||||
{
|
||||
WCS_PROFILE_MANAGEMENT_SCOPE_SYSTEM_WIDE,
|
||||
WCS_PROFILE_MANAGEMENT_SCOPE_CURRENT_USER
|
||||
}
|
||||
|
||||
[DllImport("mscms.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern bool WcsSetDefaultColorProfile(
|
||||
WCS_PROFILE_MANAGEMENT_SCOPE scope,
|
||||
string pDeviceName,
|
||||
COLORPROFILETYPE cptColorProfileType,
|
||||
COLORPROFILESUBTYPE cpstColorProfileSubType,
|
||||
uint dwProfileID,
|
||||
string pProfileName
|
||||
);
|
||||
|
||||
|
||||
public const int ENUM_CURRENT_SETTINGS = -1;
|
||||
public const string defaultDevice = "\\\\.\\DISPLAY1";
|
||||
|
||||
@@ -621,16 +636,19 @@ public class NativeMethods
|
||||
var devices = GetAllDevices().ToArray();
|
||||
int count = 0, displayNum = -1;
|
||||
|
||||
string internalName = AppConfig.GetString("internal_display");
|
||||
|
||||
foreach (var device in devices)
|
||||
{
|
||||
if (device.outputTechnology == DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY.DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL ||
|
||||
device.outputTechnology == DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY.DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED)
|
||||
device.outputTechnology == DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY.DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED ||
|
||||
device.monitorFriendlyDeviceName == internalName)
|
||||
{
|
||||
displayNum = count;
|
||||
AppConfig.Set("internal_display", device.monitorFriendlyDeviceName);
|
||||
}
|
||||
count++;
|
||||
//Logger.WriteLine(device.outputTechnology.ToString());
|
||||
//Logger.WriteLine(device.monitorFriendlyDeviceName);
|
||||
//Logger.WriteLine(device.monitorFriendlyDeviceName + ":" + device.outputTechnology.ToString());
|
||||
}
|
||||
|
||||
var screens = Screen.AllScreens;
|
||||
@@ -647,12 +665,14 @@ public class NativeMethods
|
||||
//Logger.WriteLine(screen.DeviceName);
|
||||
count++;
|
||||
}
|
||||
|
||||
if (displayNum > 0 && count == 0) laptopScreen = defaultDevice;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WriteLine(ex.ToString());
|
||||
Logger.WriteLine("Can't detect internal screen");
|
||||
//laptopScreen = Screen.PrimaryScreen.DeviceName;
|
||||
laptopScreen = Screen.PrimaryScreen.DeviceName;
|
||||
}
|
||||
|
||||
|
||||
@@ -703,6 +723,15 @@ public class NativeMethods
|
||||
dm.dmDisplayFrequency = frequency;
|
||||
int iRet = NativeMethods.ChangeDisplaySettingsEx(laptopScreen, ref dm, IntPtr.Zero, DisplaySettingsFlags.CDS_UPDATEREGISTRY, IntPtr.Zero);
|
||||
Logger.WriteLine("Screen = " + frequency.ToString() + "Hz : " + (iRet == 0 ? "OK" : iRet));
|
||||
|
||||
//Fallback scenario
|
||||
if (iRet != 0)
|
||||
{
|
||||
Thread.Sleep(300);
|
||||
iRet = NativeMethods.ChangeDisplaySettingsEx(laptopScreen, ref dm, IntPtr.Zero, DisplaySettingsFlags.CDS_UPDATEREGISTRY, IntPtr.Zero);
|
||||
Logger.WriteLine("Screen = " + frequency.ToString() + "Hz : " + (iRet == 0 ? "OK" : iRet));
|
||||
}
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
@@ -710,6 +739,20 @@ public class NativeMethods
|
||||
|
||||
}
|
||||
|
||||
public static nint GetHuibernateAfter()
|
||||
{
|
||||
Guid activePolicyGuid = GetActiveScheme();
|
||||
var type = 0;
|
||||
nint value = 0;
|
||||
var valueSize = 4u;
|
||||
|
||||
PowerReadACValue(IntPtr.Zero, activePolicyGuid,
|
||||
GUID_SLEEP_SUBGROUP, GUID_HIBERNATEIDLE,
|
||||
ref type, ref value, ref valueSize);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static Guid GetActiveScheme()
|
||||
{
|
||||
IntPtr pActiveSchemeGuid;
|
||||
@@ -736,6 +779,8 @@ public class NativeMethods
|
||||
{
|
||||
Guid activeSchemeGuid = GetActiveScheme();
|
||||
|
||||
if (boost == GetCPUBoost()) return;
|
||||
|
||||
var hrAC = PowerWriteACValueIndex(
|
||||
IntPtr.Zero,
|
||||
activeSchemeGuid,
|
||||
@@ -761,6 +806,7 @@ public class NativeMethods
|
||||
{
|
||||
PowerSetActiveScheme(IntPtr.Zero, new Guid(scheme));
|
||||
PowerSetActiveOverlayScheme(new Guid(scheme));
|
||||
Logger.WriteLine(scheme);
|
||||
}
|
||||
|
||||
public static void SetPowerScheme(int mode)
|
||||
|
||||
@@ -1,481 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NvAPIWrapper.Native;
|
||||
using NvAPIWrapper.Native.DRS;
|
||||
using NvAPIWrapper.Native.DRS.Structures;
|
||||
|
||||
namespace NvAPIWrapper.DRS
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a NVIDIA driver settings profile
|
||||
/// </summary>
|
||||
public class DriverSettingsProfile
|
||||
{
|
||||
internal DriverSettingsProfile(DRSProfileHandle handle, DriverSettingsSession parentSession)
|
||||
{
|
||||
Handle = handle;
|
||||
Session = parentSession;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of applications under this profile
|
||||
/// </summary>
|
||||
public IEnumerable<ProfileApplication> Applications
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid profile instance."
|
||||
);
|
||||
}
|
||||
|
||||
return DRSApi.EnumApplications(Session.Handle, Handle)
|
||||
.Select(application => new ProfileApplication(application, this));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the profile support value for GPU series
|
||||
/// </summary>
|
||||
public DRSGPUSupport GPUSupport
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid profile instance."
|
||||
);
|
||||
}
|
||||
|
||||
var profileInfo = DRSApi.GetProfileInfo(Session.Handle, Handle);
|
||||
|
||||
return profileInfo.GPUSupport;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid profile instance."
|
||||
);
|
||||
}
|
||||
|
||||
var profileInfo = DRSApi.GetProfileInfo(Session.Handle, Handle);
|
||||
profileInfo.GPUSupport = value;
|
||||
DRSApi.SetProfileInfo(Session.Handle, Handle, profileInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the profile handle
|
||||
/// </summary>
|
||||
public DRSProfileHandle Handle { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean value indicating if this profile is predefined
|
||||
/// </summary>
|
||||
public bool IsPredefined
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid profile instance."
|
||||
);
|
||||
}
|
||||
|
||||
var profileInfo = DRSApi.GetProfileInfo(Session.Handle, Handle);
|
||||
|
||||
return profileInfo.IsPredefined;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean value indicating if this profile is valid and contains a non-zero handle
|
||||
/// </summary>
|
||||
public bool IsValid
|
||||
{
|
||||
get => !Handle.IsNull;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the profile
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid profile instance."
|
||||
);
|
||||
}
|
||||
|
||||
var profileInfo = DRSApi.GetProfileInfo(Session.Handle, Handle);
|
||||
|
||||
return profileInfo.Name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of application registered under this profile
|
||||
/// </summary>
|
||||
public int NumberOfApplications
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid profile instance."
|
||||
);
|
||||
}
|
||||
|
||||
var profileInfo = DRSApi.GetProfileInfo(Session.Handle, Handle);
|
||||
|
||||
return profileInfo.NumberOfApplications;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of settings under this profile
|
||||
/// </summary>
|
||||
public int NumberOfSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid profile instance."
|
||||
);
|
||||
}
|
||||
|
||||
var profileInfo = DRSApi.GetProfileInfo(Session.Handle, Handle);
|
||||
|
||||
return profileInfo.NumberOfSettings;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the session that had queried this profile
|
||||
/// </summary>
|
||||
public DriverSettingsSession Session { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of settings under this profile
|
||||
/// </summary>
|
||||
public IEnumerable<ProfileSetting> Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid profile instance."
|
||||
);
|
||||
}
|
||||
|
||||
return DRSApi.EnumSettings(Session.Handle, Handle).Select(setting => new ProfileSetting(setting));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new profile
|
||||
/// </summary>
|
||||
/// <param name="session">The session to create this profile in.</param>
|
||||
/// <param name="profileName">The name of the profile.</param>
|
||||
/// <param name="gpuSupport">The supported GPU series for this profile.</param>
|
||||
/// <returns>An instance of <see cref="DriverSettingsProfile" /> representing this newly created profile.</returns>
|
||||
public static DriverSettingsProfile CreateProfile(
|
||||
DriverSettingsSession session,
|
||||
string profileName,
|
||||
DRSGPUSupport? gpuSupport = null)
|
||||
{
|
||||
gpuSupport = gpuSupport ?? new DRSGPUSupport();
|
||||
var profileInfo = new DRSProfileV1(profileName, gpuSupport.Value);
|
||||
var profileHandle = DRSApi.CreateProfile(session.Handle, profileInfo);
|
||||
|
||||
return new DriverSettingsProfile(profileHandle, session);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
return "[Invalid]";
|
||||
}
|
||||
|
||||
if (IsPredefined)
|
||||
{
|
||||
return $"{Name} (Predefined)";
|
||||
}
|
||||
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes this profile and makes this instance invalid.
|
||||
/// </summary>
|
||||
public void Delete()
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid profile instance."
|
||||
);
|
||||
}
|
||||
|
||||
DRSApi.DeleteProfile(Session.Handle, Handle);
|
||||
Handle = DRSProfileHandle.DefaultHandle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes an application by its name.
|
||||
/// </summary>
|
||||
/// <param name="applicationName">The name of the application to be deleted.</param>
|
||||
public void DeleteApplicationByName(string applicationName)
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid profile instance."
|
||||
);
|
||||
}
|
||||
|
||||
DRSApi.DeleteApplication(Session.Handle, Handle, applicationName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a setting by its identification number
|
||||
/// </summary>
|
||||
/// <param name="settingId">The identification number of the setting to be deleted.</param>
|
||||
public void DeleteSetting(uint settingId)
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid profile instance."
|
||||
);
|
||||
}
|
||||
|
||||
DRSApi.DeleteProfileSetting(Session.Handle, Handle, settingId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a setting by its known identification number.
|
||||
/// </summary>
|
||||
/// <param name="settingId">The known identification number of the setting to be deleted.</param>
|
||||
public void DeleteSetting(KnownSettingId settingId)
|
||||
{
|
||||
DeleteSetting(SettingInfo.GetSettingId(settingId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds an application by its name.
|
||||
/// </summary>
|
||||
/// <param name="applicationName">The name of the application to search for.</param>
|
||||
/// <returns>
|
||||
/// An instance of <see cref="ProfileApplication" /> if an application is found; otherwise <see langword="null" />
|
||||
/// .
|
||||
/// </returns>
|
||||
public ProfileApplication GetApplicationByName(string applicationName)
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid profile instance."
|
||||
);
|
||||
}
|
||||
|
||||
var application = DRSApi.GetApplicationInfo(Session.Handle, Handle, applicationName);
|
||||
|
||||
if (application == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ProfileApplication(application, this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Searches for a setting using its identification number.
|
||||
/// </summary>
|
||||
/// <param name="settingId">The identification number of the setting to search for.</param>
|
||||
/// <returns>An instance of <see cref="ProfileSetting" /> if a setting is found; otherwise <see langword="null" />.</returns>
|
||||
public ProfileSetting GetSetting(uint settingId)
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid profile instance."
|
||||
);
|
||||
}
|
||||
|
||||
var setting = DRSApi.GetSetting(Session.Handle, Handle, settingId);
|
||||
|
||||
if (setting == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ProfileSetting(setting.Value);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Searches for a setting using its known identification number.
|
||||
/// </summary>
|
||||
/// <param name="settingId">The known identification number of the setting to search for.</param>
|
||||
/// <returns>An instance of <see cref="ProfileSetting" /> if a setting is found; otherwise <see langword="null" />.</returns>
|
||||
public ProfileSetting GetSetting(KnownSettingId settingId)
|
||||
{
|
||||
return GetSetting(SettingInfo.GetSettingId(settingId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restores applications and settings of this profile to their default. This also deletes custom profiles resulting in
|
||||
/// their handles becoming invalid.
|
||||
/// </summary>
|
||||
public void RestoreDefaults()
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid profile instance."
|
||||
);
|
||||
}
|
||||
|
||||
var isPredefined = IsPredefined;
|
||||
DRSApi.RestoreDefaults(Session.Handle, Handle);
|
||||
|
||||
if (!isPredefined)
|
||||
{
|
||||
Handle = DRSProfileHandle.DefaultHandle;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restores a setting to its default value.
|
||||
/// </summary>
|
||||
/// <param name="settingId">The identification number of the setting.</param>
|
||||
public void RestoreSettingToDefault(uint settingId)
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid profile instance."
|
||||
);
|
||||
}
|
||||
|
||||
DRSApi.RestoreDefaults(Session.Handle, Handle, settingId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restores a setting to its default value.
|
||||
/// </summary>
|
||||
/// <param name="settingId">The known identification number of the setting.</param>
|
||||
public void RestoreSettingToDefault(KnownSettingId settingId)
|
||||
{
|
||||
RestoreSettingToDefault(SettingInfo.GetSettingId(settingId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a new value for a setting or creates a new setting and sets its value
|
||||
/// </summary>
|
||||
/// <param name="settingId">The known identification number of the setting to change its value.</param>
|
||||
/// <param name="settingType">The type of the setting value.</param>
|
||||
/// <param name="value">The new value for the setting.</param>
|
||||
public void SetSetting(KnownSettingId settingId, DRSSettingType settingType, object value)
|
||||
{
|
||||
SetSetting(SettingInfo.GetSettingId(settingId), settingType, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a new value for a setting or creates a new setting and sets its value
|
||||
/// </summary>
|
||||
/// <param name="settingId">The known identification number of the setting to change its value.</param>
|
||||
/// <param name="value">The new value for the setting.</param>
|
||||
public void SetSetting(KnownSettingId settingId, string value)
|
||||
{
|
||||
SetSetting(SettingInfo.GetSettingId(settingId), value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a new value for a setting or creates a new setting and sets its value
|
||||
/// </summary>
|
||||
/// <param name="settingId">The known identification number of the setting to change its value.</param>
|
||||
/// <param name="value">The new value for the setting.</param>
|
||||
public void SetSetting(KnownSettingId settingId, byte[] value)
|
||||
{
|
||||
SetSetting(SettingInfo.GetSettingId(settingId), value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a new value for a setting or creates a new setting and sets its value
|
||||
/// </summary>
|
||||
/// <param name="settingId">The known identification number of the setting to change its value.</param>
|
||||
/// <param name="value">The new value for the setting.</param>
|
||||
public void SetSetting(KnownSettingId settingId, uint value)
|
||||
{
|
||||
SetSetting(SettingInfo.GetSettingId(settingId), value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a new value for a setting or creates a new setting and sets its value
|
||||
/// </summary>
|
||||
/// <param name="settingId">The identification number of the setting to change its value.</param>
|
||||
/// <param name="settingType">The type of the setting value.</param>
|
||||
/// <param name="value">The new value for the setting.</param>
|
||||
public void SetSetting(uint settingId, DRSSettingType settingType, object value)
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid profile instance."
|
||||
);
|
||||
}
|
||||
|
||||
var setting = new DRSSettingV1(settingId, settingType, value);
|
||||
|
||||
DRSApi.SetSetting(Session.Handle, Handle, setting);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a new value for a setting or creates a new setting and sets its value
|
||||
/// </summary>
|
||||
/// <param name="settingId">The identification number of the setting to change its value.</param>
|
||||
/// <param name="value">The new value for the setting.</param>
|
||||
public void SetSetting(uint settingId, string value)
|
||||
{
|
||||
SetSetting(settingId, DRSSettingType.UnicodeString, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a new value for a setting or creates a new setting and sets its value
|
||||
/// </summary>
|
||||
/// <param name="settingId">The identification number of the setting to change its value.</param>
|
||||
/// <param name="value">The new value for the setting.</param>
|
||||
public void SetSetting(uint settingId, byte[] value)
|
||||
{
|
||||
SetSetting(settingId, DRSSettingType.Binary, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a new value for a setting or creates a new setting and sets its value
|
||||
/// </summary>
|
||||
/// <param name="settingId">The identification number of the setting to change its value.</param>
|
||||
/// <param name="value">The new value for the setting.</param>
|
||||
public void SetSetting(uint settingId, uint value)
|
||||
{
|
||||
SetSetting(settingId, DRSSettingType.Integer, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,236 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NvAPIWrapper.Native;
|
||||
using NvAPIWrapper.Native.DRS.Structures;
|
||||
|
||||
namespace NvAPIWrapper.DRS
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a driver settings session. This is the starting point for using DRS set of functionalities.
|
||||
/// </summary>
|
||||
public class DriverSettingsSession : IDisposable
|
||||
{
|
||||
internal DriverSettingsSession(DRSSessionHandle handle)
|
||||
{
|
||||
Handle = handle;
|
||||
}
|
||||
|
||||
private DriverSettingsSession() : this(DRSApi.CreateSession())
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the base settings profile
|
||||
/// </summary>
|
||||
public DriverSettingsProfile BaseProfile
|
||||
{
|
||||
get
|
||||
{
|
||||
var profileHandle = DRSApi.GetBaseProfile(Handle);
|
||||
|
||||
if (profileHandle.IsNull)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DriverSettingsProfile(profileHandle, this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the global settings profile
|
||||
/// </summary>
|
||||
public DriverSettingsProfile CurrentGlobalProfile
|
||||
{
|
||||
get
|
||||
{
|
||||
var profileHandle = DRSApi.GetCurrentGlobalProfile(Handle);
|
||||
|
||||
if (profileHandle.IsNull)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DriverSettingsProfile(profileHandle, this);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(value.Name))
|
||||
{
|
||||
throw new ArgumentException("Profile name can not be empty.", nameof(value));
|
||||
}
|
||||
|
||||
DRSApi.SetCurrentGlobalProfile(Handle, value.Name);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the session handle
|
||||
/// </summary>
|
||||
public DRSSessionHandle Handle { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of registered profiles
|
||||
/// </summary>
|
||||
public int NumberOfProfiles
|
||||
{
|
||||
get => DRSApi.GetNumberOfProfiles(Handle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of all registered profiles
|
||||
/// </summary>
|
||||
public IEnumerable<DriverSettingsProfile> Profiles
|
||||
{
|
||||
get { return DRSApi.EnumProfiles(Handle).Select(handle => new DriverSettingsProfile(handle, this)); }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
ReleaseUnmanagedResources();
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new session and load the settings
|
||||
/// </summary>
|
||||
/// <returns>A new instance of <see cref="DriverSettingsSession" /> representing a session.</returns>
|
||||
public static DriverSettingsSession CreateAndLoad()
|
||||
{
|
||||
var session = new DriverSettingsSession();
|
||||
session.Load();
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new session and load the settings from a file
|
||||
/// </summary>
|
||||
/// <param name="fileName">The full path of file to load settings from.</param>
|
||||
/// <returns>A new instance of <see cref="DriverSettingsSession" /> representing a session.</returns>
|
||||
public static DriverSettingsSession CreateAndLoad(string fileName)
|
||||
{
|
||||
var session = new DriverSettingsSession();
|
||||
session.Load(fileName);
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Handle} ({NumberOfProfiles} Profiles)";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds an application by name. This method is useful when passed a full path of a file as it does return an
|
||||
/// application almost always describing the NVIDIA driver behavior regarding the passed executable file.
|
||||
/// </summary>
|
||||
/// <param name="applicationName">The name of the application (with extension) or the full path of an executable file.</param>
|
||||
/// <returns>An instance of <see cref="ProfileApplication" /> class.</returns>
|
||||
public ProfileApplication FindApplication(string applicationName)
|
||||
{
|
||||
var application = DRSApi.FindApplicationByName(Handle, applicationName, out var profileHandle);
|
||||
|
||||
if (application == null || !profileHandle.HasValue || profileHandle.Value.IsNull)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var profile = new DriverSettingsProfile(profileHandle.Value, this);
|
||||
|
||||
return new ProfileApplication(application, profile);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds a profile based on the application named passed. This method is useful when passed a full path of a file as
|
||||
/// it does return a profile almost always describing the NVIDIA driver behavior regarding the passed executable file.
|
||||
/// </summary>
|
||||
/// <param name="applicationName">The name of the application (with extension) or the full path of an executable file.</param>
|
||||
/// <returns>
|
||||
/// An instance of <see cref="DriverSettingsProfile" /> class describing the NVIDIA driver behavior regarding the
|
||||
/// passed executable file.
|
||||
/// </returns>
|
||||
public DriverSettingsProfile FindApplicationProfile(string applicationName)
|
||||
{
|
||||
var application = DRSApi.FindApplicationByName(Handle, applicationName, out var profileHandle);
|
||||
|
||||
if (application == null || !profileHandle.HasValue || profileHandle.Value.IsNull)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DriverSettingsProfile(profileHandle.Value, this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds a profile based on its name.
|
||||
/// </summary>
|
||||
/// <param name="profileName">The profile name to search for.</param>
|
||||
/// <returns>An instance of <see cref="DriverSettingsProfile" /> class.</returns>
|
||||
public DriverSettingsProfile FindProfileByName(string profileName)
|
||||
{
|
||||
var profileHandle = DRSApi.FindProfileByName(Handle, profileName);
|
||||
|
||||
if (profileHandle.IsNull)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DriverSettingsProfile(profileHandle, this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets all settings to default.
|
||||
/// </summary>
|
||||
public void RestoreDefaults()
|
||||
{
|
||||
DRSApi.RestoreDefaults(Handle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the current session settings
|
||||
/// </summary>
|
||||
public void Save()
|
||||
{
|
||||
DRSApi.SaveSettings(Handle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the current session settings to a file
|
||||
/// </summary>
|
||||
/// <param name="fileName">The full path of file to save settings to.</param>
|
||||
public void Save(string fileName)
|
||||
{
|
||||
DRSApi.SaveSettings(Handle, fileName);
|
||||
}
|
||||
|
||||
private void Load()
|
||||
{
|
||||
DRSApi.LoadSettings(Handle);
|
||||
}
|
||||
|
||||
private void Load(string fileName)
|
||||
{
|
||||
DRSApi.LoadSettings(Handle, fileName);
|
||||
}
|
||||
|
||||
private void ReleaseUnmanagedResources()
|
||||
{
|
||||
DRSApi.DestroySession(Handle);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
~DriverSettingsSession()
|
||||
{
|
||||
ReleaseUnmanagedResources();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,555 +0,0 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace NvAPIWrapper.DRS
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum KnownSettingId : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// Antialiasing - Line gamma
|
||||
/// </summary>
|
||||
[Description("Antialiasing - Line gamma")]
|
||||
OpenGLAntiAliasingLineGamma = 0x2089BF6C,
|
||||
|
||||
/// <summary>
|
||||
/// Deep color for 3D applications
|
||||
/// </summary>
|
||||
[Description("Deep color for 3D applications")]
|
||||
OpenGLDeepColorScanOut = 0x2097C2F6,
|
||||
|
||||
/// <summary>
|
||||
/// OpenGL default swap interval
|
||||
/// </summary>
|
||||
[Description("OpenGL default swap interval")]
|
||||
OpenGLDefaultSwapInterval = 0x206A6582,
|
||||
|
||||
/// <summary>
|
||||
/// OpenGL default swap interval fraction
|
||||
/// </summary>
|
||||
[Description("OpenGL default swap interval fraction")]
|
||||
OpenGLDefaultSwapIntervalFractional = 0x206C4581,
|
||||
|
||||
/// <summary>
|
||||
/// OpenGL default swap interval sign
|
||||
/// </summary>
|
||||
[Description("OpenGL default swap interval sign")]
|
||||
OpenGLDefaultSwapIntervalSign = 0x20655CFA,
|
||||
|
||||
/// <summary>
|
||||
/// Event Log Severity Threshold
|
||||
/// </summary>
|
||||
[Description("Event Log Severity Threshold")]
|
||||
OpenGLEventLogSeverityThreshold = 0x209DF23E,
|
||||
|
||||
/// <summary>
|
||||
/// Extension String version
|
||||
/// </summary>
|
||||
[Description("Extension String version")]
|
||||
OpenGLExtensionStringVersion = 0x20FF7493,
|
||||
|
||||
/// <summary>
|
||||
/// Buffer-flipping mode
|
||||
/// </summary>
|
||||
[Description("Buffer-flipping mode")] OpenGLForceBlit = 0x201F619F,
|
||||
|
||||
/// <summary>
|
||||
/// Force Stereo shuttering
|
||||
/// </summary>
|
||||
[Description("Force Stereo shuttering")]
|
||||
OpenGLForceStereo = 0x204D9A0C,
|
||||
|
||||
/// <summary>
|
||||
/// Preferred OpenGL GPU
|
||||
/// </summary>
|
||||
[Description("Preferred OpenGL GPU")] OpenGLImplicitGPUAffinity = 0x20D0F3E6,
|
||||
|
||||
/// <summary>
|
||||
/// Maximum frames allowed
|
||||
/// </summary>
|
||||
[Description("Maximum frames allowed")]
|
||||
OpenGLMaximumFramesAllowed = 0x208E55E3,
|
||||
|
||||
/// <summary>
|
||||
/// Exported Overlay pixel types
|
||||
/// </summary>
|
||||
[Description("Exported Overlay pixel types")]
|
||||
OpenGLOverlayPixelType = 0x209AE66F,
|
||||
|
||||
/// <summary>
|
||||
/// Enable overlay
|
||||
/// </summary>
|
||||
[Description("Enable overlay")] OpenGLOverlaySupport = 0x206C28C4,
|
||||
|
||||
/// <summary>
|
||||
/// High level control of the rendering quality on OpenGL
|
||||
/// </summary>
|
||||
[Description("High level control of the rendering quality on OpenGL")]
|
||||
OpenGLQualityEnhancements = 0x20797D6C,
|
||||
|
||||
/// <summary>
|
||||
/// Unified back/depth buffer
|
||||
/// </summary>
|
||||
[Description("Unified back/depth buffer")]
|
||||
OpenGLSingleBackDepthBuffer = 0x20A29055,
|
||||
|
||||
/// <summary>
|
||||
/// Enable NV_gpu_multicast extension
|
||||
/// </summary>
|
||||
[Description("Enable NV_gpu_multicast extension")]
|
||||
OpenGLSLIMulticast = 0x2092D3BE,
|
||||
|
||||
/// <summary>
|
||||
/// Threaded optimization
|
||||
/// </summary>
|
||||
[Description("Threaded optimization")] OpenGLThreadControl = 0x20C1221E,
|
||||
|
||||
/// <summary>
|
||||
/// Event Log Tmon Severity Threshold
|
||||
/// </summary>
|
||||
[Description("Event Log Tmon Severity Threshold")]
|
||||
OpenGLTMONLevel = 0x202888C1,
|
||||
|
||||
/// <summary>
|
||||
/// Triple buffering
|
||||
/// </summary>
|
||||
[Description("Triple buffering")] OpenGLTripleBuffer = 0x20FDD1F9,
|
||||
|
||||
/// <summary>
|
||||
/// Antialiasing - Behavior Flags
|
||||
/// </summary>
|
||||
[Description("Antialiasing - Behavior Flags")]
|
||||
AntiAliasingBehaviorFlags = 0x10ECDB82,
|
||||
|
||||
/// <summary>
|
||||
/// Antialiasing - Transparency Multisampling
|
||||
/// </summary>
|
||||
[Description("Antialiasing - Transparency Multisampling")]
|
||||
AntiAliasingModeAlphaToCoverage = 0x10FC2D9C,
|
||||
|
||||
/// <summary>
|
||||
/// Antialiasing - Gamma correction
|
||||
/// </summary>
|
||||
[Description("Antialiasing - Gamma correction")]
|
||||
AntiAliasingModeGammaCorrection = 0x107D639D,
|
||||
|
||||
/// <summary>
|
||||
/// Antialiasing - Setting
|
||||
/// </summary>
|
||||
[Description("Antialiasing - Setting")]
|
||||
AntiAliasingModeMethod = 0x10D773D2,
|
||||
|
||||
/// <summary>
|
||||
/// Antialiasing - Transparency Supersampling
|
||||
/// </summary>
|
||||
[Description("Antialiasing - Transparency Supersampling")]
|
||||
AntiAliasingModeReplay = 0x10D48A85,
|
||||
|
||||
/// <summary>
|
||||
/// Antialiasing - Mode
|
||||
/// </summary>
|
||||
[Description("Antialiasing - Mode")] AntiAliasingModeSelector = 0x107EFC5B,
|
||||
|
||||
/// <summary>
|
||||
/// Antialiasing - SLI AA
|
||||
/// </summary>
|
||||
[Description("Antialiasing - SLI AA")] AntiAliasingModeSelectorSLIAntiAliasing = 0x107AFC5B,
|
||||
|
||||
/// <summary>
|
||||
/// Anisotropic filtering setting
|
||||
/// </summary>
|
||||
[Description("Anisotropic filtering setting")]
|
||||
AnisotropicModeLevel = 0x101E61A9,
|
||||
|
||||
/// <summary>
|
||||
/// Anisotropic filtering mode
|
||||
/// </summary>
|
||||
[Description("Anisotropic filtering mode")]
|
||||
AnisotropicModeSelector = 0x10D2BB16,
|
||||
|
||||
/// <summary>
|
||||
/// NVIDIA Predefined Ansel Usage
|
||||
/// </summary>
|
||||
[Description("NVIDIA Predefined Ansel Usage")]
|
||||
AnselAllow = 0x1035DB89,
|
||||
|
||||
/// <summary>
|
||||
/// Enable Ansel
|
||||
/// </summary>
|
||||
[Description("Enable Ansel")] AnselEnable = 0x1075D972,
|
||||
|
||||
/// <summary>
|
||||
/// Ansel flags for enabled applications
|
||||
/// </summary>
|
||||
[Description("Ansel flags for enabled applications")]
|
||||
AnselWhiteListed = 0x1085DA8A,
|
||||
|
||||
/// <summary>
|
||||
/// Application Profile Notification Popup Timeout
|
||||
/// </summary>
|
||||
[Description("Application Profile Notification Popup Timeout")]
|
||||
ApplicationProfileNotificationTimeOut = 0x104554B6,
|
||||
|
||||
/// <summary>
|
||||
/// Steam Application ID
|
||||
/// </summary>
|
||||
[Description("Steam Application ID")] ApplicationSteamId = 0x107CDDBC,
|
||||
|
||||
/// <summary>
|
||||
/// Battery Boost
|
||||
/// </summary>
|
||||
[Description("Battery Boost")] BatteryBoost = 0x10115C89,
|
||||
|
||||
/// <summary>
|
||||
/// Do not display this profile in the Control Panel
|
||||
/// </summary>
|
||||
[Description("Do not display this profile in the Control Panel")]
|
||||
ControlPanelHiddenProfile = 0x106D5CFF,
|
||||
|
||||
/// <summary>
|
||||
/// List of Universal GPU ids
|
||||
/// </summary>
|
||||
[Description("List of Universal GPU ids")]
|
||||
CUDAExcludedGPUs = 0x10354FF8,
|
||||
|
||||
/// <summary>
|
||||
/// Maximum GPU Power
|
||||
/// </summary>
|
||||
[Description("Maximum GPU Power")] D3DOpenGLGPUMaximumPower = 0x10D1EF29,
|
||||
|
||||
/// <summary>
|
||||
/// Export Performance Counters
|
||||
/// </summary>
|
||||
[Description("Export Performance Counters")]
|
||||
ExportPerformanceCounters = 0x108F0841,
|
||||
|
||||
/// <summary>
|
||||
/// NVIDIA Predefined FXAA Usage
|
||||
/// </summary>
|
||||
[Description("NVIDIA Predefined FXAA Usage")]
|
||||
FXAAAllow = 0x1034CB89,
|
||||
|
||||
/// <summary>
|
||||
/// Enable FXAA
|
||||
/// </summary>
|
||||
[Description("Enable FXAA")] FXAAEnable = 0x1074C972,
|
||||
|
||||
/// <summary>
|
||||
/// Enable FXAA Indicator
|
||||
/// </summary>
|
||||
[Description("Enable FXAA Indicator")] FXAAIndicatorEnable = 0x1068FB9C,
|
||||
|
||||
/// <summary>
|
||||
/// SLI indicator
|
||||
/// </summary>
|
||||
[Description("SLI indicator")] MCSFRShowSplit = 0x10287051,
|
||||
|
||||
/// <summary>
|
||||
/// NVIDIA Quality upscaling
|
||||
/// </summary>
|
||||
[Description("NVIDIA Quality upscaling")]
|
||||
NvidiaQualityUpScaling = 0x10444444,
|
||||
|
||||
/// <summary>
|
||||
/// Maximum AA samples allowed for a given application
|
||||
/// </summary>
|
||||
[Description("Maximum AA samples allowed for a given application")]
|
||||
OptimusMaximumAntiAliasing = 0x10F9DC83,
|
||||
|
||||
/// <summary>
|
||||
/// Display the PhysX indicator
|
||||
/// </summary>
|
||||
[Description("Display the PhysX indicator")]
|
||||
PhysxIndicator = 0x1094F16F,
|
||||
|
||||
/// <summary>
|
||||
/// Power management mode
|
||||
/// </summary>
|
||||
[Description("Power management mode")] PreferredPerformanceState = 0x1057EB71,
|
||||
|
||||
/// <summary>
|
||||
/// No override of Anisotropic filtering
|
||||
/// </summary>
|
||||
[Description("No override of Anisotropic filtering")]
|
||||
PreventUiAnisotropicOverride = 0x103BCCB5,
|
||||
|
||||
/// <summary>
|
||||
/// Frame Rate Limiter
|
||||
/// </summary>
|
||||
[Description("Frame Rate Limiter")] PerformanceStateFrameRateLimiter = 0x10834FEE,
|
||||
|
||||
/// <summary>
|
||||
/// Frame Rate Limiter 2 Control
|
||||
/// </summary>
|
||||
[Description("Frame Rate Limiter 2 Control")]
|
||||
PerformanceStateFrameRateLimiter2Control = 0x10834FFF,
|
||||
|
||||
/// <summary>
|
||||
/// Frame Rate Monitor
|
||||
/// </summary>
|
||||
[Description("Frame Rate Monitor")] PerformanceStateFrameRateLimiterGpsControl = 0x10834F01,
|
||||
|
||||
/// <summary>
|
||||
/// Frame Rate Monitor Control
|
||||
/// </summary>
|
||||
[Description("Frame Rate Monitor Control")]
|
||||
PerformanceStateFrameRateMonitorControl = 0x10834F05,
|
||||
|
||||
/// <summary>
|
||||
/// Maximum resolution allowed for a given application
|
||||
/// </summary>
|
||||
[Description("Maximum resolution allowed for a given application")]
|
||||
ShimMaxResolution = 0x10F9DC82,
|
||||
|
||||
/// <summary>
|
||||
/// Optimus flags for enabled applications
|
||||
/// </summary>
|
||||
[Description("Optimus flags for enabled applications")]
|
||||
ShimMCCOMPAT = 0x10F9DC80,
|
||||
|
||||
/// <summary>
|
||||
/// Enable application for Optimus
|
||||
/// </summary>
|
||||
[Description("Enable application for Optimus")]
|
||||
ShimRenderingMode = 0x10F9DC81,
|
||||
|
||||
/// <summary>
|
||||
/// Shim Rendering Mode Options per application for Optimus
|
||||
/// </summary>
|
||||
[Description("Shim Rendering Mode Options per application for Optimus")]
|
||||
ShimRenderingOptions = 0x10F9DC84,
|
||||
|
||||
/// <summary>
|
||||
/// Number of GPUs to use on SLI rendering mode
|
||||
/// </summary>
|
||||
[Description("Number of GPUs to use on SLI rendering mode")]
|
||||
SLIGPUCount = 0x1033DCD1,
|
||||
|
||||
/// <summary>
|
||||
/// NVIDIA predefined number of GPUs to use on SLI rendering mode
|
||||
/// </summary>
|
||||
[Description("NVIDIA predefined number of GPUs to use on SLI rendering mode")]
|
||||
SLIPredefinedGPUCount = 0x1033DCD2,
|
||||
|
||||
/// <summary>
|
||||
/// NVIDIA predefined number of GPUs to use on SLI rendering mode on DirectX 10
|
||||
/// </summary>
|
||||
[Description("NVIDIA predefined number of GPUs to use on SLI rendering mode on DirectX 10")]
|
||||
SLIPredefinedGPUCountDX10 = 0x1033DCD3,
|
||||
|
||||
/// <summary>
|
||||
/// NVIDIA predefined SLI mode
|
||||
/// </summary>
|
||||
[Description("NVIDIA predefined SLI mode")]
|
||||
SLIPredefinedMode = 0x1033CEC1,
|
||||
|
||||
/// <summary>
|
||||
/// NVIDIA predefined SLI mode on DirectX 10
|
||||
/// </summary>
|
||||
[Description("NVIDIA predefined SLI mode on DirectX 10")]
|
||||
SLIPredefinedModeDX10 = 0x1033CEC2,
|
||||
|
||||
/// <summary>
|
||||
/// SLI rendering mode
|
||||
/// </summary>
|
||||
[Description("SLI rendering mode")] SLIRenderingMode = 0x1033CED1,
|
||||
|
||||
/// <summary>
|
||||
/// Virtual Reality pre-rendered frames
|
||||
/// </summary>
|
||||
[Description("Virtual Reality pre-rendered frames")]
|
||||
VRPreRenderLimit = 0x10111133,
|
||||
|
||||
/// <summary>
|
||||
/// Toggle the VRR global feature
|
||||
/// </summary>
|
||||
[Description("Toggle the VRR global feature")]
|
||||
VRRFeatureIndicator = 0x1094F157,
|
||||
|
||||
/// <summary>
|
||||
/// Display the VRR Overlay Indicator
|
||||
/// </summary>
|
||||
[Description("Display the VRR Overlay Indicator")]
|
||||
VRROverlayIndicator = 0x1095F16F,
|
||||
|
||||
/// <summary>
|
||||
/// VRR requested state
|
||||
/// </summary>
|
||||
[Description("VRR requested state")] VRRRequestState = 0x1094F1F7,
|
||||
|
||||
/// <summary>
|
||||
/// G-SYNC
|
||||
/// </summary>
|
||||
[Description("G-SYNC")] VRRApplicationOverride = 0x10A879CF,
|
||||
|
||||
/// <summary>
|
||||
/// G-SYNC
|
||||
/// </summary>
|
||||
[Description("G-SYNC")] VRRApplicationOverrideRequestState = 0x10A879AC,
|
||||
|
||||
/// <summary>
|
||||
/// Enable G-SYNC globally
|
||||
/// </summary>
|
||||
[Description("Enable G-SYNC globally")]
|
||||
VRRMode = 0x1194F158,
|
||||
|
||||
/// <summary>
|
||||
/// Flag to control smooth AFR behavior
|
||||
/// </summary>
|
||||
[Description("Flag to control smooth AFR behavior")]
|
||||
VSyncSmoothAFR = 0x101AE763,
|
||||
|
||||
/// <summary>
|
||||
/// Variable refresh Rate
|
||||
/// </summary>
|
||||
[Description("Variable refresh Rate")] VSyncVRRControl = 0x10A879CE,
|
||||
|
||||
/// <summary>
|
||||
/// Vsync - Behavior Flags
|
||||
/// </summary>
|
||||
[Description("Vsync - Behavior Flags")]
|
||||
VSyncBehaviorFlags = 0x10FDEC23,
|
||||
|
||||
/// <summary>
|
||||
/// Stereo - Swap eyes
|
||||
/// </summary>
|
||||
[Description("Stereo - Swap eyes")] WKSAPIStereoEyesExchange = 0x11AE435C,
|
||||
|
||||
/// <summary>
|
||||
/// Stereo - Display mode
|
||||
/// </summary>
|
||||
[Description("Stereo - Display mode")] WKSAPIStereoMode = 0x11E91A61,
|
||||
|
||||
/// <summary>
|
||||
/// Memory Allocation Policy
|
||||
/// </summary>
|
||||
[Description("Memory Allocation Policy")]
|
||||
WKSMemoryAllocationPolicy = 0x11112233,
|
||||
|
||||
/// <summary>
|
||||
/// Stereo - Dongle Support
|
||||
/// </summary>
|
||||
[Description("Stereo - Dongle Support")]
|
||||
WKSStereoDongleSupport = 0x112493BD,
|
||||
|
||||
/// <summary>
|
||||
/// Stereo - Enable
|
||||
/// </summary>
|
||||
[Description("Stereo - Enable")] WKSStereoSupport = 0x11AA9E99,
|
||||
|
||||
/// <summary>
|
||||
/// Stereo <20> swap mode
|
||||
/// </summary>
|
||||
[Description("Stereo <20> swap mode")] WKSStereoSwapMode = 0x11333333,
|
||||
|
||||
/// <summary>
|
||||
/// Ambient Occlusion
|
||||
/// </summary>
|
||||
[Description("Ambient Occlusion")] AmbientOcclusionMode = 0x667329,
|
||||
|
||||
/// <summary>
|
||||
/// NVIDIA Predefined Ambient Occlusion Usage
|
||||
/// </summary>
|
||||
[Description("NVIDIA Predefined Ambient Occlusion Usage")]
|
||||
AmbientOcclusionModeActive = 0x664339,
|
||||
|
||||
/// <summary>
|
||||
/// Texture filtering - Driver Controlled LOD Bias
|
||||
/// </summary>
|
||||
[Description("Texture filtering - Driver Controlled LOD Bias")]
|
||||
AutoLODBiasAdjust = 0x638E8F,
|
||||
|
||||
/// <summary>
|
||||
/// Export Performance Counters for DX9 only
|
||||
/// </summary>
|
||||
[Description("Export Performance Counters for DX9 only")]
|
||||
ExportPerformanceCountersDX9Only = 0xB65E72,
|
||||
|
||||
/// <summary>
|
||||
/// ICafe Settings
|
||||
/// </summary>
|
||||
[Description("ICafe Settings")] ICafeLogoConfig = 0xDB1337,
|
||||
|
||||
/// <summary>
|
||||
/// Texture filtering - LOD Bias
|
||||
/// </summary>
|
||||
[Description("Texture filtering - LOD Bias")]
|
||||
LODBiasAdjust = 0x738E8F,
|
||||
|
||||
/// <summary>
|
||||
/// Enable sample interleaving (MFAA)
|
||||
/// </summary>
|
||||
[Description("Enable sample interleaving (MFAA)")]
|
||||
MaxwellBSampleInterleave = 0x98C1AC,
|
||||
|
||||
/// <summary>
|
||||
/// Maximum pre-rendered frames
|
||||
/// </summary>
|
||||
[Description("Maximum pre-rendered frames")]
|
||||
PreRenderLimit = 0x7BA09E,
|
||||
|
||||
/// <summary>
|
||||
/// Shader Cache
|
||||
/// </summary>
|
||||
[Description("Shader Cache")] PerformanceStateShaderDiskCache = 0x198FFF,
|
||||
|
||||
/// <summary>
|
||||
/// Texture filtering - Anisotropic sample optimization
|
||||
/// </summary>
|
||||
[Description("Texture filtering - Anisotropic sample optimization")]
|
||||
PerformanceStateTextureFilteringAnisotropicOptimization = 0xE73211,
|
||||
|
||||
/// <summary>
|
||||
/// Texture filtering - Anisotropic filter optimization
|
||||
/// </summary>
|
||||
[Description("Texture filtering - Anisotropic filter optimization")]
|
||||
PerformanceStateTextureFilteringBiLinearInAnisotropic = 0x84CD70,
|
||||
|
||||
/// <summary>
|
||||
/// Texture filtering - Trilinear optimization
|
||||
/// </summary>
|
||||
[Description("Texture filtering - Trilinear optimization")]
|
||||
PerformanceStateTextureFilteringDisableTrilinearSlope = 0x2ECAF2,
|
||||
|
||||
/// <summary>
|
||||
/// Texture filtering - Negative LOD bias
|
||||
/// </summary>
|
||||
[Description("Texture filtering - Negative LOD bias")]
|
||||
PerformanceStateTextureFilteringNoNegativeLODBias = 0x19BB68,
|
||||
|
||||
/// <summary>
|
||||
/// Texture filtering - Quality
|
||||
/// </summary>
|
||||
[Description("Texture filtering - Quality")]
|
||||
QualityEnhancements = 0xCE2691,
|
||||
|
||||
/// <summary>
|
||||
/// Preferred refresh rate
|
||||
/// </summary>
|
||||
[Description("Preferred refresh rate")]
|
||||
RefreshRateOverride = 0x64B541,
|
||||
|
||||
/// <summary>
|
||||
/// PowerThrottle
|
||||
/// </summary>
|
||||
[Description("PowerThrottle")] SetPowerThrottleForPCIeCompliance = 0xAE785C,
|
||||
|
||||
/// <summary>
|
||||
/// VAB Default Data
|
||||
/// </summary>
|
||||
[Description("VAB Default Data")] SetVABData = 0xAB8687,
|
||||
|
||||
/// <summary>
|
||||
/// Vertical Sync
|
||||
/// </summary>
|
||||
[Description("Vertical Sync")] VSyncMode = 0xA879CF,
|
||||
|
||||
/// <summary>
|
||||
/// Vertical Sync Tear Control
|
||||
/// </summary>
|
||||
[Description("Vertical Sync Tear Control")]
|
||||
VSyncTearControl = 0x5A375C,
|
||||
|
||||
InvalidSetting = 0xFFFFFFFF
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,424 +0,0 @@
|
||||
using System;
|
||||
using NvAPIWrapper.Native;
|
||||
using NvAPIWrapper.Native.DRS.Structures;
|
||||
using NvAPIWrapper.Native.Exceptions;
|
||||
using NvAPIWrapper.Native.Interfaces.DRS;
|
||||
|
||||
namespace NvAPIWrapper.DRS
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an application rule registered in a profile
|
||||
/// </summary>
|
||||
public class ProfileApplication
|
||||
{
|
||||
private IDRSApplication _application;
|
||||
|
||||
internal ProfileApplication(IDRSApplication application, DriverSettingsProfile profile)
|
||||
{
|
||||
Profile = profile;
|
||||
_application = application;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the application name
|
||||
/// </summary>
|
||||
public string ApplicationName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid application instance."
|
||||
);
|
||||
}
|
||||
|
||||
return _application.ApplicationName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the application command line
|
||||
/// </summary>
|
||||
public string CommandLine
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid application instance."
|
||||
);
|
||||
}
|
||||
|
||||
if (_application is DRSApplicationV4 applicationV4)
|
||||
{
|
||||
return applicationV4.ApplicationCommandLine;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of files that are necessary to be present inside the application parent directory
|
||||
/// </summary>
|
||||
public string[] FilesInFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid application instance."
|
||||
);
|
||||
}
|
||||
|
||||
if (_application is DRSApplicationV2 applicationV2)
|
||||
{
|
||||
return applicationV2.FilesInFolder;
|
||||
}
|
||||
|
||||
if (_application is DRSApplicationV3 applicationV3)
|
||||
{
|
||||
return applicationV3.FilesInFolder;
|
||||
}
|
||||
|
||||
if (_application is DRSApplicationV4 applicationV4)
|
||||
{
|
||||
return applicationV4.FilesInFolder;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the application friendly name
|
||||
/// </summary>
|
||||
public string FriendlyName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid application instance."
|
||||
);
|
||||
}
|
||||
|
||||
return _application.FriendlyName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean value indicating if this application rule needs a specific command line; or <see langword="null" />
|
||||
/// if this information is not available.
|
||||
/// </summary>
|
||||
public bool? HasCommandLine
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid application instance."
|
||||
);
|
||||
}
|
||||
|
||||
if (_application is DRSApplicationV3 applicationV3)
|
||||
{
|
||||
return applicationV3.HasCommandLine;
|
||||
}
|
||||
|
||||
if (_application is DRSApplicationV4 applicationV4)
|
||||
{
|
||||
return applicationV4.HasCommandLine;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean value indicating if this application is a metro application; or <see langword="null" /> if this
|
||||
/// information is not available.
|
||||
/// </summary>
|
||||
public bool? IsMetroApplication
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid application instance."
|
||||
);
|
||||
}
|
||||
|
||||
if (_application is DRSApplicationV3 applicationV3)
|
||||
{
|
||||
return applicationV3.IsMetroApplication;
|
||||
}
|
||||
|
||||
if (_application is DRSApplicationV4 applicationV4)
|
||||
{
|
||||
return applicationV4.IsMetroApplication;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean value indicating if this application is predefined by the NVIDIA driver
|
||||
/// </summary>
|
||||
public bool IsPredefined
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid application instance."
|
||||
);
|
||||
}
|
||||
|
||||
return _application.IsPredefined;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean value indicating if this instance of <see cref="ProfileApplication" /> is a valid instance
|
||||
/// representing an application in a profile
|
||||
/// </summary>
|
||||
public bool IsValid
|
||||
{
|
||||
get => _application != null && Profile.IsValid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the application launcher name
|
||||
/// </summary>
|
||||
public string LauncherName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid application instance."
|
||||
);
|
||||
}
|
||||
|
||||
return _application.LauncherName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parent profile instance
|
||||
/// </summary>
|
||||
public DriverSettingsProfile Profile { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new application
|
||||
/// </summary>
|
||||
/// <param name="profile">The profile to create the new application in.</param>
|
||||
/// <param name="applicationName">The application name (with extension).</param>
|
||||
/// <param name="friendlyName">The application friendly name.</param>
|
||||
/// <param name="launcherName">The application launcher name.</param>
|
||||
/// <param name="fileInFolders">An array of files necessary to be present inside the application parent directory.</param>
|
||||
/// <param name="isMetro">A boolean value indicating if this application is a metro application.</param>
|
||||
/// <param name="commandLine">The application command line string.</param>
|
||||
/// <returns>A new instance of <see cref="ProfileApplication" /> representing the newly created application.</returns>
|
||||
// ReSharper disable once TooManyArguments
|
||||
// ReSharper disable once FunctionComplexityOverflow
|
||||
public static ProfileApplication CreateApplication(
|
||||
DriverSettingsProfile profile,
|
||||
string applicationName,
|
||||
string friendlyName = null,
|
||||
string launcherName = null,
|
||||
string[] fileInFolders = null,
|
||||
bool isMetro = false,
|
||||
string commandLine = null
|
||||
)
|
||||
{
|
||||
var createDelegates = new Func<string, string, string, string[], bool, string, IDRSApplication>[]
|
||||
{
|
||||
CreateApplicationInstanceV4,
|
||||
CreateApplicationInstanceV3,
|
||||
CreateApplicationInstanceV2,
|
||||
CreateApplicationInstanceV1
|
||||
};
|
||||
|
||||
Exception lastException = null;
|
||||
IDRSApplication application = null;
|
||||
|
||||
foreach (var func in createDelegates)
|
||||
{
|
||||
try
|
||||
{
|
||||
// ReSharper disable once EventExceptionNotDocumented
|
||||
application = func(
|
||||
applicationName,
|
||||
friendlyName,
|
||||
launcherName,
|
||||
fileInFolders,
|
||||
isMetro,
|
||||
commandLine
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
catch (NVIDIANotSupportedException e)
|
||||
{
|
||||
// ignore
|
||||
lastException = e;
|
||||
}
|
||||
}
|
||||
|
||||
if (application == null)
|
||||
{
|
||||
// ReSharper disable once ThrowingSystemException
|
||||
throw lastException;
|
||||
}
|
||||
|
||||
application = DRSApi.CreateApplication(profile.Session.Handle, profile.Handle, application);
|
||||
|
||||
return new ProfileApplication(application, profile);
|
||||
}
|
||||
|
||||
// ReSharper disable once TooManyArguments
|
||||
private static IDRSApplication CreateApplicationInstanceV1(
|
||||
string applicationName,
|
||||
string friendlyName = null,
|
||||
string launcherName = null,
|
||||
string[] fileInFolders = null,
|
||||
bool isMetro = false,
|
||||
string commandLine = null
|
||||
)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(commandLine))
|
||||
{
|
||||
throw new NotSupportedException(
|
||||
"CommandLine is not supported with the current execution environment."
|
||||
);
|
||||
}
|
||||
|
||||
if (fileInFolders?.Length > 0)
|
||||
{
|
||||
throw new NotSupportedException(
|
||||
"Same folder file presence check is not supported with the current execution environment."
|
||||
);
|
||||
}
|
||||
|
||||
return new DRSApplicationV1(
|
||||
applicationName,
|
||||
friendlyName,
|
||||
launcherName
|
||||
);
|
||||
}
|
||||
|
||||
// ReSharper disable once TooManyArguments
|
||||
private static IDRSApplication CreateApplicationInstanceV2(
|
||||
string applicationName,
|
||||
string friendlyName = null,
|
||||
string launcherName = null,
|
||||
string[] fileInFolders = null,
|
||||
bool isMetro = false,
|
||||
string commandLine = null
|
||||
)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(commandLine))
|
||||
{
|
||||
throw new NotSupportedException(
|
||||
"CommandLine is not supported with the current execution environment."
|
||||
);
|
||||
}
|
||||
|
||||
return new DRSApplicationV2(
|
||||
applicationName,
|
||||
friendlyName,
|
||||
launcherName,
|
||||
fileInFolders
|
||||
);
|
||||
}
|
||||
|
||||
// ReSharper disable once TooManyArguments
|
||||
private static IDRSApplication CreateApplicationInstanceV3(
|
||||
string applicationName,
|
||||
string friendlyName = null,
|
||||
string launcherName = null,
|
||||
string[] fileInFolders = null,
|
||||
bool isMetro = false,
|
||||
string commandLine = null
|
||||
)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(commandLine))
|
||||
{
|
||||
throw new NotSupportedException(
|
||||
"CommandLine is not supported with the current execution environment."
|
||||
);
|
||||
}
|
||||
|
||||
return new DRSApplicationV3(
|
||||
applicationName,
|
||||
friendlyName,
|
||||
launcherName,
|
||||
fileInFolders,
|
||||
isMetro
|
||||
);
|
||||
}
|
||||
|
||||
// ReSharper disable once TooManyArguments
|
||||
private static IDRSApplication CreateApplicationInstanceV4(
|
||||
string applicationName,
|
||||
string friendlyName = null,
|
||||
string launcherName = null,
|
||||
string[] fileInFolders = null,
|
||||
bool isMetro = false,
|
||||
string commandLine = null
|
||||
)
|
||||
{
|
||||
return new DRSApplicationV4(
|
||||
applicationName,
|
||||
friendlyName,
|
||||
launcherName,
|
||||
fileInFolders,
|
||||
isMetro,
|
||||
commandLine
|
||||
);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
return "[Invalid]";
|
||||
}
|
||||
|
||||
if (IsPredefined)
|
||||
{
|
||||
return $"{ApplicationName} (Predefined)";
|
||||
}
|
||||
|
||||
return ApplicationName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes this application and makes this instance invalid
|
||||
/// </summary>
|
||||
public void Delete()
|
||||
{
|
||||
if (!IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Can not perform this operation with an invalid application instance."
|
||||
);
|
||||
}
|
||||
|
||||
DRSApi.DeleteApplication(Profile.Session.Handle, Profile.Handle, _application);
|
||||
_application = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
using System;
|
||||
using NvAPIWrapper.Native.DRS;
|
||||
using NvAPIWrapper.Native.DRS.Structures;
|
||||
|
||||
namespace NvAPIWrapper.DRS
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a profile setting and its value
|
||||
/// </summary>
|
||||
public class ProfileSetting
|
||||
{
|
||||
private readonly DRSSettingV1 _setting;
|
||||
|
||||
internal ProfileSetting(DRSSettingV1 setting)
|
||||
{
|
||||
_setting = setting;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current value of the setting
|
||||
/// </summary>
|
||||
public object CurrentValue
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsPredefinedValueValid && IsCurrentValuePredefined)
|
||||
{
|
||||
return _setting.PredefinedValue;
|
||||
}
|
||||
|
||||
return _setting.CurrentValue;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean value indicating if the current value is the predefined value.
|
||||
/// </summary>
|
||||
public bool IsCurrentValuePredefined
|
||||
{
|
||||
get => _setting.IsCurrentValuePredefined;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean value indicating if this setting had a predefined valid value.
|
||||
/// </summary>
|
||||
public bool IsPredefinedValueValid
|
||||
{
|
||||
get => _setting.IsPredefinedValueValid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the predefined value of this setting.
|
||||
/// </summary>
|
||||
public object PredefinedValue
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsPredefinedValueValid)
|
||||
{
|
||||
throw new InvalidOperationException("Predefined value is not valid.");
|
||||
}
|
||||
|
||||
return _setting.PredefinedValue;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the setting identification number
|
||||
/// </summary>
|
||||
public uint SettingId
|
||||
{
|
||||
get => _setting.Id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets additional information regarding this setting including possible valid values
|
||||
/// </summary>
|
||||
public SettingInfo SettingInfo
|
||||
{
|
||||
get => SettingInfo.FromId(SettingId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the profile location of this setting
|
||||
/// </summary>
|
||||
public DRSSettingLocation SettingLocation
|
||||
{
|
||||
get => _setting.SettingLocation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value type of this setting
|
||||
/// </summary>
|
||||
public DRSSettingType SettingType
|
||||
{
|
||||
get => _setting.SettingType;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
string settingName = null;
|
||||
|
||||
try
|
||||
{
|
||||
settingName = SettingInfo.Name;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(settingName))
|
||||
{
|
||||
settingName = $"#{SettingId:X}";
|
||||
}
|
||||
|
||||
if (IsCurrentValuePredefined)
|
||||
{
|
||||
return $"{settingName} = {CurrentValue ?? "[NULL]"} (Predefined)";
|
||||
}
|
||||
|
||||
return $"{settingName} = {CurrentValue ?? "[NULL]"}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,360 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using NvAPIWrapper.Native;
|
||||
using NvAPIWrapper.Native.DRS;
|
||||
|
||||
namespace NvAPIWrapper.DRS
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains information about a setting
|
||||
/// </summary>
|
||||
public class SettingInfo
|
||||
{
|
||||
private static uint[] _availableSettingIds;
|
||||
|
||||
private SettingInfo(uint settingId)
|
||||
{
|
||||
SettingId = settingId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an array of available possible valid values.
|
||||
/// </summary>
|
||||
public object[] AvailableValues
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsAvailable)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return DRSApi.EnumAvailableSettingValues(SettingId).Values;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default value of this setting
|
||||
/// </summary>
|
||||
public object DefaultValue
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsAvailable)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var values = DRSApi.EnumAvailableSettingValues(SettingId);
|
||||
|
||||
return values.DefaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean value indicating if this setting is available on this machine and with the current version of NVIDIA
|
||||
/// driver
|
||||
/// </summary>
|
||||
public bool IsAvailable
|
||||
{
|
||||
get => GetAvailableSetting().Any(info => info.SettingId == SettingId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean value indicating if this setting is know by this library
|
||||
/// </summary>
|
||||
public bool IsKnown
|
||||
{
|
||||
get => IsSettingKnown(SettingId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the description of this setting from the library or <see langword="null" /> if this setting is not known by
|
||||
/// the library.
|
||||
/// </summary>
|
||||
public string KnownDescription
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsKnown || KnownSettingId == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return GetSettingDescription(KnownSettingId.Value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the known identification number of this setting from the library or <see langword="null" /> if this setting is
|
||||
/// not known by the library.
|
||||
/// </summary>
|
||||
public KnownSettingId? KnownSettingId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsKnown)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return GetKnownSettingId(SettingId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of a static class or an enum containing possible known values for this setting from the library or
|
||||
/// <see langword="null" /> if this setting is not known by the library
|
||||
/// </summary>
|
||||
public Type KnownValueType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsKnown || !IsAvailable)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var name = KnownSettingId.ToString();
|
||||
var nameSpace = typeof(SettingInfo).Namespace + ".SettingValues";
|
||||
|
||||
if (SettingType == DRSSettingType.Integer)
|
||||
{
|
||||
return Assembly.GetExecutingAssembly().GetTypes().FirstOrDefault(type =>
|
||||
type.IsEnum &&
|
||||
type.Namespace?.Equals(nameSpace, StringComparison.InvariantCultureIgnoreCase) == true &&
|
||||
type.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
|
||||
if (SettingType == DRSSettingType.String || SettingType == DRSSettingType.UnicodeString)
|
||||
{
|
||||
return Assembly.GetExecutingAssembly().GetTypes().FirstOrDefault(type =>
|
||||
type.IsClass &&
|
||||
type.Namespace?.Equals(nameSpace, StringComparison.InvariantCultureIgnoreCase) == true &&
|
||||
type.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the setting from NVIDIA driver or <see langword="null" /> if the setting is not available on this
|
||||
/// machine.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsAvailable)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return DRSApi.GetSettingNameFromId(SettingId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the setting identification number
|
||||
/// </summary>
|
||||
public uint SettingId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value type of the setting from NVIDIA driver or <see langword="null" /> if the setting is not available on
|
||||
/// this machine.
|
||||
/// </summary>
|
||||
public DRSSettingType? SettingType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsAvailable)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var values = DRSApi.EnumAvailableSettingValues(SettingId);
|
||||
|
||||
return values.SettingType;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets information regarding a setting from its identification number.
|
||||
/// </summary>
|
||||
/// <param name="settingId">The identification number of the setting to get information about.</param>
|
||||
/// <returns>An instance of <see cref="SettingInfo" /> containing information about the setting.</returns>
|
||||
public static SettingInfo FromId(uint settingId)
|
||||
{
|
||||
return new SettingInfo(settingId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets information regarding a setting from its known identification number.
|
||||
/// </summary>
|
||||
/// <param name="settingId">The known identification number of the setting to get information about.</param>
|
||||
/// <returns>An instance of <see cref="SettingInfo" /> containing information about the setting.</returns>
|
||||
public static SettingInfo FromKnownSettingId(KnownSettingId settingId)
|
||||
{
|
||||
return FromId(GetSettingId(settingId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets information regarding a setting from its name.
|
||||
/// </summary>
|
||||
/// <param name="settingName">The name of the setting to get information about.</param>
|
||||
/// <returns>An instance of <see cref="SettingInfo" /> containing information about the setting.</returns>
|
||||
public static SettingInfo FromName(string settingName)
|
||||
{
|
||||
var settingId = DRSApi.GetSettingIdFromName(settingName);
|
||||
|
||||
return FromId(settingId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all available setting on this machine
|
||||
/// </summary>
|
||||
/// <returns>Instances of <see cref="SettingInfo" /> each representing a available setting on this machine.</returns>
|
||||
public static SettingInfo[] GetAvailableSetting()
|
||||
{
|
||||
if (_availableSettingIds == null)
|
||||
{
|
||||
_availableSettingIds = DRSApi.EnumAvailableSettingIds();
|
||||
}
|
||||
|
||||
return _availableSettingIds.Select(FromId).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the known identification number of a setting from its identification number
|
||||
/// </summary>
|
||||
/// <param name="settingId">The setting identification number.</param>
|
||||
/// <returns>The known setting identification number if the setting is known; otherwise <see langword="null" />.</returns>
|
||||
public static KnownSettingId? GetKnownSettingId(uint settingId)
|
||||
{
|
||||
if (!IsSettingKnown(settingId))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (KnownSettingId) settingId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the known setting description from its identification number
|
||||
/// </summary>
|
||||
/// <param name="knownSettingId">The known setting identification number.</param>
|
||||
/// <returns>The known setting description if available; otherwise <see langword="null" />.</returns>
|
||||
public static string GetSettingDescription(KnownSettingId knownSettingId)
|
||||
{
|
||||
var enumName = Enum.GetName(typeof(KnownSettingId), knownSettingId);
|
||||
|
||||
if (enumName == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var enumField = typeof(KnownSettingId).GetField(enumName);
|
||||
|
||||
if (enumField == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var descriptionAttribute = enumField
|
||||
.GetCustomAttributes(typeof(DescriptionAttribute), false)
|
||||
.OfType<DescriptionAttribute>()
|
||||
.FirstOrDefault();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(descriptionAttribute?.Description))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return descriptionAttribute.Description;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the identification number of a setting from its known identification number
|
||||
/// </summary>
|
||||
/// <param name="knownSettingId">The known setting identification number.</param>
|
||||
/// <returns>The setting identification number.</returns>
|
||||
public static uint GetSettingId(KnownSettingId knownSettingId)
|
||||
{
|
||||
return (uint) knownSettingId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a setting is known by this library.
|
||||
/// </summary>
|
||||
/// <param name="settingId">The setting identification number.</param>
|
||||
/// <returns>true if setting is known by this library; otherwise false.</returns>
|
||||
public static bool IsSettingKnown(uint settingId)
|
||||
{
|
||||
return Enum.IsDefined(typeof(KnownSettingId), settingId);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
try
|
||||
{
|
||||
var settingName = Name;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(settingName))
|
||||
{
|
||||
return settingName;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore;
|
||||
}
|
||||
|
||||
return $"#{SettingId:X}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to resolve the name of a known value using its actual value
|
||||
/// </summary>
|
||||
/// <param name="value">The actual value</param>
|
||||
/// <returns>The name of the known value member.</returns>
|
||||
public string ResolveKnownValueName(object value)
|
||||
{
|
||||
if (!IsKnown)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var valueType = KnownValueType;
|
||||
|
||||
if (valueType == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (valueType.IsEnum)
|
||||
{
|
||||
return Enum.GetName(valueType, value);
|
||||
}
|
||||
|
||||
var comparerType = typeof(EqualityComparer<>).MakeGenericType(value.GetType());
|
||||
var comparer = comparerType.GetProperty(nameof(EqualityComparer<object>.Default))?.GetValue(null);
|
||||
|
||||
if (!(comparer is IEqualityComparer equalityComparer))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return valueType.GetFields()
|
||||
.FirstOrDefault(info =>
|
||||
info.IsStatic &&
|
||||
equalityComparer.Equals(info.GetValue(null), value)
|
||||
)?.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum AmbientOcclusionMode : uint
|
||||
{
|
||||
Off = 0x0,
|
||||
|
||||
Low = 0x1,
|
||||
|
||||
Medium = 0x2,
|
||||
|
||||
High = 0x3,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum AmbientOcclusionModeActive : uint
|
||||
{
|
||||
Disabled = 0x0,
|
||||
|
||||
Enabled = 0x1,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum AnisotropicModeLevel : uint
|
||||
{
|
||||
Mask = 0xFFFF,
|
||||
|
||||
NonePoint = 0x0,
|
||||
|
||||
NoneLinear = 0x1,
|
||||
|
||||
Maximum = 0x10,
|
||||
|
||||
Default = 0x1
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum AnisotropicModeSelector : uint
|
||||
{
|
||||
Mask = 0xF,
|
||||
|
||||
Application = 0x0,
|
||||
|
||||
User = 0x1,
|
||||
|
||||
Condition = 0x2,
|
||||
|
||||
Maximum = 0x2,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum AnselAllow : uint
|
||||
{
|
||||
Disallowed = 0x0,
|
||||
|
||||
Allowed = 0x1,
|
||||
|
||||
Default = 0x1
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum AnselEnable : uint
|
||||
{
|
||||
Off = 0x0,
|
||||
|
||||
On = 0x1,
|
||||
|
||||
Default = 0x1
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum AnselWhiteListed : uint
|
||||
{
|
||||
Disallowed = 0x0,
|
||||
|
||||
Allowed = 0x1,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum AntiAliasingBehaviorFlags : uint
|
||||
{
|
||||
None = 0x0,
|
||||
|
||||
TreatOverrideAsApplicationControlled = 0x1,
|
||||
|
||||
TreatOverrideAsEnhance = 0x2,
|
||||
|
||||
DisableOverride = 0x3,
|
||||
|
||||
TreatEnhanceAsApplicationControlled = 0x4,
|
||||
|
||||
TreatEnhanceAsOverride = 0x8,
|
||||
|
||||
DisableEnhance = 0xC,
|
||||
|
||||
MapVCAAToMultiSampling = 0x10000,
|
||||
|
||||
SLIDisableTransparencySupersampling = 0x20000,
|
||||
|
||||
DisableCplaa = 0x40000,
|
||||
|
||||
SkipRTDIMCheckForEnhance = 0x80000,
|
||||
|
||||
DisableSLIAntiAliasing = 0x100000,
|
||||
|
||||
Default = 0x0,
|
||||
|
||||
AntiAliasingRTBPPDIV4 = 0xF0000000,
|
||||
|
||||
AntiAliasingRTBPPDIV4Shift = 0x1C,
|
||||
|
||||
NonAntiAliasingRTBPPDIV4 = 0xF000000,
|
||||
|
||||
NonAntiAliasingRTBPPDIV4Shift = 0x18,
|
||||
|
||||
Mask = 0xFF1F000F
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum AntiAliasingModeAlphaToCoverage : uint
|
||||
{
|
||||
ModeMask = 0x4,
|
||||
|
||||
ModeOff = 0x0,
|
||||
|
||||
ModeOn = 0x4,
|
||||
|
||||
ModeMaximum = 0x4,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum AntiAliasingModeGammaCorrection : uint
|
||||
{
|
||||
Mask = 0x3,
|
||||
|
||||
Off = 0x0,
|
||||
|
||||
OnIfFOS = 0x1,
|
||||
|
||||
OnAlways = 0x2,
|
||||
|
||||
Maximum = 0x2,
|
||||
|
||||
Default = 0x0,
|
||||
|
||||
DefaultTesla = 0x2,
|
||||
|
||||
DefaultFermi = 0x2
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum AntiAliasingModeMethod : uint
|
||||
{
|
||||
None = 0x0,
|
||||
|
||||
SuperSample2XHorizontal = 0x1,
|
||||
|
||||
SuperSample2XVertical = 0x2,
|
||||
|
||||
SuperSample15X15 = 0x2,
|
||||
|
||||
Free0X03 = 0x3,
|
||||
|
||||
Free0X04 = 0x4,
|
||||
|
||||
SuperSample4X = 0x5,
|
||||
|
||||
SuperSample4XBias = 0x6,
|
||||
|
||||
SuperSample4XGaussian = 0x7,
|
||||
|
||||
Free0X08 = 0x8,
|
||||
|
||||
Free0X09 = 0x9,
|
||||
|
||||
SuperSample9X = 0xA,
|
||||
|
||||
SuperSample9XBias = 0xB,
|
||||
|
||||
SuperSample16X = 0xC,
|
||||
|
||||
SuperSample16XBias = 0xD,
|
||||
|
||||
MultiSample2XDiagonal = 0xE,
|
||||
|
||||
MultiSample2XQuincunx = 0xF,
|
||||
|
||||
MultiSample4X = 0x10,
|
||||
|
||||
Free0X11 = 0x11,
|
||||
|
||||
MultiSample4XGaussian = 0x12,
|
||||
|
||||
MixedSample4XSkewed4Tap = 0x13,
|
||||
|
||||
Free0X14 = 0x14,
|
||||
|
||||
Free0X15 = 0x15,
|
||||
|
||||
MixedSample6X = 0x16,
|
||||
|
||||
MixedSample6XSkewed6Tap = 0x17,
|
||||
|
||||
MixedSample8X = 0x18,
|
||||
|
||||
MixedSample8XSkewed8Tap = 0x19,
|
||||
|
||||
MixedSample16X = 0x1A,
|
||||
|
||||
MultiSample4XGamma = 0x1B,
|
||||
|
||||
MultiSample16X = 0x1C,
|
||||
|
||||
VCAA32X8V24 = 0x1D,
|
||||
|
||||
CorruptionCheck = 0x1E,
|
||||
|
||||
_6XCT = 0x1F,
|
||||
|
||||
MultiSample2XDiagonalGamma = 0x20,
|
||||
|
||||
SuperSample4XGamma = 0x21,
|
||||
|
||||
MultiSample4XFosgamma = 0x22,
|
||||
|
||||
MultiSample2XDiagonalFosgamma = 0x23,
|
||||
|
||||
SuperSample4XFosgamma = 0x24,
|
||||
|
||||
MultiSample8X = 0x25,
|
||||
|
||||
VCAA8X4V4 = 0x26,
|
||||
|
||||
VCAA16X4V12 = 0x27,
|
||||
|
||||
VCAA16X8V8 = 0x28,
|
||||
|
||||
MixedSample32X = 0x29,
|
||||
|
||||
SuperVCAA64X4V12 = 0x2A,
|
||||
|
||||
SuperVCAA64X8V8 = 0x2B,
|
||||
|
||||
MixedSample64X = 0x2C,
|
||||
|
||||
MixedSample128X = 0x2D,
|
||||
|
||||
Count = 0x2E,
|
||||
|
||||
MethodMask = 0xFFFF,
|
||||
|
||||
MethodMaximum = 0xF1C57815,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum AntiAliasingModeReplay : uint
|
||||
{
|
||||
SamplesMask = 0x70,
|
||||
|
||||
SamplesOne = 0x0,
|
||||
|
||||
SamplesTwo = 0x10,
|
||||
|
||||
SamplesFour = 0x20,
|
||||
|
||||
SamplesEight = 0x30,
|
||||
|
||||
SamplesMaximum = 0x30,
|
||||
|
||||
ModeMask = 0xF,
|
||||
|
||||
ModeOff = 0x0,
|
||||
|
||||
ModeAlphaTest = 0x1,
|
||||
|
||||
ModePixelKill = 0x2,
|
||||
|
||||
ModeDynamicBranch = 0x4,
|
||||
|
||||
ModeOptimal = 0x4,
|
||||
|
||||
ModeAll = 0x8,
|
||||
|
||||
ModeMaximum = 0xF,
|
||||
|
||||
Transparency = 0x23,
|
||||
|
||||
DisAllowTraa = 0x100,
|
||||
|
||||
TransparencyDefault = 0x0,
|
||||
|
||||
TransparencyDefaultTesla = 0x0,
|
||||
|
||||
TransparencyDefaultFermi = 0x0,
|
||||
|
||||
Mask = 0x17F,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum AntiAliasingModeSelector : uint
|
||||
{
|
||||
Mask = 0x3,
|
||||
|
||||
ApplicationControl = 0x0,
|
||||
|
||||
Override = 0x1,
|
||||
|
||||
Enhance = 0x2,
|
||||
|
||||
Maximum = 0x2,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum AntiAliasingModeSelectorSLIAntiAliasing : uint
|
||||
{
|
||||
Disabled = 0x0,
|
||||
|
||||
Enabled = 0x1,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum ApplicationProfileNotificationTimeOut : uint
|
||||
{
|
||||
Disabled = 0x0,
|
||||
|
||||
NineSeconds = 0x9,
|
||||
|
||||
FifteenSeconds = 0xF,
|
||||
|
||||
ThirtySeconds = 0x1E,
|
||||
|
||||
OneMinute = 0x3C,
|
||||
|
||||
TwoMinutes = 0x78,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum AutoLODBiasAdjust : uint
|
||||
{
|
||||
Off = 0x0,
|
||||
|
||||
On = 0x1,
|
||||
|
||||
Default = 0x1
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum BatteryBoost : uint
|
||||
{
|
||||
Minimum = 0x1,
|
||||
|
||||
Maximum = 0xFF,
|
||||
|
||||
Enabled = 0x10000000,
|
||||
|
||||
Disabled = 0x0,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public static class CUDAExcludedGPUs
|
||||
{
|
||||
public const string Default = "none";
|
||||
public const string None = "none";
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum ControlPanelHiddenProfile : uint
|
||||
{
|
||||
Disabled = 0x0,
|
||||
|
||||
Enabled = 0x1,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public static class D3DOpenGLGPUMaximumPower
|
||||
{
|
||||
public const string Default = "0";
|
||||
public const string DefaultPower = "0";
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum ExportPerformanceCounters : uint
|
||||
{
|
||||
Off = 0x0,
|
||||
|
||||
On = 0x1,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum ExportPerformanceCountersDX9Only : uint
|
||||
{
|
||||
Off = 0x0,
|
||||
|
||||
On = 0x1,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum FXAAAllow : uint
|
||||
{
|
||||
Disallowed = 0x0,
|
||||
|
||||
Allowed = 0x1,
|
||||
|
||||
Default = 0x1
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum FXAAEnable : uint
|
||||
{
|
||||
Off = 0x0,
|
||||
|
||||
On = 0x1,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum FXAAIndicatorEnable : uint
|
||||
{
|
||||
Off = 0x0,
|
||||
|
||||
On = 0x1,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum LODBiasAdjust : uint
|
||||
{
|
||||
Minimum = 0xFFFFFF80,
|
||||
|
||||
Maximum = 0x80,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum MCSFRShowSplit : uint
|
||||
{
|
||||
Disabled = 0x34534064,
|
||||
|
||||
Enabled = 0x24545582,
|
||||
|
||||
Default = 0x34534064
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum MaxwellBSampleInterleave : uint
|
||||
{
|
||||
Off = 0x0,
|
||||
|
||||
On = 0x1,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum NvidiaQualityUpScaling : uint
|
||||
{
|
||||
Off = 0x0,
|
||||
|
||||
On = 0x1,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum OpenGLAntiAliasingLineGamma : uint
|
||||
{
|
||||
Disabled = 0x10,
|
||||
|
||||
Enabled = 0x23,
|
||||
|
||||
Minimum = 0x1,
|
||||
|
||||
Maximum = 0x64,
|
||||
|
||||
Default = 0x10
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum OpenGLDeepColorScanOut : uint
|
||||
{
|
||||
Disable = 0x0,
|
||||
|
||||
Enable = 0x1,
|
||||
|
||||
Default = 0x1
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum OpenGLDefaultSwapInterval : uint
|
||||
{
|
||||
Tear = 0x0,
|
||||
|
||||
VSyncOne = 0x1,
|
||||
|
||||
VSync = 0x1,
|
||||
|
||||
ValueMask = 0xFFFF,
|
||||
|
||||
ForceMask = 0xF0000000,
|
||||
|
||||
ForceOff = 0xF0000000,
|
||||
|
||||
ForceOn = 0x10000000,
|
||||
|
||||
ApplicationControlled = 0x0,
|
||||
|
||||
Disable = 0xFFFFFFFF,
|
||||
|
||||
Default = 0x1
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum OpenGLDefaultSwapIntervalFractional : uint
|
||||
{
|
||||
ZeroScanLines = 0x0,
|
||||
|
||||
OneFullFrameOfScanLines = 0x64,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum OpenGLDefaultSwapIntervalSign : uint
|
||||
{
|
||||
Positive = 0x0,
|
||||
|
||||
Negative = 0x1,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum OpenGLEventLogSeverityThreshold : uint
|
||||
{
|
||||
Disable = 0x0,
|
||||
|
||||
Critical = 0x1,
|
||||
|
||||
Warning = 0x2,
|
||||
|
||||
Information = 0x3,
|
||||
|
||||
All = 0x4,
|
||||
|
||||
Default = 0x4
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum OpenGLForceBlit : uint
|
||||
{
|
||||
On = 0x1,
|
||||
|
||||
Off = 0x0,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum OpenGLForceStereo : uint
|
||||
{
|
||||
Off = 0x0,
|
||||
|
||||
On = 0x1,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public static class OpenGLImplicitGPUAffinity
|
||||
{
|
||||
public const string AutoSelect = "autoselect";
|
||||
|
||||
public const string Default = "autoselect";
|
||||
public const string EnvironmentVariable = "OGL_DEFAULT_RENDERING_GPU";
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum OpenGLOverlayPixelType : uint
|
||||
{
|
||||
None = 0x0,
|
||||
|
||||
CI = 0x1,
|
||||
|
||||
RGBA = 0x2,
|
||||
|
||||
CIAndRGBA = 0x3,
|
||||
|
||||
Default = 0x1
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum OpenGLOverlaySupport : uint
|
||||
{
|
||||
Off = 0x0,
|
||||
|
||||
On = 0x1,
|
||||
|
||||
ForceSoftware = 0x2,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum OpenGLQualityEnhancements : uint
|
||||
{
|
||||
HighQuality = 0xFFFFFFF6,
|
||||
|
||||
Quality = 0x0,
|
||||
|
||||
Performance = 0xA,
|
||||
|
||||
HighPerformance = 0x14,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum OpenGLSLIMulticast : uint
|
||||
{
|
||||
Disable = 0x0,
|
||||
|
||||
Enable = 0x1,
|
||||
|
||||
ForceDisable = 0x2,
|
||||
|
||||
AllowMosaic = 0x4,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum OpenGLSingleBackDepthBuffer : uint
|
||||
{
|
||||
Disable = 0x0,
|
||||
|
||||
Enable = 0x1,
|
||||
|
||||
UseHardwareDefault = 0xFFFFFFFF,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum OpenGLTMONLevel : uint
|
||||
{
|
||||
Disable = 0x0,
|
||||
|
||||
Critical = 0x1,
|
||||
|
||||
Warning = 0x2,
|
||||
|
||||
Information = 0x3,
|
||||
|
||||
Most = 0x4,
|
||||
|
||||
Verbose = 0x5,
|
||||
|
||||
Default = 0x4
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum OpenGLThreadControl : uint
|
||||
{
|
||||
Enable = 0x1,
|
||||
|
||||
Disable = 0x2,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum OpenGLTripleBuffer : uint
|
||||
{
|
||||
Disabled = 0x0,
|
||||
|
||||
Enabled = 0x1,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum OptimusMaximumAntiAliasing : uint
|
||||
{
|
||||
Minimum = 0x0,
|
||||
|
||||
Maximum = 0x10,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum PerformanceStateFrameRateLimiter : uint
|
||||
{
|
||||
Disabled = 0x0,
|
||||
|
||||
FPS20 = 0x14,
|
||||
|
||||
FPS30 = 0x1E,
|
||||
|
||||
FPS40 = 0x28,
|
||||
|
||||
Fpsmask = 0xFF,
|
||||
|
||||
NoAlign = 0x4000,
|
||||
|
||||
BBQM = 0x8000,
|
||||
|
||||
LowerFPSToAlign = 0x20000,
|
||||
|
||||
ForceVSyncOff = 0x40000,
|
||||
|
||||
GpsWeb = 0x80000,
|
||||
|
||||
Disallowed = 0x200000,
|
||||
|
||||
UseCPUWait = 0x400000,
|
||||
|
||||
NoLagOffset = 0x800000,
|
||||
|
||||
Accurate = 0x10000000,
|
||||
|
||||
AllowWindowed = 0x20000000,
|
||||
|
||||
ForceOn = 0x40000000,
|
||||
|
||||
Enabled = 0x80000000,
|
||||
|
||||
OpenGLRemoteDesktop = 0xE000003C,
|
||||
|
||||
Mask = 0xF0EEC0FF,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum PerformanceStateFrameRateLimiter2Control : uint
|
||||
{
|
||||
DelayCE = 0x0,
|
||||
|
||||
Delay3D = 0x1,
|
||||
|
||||
AvoidNoop = 0x2,
|
||||
|
||||
DelayCEPresent3D = 0x8,
|
||||
|
||||
AllowAllMaxwell = 0x10,
|
||||
|
||||
AllowAll = 0x20,
|
||||
|
||||
ForceOff = 0x40,
|
||||
|
||||
EnableVCE = 0x80,
|
||||
|
||||
DefaultForGM10X = 0x11,
|
||||
|
||||
Default = 0x88
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum PerformanceStateFrameRateLimiterGpsControl : uint
|
||||
{
|
||||
Disabled = 0x0,
|
||||
|
||||
DecreaseFilterMask = 0x1FF,
|
||||
|
||||
PauseTimeMask = 0xFE00,
|
||||
|
||||
PauseTimeShift = 0x9,
|
||||
|
||||
TargetRenderTimeMask = 0xFF0000,
|
||||
|
||||
TargetRenderTimeShift = 0x10,
|
||||
|
||||
PerformanceStepSizeMask = 0x1F000000,
|
||||
|
||||
PerformanceStepSizeShift = 0x18,
|
||||
|
||||
IncreaseFilterMask = 0xE0000000,
|
||||
|
||||
IncreaseFilterShift = 0x1D,
|
||||
|
||||
OptimalSetting = 0x4A5A3219,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum PerformanceStateFrameRateMonitorControl : uint
|
||||
{
|
||||
Disabled = 0x0,
|
||||
|
||||
ThresholdPctMask = 0xFF,
|
||||
|
||||
MovingAverageXMask = 0xF00,
|
||||
|
||||
MovingAverageXShift = 0x8,
|
||||
|
||||
EnableFineGrained = 0x400000,
|
||||
|
||||
EnableOnVSync = 0x800000,
|
||||
|
||||
VSyncOffsetMask = 0xF000,
|
||||
|
||||
VSyncOffsetShift = 0xC,
|
||||
|
||||
FPSUseFrl = 0x0,
|
||||
|
||||
FPS30 = 0x1E000000,
|
||||
|
||||
FPS60 = 0x3C000000,
|
||||
|
||||
FPSMask = 0xFF000000,
|
||||
|
||||
FPSShift = 0x18,
|
||||
|
||||
OptimalSetting = 0x364,
|
||||
|
||||
VSyncOptimalSetting = 0x80F364,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum PerformanceStateShaderDiskCache : uint
|
||||
{
|
||||
Off = 0x0,
|
||||
|
||||
On = 0x1,
|
||||
|
||||
Default = 0x1
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum PerformanceStateTextureFilteringAnisotropicOptimization : uint
|
||||
{
|
||||
Off = 0x0,
|
||||
|
||||
On = 0x1,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum PerformanceStateTextureFilteringBiLinearInAnisotropic : uint
|
||||
{
|
||||
Off = 0x0,
|
||||
|
||||
On = 0x1,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum PerformanceStateTextureFilteringDisableTrilinearSlope : uint
|
||||
{
|
||||
Off = 0x0,
|
||||
|
||||
On = 0x1,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum PerformanceStateTextureFilteringNoNegativeLODBias : uint
|
||||
{
|
||||
Off = 0x0,
|
||||
|
||||
On = 0x1,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum PhysxIndicator : uint
|
||||
{
|
||||
Disabled = 0x34534064,
|
||||
|
||||
Enabled = 0x24545582,
|
||||
|
||||
Default = 0x34534064
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum PreRenderLimit : uint
|
||||
{
|
||||
Minimum = 0x0,
|
||||
|
||||
Maximum = 0xFF,
|
||||
|
||||
ApplicationControlled = 0x0,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum PreferredPerformanceState : uint
|
||||
{
|
||||
Adaptive = 0x0,
|
||||
|
||||
PreferMaximum = 0x1,
|
||||
|
||||
DriverControlled = 0x2,
|
||||
|
||||
PreferConsistentPerformance = 0x3,
|
||||
|
||||
PreferMinimum = 0x4,
|
||||
|
||||
OptimalPower = 0x5,
|
||||
|
||||
Minimum = 0x0,
|
||||
|
||||
Maximum = 0x5,
|
||||
|
||||
Default = 0x5
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum PreventUiAnisotropicOverride : uint
|
||||
{
|
||||
Off = 0x0,
|
||||
|
||||
On = 0x1,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum QualityEnhancements : uint
|
||||
{
|
||||
HighQuality = 0xFFFFFFF6,
|
||||
|
||||
Quality = 0x0,
|
||||
|
||||
Performance = 0xA,
|
||||
|
||||
HighPerformance = 0x14,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum RefreshRateOverride : uint
|
||||
{
|
||||
ApplicationControlled = 0x0,
|
||||
|
||||
HighestAvailable = 0x1,
|
||||
|
||||
LowLatencyRefreshRateMask = 0xFF0,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum SLIGPUCount : uint
|
||||
{
|
||||
AutoSelect = 0x0,
|
||||
|
||||
One = 0x1,
|
||||
|
||||
Two = 0x2,
|
||||
|
||||
Three = 0x3,
|
||||
|
||||
Four = 0x4,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum SLIPredefinedGPUCount : uint
|
||||
{
|
||||
AutoSelect = 0x0,
|
||||
|
||||
One = 0x1,
|
||||
|
||||
Two = 0x2,
|
||||
|
||||
Three = 0x3,
|
||||
|
||||
Four = 0x4,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum SLIPredefinedGPUCountDX10 : uint
|
||||
{
|
||||
AutoSelect = 0x0,
|
||||
|
||||
One = 0x1,
|
||||
|
||||
Two = 0x2,
|
||||
|
||||
Three = 0x3,
|
||||
|
||||
Four = 0x4,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
namespace NvAPIWrapper.DRS.SettingValues
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
public enum SLIPredefinedMode : uint
|
||||
{
|
||||
AutoSelect = 0x0,
|
||||
|
||||
ForceSingle = 0x1,
|
||||
|
||||
ForceAFR = 0x2,
|
||||
|
||||
ForceAFR2 = 0x3,
|
||||
|
||||
ForceSFR = 0x4,
|
||||
|
||||
ForceAFROfSFRFallback3AFR = 0x5,
|
||||
|
||||
Default = 0x0
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user