public override void KeyPressed(KeyPayload payload)
        {
            // Used for long press
            keyPressStart = DateTime.Now;
            keyPressed    = true;
            longKeyPress  = false;

            Logger.Instance.LogMessage(TracingLevel.INFO, "Key Pressed");

            if (payload.IsInMultiAction)
            {
                HandleMultiActionKeyPress(payload.UserDesiredState);
                return;
            }

            if (StopwatchManager.Instance.IsStopwatchEnabled(stopwatchId)) // Stopwatch is already running
            {
                if (settings.LapMode)
                {
                    StopwatchManager.Instance.RecordLap(stopwatchId);
                }
                else
                {
                    PauseStopwatch();
                }
            }
            else // Stopwatch is already paused
            {
                HandleStopwatchResume();
            }
        }
        public override async void KeyPressed(KeyPayload payload)
        {
            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

                string requestUri = $"https://api.lifx.com/v1/lights/{settings.Selector}/state";
                string authToken  = settings.AuthToken;

                var state = new Payload()
                {
                    Brightness = Convert.ToDouble(settings.Brightness / 100),
                    Duration   = Convert.ToDouble(settings.Duration)
                };
                var content = new StringContent(JsonConvert.SerializeObject(state), Encoding.UTF8, "application/json");

                var request = new HttpRequestMessage(HttpMethod.Put, requestUri);
                request.Headers.Add("Authorization", $"Bearer {settings.AuthToken}");
                request.Content = content;

                var response = await client.SendAsync(request);

                if (!response.IsSuccessStatusCode)
                {
                    Logger.Instance.LogMessage(TracingLevel.INFO, $"Call to LIFX API failed");
                    Logger.Instance.LogMessage(TracingLevel.INFO, $"Status Code: {response.StatusCode}");
                    Logger.Instance.LogMessage(TracingLevel.INFO, $"{response.Content}");
                }
            }
            Logger.Instance.LogMessage(TracingLevel.INFO, "Key Pressed");
        }
        public async override void KeyPressed(KeyPayload payload)
        {
            Logger.Instance.LogMessage(TracingLevel.INFO, $"{this.GetType()} Key Pressed");
            if (OBSManager.Instance.IsConnected)
            {
                if (String.IsNullOrEmpty(Settings.SourceName))
                {
                    Logger.Instance.LogMessage(TracingLevel.WARN, $"Key Pressed but SourceName is empty");
                    await Connection.ShowAlert();

                    return;
                }

                // Get current volume
                var volumeInfo = OBSManager.Instance.GetSourceVolume(Settings.SourceName);
                if (volumeInfo != null)
                {
                    float outputVolume = volumeInfo.Volume + volumeStep;
                    if (outputVolume > 0)
                    {
                        outputVolume = 0;
                    }
                    if (outputVolume < MINIMAL_DB_VALUE)
                    {
                        outputVolume = MINIMAL_DB_VALUE;
                    }
                    OBSManager.Instance.SetSourceVolume(Settings.SourceName, outputVolume);
                }
            }
            else
            {
                await Connection.ShowAlert();
            }
        }
Example #4
0
        public async override void KeyPressed(KeyPayload payload)
        {
            baseHandledKeypress = false;
            base.KeyPressed(payload);

            if (!baseHandledKeypress)
            {
                if (String.IsNullOrEmpty(Settings.Hotkey) || sequence == null || !sequence.IsValidSequence)
                {
                    Logger.Instance.LogMessage(TracingLevel.ERROR, $"{this.GetType()} KeyPressed but Invalid Hotkey {Settings.Hotkey}");
                    await Connection.ShowAlert();

                    return;
                }
                else
                {
                    if (OBSManager.Instance.TriggerHotkey(sequence.Keycode.ToOBSKey(), sequence.CtrlPressed, sequence.AltPressed, sequence.ShiftPressed, sequence.WinPressed))
                    {
                        await Connection.ShowOk();
                    }
                    else
                    {
                        await Connection.ShowAlert();
                    }
                }
            }
        }
        public override void KeyPressed(KeyPayload payload)
        {
            Logger.Instance.LogMessage(TracingLevel.INFO, "Key Pressed");
            var country = settings.Country.Replace("USA", "US");

            System.Diagnostics.Process.Start($"{KEYPRESS_WEBSITE_URL}{country}/");
        }
