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); }
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; } }
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)); } }
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; }
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); }
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); }
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); }
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); }
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); }