public IInputMap Clone() { JoystickMap clone = new JoystickMap(deviceId); clone.buttons.AddRange(buttons); clone.axes.AddRange(axes); clone.balls.AddRange(balls); clone.hats.AddRange(hats); return(clone); }
public bool SetFrom(IInputMap that) { JoystickMap jsCast = that as JoystickMap; if (jsCast == null) { Debug.LogError("Type incompatibility when trying to call SetFrom on a joystick input map"); return(false); } SetEmpty(); buttons.AddRange(jsCast.buttons); axes.AddRange(jsCast.axes); balls.AddRange(jsCast.balls); hats.AddRange(jsCast.hats); return(true); }
public void Add(IInputMap map) { KeyboardMap kbMap = map as KeyboardMap; if (kbMap != null) { kbMaps.Add(kbMap); } GamepadMap gpButtonMap = map as GamepadMap; if (gpButtonMap != null) { gpButtonMaps.Add(gpButtonMap); } JoystickMap jsButtonMap = map as JoystickMap; if (jsButtonMap != null) { jsMaps.Add(jsButtonMap); } }
public bool HasConflict(IInputMap other, InputAction.Properties properties) { JoystickMap otherMap = other as JoystickMap; if (otherMap == null || otherMap.IsEmpty) { return(false); } bool allowSameFrameMultiInput = properties.allowSameFrameMultiInput; if (allowSameFrameMultiInput) { if (buttons.Count > 0 && otherMap.buttons.Count > 0) { // Check if they match exactly, or if one map is a sub-set of the other var smallerButtonMap = buttons.Count < otherMap.buttons.Count ? buttons : otherMap.buttons; var largerButtonMap = buttons.Count < otherMap.buttons.Count ? otherMap.buttons : buttons; int sameInputCount = 0; foreach (var button in smallerButtonMap) { bool contains = false; foreach (var otherButton in largerButtonMap) { if (button.buttonIndex == otherButton.buttonIndex) { contains = true; break; } } if (contains) { ++sameInputCount; } } if (sameInputCount == smallerButtonMap.Count) { return(true); } } } else { foreach (var button in buttons) { foreach (var otherButton in otherMap.buttons) { if (button.buttonIndex == otherButton.buttonIndex) { return(true); } } } } foreach (var axis in axes) { foreach (var otherAxis in otherMap.axes) { if (axis.axisIndex == otherAxis.axisIndex && (axis.dir == otherAxis.dir || axis.dir == JoystickDevice.AxisDir.Any || otherAxis.dir == JoystickDevice.AxisDir.Any)) { return(true); } } } foreach (var ballIndex in balls) { foreach (var otherBallIndex in otherMap.balls) { if (ballIndex.ballIndex == otherBallIndex.ballIndex) { return(true); } } } foreach (var hat in hats) { foreach (var otherHat in otherMap.hats) { if (hat.hatIndex == otherHat.hatIndex && hat.position == otherHat.position) { return(true); } } } return(false); }