示例#1
0
        public bool RemoveBinding(HeadAxis axis)
        {
            // remove the axis from all devices
            bool result     = false;
            var  removeFrom = new Queue <List <Binding> >(config.Values);

            while (removeFrom.Count > 0)
            {
                List <Binding> bindings = removeFrom.Dequeue();
                for (int iBind = 0; iBind < bindings.Count; iBind++)
                {
                    if (bindings[iBind].Axis == axis)
                    {
                        bindings.RemoveAt(iBind);
                        iBind -= 1;
                        result = true;
                    }
                }
            }
            // cleanup, remove empty device config
            var toRemove = new Queue <int>();

            foreach (var pair in config)
            {
                if (pair.Value.Count == 0)
                {
                    toRemove.Enqueue(pair.Key);
                }
            }
            while (toRemove.Count > 0)
            {
                config.Remove(toRemove.Dequeue());
            }
            return(result);
        }
示例#2
0
        public void SetAxis(HeadAxis axis, KeyState state)
        {
            switch (axis)
            {
            case HeadAxis.X:
                PosX = state;
                break;

            case HeadAxis.Y:
                PosY = state;
                break;

            case HeadAxis.Z:
                PosZ = state;
                break;

            case HeadAxis.Yaw:
                Yaw = state;
                break;

            case HeadAxis.Pitch:
                Pitch = state;
                break;

            case HeadAxis.Roll:
                Roll = state;
                break;

            default:
                break;
            }
        }
示例#3
0
        public KeyState GetAxis(HeadAxis axis)
        {
            switch (axis)
            {
            case HeadAxis.X:
                return(PosX);

            case HeadAxis.Y:
                return(PosY);

            case HeadAxis.Z:
                return(PosZ);

            case HeadAxis.Yaw:
                return(Yaw);

            case HeadAxis.Pitch:
                return(Pitch);

            case HeadAxis.Roll:
                return(Roll);

            default:
                return(new KeyState(0.0f, 0.0f));
            }
        }
示例#4
0
 public Binding(HeadAxis axis, VirtualDeviceCapability capability, object posKey, object negKey, object mapping)
 {
     this.sourceAxis       = axis;
     this.targetCapability = capability;
     this.targetPosKey     = posKey;
     this.targetNegKey     = negKey;
     this.mapping          = mapping;
 }
示例#5
0
        public void AddBinding(HeadAxis axis, int deviceIndex, VirtualDeviceCapability capability, object posKey, object negKey, object mapping)
        {
            List <Binding> deviceBindings;

            if (!config.TryGetValue(deviceIndex, out deviceBindings))
            {
                deviceBindings = new List <Binding>();
                config.Add(deviceIndex, deviceBindings);
            }
            var binding = new Binding(axis, capability, posKey, negKey, mapping);

            deviceBindings.Add(binding);
        }
示例#6
0
 public VirtualDeviceCapability GetDeviceCapability(HeadAxis axis)
 {
     foreach (var lst in config.Values)
     {
         foreach (var binding in lst)
         {
             if (binding.Axis == axis)
             {
                 return(binding.Capability);
             }
         }
     }
     return(VirtualDeviceCapability.Axis);
 }
示例#7
0
 public int GetDeviceIndex(HeadAxis axis)
 {
     foreach (var pair in config)
     {
         foreach (var binding in pair.Value)
         {
             if (binding.Axis == axis)
             {
                 return(pair.Key);
             }
         }
     }
     return(-1);
 }
示例#8
0
 public object GetMapping(HeadAxis axis)
 {
     foreach (var lst in config.Values)
     {
         foreach (var binding in lst)
         {
             if (binding.Axis == axis)
             {
                 return(binding.Mapping);
             }
         }
     }
     return(null);
 }
示例#9
0
 public Tuple <object, object> GetDeviceKeys(HeadAxis axis)
 {
     foreach (var lst in config.Values)
     {
         foreach (var binding in lst)
         {
             if (binding.Axis == axis)
             {
                 return(Tuple.Create(binding.PosKey, binding.NegKey));
             }
         }
     }
     return(null);
 }