-
Notifications
You must be signed in to change notification settings - Fork 51
/
QuestForm.cs
352 lines (308 loc) · 14.2 KB
/
QuestForm.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
using System;
using System.IO;
using System.Windows.Forms;
namespace AndroidSideloader
{
public partial class QuestForm : Form
{
public static int length = 0;
public static string[] result;
public bool settingsexist = false;
public static bool QUSon = false;
public bool delsh = false;
public QuestForm()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
bool ChangesMade = false;
//Quest 2 settings, might remove them in the future since some of them are broken
if (RefreshRateComboBox.SelectedIndex != -1)
{
_ = ADB.RunAdbCommandToString($"shell setprop debug.oculus.refreshRate {RefreshRateComboBox.SelectedItem}");
_ = ADB.RunAdbCommandToString($"shell settings put global 90hz_global {RefreshRateComboBox.SelectedIndex}");
_ = ADB.RunAdbCommandToString($"shell settings put global 90hzglobal {RefreshRateComboBox.SelectedIndex}");
ChangesMade = true;
}
if (TextureResTextBox.Text.Length > 0)
{
_ = int.TryParse(TextureResTextBox.Text, out _);
_ = ADB.RunAdbCommandToString($"shell settings put global texture_size_Global {TextureResTextBox.Text}");
_ = ADB.RunAdbCommandToString($"shell setprop debug.oculus.textureWidth {TextureResTextBox.Text}");
_ = ADB.RunAdbCommandToString($"shell setprop debug.oculus.textureHeight {TextureResTextBox.Text}");
ChangesMade = true;
}
if (CPUComboBox.SelectedIndex != -1)
{
_ = ADB.RunAdbCommandToString($"shell setprop debug.oculus.cpuLevel {CPUComboBox.SelectedItem}");
ChangesMade = true;
}
if (GPUComboBox.SelectedIndex != -1)
{
_ = ADB.RunAdbCommandToString($"shell setprop debug.oculus.gpuLevel {GPUComboBox.SelectedItem}");
ChangesMade = true;
}
if (ChangesMade)
{
_ = MessageBox.Show("Settings applied!");
}
}
public static void setLength(int value)
{
result = new string[value];
}
public void ResetQU_click(object sender, EventArgs e)
{
ResBox.Text = "0";
UsrBox.Text = "Change Me";
FOVx.Text = "0";
FOVy.Text = "0";
QURfrRt.SelectedIndex = 0;
}
private void DeleteShots_CheckedChanged(object sender, EventArgs e)
{
delsh = DeleteShots.Checked;
}
private void QUon_CheckedChanged(object sender, EventArgs e)
{
if (QUon.Checked)
{
ResBox.Visible = true;
UsrBox.Visible = true;
FOVx.Visible = true;
FOVy.Visible = true;
QURfrRt.Visible = true;
ResetQU.Visible = true;
QUEnable.Visible = true;
label5.Visible = true;
label6.Visible = true;
label7.Visible = true;
label8.Visible = true;
label9.Visible = true;
label10.Visible = true;
deleteButton.Visible = true;
ResBox.Text = Properties.Settings.Default.QUres;
UsrBox.Text = Properties.Settings.Default.QUname;
FOVy.Text = Properties.Settings.Default.QUy;
FOVx.Text = Properties.Settings.Default.QUx;
QURfrRt.SelectedValue = Properties.Settings.Default.QUhz;
Properties.Settings.Default.QUturnedon = true;
}
else if (!QUon.Checked)
{
ResBox.Visible = false;
UsrBox.Visible = false;
FOVx.Visible = false;
FOVy.Visible = false;
QURfrRt.Visible = false;
ResetQU.Visible = false;
QUEnable.Visible = false;
label5.Visible = false;
label6.Visible = false;
label7.Visible = false;
label8.Visible = false;
label9.Visible = false;
label10.Visible = false;
deleteButton.Visible = false;
Properties.Settings.Default.QUturnedon = false;
_ = MessageBox.Show("Ok, Deleted your custom settings file.\nIf you would like to re-enable return here and apply settings again");
File.Delete($"{Environment.CurrentDirectory}\\Config.Json");
File.Delete($"{Environment.CurrentDirectory}\\delete_settings");
}
}
private static readonly Random random = new Random();
private static readonly object syncLock = new object();
public static int RandomNumber(int min, int max)
{
lock (syncLock)
{ // synchronize
return random.Next(min, max);
}
}
private void QUEnable_Click(object sender, EventArgs e)
{
settingsexist = true;
_ = MessageBox.Show("OK, any -QU packages installed will have these settings applied!\nTo delete settings: goto main app window, select a game with top menu, and click \"Remove QU Setting\"");
if (QUon.Checked)
{
Properties.Settings.Default.QUturnedon = true;
Random r = new Random();
int x = r.Next(999999999);
int y = r.Next(9999999);
long sum = (y * (long)1000000000) + x;
int x2 = r.Next(999999999);
int y2 = r.Next(9999999);
long sum2 = (y2 * (long)1000000000) + x2;
QUSon = true;
string selected = QURfrRt.GetItemText(QURfrRt.SelectedItem);
Properties.Settings.Default.QUString = $"\"refresh_rate\":{selected},\"eye_texture_width\":{ResBox.Text},\"fov_x\":{FOVx.Text},\"fov_y\":{FOVy.Text},\"username\":\"{UsrBox.Text}\"}}";
Properties.Settings.Default.QUStringF = $"{{\"user_id\":{sum},\"app_id\":\"{sum2}\",";
Properties.Settings.Default.Save();
File.WriteAllText($"{Properties.Settings.Default.MainDir}\\delete_settings", "");
string boff = Properties.Settings.Default.QUStringF + Properties.Settings.Default.QUString;
File.WriteAllText($"{Properties.Settings.Default.MainDir}\\config.json", boff);
}
else
{
Properties.Settings.Default.QUturnedon = false;
}
}
private void QuestForm_FormClosed(object sender, FormClosedEventArgs e)
{
if (QUon.Checked)
{
Properties.Settings.Default.QUsett = true;
Properties.Settings.Default.Save();
}
if (!QUon.Checked)
{
Properties.Settings.Default.QUsett = false;
Properties.Settings.Default.Save();
}
if (DeleteShots.Checked)
{
Properties.Settings.Default.delsh = true;
Properties.Settings.Default.Save();
}
if (!DeleteShots.Checked)
{
Properties.Settings.Default.delsh = false;
Properties.Settings.Default.Save();
}
}
private void QuestForm_Load(object sender, EventArgs e)
{
DeleteShots.Checked = Properties.Settings.Default.delsh;
if (Properties.Settings.Default.QUsett)
{
ResBox.Text = Properties.Settings.Default.QUres;
UsrBox.Text = Properties.Settings.Default.QUname;
FOVy.Text = Properties.Settings.Default.QUy;
FOVx.Text = Properties.Settings.Default.QUx;
QURfrRt.Text = Properties.Settings.Default.QUhz;
QUon.Checked = true;
if (settingsexist)
{
QUSon = true;
}
}
GlobalUsername.Text = Properties.Settings.Default.GlobalUsername;
}
private void ResBox_TextChanged(object sender, EventArgs e)
{
Properties.Settings.Default.QUres = ResBox.Text;
Properties.Settings.Default.Save();
}
private void UsrBox_TextChanged(object sender, EventArgs e)
{
Properties.Settings.Default.QUname = UsrBox.Text;
Properties.Settings.Default.Save();
}
private void FOVx_TextChanged(object sender, EventArgs e)
{
Properties.Settings.Default.QUx = FOVx.Text;
Properties.Settings.Default.Save();
}
private void FOVy_TextChanged(object sender, EventArgs e)
{
Properties.Settings.Default.QUy = FOVy.Text;
Properties.Settings.Default.Save();
}
private void QURfrRt_SelectedIndexChanged(object sender, EventArgs e)
{
string selected = QURfrRt.GetItemText(QURfrRt.SelectedItem);
Properties.Settings.Default.QUhz = selected;
Properties.Settings.Default.Save();
}
private void DeleteButton_Click(object sender, EventArgs e)
{
_ = MessageBox.Show("Ok, Deleted your custom settings file.\nIf you would like to re-enable return here and apply settings again");
File.Delete($"{Properties.Settings.Default.MainDir}\\Config.Json");
}
private void questPics_Click(object sender, EventArgs e)
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
if (!Directory.Exists($"{path}\\Quest ScreenShots"))
{
_ = Directory.CreateDirectory($"{path}\\Quest ScreenShots");
}
_ = MessageBox.Show("Please wait until you get the message that the transfer has finished.");
Program.form.changeTitle("Pulling files...");
_ = ADB.RunAdbCommandToString($"pull \"/sdcard/Oculus/Screenshots\" \"{path}\\Quest ScreenShots\"");
if (delsh)
{
DialogResult dialogResult = MessageBox.Show("You have chosen to delete files from headset after transferring, so be sure to move them from your desktop to somewhere safe!", "Warning!", MessageBoxButtons.OKCancel);
if (dialogResult == DialogResult.OK)
{
_ = ADB.RunAdbCommandToString("shell rm -r /sdcard/Oculus/Screenshots");
_ = ADB.RunAdbCommandToString("shell mkdir /sdcard/Oculus/Screenshots");
}
}
_ = MessageBox.Show("Transfer finished! ScreenShots can be found in a folder named Quest Screenshots on your desktop!");
Program.form.changeTitle("Done!");
}
private void questVids_Click(object sender, EventArgs e)
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
if (!Directory.Exists($"{path}\\Quest VideoShots"))
{
_ = Directory.CreateDirectory($"{path}\\Quest VideoShots");
}
_ = MessageBox.Show("Please wait until you get the message that the transfer has finished.");;
Program.form.changeTitle("Pulling files...");
_ = ADB.RunAdbCommandToString($"pull \"/sdcard/Oculus/Videoshots\" \"{path}\\Quest VideoShots\"");
if (delsh)
{
DialogResult dialogResult = MessageBox.Show("You have chosen to delete files from headset after transferring, so be sure to move them from your desktop to somewhere safe!", "Warning!", MessageBoxButtons.OKCancel);
if (dialogResult == DialogResult.OK)
{
_ = ADB.RunAdbCommandToString("shell rm -r /sdcard/Oculus/Videoshots");
_ = ADB.RunAdbCommandToString("shell mkdir /sdcard/Oculus/Videoshots");
}
}
_ = MessageBox.Show("Transfer finished! VideoShots can be found in a folder named Quest VideoShots on your desktop!");
Program.form.changeTitle("Done!");
}
private void button3_Click(object sender, EventArgs e)
{
if (GlobalUsername.Text.Contains(" "))
{
_ = MessageBox.Show("Usernames with a space are not permitted.", "Detected a space in username!");
}
else
{
_ = ADB.RunAdbCommandToString($"shell settings put global username {GlobalUsername.Text}");
_ = MessageBox.Show($"Username set as {GlobalUsername.Text}", "Success");
}
}
private void Form_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
Close();
}
}
protected override bool ProcessDialogKey(Keys keyData)
{
if (Form.ModifierKeys == Keys.None && keyData == Keys.Escape)
{
Close();
return true;
}
return base.ProcessDialogKey(keyData);
}
private void WifiWake_Click(object sender, EventArgs e)
{
_ = ADB.RunAdbCommandToString("shell settings put global wifi_wakeup_available 1");
_ = ADB.RunAdbCommandToString("shell settings put global wifi_wakeup_enabled 1");
_ = MessageBox.Show("Wake on Wifi enabled!\n\nNOTE: This requires having wireless ADB enabled to work. (Obviously)");
}
private void GlobalUsername_TextChanged(object sender, EventArgs e)
{
button3.Enabled = GlobalUsername.TextLength > 0;
Properties.Settings.Default.GlobalUsername = GlobalUsername.Text;
Properties.Settings.Default.Save();
}
}
}