cec: sleep 5 ms in CUSBCECAdapterCommunication::Process() or other threads won't...
[deb_libcec.git] / src / cec-config-gui / actions / UpdateConnectedDevice.cs
CommitLineData
a42ad439 1using CecSharp;
006b76b9
LOK
2
3namespace CecConfigGui.actions
4{
5 class UpdateConnectedDevice : UpdateProcess
6 {
7 public UpdateConnectedDevice(ref LibCecSharp lib, CecLogicalAddress address, int portNumber)
8 {
9 Lib = lib;
10 Address = address;
11 PortNumber = portNumber;
12 }
13
14 public override void Process()
15 {
16 SendEvent(UpdateEventType.StatusText, "Requesting physical address...");
17 SendEvent(UpdateEventType.ProgressBar, 0);
18
19 ushort iPhysicalAddress = Lib.GetDevicePhysicalAddress(Address);
20 SendEvent(UpdateEventType.BaseDevicePhysicalAddress, iPhysicalAddress);
21
22 SendEvent(UpdateEventType.StatusText, "Setting new configuration...");
23 SendEvent(UpdateEventType.ProgressBar, 25);
24
25 if (!Lib.SetHDMIPort(Address, (byte)PortNumber))
26 {
27 SendEvent(UpdateEventType.StatusText, "Could not activate the new source");
28 }
29 else
30 {
31 LibCECConfiguration config = new LibCECConfiguration();
32 Lib.GetCurrentConfiguration(config);
33
34 SendEvent(UpdateEventType.StatusText, "Activating source...");
35 SendEvent(UpdateEventType.ProgressBar, 50);
36 Lib.SetActiveSource(config.DeviceTypes.Types[0]);
37
38 SendEvent(UpdateEventType.StatusText, "Reading configuration...");
39 SendEvent(UpdateEventType.ProgressBar, 75);
40 Lib.GetCurrentConfiguration(config);
41
68b94c34 42 SendEvent(config);
006b76b9
LOK
43 SendEvent(UpdateEventType.StatusText, "Ready.");
44 }
45 SendEvent(UpdateEventType.ProgressBar, 100);
46 }
47
48 private LibCecSharp Lib;
49 private CecLogicalAddress Address;
50 private int PortNumber;
51 }
52}