void TestInputMapping(InputControlMapping.Range sourceRange, InputControlMapping.Range targetRange, bool invert, float expectA, float expectB, float expectC) { var mapping = new InputControlMapping() { SourceRange = sourceRange, TargetRange = targetRange, Invert = invert }; float value; string sr = "Complete"; if (sourceRange == InputControlMapping.Range.Negative) { sr = "Negative"; } else if (sourceRange == InputControlMapping.Range.Positive) { sr = "Positive"; } string tr = "Complete"; if (targetRange == InputControlMapping.Range.Negative) { tr = "Negative"; } else if (targetRange == InputControlMapping.Range.Positive) { tr = "Positive"; } value = mapping.MapValue(-1.0f); if (Mathf.Abs(value - expectA) > Single.Epsilon) { Debug.LogError("Got unexpected value A " + value + " instead of " + expectA + " (SR = " + sr + ", TR = " + tr + ")"); } value = mapping.MapValue(0.0f); if (Mathf.Abs(value - expectB) > Single.Epsilon) { Debug.LogError("Got unexpected value B " + value + " instead of " + expectB + " (SR = " + sr + ", TR = " + tr + ")"); } value = mapping.MapValue(1.0f); if (Mathf.Abs(value - expectC) > Single.Epsilon) { Debug.LogError("Got unexpected value C " + value + " instead of " + expectC + " (SR = " + sr + ", TR = " + tr + ")"); } }
protected static InputControlMapping RightTriggerMapping(int analog) { InputControlMapping inputControlMapping = new InputControlMapping(); inputControlMapping.Handle = "Right Trigger"; inputControlMapping.Target = InputControlType.RightTrigger; inputControlMapping.Source = Analog(analog); inputControlMapping.SourceRange = InputRange.MinusOneToOne; inputControlMapping.TargetRange = InputRange.ZeroToOne; inputControlMapping.IgnoreInitialZeroValue = true; return(inputControlMapping); }
public UnityUnknownDeviceProfile(string joystickName) { Name = "Unknown Device"; if (joystickName != "") { Name += " (" + joystickName + ")"; } Meta = ""; Sensitivity = 1.0f; LowerDeadZone = 0.2f; SupportedPlatforms = null; JoystickNames = new[] { joystickName }; AnalogMappings = new InputControlMapping[UnityInputDevice.MaxAnalogs]; for (int i = 0; i < UnityInputDevice.MaxAnalogs; i++) { AnalogMappings[i] = new InputControlMapping { Handle = "Analog " + i, Source = Analog(i), Target = InputControlType.Analog0 + i }; } ButtonMappings = new InputControlMapping[UnityInputDevice.MaxButtons]; for (int i = 0; i < UnityInputDevice.MaxButtons; i++) { ButtonMappings[i] = new InputControlMapping { Handle = "Button " + i, Source = Button(i), Target = InputControlType.Button0 + i }; } }
public GyroProfile() { Name = "Gyroscope"; Meta = "Gyroscope on iOS."; // This profile only works on mobile. SupportedPlatforms = new[] { "iPhone", "Android" }; ButtonMappings = new InputControlMapping[] { }; AnalogMappings = new[] { new InputControlMapping { Handle = "Move X", Target = InputControlType.LeftStickX, Source = new UnityGyroAxisSource(UnityGyroAxisSource.GyroAxis.X), Raw = true, Scale = 3.0f }, new InputControlMapping { Handle = "Move Y", Target = InputControlType.LeftStickY, Source = new UnityGyroAxisSource(UnityGyroAxisSource.GyroAxis.Y), Raw = true, Scale = 3.0f }, }; }
public MouseKeyboardMapping() { Name = "Mouse/Keyboard mapping"; Sensitivity = 1f; LowerDeadZone = 0f; UpperDeadZone = 1f; ButtonMappings = new InputControlMapping[] { new InputControlMapping() { Handle = "Attack - Left Hand", Target = InputControlType.LeftTrigger, Source = new UnityMouseButtonSource(0) }, new InputControlMapping() { Handle = "Attack - Right Hand", Target = InputControlType.RightTrigger, Source = new UnityMouseButtonSource(1) }, new InputControlMapping() { Handle = "Drop Weapon - Left Hand", Target = InputControlType.LeftBumper, Source = new UnityKeyCodeSource(KeyCode.LeftControl) }, new InputControlMapping() { Handle = "Drop Weapon - Right Hand", Target = InputControlType.RightBumper, Source = new UnityKeyCodeSource(KeyCode.Space) }, new InputControlMapping() { Handle = "Pause Button", Target = InputControlType.Start, Source = new UnityKeyCodeSource(KeyCode.Escape) } }; AnalogMappings = new InputControlMapping[] { new InputControlMapping() { Handle = "Move Left X", Target = InputControlType.LeftStickLeft, Source = new UnityKeyCodeSource(KeyCode.A) }, new InputControlMapping() { Handle = "Move Right X", Target = InputControlType.LeftStickRight, Source = new UnityKeyCodeSource(KeyCode.D) }, new InputControlMapping() { Handle = "Move Up Y", Target = InputControlType.LeftStickUp, Source = new UnityKeyCodeSource(KeyCode.W) }, new InputControlMapping() { Handle = "Move Down Y", Target = InputControlType.LeftStickDown, Source = new UnityKeyCodeSource(KeyCode.S) }, /* * new InputControlMapping() * { * Handle = "Look X", * Target = InputControlType.RightStickLeft | InputControlType.RightStickRight, * Source = MouseXAxis, * }, * new InputControlMapping() * { * Handle = "Look Y", * Target = InputControlType.RightStickUp | InputControlType.RightStickDown, * Source = MouseYAxis, * }*/ }; }
public MovementActions(InputControlMapping wrapper) { m_Wrapper = wrapper; }