/// <summary> /// Input bound to a move is process via this routine. /// </summary> /// <param name="mapType">Type of move mapping.</param> /// <param name="idx">Move index (stick number, button number, etc.)</param> /// <param name="value">Value of input event.</param> void _SetMoveValue(MoveMapTypes mapType, int idx, float value) { if (_moveManager == null) return; switch (mapType) { case MoveMapTypes.Button: _moveManager.SetButton(idx, value > 0.5f); break; case MoveMapTypes.TriggerAnalog: _moveManager.SetTriggerDirect(idx, value); break; case MoveMapTypes.TriggerDigital: _moveManager.SetTriggerTarget(idx, value > 0.5f); break; case MoveMapTypes.LeverAnalog: _moveManager.SetLeverDirect(idx, value); break; case MoveMapTypes.LeverDigitalMinus: _moveManager.SetLeverNegative(idx, value > 0.5f); break; case MoveMapTypes.LeverDigitalPlus: _moveManager.SetLeverPositive(idx, value > 0.5f); break; case MoveMapTypes.StickAnalogHorizontal: _moveManager.SetStickHorizontalDirect(idx, value); break; case MoveMapTypes.StickDigitalLeft: _moveManager.SetStickLeft(idx, value > 0.5f); break; case MoveMapTypes.StickDigitalRight: _moveManager.SetStickRight(idx, value > 0.5f); break; case MoveMapTypes.StickAnalogVertical: _moveManager.SetStickVerticalDirect(idx, value); break; case MoveMapTypes.StickDigitalDown: _moveManager.SetStickDown(idx, value > 0.5f); break; case MoveMapTypes.StickDigitalUp: _moveManager.SetStickUp(idx, value > 0.5f); break; } }
/// <summary> /// Bind move manager move to particular make/break/move event. /// </summary> /// <param name="deviceName">Name of device to bind to, e.g. "gamepad1", "mouse0", "keyboard0".</param> /// <param name="inputObject">Name of input object to bind to, e.g. "ThumbStickX", "LeftTriggerButton".</param> /// <param name="mapType">Type of move map binding. This parameter controls whether we bind to a move stick, lever, trigger, /// or button, and whether we assume a digital input (e.g., keypress, button press) or an analog input (e.g., thumbstick).</param> /// <param name="moveIdx">Index of stick, lever, trigger, or button on the move manager to bind to.</param> /// <returns>True if binding is successful.</returns> public bool BindMove(String deviceName, String inputObject, MoveMapTypes mapType, int moveIdx) { return BindMove(deviceName, inputObject, TorqueInputDevice.Action.None, mapType, moveIdx); }
/// <summary> /// Bind move manager move to particular make/break/move event. /// </summary> /// <param name="deviceName">Name of device to bind to, e.g. "gamepad1", "mouse0", "keyboard0".</param> /// <param name="inputObject">Name of input object to bind to, e.g. "ThumbStickX", "LeftTriggerButton".</param> /// <param name="modifier">Restrict binding to be in effect only when given modifier is present. Valid modifiers are /// Shift, Ctrl, LeftClick, MiddleClick, RightClick</param> /// <param name="mapType">Type of move map binding. This parameter controls whether we bind to a move stick, lever, trigger, /// or button, and whether we assume a digital input (e.g., keypress, button press) or an analog input (e.g., thumbstick).</param> /// <param name="moveIdx">Index of stick, lever, trigger, or button on the move manager to bind to.</param> /// <returns>True if binding is successful.</returns> public bool BindMove(String deviceName, String inputObject, TorqueInputDevice.Action modifier, MoveMapTypes mapType, int moveIdx) { int deviceNumber = InputManager.Instance.FindDevice(deviceName); if (deviceNumber == -1) return false; TorqueInputDevice device = InputManager.Instance.GetDevice(deviceNumber); int objectId = device.GetObjectId(inputObject); if (objectId == -1) return false; return BindMove(deviceNumber, objectId, modifier, mapType, moveIdx); }
/// <summary> /// Bind move manager move to particular make/break/move event. /// </summary> /// <param name="deviceNumber">Device number to bind.</param> /// <param name="objectId">Device object to bind to. E.g., GamePads have thumb sticks, buttons, and triggers, which /// have id's corresponding to XGamePadDevice.GamePadObjects enum values.</param> /// <param name="mapType">Type of move map binding. This parameter controls whether we bind to a move stick, lever, trigger, /// or button, and whether we assume a digital input (e.g., keypress, button press) or an analog input (e.g., thumbstick).</param> /// <param name="moveIdx">Index of stick, lever, trigger, or button on the move manager to bind to.</param> /// <returns>True if binding is successful.</returns> public bool BindMove(int deviceNumber, int objectId, MoveMapTypes mapType, int moveIdx) { return BindMove(deviceNumber, objectId, TorqueInputDevice.Action.None, mapType, moveIdx); }
/// <summary> /// Bind move manager move to particular make/break/move event. /// </summary> /// <param name="deviceNumber">Device number to bind.</param> /// <param name="objectId">Device object to bind to. E.g., GamePads have thumb sticks, buttons, and triggers, which /// have id's corresponding to XGamePadDevice.GamePadObjects enum values.</param> /// <param name="modifier">Restrict binding to be in effect only when given modifier is present. Valid modifiers are /// Shift, Ctrl, LeftClick, MiddleClick, RightClick</param> /// <param name="mapType">Type of move map binding. This parameter controls whether we bind to a move stick, lever, trigger, /// or button, and whether we assume a digital input (e.g., keypress, button press) or an analog input (e.g., thumbstick).</param> /// <param name="moveIdx">Index of stick, lever, trigger, or button on the move manager to bind to.</param> /// <returns>True if binding is successful.</returns> public bool BindMove(int deviceNumber, int objectId, TorqueInputDevice.Action modifier, MoveMapTypes mapType, int moveIdx) { if (deviceNumber < 0 || deviceNumber >= InputManager.Instance.GetNumDevices()) return false; TorqueInputDevice device = InputManager.Instance.GetDevice(deviceNumber); if (!device.IsValidObject(objectId)) return false; InputNode node = new InputNode(); node.DeviceNumber = deviceNumber; node.ObjectId = objectId; node.Modifier = modifier; node.Flags = InputNode.ActionFlags.None; node.DeadZoneBegin = 0.0f; node.DeadZoneEnd = 0.0f; node.ScaleFactor = 1.0f; node.MoveIndex = moveIdx; node.MoveMapType = mapType; _currentBindIndex = _SetInputNode(deviceNumber, objectId, modifier, ref node); _UpdateMoveManager(node); return true; }