Example #1
0
        public DriverDaemon()
        {
            Log.Output += (sender, message) =>
            {
                LogMessages.Add(message);
                Console.WriteLine(Log.GetStringFormat(message));
                Message?.Invoke(sender, message);
            };
            Driver.TabletsChanged += (sender, e) => TabletsChanged?.Invoke(sender, e);
            HidSharpDeviceRootHub.Current.DevicesChanged += async(sender, args) =>
            {
                if (args.Additions.Any())
                {
                    await DetectTablets();
                    await SetSettings(Settings);
                }
            };

            foreach (var driverInfo in DriverInfo.GetDriverInfos())
            {
                Log.Write("Detect", $"Another tablet driver found: {driverInfo.Name}", LogLevel.Warning);
                if (driverInfo.IsBlockingDriver)
                {
                    Log.Write("Detect", $"Detection for {driverInfo.Name} tablets might be impaired", LogLevel.Warning);
                }
                else if (driverInfo.IsSendingInput)
                {
                    Log.Write("Detect", $"Detected input coming from {driverInfo.Name} driver", LogLevel.Error);
                }
            }

            LoadUserSettings();
        }
        protected override void OnConnected()
        {
            base.OnConnected();

            Instance.Message += (sender, e) =>
                                Application.Instance.AsyncInvoke(() => Message?.Invoke(sender, e));
            Instance.DeviceReport += (sender, e) =>
                                     Application.Instance.AsyncInvoke(() => DeviceReport?.Invoke(sender, e));
            Instance.TabletsChanged += (sender, e) =>
                                       Application.Instance.AsyncInvoke(() => TabletsChanged?.Invoke(sender, e));
        }
Example #3
0
        public DriverDaemon(Driver driver)
        {
            Driver = driver;

            Log.Output += (sender, message) =>
            {
                LogMessages.Add(message);
                Console.WriteLine(Log.GetStringFormat(message));
                Message?.Invoke(sender, message);
            };

            Driver.TabletsChanged += (sender, e) => TabletsChanged?.Invoke(sender, e);
            Driver.CompositeDeviceHub.DevicesChanged += async(sender, args) =>
            {
                if (args.Additions.Any())
                {
                    await DetectTablets();
                    await SetSettings(Settings);
                }
            };

            foreach (var driverInfo in DriverInfo.GetDriverInfos())
            {
                Log.Write("Detect", $"Another tablet driver found: {driverInfo.Name}", LogLevel.Warning);
                if (driverInfo.IsBlockingDriver)
                {
                    Log.Write("Detect", $"Detection for {driverInfo.Name} tablets might be impaired", LogLevel.Warning);
                }
                else if (driverInfo.IsSendingInput)
                {
                    Log.Write("Detect", $"Detected input coming from {driverInfo.Name} driver", LogLevel.Error);
                }
            }

            LoadUserSettings();

#if !DEBUG
            SleepDetection = new(async() =>
            {
                Log.Write(nameof(SleepDetectionThread), "Sleep detected...", LogLevel.Info);
                await DetectTablets();
                await SetSettings(Settings);
            });

            SleepDetection.Start();
#endif
        }
Example #4
0
        public DriverDaemon()
        {
            Log.Output += (sender, message) =>
            {
                LogMessages.Add(message);
                Console.WriteLine(Log.GetStringFormat(message));
                Message?.Invoke(sender, message);
            };
            Driver.TabletsChanged += (sender, e) => TabletsChanged?.Invoke(sender, e);
            HidSharpDeviceRootHub.Current.DevicesChanged += async(sender, args) =>
            {
                if (args.Additions.Any())
                {
                    await DetectTablets();
                    await SetSettings(Settings);
                }
            };

            LoadUserSettings();
        }
Example #5
0
        public virtual bool Detect()
        {
            bool success = false;

            Devices.Clear();
            foreach (var config in GetTabletConfigurations())
            {
                if (Match(config) is InputDeviceTree tree)
                {
                    success = true;
                    Devices.Add(tree);

                    tree.Disconnected += (sender, e) =>
                    {
                        Devices.Remove(tree);
                        TabletsChanged?.Invoke(this, Tablets);
                    };
                }
            }

            TabletsChanged?.Invoke(this, Tablets);

            return(success);
        }