private bool HandleProfile(StreamDeckDeviceInfo deviceInfo, Dictionary <Profile.ProfileType, Profile.ProfileData> profiles, Profile.ProfileType stateType, bool state) { var key = stateType + deviceInfo.Id; if (!_lastStatus.ContainsKey(key)) { _lastStatus.Add(key, null); } if (state && _lastStatus[key] != true) { foreach (var p in profiles.Where(x => x.Key == stateType)) { Logger.Instance.LogMessage(TracingLevel.DEBUG, "switch profile " + stateType + " to " + p.Value.Name + " for " + p.Value.DeviceType); Connection.SwitchProfileAsync(p.Value.Name); } } _lastStatus[key] = state; if (state && stateType != Profile.ProfileType.Main) { _lastStatus[Profile.ProfileType.Main + deviceInfo.Id] = false; } return(state); }
private bool HandleProfile(StreamDeckDeviceInfo deviceInfo, Dictionary <Profile.ProfileType, Profile.ProfileData> profiles, Profile.ProfileType stateType, bool state) { if (!profiles.ContainsKey(stateType)) { return(false); } if (!_lastStatus.ContainsKey(deviceInfo.Id)) { _lastStatus.Add(deviceInfo.Id, null); } if (state && _lastStatus[deviceInfo.Id] != stateType.ToString()) { var p = profiles[stateType]; Logger.Instance.LogMessage(TracingLevel.DEBUG, "switch profile " + stateType + " to " + p.Name + " for " + p.DeviceType); Connection.SwitchProfileAsync(p.Name); _lastStatus[deviceInfo.Id] = stateType.ToString(); } return(state); }
public async Task <bool> ShowMixer(ISDConnection connection, MixerSettings mixerSettings) { this.connection = connection; this.mixerSettings = mixerSettings; if (connection == null) { Logger.Instance.LogMessage(TracingLevel.ERROR, $"AudioMixerManager ShowMixer called with null connection"); return(false); } streamDeckDeviceInfo = connection.DeviceInfo(); int keys = streamDeckDeviceInfo.Size.Cols * streamDeckDeviceInfo.Size.Rows; currentPage = 0; appsPerPage = streamDeckDeviceInfo.Size.Cols - ACTION_KEY_COLUMN_START; if (!UIManager.Instance.RegisterUIHandler(this, keys)) { Logger.Instance.LogMessage(TracingLevel.ERROR, $"AudioMixerManager RegisterGameHandler failed"); return(false); } await FetchAudioApplications(); // Wait until the GameUI Action keys have subscribed to get events int retries = 0; while (!UIManager.Instance.IsUIReady && retries < 100) { Thread.Sleep(100); retries++; } if (!UIManager.Instance.IsUIReady) { return(false); } // Generate game board GenerateMixer(); tmrRefreshVolume.Start(); return(true); }
/// <summary> /// Constructor /// </summary> /// <param name="deviceInfo"></param> public DeviceDidConnect(StreamDeckDeviceInfo deviceInfo) { Device = deviceInfo?.Id; DeviceInfo = deviceInfo; }