示例#1
0
        protected override bool Initialize()
        {
            if (!base.Initialize())
            {
                return(false);
            }

            Log.Debug("Device", $"Initializing device '{Endpoint.FriendlyName}' {Endpoint.DevicePath}");
            Log.Debug("Device", $"Using report parser type '{Identifier.ReportParser}'");

            foreach (byte index in Identifier.InitializationStrings ?? new List <byte>())
            {
                Endpoint.GetDeviceString(index);
                Log.Debug("Device", $"Initialized string index {index}");
            }

            foreach (var report in Identifier.FeatureInitReport ?? new List <byte[]>())
            {
                if (report == null || report.Length == 0)
                {
                    continue;
                }

                try
                {
                    ReportStream.SetFeature(report);
                    Log.Debug("Device", "Set device feature: " + BitConverter.ToString(report));
                }
                catch
                {
                    Log.Write("Device", "Failed to set device feature: " + BitConverter.ToString(report), LogLevel.Warning);
                }
            }

            foreach (var report in Identifier.OutputInitReport ?? new List <byte[]>())
            {
                if (report == null || report.Length == 0)
                {
                    continue;
                }

                try
                {
                    ReportStream.Write(report);
                    Log.Debug("Device", "Set device output: " + BitConverter.ToString(report));
                }
                catch
                {
                    Log.Write("Device", "Failed to set device output: " + BitConverter.ToString(report), LogLevel.Warning);
                }
            }

            return(true);
        }
示例#2
0
        protected override bool Initialize()
        {
            if (!base.Initialize())
            {
                return(false);
            }

            Log.Debug("Device", $"Initializing device '{Endpoint.FriendlyName}' {Endpoint.DevicePath}");
            Log.Debug("Device", $"Using report parser type '{Identifier.ReportParser}'");

            if (_featureInitDelayMs != 0)
            {
                Log.Debug("Device", $"{DELAY_ATTRIBUTE_KEY_NAME} is set in tablet configuration, will sleep for {_featureInitDelayMs}ms between FeatureInitReports");
            }

            foreach (byte index in Identifier.InitializationStrings ?? new List <byte>())
            {
                Endpoint.GetDeviceString(index);
                Log.Debug("Device", $"Initialized string index {index}");
            }

            foreach (var report in Identifier.FeatureInitReport ?? new List <byte[]>())
            {
                if (report == null || report.Length == 0)
                {
                    continue;
                }

                try
                {
                    if (_featureInitDelayMs != 0)
                    {
                        Thread.Sleep((int)_featureInitDelayMs);
                    }
                    ReportStream.SetFeature(report);
                    Log.Debug("Device", "Set device feature: " + BitConverter.ToString(report));
                }
                catch
                {
                    Log.Write("Device", "Failed to set device feature: " + BitConverter.ToString(report), LogLevel.Warning);
                }
            }

            foreach (var report in Identifier.OutputInitReport ?? new List <byte[]>())
            {
                if (report == null || report.Length == 0)
                {
                    continue;
                }

                try
                {
                    ReportStream.Write(report);
                    Log.Debug("Device", "Set device output: " + BitConverter.ToString(report));
                }
                catch
                {
                    Log.Write("Device", "Failed to set device output: " + BitConverter.ToString(report), LogLevel.Warning);
                }
            }

            return(true);
        }