private async void OnFrameArrived(Direct3D11CaptureFramePool sender, object args)
        {
            _currentFrame = sender.TryGetNextFrame();


            BarcodeReader reader = new BarcodeReader();

            reader.AutoRotate              = true;
            reader.Options.TryHarder       = true;
            reader.Options.PureBarcode     = false;
            reader.Options.PossibleFormats = new List <BarcodeFormat>();
            reader.Options.PossibleFormats.Add(BarcodeFormat.QR_CODE);

            var bitmap = await SoftwareBitmap.CreateCopyFromSurfaceAsync(_currentFrame.Surface).AsTask();

            var result = reader.Decode(bitmap);

            if (!string.IsNullOrEmpty(result?.Text) && (result.Text.StartsWith("suavekeys|expression") || result.Text.StartsWith("suavekeys|gesture")))
            {
                Debug.WriteLine("WOOHOO WE FOUND A CODE");
                if (!_isSending)
                {
                    _isSending = true;
                    var command = result.Text.Split('|')[2];
                    await _suaveKeysService.SendCommandAsync(command);

                    _isSending = false;
                }
            }
            _frameEvent.Set();
        }
Exemplo n.º 2
0
        private async void TwitchService_OnCommandReceived(object sender, string command)
        {
            // pass the command to the key service and also append to log
            if (command.StartsWith($"!{Prefix}"))
            {
                await _suaveKeysService.SendCommandAsync(command.Replace($"!{Prefix}", string.Empty).Trim());

                CommandLog += $"\n\n{command}";
            }
        }