static void Main(string[] args) { if (args != null && args.Length > 0) { RemoteCommand cmd = null; switch (args[0]) { case "CinematicSettings": CinematicSettingsCommand ccmd = new CinematicSettingsCommand(); foreach (var cmdParam in args.Skip(1)) { string[] parts = cmdParam.Split("=".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (parts.Length != 2) { continue; } string param = parts[0]; byte value; if (!byte.TryParse(parts[1], out value)) { continue; } switch (param) { case "Size": ccmd.Size = value; break; case "Distance": ccmd.Distance = value; break; case "Brightness": ccmd.Brightness = value; break; } } ccmd.Command = "CinematicSettings"; cmd = ccmd; break; case "LedSettings": LEDSettingsCommand lcmd = new LEDSettingsCommand(); foreach (var cmdParam in args.Skip(1)) { string[] parts = cmdParam.Split("=".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (parts.Length != 2) { continue; } string param = parts[0]; byte value; if (!byte.TryParse(parts[1], out value)) { continue; } switch (param) { case "LedA": lcmd.LedA = value; break; case "LedB": lcmd.LedB = value; break; case "LedC": lcmd.LedC = value; break; case "LedD": lcmd.LedD = value; break; case "LedE": lcmd.LedE = value; break; case "LedF": lcmd.LedF = value; break; case "LedG": lcmd.LedG = value; break; case "LedH": lcmd.LedH = value; break; case "LedI": lcmd.LedI = value; break; } } lcmd.Command = "LedSettings"; cmd = lcmd; break; default: cmd = new RemoteCommand { Command = args[0] }; break; } if (cmd != null) { string ser = JsonConvert.SerializeObject(cmd); byte[] data = Encoding.UTF8.GetBytes(ser); var ep = new IPEndPoint(IPAddress.Parse("255.255.255.255"), 14598); var client = new UdpClient(); client.EnableBroadcast = true; client.Send(data, data.Length, ep); client.Close(); } return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); }
private void ProcessCommand(RemoteCommand cmd) { switch (cmd.Command) { case "HeadsetOn": PSVRController.HeadsetOn(); break; case "HeadsetOff": PSVRController.HeadsetOff(); break; case "EnableVRTracking": PSVRController.EnableVRTracking(); break; case "EnableVRMode": PSVRController.EnableVRMode(); break; case "EnableCinematicMode": PSVRController.EnableCinematicMode(); break; case "Recenter": PSVRController.Recenter(); break; case "Shutdown": PSVRController.Shutdown(); break; case "CinematicSettings": CinematicSettingsCommand ccmd = cmd as CinematicSettingsCommand; if (ccmd != null) { bool apply = false; if (ccmd.Brightness != null && ccmd.Brightness.HasValue) { var bright = ccmd.Brightness.Value; if (bright > 32) { return; } Settings.Instance.Brightness = bright; apply = true; } if (ccmd.Size != null && ccmd.Size.HasValue) { var siz = ccmd.Size.Value + 26; if (siz > 80) { Settings.ReadSettings(); return; } Settings.Instance.ScreenSize = (byte)siz; apply = true; } if (ccmd.Distance != null && ccmd.Distance.HasValue) { var dist = ccmd.Distance.Value + 2; if (dist > 50) { Settings.ReadSettings(); return; } Settings.Instance.ScreenDistance = (byte)dist; apply = true; } if (apply) { PSVRController.ApplyCinematicSettings(); } } break; case "LedSettings": LEDSettingsCommand lcmd = cmd as LEDSettingsCommand; if (lcmd != null) { bool apply = false; if (lcmd.LedA != null && lcmd.LedA.HasValue) { if (lcmd.LedA.Value > 100) { return; } Settings.Instance.LedAIntensity = lcmd.LedA.Value; apply = true; } if (lcmd.LedB != null && lcmd.LedB.HasValue) { if (lcmd.LedB.Value > 100) { Settings.ReadSettings(); return; } Settings.Instance.LedBIntensity = lcmd.LedB.Value; apply = true; } if (lcmd.LedC != null && lcmd.LedC.HasValue) { if (lcmd.LedC.Value > 100) { Settings.ReadSettings(); return; } Settings.Instance.LedCIntensity = lcmd.LedC.Value; apply = true; } if (lcmd.LedD != null && lcmd.LedD.HasValue) { if (lcmd.LedD.Value > 100) { Settings.ReadSettings(); return; } Settings.Instance.LedDIntensity = lcmd.LedD.Value; apply = true; } if (lcmd.LedE != null && lcmd.LedE.HasValue) { if (lcmd.LedE.Value > 100) { Settings.ReadSettings(); return; } Settings.Instance.LedEIntensity = lcmd.LedE.Value; apply = true; } if (lcmd.LedF != null && lcmd.LedF.HasValue) { if (lcmd.LedF.Value > 100) { Settings.ReadSettings(); return; } Settings.Instance.LedFIntensity = lcmd.LedF.Value; apply = true; } if (lcmd.LedG != null && lcmd.LedG.HasValue) { if (lcmd.LedG.Value > 100) { Settings.ReadSettings(); return; } Settings.Instance.LedGIntensity = lcmd.LedG.Value; apply = true; } if (lcmd.LedH != null && lcmd.LedH.HasValue) { if (lcmd.LedH.Value > 100) { Settings.ReadSettings(); return; } Settings.Instance.LedHIntensity = lcmd.LedH.Value; apply = true; } if (lcmd.LedI != null && lcmd.LedI.HasValue) { if (lcmd.LedI.Value > 100) { Settings.ReadSettings(); return; } Settings.Instance.LedIIntensity = lcmd.LedI.Value; apply = true; } if (apply) { PSVRController.ApplyLedSettings(); } } break; case "StoreSettings": Settings.SaveSettings(); break; case "DiscardSettings": Settings.ReadSettings(); break; } }