Esempio n. 1
0
        private void SetBindingHandlerSettings(InputDeviceTree dev, IOutputMode outputMode, BindingSettings settings)
        {
            string group          = dev.Properties.Name;
            var    bindingHandler = new BindingHandler(outputMode);

            var    bindingServiceProvider = new ServiceManager();
            object pointer = outputMode switch
            {
                AbsoluteOutputMode absoluteOutputMode => absoluteOutputMode.Pointer,
                RelativeOutputMode relativeOutputMode => relativeOutputMode.Pointer,
                   _ => null
            };

            if (pointer is IVirtualMouse virtualMouse)
            {
                bindingServiceProvider.AddService <IVirtualMouse>(() => virtualMouse);
            }

            var tipbinding = bindingHandler.TipBinding = settings.TipButton?.Construct <IBinding>();

            bindingServiceProvider.Inject(tipbinding);
            bindingHandler.TipActivationPressure = settings.TipActivationPressure;
            Log.Write(group, $"Tip Binding: [{bindingHandler.TipBinding}]@{bindingHandler.TipActivationPressure}%");

            var eraserBinding = bindingHandler.EraserBinding = settings.EraserButton?.Construct <IBinding>();

            bindingServiceProvider.Inject(eraserBinding);
            bindingHandler.EraserActivationPressure = settings.EraserActivationPressure;
            Log.Write(group, $"Eraser Binding: [{bindingHandler.EraserBinding}]@{bindingHandler.EraserActivationPressure}%");

            if (settings.PenButtons != null)
            {
                for (int index = 0; index < settings.PenButtons.Count; index++)
                {
                    var bind = settings.PenButtons[index]?.Construct <IBinding>();
                    if (!bindingHandler.PenButtonBindings.TryAdd(index, bind))
                    {
                        bindingHandler.PenButtonBindings[index] = bind;
                        bindingServiceProvider.Inject(bind);
                    }
                }

                Log.Write(group, $"Pen Bindings: " + string.Join(", ", bindingHandler.PenButtonBindings));
            }

            if (settings.AuxButtons != null)
            {
                for (int index = 0; index < settings.AuxButtons.Count; index++)
                {
                    var bind = settings.AuxButtons[index]?.Construct <IBinding>();
                    if (!bindingHandler.AuxButtonBindings.TryAdd(index, bind))
                    {
                        bindingHandler.AuxButtonBindings[index] = bind;
                        bindingServiceProvider.Inject(bind);
                    }
                }

                Log.Write(group, $"Express Key Bindings: " + string.Join(", ", bindingHandler.AuxButtonBindings));
            }
        }
Esempio n. 2
0
        public BindingHandler(IOutputMode outputMode)
        {
            this.outputMode = outputMode;

            // Force consume all reports from the last element
            var lastElement = this.outputMode.Elements?.LastOrDefault() ?? (IPipelineElement <IDeviceReport>)outputMode;

            lastElement.Emit += Consume;
        }
Esempio n. 3
0
        private void SetOutputModeSettings(IOutputMode outputMode)
        {
            var filters = from store in Settings.Filters
                          where store.Enable == true
                          select store.Construct <IFilter>();

            outputMode.Filters = filters.ToList();

            if (outputMode.Filters != null && outputMode.Filters.Count() > 0)
            {
                Log.Write("Settings", $"Filters: {string.Join(", ", outputMode.Filters)}");
            }

            outputMode.Tablet = Driver.Tablet;
        }