Example #6
0
 public override void KeyReleased(KeyPayload payload)
 {
     if (settings.MicType == MicTypeEnum.PTT)
     {
         VMManager.Instance.SetParam(BuildDeviceName(), 1);
     }
 }
Example #7
0
        public override async void KeyPressed(KeyPayload payload)
        {
            Logger.Instance.LogMessage(TracingLevel.INFO, $"{this.GetType()} KeyPressed");
            var viewers = await TwitchChannelInfoManager.Instance.GetChannelViewers(Settings.ChannelName);

            // We have a list of usernames, get some more details on them so we can display their image on the StreamDeck
            List <ChatMessageKey> chatMessages = new List <ChatMessageKey>();

            foreach (string username in viewers.AllViewers)
            {
                var userInfo = await TwitchUserInfoManager.Instance.GetUserInfo(username);

                if (userInfo != null)
                {
                    chatMessages.Add(new ChatMessageKey(userInfo?.Name, userInfo?.ProfileImageUrl, null));
                }
                else
                {
                    Logger.Instance.LogMessage(TracingLevel.ERROR, $"Could not fetch twitch user info for user: {username}");
                }
            }
            Logger.Instance.LogMessage(TracingLevel.INFO, $"{this.GetType()} KeyPress returned {chatMessages?.Count} viewers");

            // Show the active chatters on the StreamDeck
            if (chatMessages != null && chatMessages.Count > 0)
            {
                AlertManager.Instance.Initialize(Connection);
                AlertManager.Instance.ShowChatMessages(chatMessages.OrderBy(c => c.KeyTitle).ToArray(), null);
            }
        }
Example #8
0
        public async override void KeyPressed(KeyPayload payload)
        {
            Logger.Instance.LogMessage(TracingLevel.INFO, $"{GetType()} Key Pressed");
            if (String.IsNullOrEmpty(settings.Application))
            {
                Logger.Instance.LogMessage(TracingLevel.WARN, $"{GetType()} Key Pressed but no application is set");
                return;
            }

            Logger.Instance.LogMessage(TracingLevel.INFO, $"Setting {settings.Application}'s volume to {volume}");
            int totalFadeLength = 0;

            if (settings.FadeVolume)
            {
                totalFadeLength = fadeLength;
            }
            if (await BRAudio.SetAppVolume(settings.Application, volume, totalFadeLength))
            {
                await Connection.ShowOk();
            }
            else
            {
                await Connection.ShowAlert();
            }
        }
        public override void KeyPressed(KeyPayload payload)
        {
            baseHandledKeypress = false;
            base.KeyPressed(payload);

            if (!baseHandledKeypress)
            {
                if (payload.IsInMultiAction)
                {
                    HandleMultiAction(payload.UserDesiredState);
                    return;
                }
                else // Not a multi action, perform a normal toggle.
                {
                    if (OBSManager.Instance.IsStudioModeEnabled())
                    {
                        OBSManager.Instance.StopStudioMode();
                    }
                    else
                    {
                        OBSManager.Instance.StartStudioMode();
                    }
                }
            }
        }
