示例#1
0
        private void InputChanged(ProviderDescriptor providerDescriptor, DeviceDescriptor deviceDescriptor, BindingReport bindingReport, int value)
        {
            if (!DeviceBinding.MapCategory(bindingReport.Category).Equals(_deviceBinding.DeviceBindingCategory))
            {
                return;
            }
            if (!IsInputValid(bindingReport.Category, value))
            {
                return;
            }

            var device = FindDevice(providerDescriptor, deviceDescriptor);

            _deviceBinding.SetDeviceGuid(device.Guid);
            _deviceBinding.SetKeyTypeValue((int)bindingReport.BindingDescriptor.Type, bindingReport.BindingDescriptor.Index, bindingReport.BindingDescriptor.SubIndex);
            EndBindMode();
        }
示例#2
0
        private static List <DeviceBindingNode> GetDeviceBindingMenu(List <DeviceReportNode> deviceNodes, DeviceIoType type)
        {
            var result = new List <DeviceBindingNode>();

            if (deviceNodes == null)
            {
                return(result);
            }

            foreach (var deviceNode in deviceNodes)
            {
                var groupNode = new DeviceBindingNode()
                {
                    Title         = deviceNode.Title,
                    IsBinding     = false,
                    ChildrenNodes = GetDeviceBindingMenu(deviceNode.Nodes, type),
                };

                foreach (var bindingInfo in deviceNode.Bindings)
                {
                    var bindingNode = new DeviceBindingNode()
                    {
                        Title         = bindingInfo.Title,
                        IsBinding     = true,
                        DeviceBinding = new DeviceBinding(null, null, type)
                        {
                            IsBound               = false,
                            KeyType               = (int)bindingInfo.BindingDescriptor.Type,
                            KeyValue              = bindingInfo.BindingDescriptor.Index,
                            KeySubValue           = bindingInfo.BindingDescriptor.SubIndex,
                            DeviceBindingCategory = DeviceBinding.MapCategory(bindingInfo.Category)
                                                    // TODO Extract to class instead of using DeviceBinding?
                        }
                    };
                    if (groupNode.ChildrenNodes == null)
                    {
                        groupNode.ChildrenNodes = new List <DeviceBindingNode>();
                    }

                    groupNode.ChildrenNodes.Add(bindingNode);
                }
                result.Add(groupNode);
            }
            return(result.Count != 0 ? result : null);
        }
示例#3
0
        private static List <DeviceBindingNode> BuildDeviceBindingMenu(List <DeviceReportNode> deviceNodes, DeviceIoType type)
        {
            var result = new List <DeviceBindingNode>();

            if (deviceNodes == null)
            {
                return(result);
            }

            foreach (var deviceNode in deviceNodes)
            {
                var groupNode = new DeviceBindingNode()
                {
                    Title         = deviceNode.Title,
                    ChildrenNodes = BuildDeviceBindingMenu(deviceNode.Nodes, type),
                };

                if (groupNode.ChildrenNodes == null)
                {
                    groupNode.ChildrenNodes = new List <DeviceBindingNode>();
                }


                foreach (var bindingInfo in deviceNode.Bindings)
                {
                    var bindingNode = new DeviceBindingNode()
                    {
                        Title             = bindingInfo.Title,
                        DeviceBindingInfo = new DeviceBindingInfo()
                        {
                            KeyType               = (int)bindingInfo.BindingDescriptor.Type,
                            KeyValue              = bindingInfo.BindingDescriptor.Index,
                            KeySubValue           = bindingInfo.BindingDescriptor.SubIndex,
                            DeviceBindingCategory = DeviceBinding.MapCategory(bindingInfo.Category),
                            Blockable             = bindingInfo.Blockable
                        }
                    };


                    groupNode.ChildrenNodes.Add(bindingNode);
                }
                result.Add(groupNode);
            }
            return(result.Count != 0 ? result : null);
        }
示例#4
0
        private bool IsInputValid(BindingCategory bindingCategory, int value)
        {
            switch (DeviceBinding.MapCategory(bindingCategory))
            {
            case DeviceBindingCategory.Delta:
            case DeviceBindingCategory.Event:
                return(true);

            case DeviceBindingCategory.Momentary:
                return(value != 0);

            case DeviceBindingCategory.Range:
                return(Constants.AxisMaxValue * 0.4 < Math.Abs(value) &&
                       Constants.AxisMaxValue * 0.6 > Math.Abs(value));

            default:
                return(false);
            }
        }
示例#5
0
        private bool IsInputValid(BindingCategory bindingCategory, short value)
        {
            switch (DeviceBinding.MapCategory(bindingCategory))
            {
            case DeviceBindingCategory.Delta:
            case DeviceBindingCategory.Event:
                return(true);

            case DeviceBindingCategory.Momentary:
                return(value != 0);

            case DeviceBindingCategory.Range:
                var wideVal = Functions.WideAbs(value);
                return(Constants.AxisMaxValue * 0.4 < wideVal &&
                       Constants.AxisMaxValue * 0.6 > wideVal);

            default:
                return(false);
            }
        }