예제 #1
0
        private Task StartBitmapWriterTask()
        {
            return(Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    KeyValuePair <int, byte[]> res;

                    try
                    {
                        res = imageQueue.Take();
                    }
                    catch (InvalidOperationException)
                    {
                        break;
                    }

                    foreach (var report in OutputReportSplitter.Split(res.Value, Buffer, HardwareInfo.ReportSize, HardwareInfo.HeaderSize, res.Key, HardwareInfo.PrepareDataForTransmittion))
                    {
                        DeckHid.WriteReport(report);
                    }
                }
            },
                                         CancellationToken.None,
                                         TaskCreationOptions.LongRunning,
                                         TaskScheduler.Default
                                         ));
        }
예제 #2
0
        public string GetSerialNumber()
        {
            if (!DeckHid.ReadFeatureData(HardwareInfo.SerialNumberFeatureId, out var featureData))
            {
                return(null);
            }

            return(Encoding.UTF8.GetString(featureData, HardwareInfo.SerialNumberReportSkip, featureData.Length - HardwareInfo.SerialNumberReportSkip).Trim('\0'));
        }
예제 #3
0
        public string GetFirmwareVersion()
        {
            if (!DeckHid.ReadFeatureData(HardwareInfo.FirmwareVersionFeatureId, out var featureData))
            {
                return(null);
            }

            return(Encoding.UTF8.GetString(featureData, HardwareInfo.FirmwareReportSkip, featureData.Length - HardwareInfo.FirmwareReportSkip).Trim('\0'));
        }
예제 #4
0
        public virtual void SetKeyBitmap(int keyId, KeyBitmap bitmapData)
        {
            keyId = HardwareInfo.ExtKeyIdToHardwareKeyId(keyId);

            var payload = HardwareInfo.GeneratePayload(bitmapData);

            foreach (var report in OutputReportSplitter.Split(payload, Buffer, HardwareInfo.ReportSize, HardwareInfo.HeaderSize, keyId, HardwareInfo.PrepareDataForTransmittion))
            {
                DeckHid.WriteReport(report);
            }
        }
예제 #5
0
        public void Dispose()
        {
            lock (disposeLock)
            {
                if (IsDisposed)
                {
                    return;
                }

                IsDisposed = true;
            }

            Shutdown();
            ShowLogoWithoutDisposeVerification();

            DeckHid.Dispose();

            Dispose(true);
        }
예제 #6
0
 public void SetBrightness(byte percent)
 {
     VerifyNotDisposed();
     DeckHid.WriteFeature(HardwareInfo.GetBrightnessMessage(percent));
 }
예제 #7
0
 private void ShowLogoWithoutDisposeVerification()
 {
     DeckHid.WriteFeature(HardwareInfo.GetLogoMessage());
 }