-
Notifications
You must be signed in to change notification settings - Fork 20
/
GameDVR_ConfigForm.cs
161 lines (134 loc) · 6.45 KB
/
GameDVR_ConfigForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
namespace GameDVR_Config
{
public partial class GameDVR_ConfigForm : Form
{
const string keyName = "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\GameDVR";
public GameDVR_ConfigForm()
{
InitializeComponent();
}
private void GameDVR_ConfigForm_Load(object sender, EventArgs e)
{
EnableGameDVRCheckBox.Checked = GetBool("AppCaptureEnabled", true);
EnableAudioCaptureCheckBox.Checked = GetBool("AudioCaptureEnabled", true);
EnableMicrophoneCaptureCheckBox.Checked = GetBool("MicrophoneCaptureEnabled", false);
int audioBitrate = GetInt("AudioEncodingBitrate", 192000);
try { AudioBitrateComboBox.SelectedItem = (audioBitrate / 1000).ToString(); }
finally
{
if (AudioBitrateComboBox.SelectedIndex == -1)
AudioBitrateComboBox.SelectedIndex = 3;
}
int videoBitrate = GetInt("CustomVideoEncodingBitrate", 4000000);
VideoBitrateTextBox.Text = (videoBitrate / 1000).ToString();
ResizeVideoCheckBox.Checked = GetInt("VideoEncodingResolutionMode", 2) == 0;
WidthTextBox.Text = GetInt("CustomVideoEncodingWidth", 1280).ToString();
HeightTextBox.Text = GetInt("CustomVideoEncodingHeight", 720).ToString();
ForceSoftwareMFTCheckBox.Checked = GetBool("ForceSoftwareMFT", false);
DisableCursorBlendingCheckBox.Checked = GetBool("DisableCursorBlending", false);
BackgroundRecordingCheckBox.Checked = GetBool("HistoricalCaptureEnabled", false);
RecordTheLastTextBox.Text = GetInt("HistoricalBufferLength", 15).ToString();
RecordOnBatteryCheckBox.Checked = GetBool("HistoricalCaptureOnBatteryAllowed", true);
RecordOnWirelessDisplayCheckBox.Checked = GetBool("HistoricalCaptureOnWirelessDisplayAllowed", true);
SetInt("VideoEncodingBitrateMode", 0);
}
private void EnableGameDVRCheckBox_CheckedChanged(object sender, EventArgs e)
{
SetBool("AppCaptureEnabled", EnableGameDVRCheckBox.Checked);
}
private void EnableAudioCaptureCheckBox_CheckedChanged(object sender, EventArgs e)
{
SetBool("AudioCaptureEnabled", EnableAudioCaptureCheckBox.Checked);
}
private void EnableMicrophoneCaptureCheckBox_CheckedChanged(object sender, EventArgs e)
{
SetBool("MicrophoneCaptureEnabled", EnableMicrophoneCaptureCheckBox.Checked);
}
private void AudioBitrateComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
SetInt("AudioEncodingBitrate", Convert.ToInt32(AudioBitrateComboBox.SelectedItem) * 1000);
}
private void VideoBitrateTextBox_TextChanged(object sender, EventArgs e)
{
int videoBitrate;
try { videoBitrate = Convert.ToInt32(VideoBitrateTextBox.Text) * 1000; }
catch { videoBitrate = 4000000; }
SetInt("CustomVideoEncodingBitrate", videoBitrate > 30000000 ? 30000000 : videoBitrate);
}
private void ResizeVideoCheckBox_CheckedChanged(object sender, EventArgs e)
{
SetInt("VideoEncodingResolutionMode", ResizeVideoCheckBox.Checked ? 0 : 2);
HeightLabel.Enabled = WidthLabel.Enabled = WidthTextBox.Enabled = HeightTextBox.Enabled = ResizeVideoCheckBox.Checked;
}
private void WidthTextBox_TextChanged(object sender, EventArgs e)
{
int width;
try { width = Convert.ToInt32(WidthTextBox.Text); }
catch { width = 1280; }
SetInt("CustomVideoEncodingWidth", width > 1920 ? 1920 : width);
}
private void HeightTextBox_TextChanged(object sender, EventArgs e)
{
int height;
try { height = Convert.ToInt32(HeightTextBox.Text); }
catch { height = 720; }
SetInt("CustomVideoEncodingHeight", height > 1080 ? 1080 : height);
}
private void ForceSoftwareMFTCheckBox_CheckedChanged(object sender, EventArgs e)
{
SetBool("ForceSoftwareMFT", ForceSoftwareMFTCheckBox.Checked);
SetBool("AllowSoftwareEncode", ForceSoftwareMFTCheckBox.Checked);
}
private void DisableCursorBlendingCheckBox_CheckedChanged(object sender, EventArgs e)
{
SetBool("DisableCursorBlending", DisableCursorBlendingCheckBox.Checked);
}
private void BackgroundRecordingCheckBox_CheckedChanged(object sender, EventArgs e)
{
SetBool("HistoricalCaptureEnabled", BackgroundRecordingCheckBox.Checked);
RecordTheLastLabel.Enabled = RecordTheLastTextBox.Enabled = RecordOnBatteryCheckBox.Enabled =
RecordOnWirelessDisplayCheckBox.Enabled = SecondsLabel.Enabled = BackgroundRecordingCheckBox.Checked;
}
private void RecordTheLastTextBox_TextChanged(object sender, EventArgs e)
{
int seconds;
try { seconds = Convert.ToInt32(RecordTheLastTextBox.Text); }
catch { seconds = 15; }
SetInt("HistoricalBufferLength", seconds);
}
private void RecordOnBatteryCheckBox_CheckedChanged(object sender, EventArgs e)
{
SetBool("HistoricalCaptureOnBatteryAllowed", RecordOnBatteryCheckBox.Checked);
}
private void RecordOnWirelessDisplayCheckBox_CheckedChanged(object sender, EventArgs e)
{
SetBool("HistoricalCaptureOnWirelessDisplayAllowed", RecordOnWirelessDisplayCheckBox.Checked);
}
int GetInt(string valueName, int defaultValue)
{
try { return (int)Registry.GetValue(keyName, valueName, defaultValue.ToString()); }
catch { return defaultValue; }
}
bool GetBool(string valueName, bool defaultValue)
{
try { return (int)Registry.GetValue(keyName, valueName, defaultValue ? "1" : "0") == 1; }
catch { return defaultValue; }
}
void SetInt(string valueName, int value)
{
Registry.SetValue(keyName, valueName, value);
}
void SetBool(string valueName, bool value)
{
Registry.SetValue(keyName, valueName, value ? 1 : 0);
}
}
}