Example #10
0
        public override void KeyPressed(KeyPayload payload)
        {
            // Used for long press
            keyPressStart = DateTime.Now;
            keyPressed    = true;
            longKeyPress  = false;

            Logger.Instance.LogMessage(TracingLevel.INFO, "Key Pressed");

            if (StopwatchManager.Instance.IsStopwatchEnabled(stopwatchId)) // Stopwatch is already running
            {
                if (settings.LapMode)
                {
                    StopwatchManager.Instance.RecordLap(stopwatchId);
                }
                else
                {
                    PauseStopwatch();
                }
            }
            else // Stopwatch is already paused
            {
                if (!settings.ResumeOnClick)
                {
                    ResetCounter();
                }

                ResumeStopwatch();
            }
        }
        public override void KeyPressed(KeyPayload payload)
        {
            base.KeyPressed(payload);

            try
            {
                var(foregroundHandle, foregroundProcessId) = GetForeground();

                if (IsVisualStudioInstanceFocused(foregroundProcessId))
                {
                    GetDTEInstances((int)foregroundProcessId).FirstOrDefault()?.ExecuteCommand(settings.Command);
                }
                else
                {
                    foreach (var dte in GetDTEInstances())
                    {
                        if (IsFocusingDebugProcess(foregroundProcessId, dte))
                        {
                            dte.ExecuteCommand(settings.Command);

                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, ex.Message);
            }
        }
Example #12
0
        public override void KeyPressed(KeyPayload payload)
        {
            // Used for long press
            keyPressStart = DateTime.Now;
            keyPressed    = true;
            longKeyPress  = false;

            Logger.Instance.LogMessage(TracingLevel.INFO, "Key Pressed");

            /*if (StopwatchManager.Instance.IsStopwatchEnabled(stopwatchId)) // Stopwatch is already running
             * {
             * }
             * else // Stopwatch is already paused
             * {
             *  if (!settings.ResumeOnClick)
             *  {
             *      ResetCounter();
             *  }
             *
             *  ResumeStopwatch();
             * }*/


            StopwatchManager.Instance.LoadStopwatchAndRun(new StopwatchSettings()
            {
                StopwatchId      = stopwatchId,
                FileName         = settings.FileName,
                ClearFileOnReset = settings.ClearFileOnReset,
                LapMode          = settings.LapMode,
                ResetOnStart     = !settings.ResumeOnClick,
                SpineFileName    = settings.SpineFileName
            });
        }
        public override void KeyPressed(KeyPayload payload)
        {
            baseHandledKeypress = false;
            base.KeyPressed(payload);

            if (!baseHandledKeypress)
            {
                if (payload.IsInMultiAction && payload.UserDesiredState == 0 && !OBSManager.Instance.IsRecording) // Multiaction mode, check if desired state is 0 (0==Start, 1==Stop)
                {
                    OBSManager.Instance.StartRecording();
                }
                else if (payload.IsInMultiAction && payload.UserDesiredState == 1 && OBSManager.Instance.IsRecording) // Multiaction mode, check if desired state is 1 (0==Start, 1==Stop)
                {
                    OBSManager.Instance.StopRecording();
                }
                else if (!payload.IsInMultiAction) // Not in a multi action
                {
                    if (OBSManager.Instance.IsRecording)
                    {
                        OBSManager.Instance.StopRecording();
                    }
                    else
                    {
                        OBSManager.Instance.StartRecording();
                    }
                }
            }
        }
Example #14
0
        public override async void KeyPressed(KeyPayload payload)
        {
            Logger.Instance.LogMessage(TracingLevel.INFO, $"{this.GetType()} KeyPressed");

            if (String.IsNullOrEmpty(Settings.ChannelName) || Settings.KeypressDisabled)
            {
                await Connection.ShowAlert();

                return;
            }

            string url = String.Empty;

            if (Settings.KeypressStream)
            {
                url = URL_STREAM;
            }
            else if (Settings.KeypressMod)
            {
                url = URL_MOD;
            }
            else if (Settings.KeypressCreator)
            {
                url = URL_CREATOR;
            }

            if (String.IsNullOrEmpty(url))
            {
                Logger.Instance.LogMessage(TracingLevel.WARN, $"Channel: Invalid Keypress setting, url is null");
                return;
            }

            System.Diagnostics.Process.Start(String.Format(url, Settings.ChannelName.ToLowerInvariant()));
        }
Example #15
0
 public override void KeyPressed(KeyPayload payload)
 {
     keyPressed = true;
     Logger.Instance.LogMessage(TracingLevel.INFO, "Key Pressed");
     longKeyPress    = false;
     keyPressStartAt = DateTime.Now;
 }
        public async override void KeyPressed(KeyPayload payload)
        {
            Logger.Instance.LogMessage(TracingLevel.INFO, $"Image Settings KeyPress");

            baseHandledKeypress = false;
            base.KeyPressed(payload);

            if (!baseHandledKeypress)
            {
                if (String.IsNullOrEmpty(Settings.ImageFileName))
                {
                    Logger.Instance.LogMessage(TracingLevel.WARN, "KeyPressed called, but no Image File configured");
                    await Connection.ShowAlert();

                    return;
                }

                if (!File.Exists(Settings.ImageFileName))
                {
                    Logger.Instance.LogMessage(TracingLevel.WARN, $"KeyPressed called, but file does not exist: {Settings.ImageFileName}");
                    await Connection.ShowAlert();

                    return;
                }

                await OBSManager.Instance.ModifyImageSource(Settings.SourceName, Settings.ImageFileName, autoHideTime);
            }
        }
Example #17
0
        public async override void KeyPressed(KeyPayload payload)
        {
            if (!VMManager.Instance.IsConnected)
            {
                await Connection.ShowAlert();

                return;
            }

            switch (settings.MicType)
            {
            case MicTypeEnum.SingleMode:
                int value;
                if (Int32.TryParse(settings.SingleValue, out value))
                {
                    VMManager.Instance.SetParam(BuildDeviceName(), value);
                }
                else
                {
                    await Connection.ShowAlert();
                }
                break;

            case MicTypeEnum.Toggle:
                bool isMuted = VMManager.Instance.GetParamBool(BuildDeviceName());
                VMManager.Instance.SetParam(BuildDeviceName(), isMuted ? 0 : 1);
                break;

            case MicTypeEnum.PTT:
                VMManager.Instance.SetParam(BuildDeviceName(), 0);
                break;
            }
        }
Example #18
0
        public override void KeyPressed(KeyPayload payload)
        {
            if (InputRunning || Program.Bindings == null)
            {
                ForceStop = true;
                return;
            }

            ForceStop = false;

            switch (settings.Function)
            {
            case "HYPERSUPERCOMBINATION":     // context dependent, i.e. jump if another system is targeted, supercruise if not.
                SendKeypress(Program.Bindings.HyperSuperCombination);
                break;

            case "SUPERCRUISE":     // supercruise even if another system targeted
                SendKeypress(Program.Bindings.Supercruise);
                break;

            case "HYPERSPACE":     // jump
                SendKeypress(Program.Bindings.Hyperspace);
                break;
            }


            AsyncHelper.RunSync(HandleDisplay);
        }
        public override void KeyReleased(KeyPayload payload)
        {
            try
            {
                PipeServerConnection.Instance.RestartChannel();
                switch (settings.ValueToChange)
                {
                case "Smoothness":
                    PipeServerConnection.Instance.Channel.ControllerSmoothnessDisable(settings.ControllerName);
                    break;

                default:
                    Logger.Instance.LogMessage(TracingLevel.ERROR, "Error: ValueToChange not set correctly: " + settings.ValueToChange);
                    break;
                }
            }
            catch (EndpointNotFoundException endpointNotFoundException)
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, "Error: Endpoint not found - Is SimFeedback available and is the Plugin enabled? " + endpointNotFoundException.Message);
            }
            catch (CommunicationObjectFaultedException communicationObjectFaultedException)
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, "Error: communicationObjectFaultedException: " + communicationObjectFaultedException.Message);
            }
            catch (Exception ex)
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, "Error during Key processing: " + ex.Message);
            }
        }