Esempio n. 4
0
        private void SetOutputModeSettings(IOutputMode outputMode)
        {
            outputMode.Tablet = Driver.Tablet;

            var elements = from store in Settings.Filters
                           where store.Enable == true
                           let filter = store.Construct <IPositionedPipelineElement <IDeviceReport> >()
                                        where filter != null
                                        select filter;

            outputMode.Elements = elements.ToList();

            if (outputMode.Elements != null && outputMode.Elements.Count() > 0)
            {
                Log.Write("Settings", $"Filters: {string.Join(", ", outputMode.Elements)}");
            }
        }
        private void SetOutputModeSettings(InputDeviceTree dev, IOutputMode outputMode, Profile profile, TabletReference tabletReference)
        {
            string group = dev.Properties.Name;

            outputMode.Tablet = dev;

            var elements = from store in profile.Filters
                           where store.Enable == true
                           let filter = store.Construct <IPositionedPipelineElement <IDeviceReport> >(tabletReference)
                                        where filter != null
                                        select filter;

            outputMode.Elements = elements.ToList();

            if (outputMode.Elements != null && outputMode.Elements.Count > 0)
            {
                Log.Write(group, $"Filters: {string.Join(", ", outputMode.Elements)}");
            }
        }
        private void SetOutputModeSettings(IOutputMode outputMode)
        {
            outputMode.Filters = from filterPath in Settings?.Filters
                                 let filter = new PluginReference(filterPath).Construct <IFilter>()
                                              where filter != null
                                              select filter;

            foreach (var filter in outputMode.Filters)
            {
                foreach (var property in filter.GetType().GetProperties())
                {
                    var settingPath = filter.GetType().FullName + "." + property.Name;
                    if (property.GetCustomAttribute <PropertyAttribute>(false) != null &&
                        Settings.PluginSettings.TryGetValue(settingPath, out var strValue))
                    {
                        try
                        {
                            var value = Convert.ChangeType(strValue, property.PropertyType);
                            property.SetValue(filter, value);
                        }
                        catch (FormatException)
                        {
                            Log.Write("Settings", $"Invalid filter setting for '{property.Name}', this setting will be cleared.");
                            Settings.PluginSettings.Remove(settingPath);
                        }
                    }
                }
            }

            if (outputMode.Filters != null && outputMode.Filters.Count() > 0)
            {
                Log.Write("Settings", $"Filters: {string.Join(", ", outputMode.Filters)}");
            }

            outputMode.TabletProperties = Driver.TabletProperties;
        }
        private void SetBindingHandlerSettings(InputDeviceTree dev, IOutputMode outputMode, BindingSettings settings, TabletReference tabletReference)
        {
            string group          = dev.Properties.Name;
            var    bindingHandler = new BindingHandler(outputMode);

            var    bindingServiceProvider = new ServiceManager();
            object?pointer = outputMode switch
            {
                AbsoluteOutputMode absoluteOutputMode => absoluteOutputMode.Pointer,
                RelativeOutputMode relativeOutputMode => relativeOutputMode.Pointer,
                  _ => null
            };

            if (pointer is IMouseButtonHandler mouseButtonHandler)
            {
                bindingServiceProvider.AddService(() => mouseButtonHandler);
            }

            var tip = bindingHandler.Tip = new ThresholdBindingState
            {
                Binding = settings.TipButton?.Construct <IBinding>(bindingServiceProvider, tabletReference),

                ActivationThreshold = settings.TipActivationThreshold
            };

            if (tip.Binding != null)
            {
                Log.Write(group, $"Tip Binding: [{tip.Binding}]@{tip.ActivationThreshold}%");
            }

            var eraser = bindingHandler.Eraser = new ThresholdBindingState
            {
                Binding             = settings.EraserButton?.Construct <IBinding>(bindingServiceProvider, tabletReference),
                ActivationThreshold = settings.EraserActivationThreshold
            };

            if (eraser.Binding != null)
            {
                Log.Write(group, $"Eraser Binding: [{eraser.Binding}]@{eraser.ActivationThreshold}%");
            }

            if (settings.PenButtons != null && settings.PenButtons.Any(b => b?.Path != null))
            {
                SetBindingHandlerCollectionSettings(bindingServiceProvider, settings.PenButtons, bindingHandler.PenButtons, tabletReference);
                Log.Write(group, $"Pen Bindings: " + string.Join(", ", bindingHandler.PenButtons.Select(b => b.Value?.Binding)));
            }

            if (settings.AuxButtons != null && settings.AuxButtons.Any(b => b?.Path != null))
            {
                SetBindingHandlerCollectionSettings(bindingServiceProvider, settings.AuxButtons, bindingHandler.AuxButtons, tabletReference);
                Log.Write(group, $"Express Key Bindings: " + string.Join(", ", bindingHandler.AuxButtons.Select(b => b.Value?.Binding)));
            }

            if (settings.MouseButtons != null && settings.MouseButtons.Any(b => b?.Path != null))
            {
                SetBindingHandlerCollectionSettings(bindingServiceProvider, settings.MouseButtons, bindingHandler.MouseButtons, tabletReference);
                Log.Write(group, $"Mouse Button Bindings: [" + string.Join("], [", bindingHandler.MouseButtons.Select(b => b.Value?.Binding)) + "]");
            }

            var scrollUp = bindingHandler.MouseScrollUp = new BindingState
            {
                Binding = settings.MouseScrollUp?.Construct <IBinding>(bindingServiceProvider, tabletReference)
            };

            var scrollDown = bindingHandler.MouseScrollDown = new BindingState
            {
                Binding = settings.MouseScrollDown?.Construct <IBinding>(bindingServiceProvider, tabletReference)
            };

            if (scrollUp.Binding != null || scrollDown.Binding != null)
            {
                Log.Write(group, $"Mouse Scroll: Up: [{scrollUp?.Binding}] Down: [{scrollDown?.Binding}]");
            }
        }
Esempio n. 8
0
        private void SetOutputModeSettings(IServiceCollection serviceCollection, InputDeviceTree dev, IOutputMode outputMode, Profile profile)
        {
            var provider = serviceCollection.BuildServiceProvider();

            string group = dev.Properties.Name;

            outputMode.Tablet = dev;

            var elements = from store in profile.Filters
                           where store.Enable
                           let filter = store.Construct <IPositionedPipelineElement <IDeviceReport> >(provider)
                                        where filter != null
                                        select filter;

            outputMode.Elements = elements.ToList();

            if (outputMode.Elements != null && outputMode.Elements.Count() > 0)
            {
                Log.Write(group, $"Filters: {string.Join(", ", outputMode.Elements)}");
            }
        }