Example #20
0
        private async Task HandleMultiAction(KeyPayload payload)
        {
            switch (payload.UserDesiredState) // 0 = Enable, 1 = Disable, 2 = Create Replay
            {
            case 0:
                if (!OBSManager.Instance.IsReplayBufferEnabled())
                {
                    OBSManager.Instance.StartInstantReplay();
                }
                break;

            case 1:
                if (OBSManager.Instance.IsReplayBufferEnabled())
                {
                    OBSManager.Instance.StopInstantReplay();
                }
                break;

            case 2:
                if (OBSManager.Instance.IsReplayBufferEnabled())
                {
                    await HandleInstantReplayRequest();
                }
                break;

            default:
                Logger.Instance.LogMessage(TracingLevel.ERROR, $"Invalid MultiAction State: {payload.UserDesiredState}");
                break;
            }
        }
        public async override void KeyPressed(KeyPayload payload)
        {
            Logger.Instance.LogMessage(TracingLevel.INFO, $"Key Pressed {this.GetType()}");
            string drivePath;

            if (settings.DisplayMode == DisplayMode.SingleDrive)
            {
                if (driveInfo == null)
                {
                    Logger.Instance.LogMessage(TracingLevel.ERROR, "Key Pressed but driveInfo is null!");
                    await Connection.ShowAlert();

                    return;
                }
                else
                {
                    drivePath = driveInfo?.Name;
                }
            }
            else // Multiple Drives, find the current selected one
            {
                drivePath = settings.DiskDrives[currentDrive]?.Name;
            }

            await OpenFolder(drivePath);
        }
        public override async void KeyPressed(KeyPayload payload)
        {
            Logger.Instance.LogMessage(TracingLevel.INFO, "Key Pressed");

            try
            {
                if (PrismatikApiClient.PRISMATIC_CLIENT == null || !PrismatikApiClient.PRISMATIC_CLIENT.IsConnected)
                {
                    PrismatikApiClient.SetupTelnetClient(this.global.ApiKey);
                    if (PrismatikApiClient.PRISMATIC_CLIENT == null)
                    {
                        return;
                    }

                    if (payload.IsInMultiAction)
                    {
                        await ApiSetProfilAction((int)payload.UserDesiredState);
                    }
                    else
                    {
                        await ApiSetProfilAction();
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Example #23
0
        public override async void KeyPressed(KeyPayload payload)
        {
            Logger.Instance.LogMessage(TracingLevel.INFO, $"Key Pressed {this.GetType()}");

            if (String.IsNullOrEmpty(settings.PowerPlan))
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, "Key Pressed but power plan is empty");
                await Connection.ShowAlert();

                return;
            }

            if (!Guid.TryParse(settings.PowerPlan, out Guid guid))
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, $"Could not parse power plan guid {settings.PowerPlan}");
                await Connection.ShowAlert();

                return;
            }

            try
            {
                PowerPlans.SwitchPowerPlan(guid);
                await Connection.ShowOk();
            }
            catch (Exception ex)
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, $"SwitchPowerPlan Exception: {ex}");
                await Connection.ShowAlert();
            }
        }
Example #24
0
 public override void KeyReleased(KeyPayload payload)
 {
     if (MidiDevice.MidiDevice.outputDevice != null)
     {
         MidiDevice.MidiDevice.outputDevice.Close();
     }
 }
Example #25
0
 public async override void KeyPressed(KeyPayload payload)
 {
     keyPressed    = true;
     keyPressStart = DateTime.Now;
     showDetails   = !showDetails;
     await DrawSymbolData(stockData);
 }
Example #26
0
 public override void KeyPressed(KeyPayload payload)
 {
     if (settings.buttonProcessingOnPush)
     {
         ToggleJoystickButton();
     }
 }
 public override void KeyPressed(KeyPayload payload)
 {
     keyPressed     = true;
     longKeyPressed = false;
     keyPressStart  = DateTime.Now;
     Logger.Instance.LogMessage(TracingLevel.INFO, $"Keypressed {this.GetType()}");
 }
Example #28
0
 public override void KeyReleased(KeyPayload payload)
 {
     if (settings.buttonProcessingAfterReleased)
     {
         ToggleJoystickButton();
     }
 }
Example #29
0
 public override void KeyPressed(KeyPayload payload)
 {
     Logger.Instance.LogMessage(TracingLevel.INFO, $"Key Pressed {this.GetType()}");
     forceOneRound = false;
     keyPressed    = true;
     RunCommand(Settings.Command);
 }
        public override void KeyReleased(KeyPayload payload)
        {
            var returnVal = -1;

            try
            {
                PipeServerConnection.Instance.RestartChannel();
                returnVal = PipeServerConnection.Instance.Channel.DecrementOverallIntensity(Convert.ToInt32(settings.Steps));
            }
            catch (EndpointNotFoundException endpointNotFoundException)
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, "Error: Endpoint not found - Is SimFeedback available and is the Plugin enabled? " + endpointNotFoundException.Message);
            }
            catch (CommunicationObjectFaultedException communicationObjectFaultedException)
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, "Error: communicationObjectFaultedException: " + communicationObjectFaultedException.Message);
            }
            catch (Exception ex)
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, "Error during Key processing: " + ex.Message);
            }

            if (settings.showValueAfterChange)
            {
                DrawValueData(returnVal);
            }
        }