Inheritance: NeitriBehavior, IDevice, IInteraction
Exemplo n.º 1
0
 // Update is called once per frame
 void GetInput(InputDevice inputDevice)
 {
     if(inputDevice.MenuWasPressed)
     {
         Application.LoadLevel(1);
     }
 }
Exemplo n.º 2
0
        public Editor(InputDevice input)
        {
            this.input = input;

            player = new Player(input);
            player.position.Y = 0.0f;
            player.position.Z = 15.0f;

            camera = new FirstPersonCamera(player);
            camera.width = Application.WIDTH;
            camera.height = Application.HEIGHT;
            camera.near = 0.1f;
            camera.far = 500;
            camera.fov = 1.1f;

            depth_values = new float[]{ 0, -150, -400};
            curr_depth_index = 0;

            cursor = new Cursor(6);
            cursor.color = Color.Gray;

            level = new Level();

            asset_list = new List<object>();
            asset_list.Add(Resources.box_model);
            asset_list.Add(Resources.rock_model);
            asset_list.Add(Resources.seaurchin_model);
            asset_list.Add(Resources.ray_texture);
            asset_list.Add(Resources.starfish_model);

            instance = this;
        }
Exemplo n.º 3
0
 void Update() {
     //Check for A button to change scene to correct boss
     inputDevice = InputManager.ActiveDevice;
     if(Input.GetKeyDown(KeyCode.A) || inputDevice.GetControl(InputControlType.Action1).WasPressed){
         GameController.LoadLastScene();
     }
 }
Exemplo n.º 4
0
    public void changePlayer(InputDevice inputDevice)
    {
        if (inputDevice.Action4.WasPressed  )
        {

        }
    }
 // Use this for initialization
 void Start()
 {
     asource = this.GetComponent<AudioSource>();
     inputDevice = (InputManager.Devices.Count > 0) ? InputManager.Devices[0] : null;
     started_timer = true;
     timer = max_timer;
 }
    // Update is called once per frame
    void Update()
    {
        if (InputManager.Devices.Count - 1 >= playerIndex)
            myDevice = InputManager.Devices[playerIndex];
        else
            myDevice = null;

        if (myDevice == null) return;

        aIn = myDevice.Action1.WasPressed;

        for (int i = 0; i < InputManager.Devices.Count; i++) {
            if(i < 2){
                controllers[i].color = Color.blue;
            } else {
                controllers[i].color = Color.red;
            }
        }

        if (InputManager.Devices.Count < 4) {
            Text prompt = GameObject.Find("Instructions").GetComponent<Text>();
            prompt.text = "Waiting for "+(4-InputManager.Devices.Count)+" more players...";
        }

        if (aIn) {
            Launch ();
        }
    }
Exemplo n.º 7
0
 public static float GetAxisRawForPlayer(string axisName, int playerIndex, InputDevice device)
 {
     //        return Input.GetAxisRaw (ConcatPlayerIndex(axisName, playerIndex, device));
     float xbox = Input.GetAxisRaw (ConcatPlayerIndex (axisName, playerIndex, InputDevices.GetAllInputDevices () [(int)InputDevices.ControllerTypes.XBox]));
     float keyboard = Input.GetAxisRaw (ConcatPlayerIndex (axisName, playerIndex, InputDevices.GetAllInputDevices () [(int)InputDevices.ControllerTypes.Keyboard]));
     return xbox + keyboard;
 }
Exemplo n.º 8
0
 public static bool GetButtonUpForPlayer(string buttonName, int playerIndex, InputDevice device)
 {
     //        return Input.GetButtonUp (ConcatPlayerIndex (buttonName, playerIndex, device));
     bool xbox = Input.GetButtonUp (ConcatPlayerIndex (buttonName, playerIndex, InputDevices.GetAllInputDevices () [(int)InputDevices.ControllerTypes.XBox]));
     bool keyboard = Input.GetButtonUp (ConcatPlayerIndex (buttonName, playerIndex, InputDevices.GetAllInputDevices () [(int)InputDevices.ControllerTypes.Keyboard]));
     return xbox || keyboard;
 }
 // Use this for initialization
 void Start()
 {
     start_btn = exit_game_button.GetComponent<console_button>();
     asource = this.GetComponent<AudioSource>();
     inputDevice = (InputManager.Devices.Count > 0) ? InputManager.Devices[0] : null;
     start_btn.set_selected();
 }
Exemplo n.º 10
0
	void UpdateCubeWithInputDevice( InputDevice inputDevice )
	{
		// Set object material color based on which action is pressed.
		if (inputDevice.Action1)
		{
			cubeRenderer.material.color = Color.green;
		}
		else
			if (inputDevice.Action2)
		{
			cubeRenderer.material.color = Color.red;
		}
		else
			if (inputDevice.Action3)
		{
			cubeRenderer.material.color = Color.blue;
		}
		else
			if (inputDevice.Action4)
		{
			cubeRenderer.material.color = Color.yellow;
		}
		else
		{
			cubeRenderer.material.color = Color.white;
		}
		
		// Rotate target object with both sticks and d-pad.
		transform.Rotate( Vector3.down, 500.0f * Time.deltaTime * inputDevice.Direction.X, Space.World );
		transform.Rotate( Vector3.right, 500.0f * Time.deltaTime * inputDevice.Direction.Y, Space.World );
		transform.Rotate( Vector3.down, 500.0f * Time.deltaTime * inputDevice.RightStickX, Space.World );
		transform.Rotate( Vector3.right, 500.0f * Time.deltaTime * inputDevice.RightStickY, Space.World );
	}
Exemplo n.º 11
0
    //mouvement du player sur les axes x et z
    public void checkInputPlayer(InputDevice inputDevice)
    {
        inputDevice = (InputManager.Devices.Count > playerNum) ? InputManager.Devices[playerNum] : null;

        if(inputDevice!=null)
        updateWithInControle (inputDevice);
    }
Exemplo n.º 12
0
	public MonkActions(InputDevice device)
	{
		spawn0 = CreatePlayerAction ("Spawn0");
		spawn1 = CreatePlayerAction ("Spawn1");
		spawn2 = CreatePlayerAction ("Spawn2");
		spawn3 = CreatePlayerAction ("Spawn3");
		fireTurret = CreatePlayerAction ("FireTurret");
		moveUnitLeft = CreatePlayerAction ("MoveUnitLeft");
		moveUnitRight = CreatePlayerAction ("MoveUnitRight");
		moveHorizontal = CreateOneAxisPlayerAction (moveUnitLeft, moveUnitRight);

		moveUnitUp = CreatePlayerAction ("MoveUnitUp");
		moveUnitDown = CreatePlayerAction ("MoveUnitDown");
		moveVertical = CreateOneAxisPlayerAction (moveUnitDown,moveUnitUp);

		Device = device;

		spawn0.AddDefaultBinding (InputControlType.Action1);
		spawn1.AddDefaultBinding (InputControlType.Action2);
		spawn2.AddDefaultBinding (InputControlType.Action3);
		spawn3.AddDefaultBinding (InputControlType.Action4);
		fireTurret.AddDefaultBinding (InputControlType.RightTrigger);

		moveUnitLeft.AddDefaultBinding (InputControlType.LeftStickLeft);
		moveUnitRight.AddDefaultBinding (InputControlType.LeftStickRight);
		moveUnitUp.AddDefaultBinding (InputControlType.LeftStickUp);
		moveUnitDown.AddDefaultBinding (InputControlType.LeftStickDown);

	}
Exemplo n.º 13
0
        public override void OnActive(double elapsed, InputDevice input)
        {
            editor.Update(elapsed);

            if (input.IsPressed(Buttons.Start))
                screenmanager.FadeIn(menu_screen);
        }
    Cursor CreateButton( InputDevice inputDevice )
    {
        if (colorSelectionManagers.Count < maxColorSelectors)
            {
                // Pop a position off the list. We'll add it back if the player is removed.
                //var playerPosition = spawnPoints[0];
                //spawnPoints.RemoveAt( 0 );

                var gameObject = (GameObject) Instantiate( colorSelectionManagerPrefab, new Vector3(0,0,0), Quaternion.identity );
                gameObject.transform.SetParent(GameObject.Find("ColorInputManager").transform);
                gameObject.transform.localPosition = new Vector3(0,0,0);
                gameObject.transform.localScale = new Vector3(1,1,1);
                var buttonManager = gameObject.GetComponent<Cursor>();
                buttonManager.device = inputDevice;
                buttonManager.liaison = layla;
                //scale.c1 = Color.cyan;
                //colorSelectionManagers.Add( buttonManager );

        //				Debug.Log("Adding a new player with device: " + inputDevice);
                layla.GetComponent<GameControlLiaison>().CreatePlayer(inputDevice);
                return buttonManager;
            }

            return null;
    }
Exemplo n.º 15
0
    // Update is called once per frame
    void GetInput(InputDevice inputDevice)
    {
        if(inputDevice.MenuWasPressed)
        {
            Join ();
        }

        if (playerJoined)
        {
            if(!playerReady)
            {
                if(inputDevice.Action1)
                {
                    Ready ();
                }
                if(inputDevice.Action2.WasPressed)
                {
                    Leave ();
                }
            } else
            {
                if(inputDevice.Action2.WasPressed)
                {
                    Unready ();
                }
            }
        }
    }
Exemplo n.º 16
0
        public SpaceShip(PlayerIndex playerNumber, Vector2 position, float rotation, SpriteSheet spriteSheet, ProjectileSystem projectileSystem, GameSettings settings, ContentManager content)
        {
            // instantiate the player's number with a player index
            m_playerNumber = playerNumber;
                 if(m_playerNumber == PlayerIndex.One)   { m_colour = SpaceShipColour.Red; }
            else if(m_playerNumber == PlayerIndex.Two)   { m_colour = SpaceShipColour.Blue; }
            else if(m_playerNumber == PlayerIndex.Three) { m_colour = SpaceShipColour.Green; }
            else if(m_playerNumber == PlayerIndex.Four)  { m_colour = SpaceShipColour.Yellow; }

            // instantiate the player's input device type
            m_inputDevice = settings.getInputDevice(playerNumber);
                 if(m_inputDevice == InputDevice.Controller1) { m_controllerNumber = PlayerIndex.One; }
            else if(m_inputDevice == InputDevice.Controller2) { m_controllerNumber = PlayerIndex.Two; }
            else if(m_inputDevice == InputDevice.Controller3) { m_controllerNumber = PlayerIndex.Three; }
            else if(m_inputDevice == InputDevice.Controller4) { m_controllerNumber = PlayerIndex.Four; }
            else											  { m_controllerNumber = PlayerIndex.One; }

            // instantiate local variables
            this.position = position;
            this.rotation = rotation;
            m_scale = new Vector2(1, 1);

            m_maximumVelocity = 5.8f;
            m_acceleration = 0.048f;
            m_rotationSpeed = 3.1f;

            m_settings = settings;
            m_spriteSheet = spriteSheet;
            m_projectileSystem = projectileSystem;

            if(m_spriteSheet == null) { return; }

            // initialize sprite / sprite animation arrays
            m_idleSprite = new Sprite[3];
            m_movingAnimation = new SpriteAnimation[3];

            // set the space ship sprite sheet offset based on the space ship colour
            int spriteOffset = 0;
                 if(m_colour == SpaceShipColour.Red)    { spriteOffset = 0; }
            else if(m_colour == SpaceShipColour.Blue)   { spriteOffset = 18; }
            else if(m_colour == SpaceShipColour.Green)  { spriteOffset = 3; }
            else if(m_colour == SpaceShipColour.Yellow) { spriteOffset = 21; }

            // load the idle sprites for each colour
            for(int i=0;i<3;i++) {
                m_idleSprite[i] = m_spriteSheet.getSprite(i + spriteOffset);
            }
            // create and store the movement animations for each colour
            for(int i=0;i<3;i++) {
                m_movingAnimation[i] = new SpriteAnimation(0.16f, SpriteAnimationType.Loop);
                m_movingAnimation[i].addSprite(m_spriteSheet.getSprite(i + spriteOffset + 6));
                m_movingAnimation[i].addSprite(m_spriteSheet.getSprite(i + spriteOffset + 12));
            }

            m_offset = new Vector2(m_idleSprite[1].xOffset * 0.9f, m_idleSprite[1].yOffset * 0.9f);
            m_size = new Vector2(m_offset.X * 2.0f, m_offset.Y * 2.0f);

            updateInitialValues();
        }
Exemplo n.º 17
0
 public Player(int index, int playerInputLayer, InputDevice inputDevice)
 {
     m_playerIndex = index;
     m_playerInputLayer = playerInputLayer;
     m_money = 500;
     m_health = 3;
     m_device = inputDevice;
 }
Exemplo n.º 18
0
    public void BindPlayer(int index, InputDevice device)
    {
        isPlayerBound = true;

        PlayerIndex = index;
        playerDevice = device;
        fighter.SetHuman (true);
    }
Exemplo n.º 19
0
 public Player(int num, InputDevice d)
 {
     playerNum = num;
     device = d;
     ResetElementStats(Element.EARTH);
     ResetElementStats(Element.FIRE);
     ResetElementStats(Element.WATER);
 }
 void OnDeviceDetached( InputDevice inputDevice )
 {
     var player = FindPlayerUsingDevice( inputDevice );
         if (player != null)
         {
             //RemovePlayer( player );
         }
 }
 // Use this for initialization
 void Start()
 {
     if (InputManager.Devices.Count >= playerID)
     {
         iDevice = InputManager.Devices[playerID - 1];
     }
     headOriginPos = head.transform.localPosition;
 }
Exemplo n.º 22
0
    public void Show(InputDevice inputUsed, int monsterChoice)
    {
        this.monsterChoice = monsterChoice;
        ShowMonsterChoice();

        this.inputUsed = inputUsed;
        isInUse = true;
    }
Exemplo n.º 23
0
	public void Init(InputDevice device, UnitColor color){
		base.Init(color);

		attackerActions = new AttackerActions(device);
		motor.Init(attackerActions);
		atk.Init(attackerActions);

	}
Exemplo n.º 24
0
 public bool PlayerJoin(InputDevice inputDevice)
 {
     if (!activeDevices.Contains(inputDevice)) {
         activeDevices.Add(inputDevice);
         return true;
     }
     return false;
 }
Exemplo n.º 25
0
 public Player(InputDevice input, int monsterChoice, string name, Color color)
 {
     kills = 0;
     deaths = 0;
     this.input = input;
     this.monsterChoice = monsterChoice;
     this.name = name;
     this.color = color;
 }
Exemplo n.º 26
0
        public override void OnActive(double elapsed, InputDevice input)
        {
            if (input.IsPressed(Buttons.B))
            {
                TransitionTo(parent);
            }

            base.OnActive(elapsed, input);
        }
Exemplo n.º 27
0
 //For now this is called whenever a device is connected or disconnected.
 //This is because we need to reconnect to the controller we originally connected to.
 public void DeviceUpdate()
 {
     foreach(InputDevice d in InputManager.Devices) {
         if (d.Meta == m_device.Meta) {
             m_device = d;
             return;
         }
     }
 }
    private void Update()
    {
        inputDevice = InputManager.ActiveDevice;

        h = inputDevice.LeftStickX.Value;
        v = inputDevice.LeftStickY.Value;
        orbitH = inputDevice.RightStickX;
        orbitV = inputDevice.RightStickY;
        //print (inputDevice.RightStickX);

        //----------------------------------------------------------------------------------------------------------------------
        // Character Movement
        //----------------------------------------------------------------------------------------------------------------------

        if (inputDevice.LeftStickY.WasPressed)
        {
            onInput(InputEvent.StartRunning);
            onInput(InputEvent.faceOppositeDirection);
        }

        if (inputDevice.LeftStickY.WasReleased)
            onInput(InputEvent.StopRunning);

        //----------------------------------------------------------------------------------------------------------------------
        // Jumping
        //----------------------------------------------------------------------------------------------------------------------

        if (inputDevice.Action4.IsPressed)
            jumpKeyHoldDuration += Time.deltaTime;

        // if pressed Y or pressed Space
        if (inputDevice.Action4.WasReleased)
        {
            onInput(InputEvent.JumpUp);

            // Reset the jump key timer
            jumpKeyHoldDuration = 0.0f;
        }

        //----------------------------------------------------------------------------------------------------------------------
        // Recenter Camera
        //----------------------------------------------------------------------------------------------------------------------

        if (inputDevice.RightBumper.WasReleased)
            onInput(InputEvent.RecenterCam);

        //----------------------------------------------------------------------------------------------------------------------
        // Camera Orbiting
        //----------------------------------------------------------------------------------------------------------------------

        if (inputDevice.RightStickX.IsPressed)
            onInput(InputEvent.OrbitCamera);

        if (inputDevice.RightStickX.WasReleased)
            onInput(InputEvent.CamBehind);
    }
Exemplo n.º 29
0
	void UpdateCubeWithInputDevice(InputDevice device)
	{
		if (device.RightStick.X == 0 && device.RightStick.Y == 0 ) {
			stick.transform.position = player.transform.position;
		} 

		else {
			stick.transform.position = player.transform.position + new Vector3 (device.RightStick.X * 3, device.RightStick.Y * 3, stick.transform.position.z);
			}
	}
Exemplo n.º 30
0
        public override void OnActive(double elapsed, InputDevice input)
        {
            if (input.IsPressed(Buttons.Start) || input.IsPressed(Buttons.B))
                TransitionTo(parent);

            if (input.IsPressed(Buttons.A) && curr_option == 3)
                Application.GetInstance().Exit();

            base.OnActive(elapsed, input);
        }
Exemplo n.º 31
0
 private bool ThereIsNoPlayerUsingJoystick(InputDevice inputDevice)
 {
     return(FindPlayerUsingJoystick(inputDevice) == null);
 }
Exemplo n.º 32
0
 private void GetRightDevice()
 {
     InputDevices.GetDevicesAtXRNode(rightHand, devicesRight);
     DeviceRight = devicesRight.FirstOrDefault();
 }
Exemplo n.º 33
0
 public RemoteControlEventArgs()
 {
     _rcb    = RemoteControlButton.Unknown;
     _device = InputDevice.Key;
 }
Exemplo n.º 34
0
            public TraceEffect(Grid parent, double radius, Point center, Vector direction, double minLength, int i)
            {
                Index           = i;
                Center          = center;
                Radius          = radius;
                Direction       = direction;
                MainBall.Height = MainBall.Width = radius * 2;
                MainBall.Margin = new Thickness {
                    Left = center.X - radius, Top = center.Y - radius
                };
                InputDevice d    = null;
                var         ball = new Ellipse {
                    Fill   = Brushes.pending,
                    Width  = radius,
                    Height = radius,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment   = VerticalAlignment.Top,
                };
                var line = new Line {
                    Stroke = Brushes.pending,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment   = VerticalAlignment.Top,
                    IsHitTestVisible    = false
                };
                Action <Point> moveTo = newTo => {
                    ball.Margin = new Thickness {
                        Left = newTo.X - ball.Width / 2, Top = newTo.Y - ball.Width / 2
                    };
                    line.X2 = newTo.X;
                    line.Y2 = newTo.Y;
                };
                EventHandler <TouchEventArgs> start = (s, e) => {
                    if (d != null)
                    {
                        return;
                    }
                    d             = e.Device;
                    MainBall.Fill = Brushes.picked;
                    moveTo(e.GetTouchPoint(parent).Position);
                    ReadyToMove?.Invoke(this, EventArgs.Empty);
                };

                MainBall.TouchDown += start;
                ball.TouchDown     += start;
                var to = center + Direction;

                line.X1 = center.X;
                line.Y1 = center.Y;
                moveTo(to);
                ball.Height = Width / 3;
                ball.Width  = Width / 3;
                parent.Children.Add(line);
                parent.Children.Add(MainBall);
                parent.Children.Add(ball);
                moveTo(to);
                Func <TouchEventArgs, bool> tryMove = e => {
                    if (e.Device != d)
                    {
                        return(false);
                    }
                    var newTo = e.GetTouchPoint(parent).Position;
                    Direction = newTo - Center;
                    moveTo(newTo);
                    return(true);
                };

                parent.TouchMove += (s, e) => {
                    if (tryMove(e))
                    {
                        Moving?.Invoke(this, EventArgs.Empty);
                    }
                };
                Func <GradientStopCollection> tempSc = () => {
                    var r  = new Random();
                    var b  = new byte[3];
                    var rr = new List <Color>();
                    for (var ii = 0; ii < 3; ii++)
                    {
                        r.NextBytes(b);
                        rr.Add(Color.FromArgb(255, b[0], b[1], b[2]));
                    }
                    var os = 0;
                    return(new GradientStopCollection(rr.Select(rrrr => new GradientStop {
                        Color = rrrr,
                        Offset = os++ / 2.0
                    })));
                };

                parent.TouchLeave += (s, e) => {
                    if (!tryMove(e))
                    {
                        return;
                    }
                    d        = null;
                    Released = true;
                    if (Direction.Length < minLength)
                    {
                        Direction = new Vector();
                        moveTo(center);
                    }
                    else
                    {
                        var sc = tempSc();
                        ball.Fill = MainBall.Fill = new RadialGradientBrush(sc);
                        line.Fill = new LinearGradientBrush(sc);
                    }
                    Moved?.Invoke(this, EventArgs.Empty);
                };
            }
Exemplo n.º 35
0
 private bool deviceIsController(InputDevice device)
 {
     return(!device.Name.Equals("None", StringComparison.InvariantCulture));
 }
        /// <inheritdoc />
        protected override void UpdateButtonData(MixedRealityInteractionMapping interactionMapping, InputDevice inputDevice)
        {
            using (UpdateButtonDataPerfMarker.Auto())
            {
                Debug.Assert(interactionMapping.AxisType == AxisType.Digital);

                InputFeatureUsage <bool> buttonUsage;

                // These mappings are flipped from the base class,
                // where thumbstick is primary and touchpad is secondary.
                switch (interactionMapping.InputType)
                {
                case DeviceInputType.TouchpadTouch:
                    buttonUsage = CommonUsages.primary2DAxisTouch;
                    break;

                case DeviceInputType.TouchpadPress:
                    buttonUsage = CommonUsages.primary2DAxisClick;
                    break;

                case DeviceInputType.ThumbStickPress:
                    buttonUsage = CommonUsages.secondary2DAxisClick;
                    break;

                default:
                    base.UpdateButtonData(interactionMapping, inputDevice);
                    return;
                }

                if (inputDevice.TryGetFeatureValue(buttonUsage, out bool buttonPressed))
                {
                    interactionMapping.BoolData = buttonPressed;
                }

                // If our value changed raise it.
                if (interactionMapping.Changed)
                {
                    // Raise input system event if it's enabled
                    if (interactionMapping.BoolData)
                    {
                        CoreServices.InputSystem?.RaiseOnInputDown(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction);
                    }
                    else
                    {
                        CoreServices.InputSystem?.RaiseOnInputUp(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction);
                    }
                }
            }
        }
        /// <summary>
        /// Gets or adds a controller using the InputDevice name provided.
        /// </summary>
        /// <param name="inputDevice">The InputDevice from XR SDK.</param>
        /// <returns>The controller reference.</returns>
        protected virtual GenericXRSDKController GetOrAddController(InputDevice inputDevice)
        {
            using (GetOrAddControllerPerfMarker.Auto())
            {
                // If a device is already registered with the ID provided, just return it.
                if (ActiveControllers.ContainsKey(inputDevice))
                {
                    var controller = ActiveControllers[inputDevice];
                    Debug.Assert(controller != null);
                    return(controller);
                }

                Handedness controllingHand;

                if (inputDevice.characteristics.IsMaskSet(InputDeviceCharacteristics.Left))
                {
                    controllingHand = Handedness.Left;
                }
                else if (inputDevice.characteristics.IsMaskSet(InputDeviceCharacteristics.Right))
                {
                    controllingHand = Handedness.Right;
                }
                else
                {
                    controllingHand = Handedness.None;
                }

                SupportedControllerType currentControllerType = GetCurrentControllerType(inputDevice);
                Type controllerType = GetControllerType(currentControllerType);

                if (controllerType == null)
                {
                    return(null);
                }

                InputSourceType inputSourceType = GetInputSourceType(currentControllerType);

                IMixedRealityPointer[]   pointers           = RequestPointers(currentControllerType, controllingHand);
                IMixedRealityInputSource inputSource        = Service?.RequestNewGenericInputSource($"{currentControllerType} Controller {controllingHand}", pointers, inputSourceType);
                GenericXRSDKController   detectedController = Activator.CreateInstance(controllerType, TrackingState.NotTracked, controllingHand, inputSource, null) as GenericXRSDKController;

                if (detectedController == null || !detectedController.Enabled)
                {
                    // Controller failed to be set up correctly.
                    Debug.LogError($"Failed to create {controllerType.Name} controller");

                    // Return null so we don't raise the source detected.
                    return(null);
                }

                for (int i = 0; i < detectedController.InputSource?.Pointers?.Length; i++)
                {
                    detectedController.InputSource.Pointers[i].Controller = detectedController;
                }

                ActiveControllers.Add(inputDevice, detectedController);

                Service?.RaiseSourceDetected(detectedController.InputSource, detectedController);

                return(detectedController);
            }
        }
    // Update is called once per frame
    void Update()
    {
        InputDevice device = InputDevices.GetDeviceAtXRNode(inputSource);

        device.TryGetFeatureValue(CommonUsages.primary2DAxis, out inputAxis);
    }
Exemplo n.º 39
0
        void OnGUI()
        {
            switch (inputDevice)
            {
            case InputDevice.MouseKeyboard:
                if (isJoystickInput())
                {
                    inputDevice = InputDevice.Joystick;

                    if (hud != null)
                    {
                        hud.controllerInput = true;
                        hud.ShowText("Control scheme changed to Controller", 2f, 0.5f);
                    }
                }
                else if (isMobileInput())
                {
                    inputDevice = InputDevice.Mobile;
                    if (hud != null)
                    {
                        hud.controllerInput = true;
                        hud.ShowText("Control scheme changed to Mobile", 2f, 0.5f);
                    }
                }
                break;

            case InputDevice.Joystick:
                if (isMouseKeyboard())
                {
                    inputDevice = InputDevice.MouseKeyboard;
                    if (hud != null)
                    {
                        hud.controllerInput = false;
                        hud.ShowText("Control scheme changed to Keyboard/Mouse", 2f, 0.5f);
                    }
                }
                else if (isMobileInput())
                {
                    inputDevice = InputDevice.Mobile;
                    if (hud != null)
                    {
                        hud.controllerInput = true;
                        hud.ShowText("Control scheme changed to Mobile", 2f, 0.5f);
                    }
                }
                break;

            case InputDevice.Mobile:
                if (isMouseKeyboard())
                {
                    inputDevice = InputDevice.MouseKeyboard;
                    if (hud != null)
                    {
                        hud.controllerInput = false;
                        hud.ShowText("Control scheme changed to Keyboard/Mouse", 2f, 0.5f);
                    }
                }
                else if (isJoystickInput())
                {
                    inputDevice = InputDevice.Joystick;
                    if (hud != null)
                    {
                        hud.controllerInput = true;
                        hud.ShowText("Control scheme changed to Controller", 2f, 0.5f);
                    }
                }
                break;
            }
        }
Exemplo n.º 40
0
    private void ConnectInterfaces(object obj, InputDevice device = null)
    {
        var mainMenu = obj as IMainMenu;

        if (device != null)
        {
            var ray = obj as IRay;
            if (ray != null)
            {
                foreach (var proxy in m_AllProxies)
                {
                    if (!proxy.active)
                    {
                        continue;
                    }

                    var node = GetDeviceNode(device);
                    if (node.HasValue)
                    {
                        bool continueSearching = true;

                        Transform rayOrigin;
                        if (proxy.rayOrigins.TryGetValue(node.Value, out rayOrigin))
                        {
                            ray.rayOrigin = rayOrigin;

                            // Specific proxy ray setting
                            DefaultProxyRay dpr       = null;
                            var             customRay = obj as ICustomRay;
                            if (customRay != null)
                            {
                                dpr = rayOrigin.GetComponentInChildren <DefaultProxyRay>();
                                customRay.showDefaultRay = dpr.Show;
                                customRay.hideDefaultRay = dpr.Hide;
                            }

                            var lockableRay = obj as ILockRay;
                            if (lockableRay != null)
                            {
                                dpr = dpr ?? rayOrigin.GetComponentInChildren <DefaultProxyRay>();
                                lockableRay.lockRay   = dpr.LockRay;
                                lockableRay.unlockRay = dpr.UnlockRay;
                            }

                            continueSearching = false;
                        }

                        if (mainMenu != null)
                        {
                            Transform mainMenuOrigin;
                            if (proxy.menuOrigins.TryGetValue(node.Value, out mainMenuOrigin))
                            {
                                mainMenu.menuOrigin = mainMenuOrigin;
                                Transform alternateMenuOrigin;
                                if (proxy.alternateMenuOrigins.TryGetValue(node.Value, out alternateMenuOrigin))
                                {
                                    mainMenu.alternateMenuOrigin = alternateMenuOrigin;
                                }
                            }
                        }

                        if (!continueSearching)
                        {
                            break;
                        }
                    }
                }
            }
        }

        var locomotion = obj as ILocomotion;

        if (locomotion != null)
        {
            locomotion.viewerPivot = VRView.viewerPivot;
        }

        var instantiateUI = obj as IInstantiateUI;

        if (instantiateUI != null)
        {
            instantiateUI.instantiateUI = InstantiateUI;
        }

        var raycaster = obj as IRaycaster;

        if (raycaster != null)
        {
            raycaster.getFirstGameObject = GetFirstGameObject;
        }

        var highlight = obj as IHighlight;

        if (highlight != null)
        {
            highlight.setHighlight = m_HighlightModule.SetHighlight;
        }

        var placeObjects = obj as IPlaceObjects;

        if (placeObjects != null)
        {
            placeObjects.placeObject = PlaceObject;
        }

        var positionPreview = obj as IPositionPreview;

        if (positionPreview != null)
        {
            positionPreview.positionPreview = m_ObjectPlacementModule.PositionPreview;
            positionPreview.getPreviewOriginForRayOrigin = GetPreviewOriginForRayOrigin;
        }

        var selectionChanged = obj as ISelectionChanged;

        if (selectionChanged != null)
        {
            m_SelectionChanged += selectionChanged.OnSelectionChanged;
        }

        if (mainMenu != null)
        {
            mainMenu.menuTools       = m_AllTools.ToList();
            mainMenu.selectTool      = SelectTool;
            mainMenu.menuWorkspaces  = m_AllWorkspaceTypes.ToList();
            mainMenu.createWorkspace = CreateWorkspace;
            mainMenu.node            = GetDeviceNode(device);
            mainMenu.setup();
        }
    }
Exemplo n.º 41
0
        private static GamePadCapabilities CapabilitiesOfDevice(InputDevice device)
        {
            //TODO: There is probably a better way to do this. Maybe device.GetMotionRange and device.GetKeyCharacterMap?
            //Or not http://stackoverflow.com/questions/11686703/android-enumerating-the-buttons-on-a-gamepad

            var capabilities = new GamePadCapabilities();

            capabilities.IsConnected           = true;
            capabilities.GamePadType           = GamePadType.GamePad;
            capabilities.HasLeftVibrationMotor = capabilities.HasRightVibrationMotor = device.Vibrator.HasVibrator;

            switch (device.Name)
            {
            case "OUYA Game Controller":

                capabilities.HasAButton = true;
                capabilities.HasBButton = true;
                capabilities.HasXButton = true;
                capabilities.HasYButton = true;

                capabilities.HasLeftXThumbStick  = true;
                capabilities.HasLeftYThumbStick  = true;
                capabilities.HasRightXThumbStick = true;
                capabilities.HasRightYThumbStick = true;

                capabilities.HasLeftShoulderButton  = true;
                capabilities.HasRightShoulderButton = true;
                capabilities.HasLeftTrigger         = true;
                capabilities.HasRightTrigger        = true;

                capabilities.HasDPadDownButton  = true;
                capabilities.HasDPadLeftButton  = true;
                capabilities.HasDPadRightButton = true;
                capabilities.HasDPadUpButton    = true;
                break;

            case "Microsoft X-Box 360 pad":
                capabilities.HasAButton = true;
                capabilities.HasBButton = true;
                capabilities.HasXButton = true;
                capabilities.HasYButton = true;

                capabilities.HasLeftXThumbStick  = true;
                capabilities.HasLeftYThumbStick  = true;
                capabilities.HasRightXThumbStick = true;
                capabilities.HasRightYThumbStick = true;

                capabilities.HasLeftShoulderButton  = true;
                capabilities.HasRightShoulderButton = true;
                capabilities.HasLeftTrigger         = true;
                capabilities.HasRightTrigger        = true;

                capabilities.HasDPadDownButton  = true;
                capabilities.HasDPadLeftButton  = true;
                capabilities.HasDPadRightButton = true;
                capabilities.HasDPadUpButton    = true;

                capabilities.HasStartButton = true;
                capabilities.HasBackButton  = true;
                break;
            }
            return(capabilities);
        }
        /// <summary>
        /// Update spatial pointer and spatial grip data.
        /// </summary>
        protected override void UpdatePoseData(MixedRealityInteractionMapping interactionMapping, InputDevice inputDevice)
        {
            using (UpdatePoseDataPerfMarker.Auto())
            {
                Debug.Assert(interactionMapping.AxisType == AxisType.SixDof);

                // Update the interaction data source
                switch (interactionMapping.InputType)
                {
                case DeviceInputType.SpatialPointer:
                    if (inputDevice.TryGetFeatureValue(CustomUsages.PointerPosition, out currentPointerPosition))
                    {
                        currentPointerPose.Position = MixedRealityPlayspace.TransformPoint(currentPointerPosition);
                    }

                    if (inputDevice.TryGetFeatureValue(CustomUsages.PointerRotation, out currentPointerRotation))
                    {
                        currentPointerPose.Rotation = MixedRealityPlayspace.Rotation * currentPointerRotation;
                    }

                    interactionMapping.PoseData = currentPointerPose;

                    // If our value changed raise it.
                    if (interactionMapping.Changed)
                    {
                        // Raise input system event if it's enabled
                        CoreServices.InputSystem?.RaisePoseInputChanged(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, interactionMapping.PoseData);
                    }
                    break;

                default:
                    base.UpdatePoseData(interactionMapping, inputDevice);
                    break;
                }
            }
        }
Exemplo n.º 43
0
 public void SetDrivers(InputDevice device, InputFeatureUsage <Vector3> angularVelocityUsage)
 {
     m_Device = device;
     m_AngularVelocityUsage = angularVelocityUsage;
 }
 /// <summary>
 /// Gets the current controller type for the InputDevice name provided.
 /// </summary>
 /// <param name="inputDevice">The InputDevice from XR SDK.</param>
 /// <returns>The supported controller type.</returns>
 protected virtual SupportedControllerType GetCurrentControllerType(InputDevice inputDevice)
 {
     Debug.Log($"{inputDevice.name} does not have a defined controller type, falling back to generic controller type");
     return(SupportedControllerType.GenericUnity);
 }
Exemplo n.º 45
0
    public void Devices_SupportXboxControllerOnWindows()
    {
        var description = new InputDeviceDescription
        {
            interfaceName = "XInput",
        };

        InputDevice device = null;

        Assert.That(() => device = InputSystem.AddDevice(description), Throws.Nothing);
        var gamepad = (XInputController)device;

        Assert.That(gamepad.name, Is.EqualTo("XInputControllerWindows"));

        // Test right and down and that the layouts get inversion correct
        InputSystem.QueueStateEvent(gamepad,
                                    new XINPUT_GAMEPADState
        {
            triggerLeft  = 255,
            triggerRight = 255,
            leftX        = 32767,
            leftY        = -32767,
            rightX       = 32767,
            rightY       = -32767,
        });

        InputSystem.Update();
        Assert.That(gamepad.leftTrigger.ReadValue(), Is.EqualTo(0.9999).Within(0.001));
        Assert.That(gamepad.rightTrigger.ReadValue(), Is.EqualTo(0.9999).Within(0.001));
        Assert.That(gamepad.leftStick.x.ReadValue(), Is.EqualTo(0.9999).Within(0.001));
        Assert.That(gamepad.leftStick.y.ReadValue(), Is.EqualTo(-0.9999).Within(0.001));
        Assert.That(gamepad.rightStick.x.ReadValue(), Is.EqualTo(0.9999).Within(0.001));
        Assert.That(gamepad.rightStick.y.ReadValue(), Is.EqualTo(-0.9999).Within(0.001));

        // Test left and up and that the layouts get inversion correct
        InputSystem.QueueStateEvent(gamepad,
                                    new XINPUT_GAMEPADState
        {
            triggerLeft  = 255,
            triggerRight = 255,
            leftX        = -32767,
            leftY        = 32767,
            rightX       = -32767,
            rightY       = 32767,
        });

        InputSystem.Update();

        Assert.That(gamepad.leftTrigger.ReadValue(), Is.EqualTo(0.9999).Within(0.001));
        Assert.That(gamepad.rightTrigger.ReadValue(), Is.EqualTo(0.9999).Within(0.001));
        Assert.That(gamepad.leftStick.y.ReadValue(), Is.EqualTo(0.9999).Within(0.001));
        Assert.That(gamepad.leftStick.x.ReadValue(), Is.EqualTo(-0.9999).Within(0.001));
        Assert.That(gamepad.leftStick.y.ReadValue(), Is.EqualTo(0.9999).Within(0.001));
        Assert.That(gamepad.rightStick.x.ReadValue(), Is.EqualTo(-0.9999).Within(0.001));
        Assert.That(gamepad.rightStick.y.ReadValue(), Is.EqualTo(0.9999).Within(0.001));

        AssertButtonPress(gamepad, new XINPUT_GAMEPADState {
            buttons = 1
        }, gamepad.dpad.up);
        AssertButtonPress(gamepad, new XINPUT_GAMEPADState {
            buttons = 2
        }, gamepad.dpad.down);
        AssertButtonPress(gamepad, new XINPUT_GAMEPADState {
            buttons = 4
        }, gamepad.dpad.left);
        AssertButtonPress(gamepad, new XINPUT_GAMEPADState {
            buttons = 8
        }, gamepad.dpad.right);
        AssertButtonPress(gamepad, new XINPUT_GAMEPADState {
            buttons = 16
        }, gamepad.startButton);
        AssertButtonPress(gamepad, new XINPUT_GAMEPADState {
            buttons = 32
        }, gamepad.selectButton);
        AssertButtonPress(gamepad, new XINPUT_GAMEPADState {
            buttons = 64
        }, gamepad.leftStickButton);
        AssertButtonPress(gamepad, new XINPUT_GAMEPADState {
            buttons = 128
        }, gamepad.rightStickButton);
        AssertButtonPress(gamepad, new XINPUT_GAMEPADState {
            buttons = 256
        }, gamepad.leftShoulder);
        AssertButtonPress(gamepad, new XINPUT_GAMEPADState {
            buttons = 512
        }, gamepad.rightShoulder);
        AssertButtonPress(gamepad, new XINPUT_GAMEPADState {
            buttons = 4096
        }, gamepad.buttonSouth);
        AssertButtonPress(gamepad, new XINPUT_GAMEPADState {
            buttons = 8192
        }, gamepad.buttonEast);
        AssertButtonPress(gamepad, new XINPUT_GAMEPADState {
            buttons = 16384
        }, gamepad.buttonWest);
    }
Exemplo n.º 46
0
 bool ThereIsNoPlayerUsingDevice(InputDevice inputDevice)
 {
     return(FindPlayerUsingDevice(inputDevice) == null);
 }
Exemplo n.º 47
0
 void Awake()
 {
     device = InputManager.Devices[player_num];
 }
Exemplo n.º 48
0
    public static float PlayVibration(string situationName, InputDevice device)
    {
        float duration = 0f;

        switch (situationName)
        {
        case "HookDestruction":
            device.Vibrate(balanceData.mediumRumble, 0f);
            duration = balanceData.mediumVibrationDuration;
            return(duration);

        case "RopeCut":
            device.Vibrate(balanceData.mediumRumble, 0f);
            duration = balanceData.shortVibrationDuration;
            return(duration);

        case "Dash":
            device.Vibrate(0f, balanceData.mediumVibration);
            duration = balanceData.shortVibrationDuration;
            return(duration);

        // TO DEBUG
        case "Death":
            CameraShaker.Instance.ShakeOnce(balanceData.heavyMagnitude, balanceData.roughness, balanceData.fadeIn, balanceData.fadeOut * 3f);
            device.Vibrate(balanceData.heavyVibration);
            duration = balanceData.longVibrationDuration;
            return(duration);

        // Works for both player to player collision and player to platform collision
        case "CollisionPlayerPlayer":
            device.Vibrate(0f, balanceData.lightVibration);
            duration = balanceData.shortVibrationDuration;
            return(duration);

        case "CollisionArrowPlayer":
            CameraShaker.Instance.ShakeOnce(balanceData.lightMagnitude, balanceData.roughness, balanceData.fadeIn, balanceData.fadeOut);
            device.Vibrate(0f, balanceData.mediumLightVibration);
            duration = balanceData.mediumVibrationDuration;
            return(duration);

        case "KillingPlayer":
            device.Vibrate(balanceData.lightRumble, balanceData.heavyVibration);
            duration = balanceData.mediumVibration;
            return(duration);

        case "CollisionArrowShield":
            device.Vibrate(balanceData.mediumlightRumble, 0f);
            duration = balanceData.mediumVibrationDuration;
            return(duration);

        case "CollisionArrowArrow":
            CameraShaker.Instance.ShakeOnce(balanceData.lightMagnitude, balanceData.roughness, balanceData.fadeIn, balanceData.fadeOut);
            device.Vibrate(balanceData.mediumRumble, 0f);
            duration = balanceData.mediumVibrationDuration;
            return(duration);

        case "LaserEdge":
            CameraShaker.Instance.ShakeOnce(balanceData.lightMagnitude, balanceData.roughness, balanceData.fadeIn, balanceData.fadeOut / 2f);
            device.Vibrate(balanceData.mediumRumble, balanceData.mediumVibration);
            duration = balanceData.mediumVibrationDuration;
            return(duration);

        case "HookheadOnPlayer":
            device.Vibrate(0f, balanceData.lightVibration);
            duration = balanceData.mediumVibrationDuration;
            return(duration);

        // TO TEST
        case "HookProjectileDestroyed":
            device.Vibrate(balanceData.lightRumble, 0f);
            duration = balanceData.mediumVibrationDuration;
            return(duration);

        default:
            return(0f);
        }
    }
Exemplo n.º 49
0
        /// <inheritdoc />
        protected override void UpdateButtonData(MixedRealityInteractionMapping interactionMapping, InputDevice inputDevice)
        {
            using (UpdateButtonDataPerfMarker.Auto())
            {
                Debug.Assert(interactionMapping.AxisType == AxisType.Digital);

                // Update the interaction data source
                switch (interactionMapping.InputType)
                {
                case DeviceInputType.Select:
                    if (inputDevice.TryGetFeatureValue(CommonUsages.primaryButton, out bool buttonPressed))
                    {
                        interactionMapping.BoolData = buttonPressed;
                    }
                    break;

                default:
                    base.UpdateButtonData(interactionMapping, inputDevice);
                    return;
                }

                // If our value changed raise it.
                if (interactionMapping.Changed)
                {
                    // Raise input system event if it's enabled
                    if (interactionMapping.BoolData)
                    {
                        CoreServices.InputSystem?.RaiseOnInputDown(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction);
                    }
                    else
                    {
                        CoreServices.InputSystem?.RaiseOnInputUp(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction);
                    }
                }
            }
        }
        /// <inheritdoc />
        protected override void UpdateDualAxisData(MixedRealityInteractionMapping interactionMapping, InputDevice inputDevice)
        {
            using (UpdateDualAxisDataPerfMarker.Auto())
            {
                Debug.Assert(interactionMapping.AxisType == AxisType.DualAxis);

                InputFeatureUsage <Vector2> axisUsage;

                // These mappings are flipped from the base class,
                // where thumbstick is primary and touchpad is secondary.
                switch (interactionMapping.InputType)
                {
                case DeviceInputType.ThumbStick:
                    axisUsage = CommonUsages.secondary2DAxis;
                    break;

                case DeviceInputType.Touchpad:
                    axisUsage = CommonUsages.primary2DAxis;
                    break;

                default:
                    base.UpdateDualAxisData(interactionMapping, inputDevice);
                    return;
                }

                if (inputDevice.TryGetFeatureValue(axisUsage, out Vector2 axisData))
                {
                    // Update the interaction data source
                    interactionMapping.Vector2Data = axisData;
                }

                // If our value changed raise it.
                if (interactionMapping.Changed)
                {
                    // Raise input system event if it's enabled
                    CoreServices.InputSystem?.RaisePositionInputChanged(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, interactionMapping.Vector2Data);
                }
            }
        }
Exemplo n.º 51
0
 bool JoinButtonWasPressedOnDevice(InputDevice inputDevice)
 {
     return(inputDevice.Action1.WasPressed || inputDevice.Action2.WasPressed || inputDevice.Action3.WasPressed || inputDevice.Action4.WasPressed);
 }
Exemplo n.º 52
0
        /// <inheritdoc />
        protected override void UpdateSingleAxisData(MixedRealityInteractionMapping interactionMapping, InputDevice inputDevice)
        {
            using (UpdateSingleAxisDataPerfMarker.Auto())
            {
                Debug.Assert(interactionMapping.AxisType == AxisType.SingleAxis);
                // Update the interaction data source
                switch (interactionMapping.InputType)
                {
                case DeviceInputType.TriggerPress:
                case DeviceInputType.GripPress:
                    if (inputDevice.TryGetFeatureValue(CommonUsages.grip, out float gripAmount))
                    {
                        interactionMapping.BoolData = Mathf.Approximately(gripAmount, 1.0f);
                    }
                    break;

                default:
                    base.UpdateSingleAxisData(interactionMapping, inputDevice);
                    return;
                }

                // If our value changed raise it.
                if (interactionMapping.Changed)
                {
                    // Raise bool input system event if it's available
                    if (interactionMapping.BoolData)
                    {
                        CoreServices.InputSystem?.RaiseOnInputDown(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction);
                    }
                    else
                    {
                        CoreServices.InputSystem?.RaiseOnInputUp(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction);
                    }
                }
            }
        }
        private uint GetControllerId(InputDevice inputDevice)
        {
            var handedness = ((uint)(inputDevice.characteristics.HasFlag(InputDeviceCharacteristics.Right) ? 2 : inputDevice.characteristics.HasFlag(InputDeviceCharacteristics.Left) ? 1 : 0));

            return(GetControllerId(handedness));
        }
Exemplo n.º 54
0
 public UserChange(InputUser user, InputUserChange change, InputDevice device = null)
 {
     this.user   = user;
     this.change = change;
     this.device = device;
 }
Exemplo n.º 55
0
 public void SetupDevice(int playerNum, InputDevice newDevice, Controls newControls)
 {
     pauseMenuUI [playerNum].SetDevice(1, newDevice, newControls);
 }
Exemplo n.º 56
0
        public bool GetState(InputDevice inputDevice)
        {
            var unityDevice = inputDevice as UnityInputDevice;

            return(unityDevice.ReadRawButtonState(ButtonIndex));
        }
Exemplo n.º 57
0
 public RemoteControlEventArgs(RemoteControlButton rcb, InputDevice device)
 {
     _rcb    = rcb;
     _device = device;
 }
Exemplo n.º 58
0
 public float GetValue(InputDevice inputDevice)
 {
     return(GetState(inputDevice) ? 1.0f : 0.0f);
 }
Exemplo n.º 59
0
    public static bool IsPressed(this InputDevice device, Button button, out bool isPressed, float pressThreshold = -1.0f)
    {
        if ((int)button >= s_ButtonData.Length)
        {
            throw new ArgumentException("[InputHelpers.IsPressed] The value of <button> is out or the supported range.");
        }

        if (!device.isValid)
        {
            isPressed = false;
            return(false);
        }

        ButtonInfo info = s_ButtonData[(int)button];

        switch (info.type)
        {
        case ButtonReadType.Binary:
        {
            if (device.TryGetFeatureValue(new InputFeatureUsage <bool>(info.name), out bool value))
            {
                isPressed = value;
                return(true);
            }
        }
        break;

        case ButtonReadType.Axis1D:
        {
            if (device.TryGetFeatureValue(new InputFeatureUsage <float>(info.name), out float value))
            {
                float threshold = (pressThreshold >= 0.0f) ? pressThreshold : s_DefaultPressThreshold;
                isPressed = value >= threshold;
                return(true);
            }
        }
        break;

        case ButtonReadType.Axis2DUp:
        {
            if (device.TryGetFeatureValue(new InputFeatureUsage <Vector2>(info.name), out Vector2 value))
            {
                float threshold = (pressThreshold >= 0.0f) ? pressThreshold : s_DefaultPressThreshold;
                isPressed = value.y >= threshold;
                return(true);
            }
        }
        break;

        case ButtonReadType.Axis2DDown:
        {
            if (device.TryGetFeatureValue(new InputFeatureUsage <Vector2>(info.name), out Vector2 value))
            {
                float threshold = (pressThreshold >= 0.0f) ? pressThreshold : s_DefaultPressThreshold;
                isPressed = value.y <= -threshold;
                return(true);
            }
        }
        break;

        case ButtonReadType.Axis2DLeft:
        {
            if (device.TryGetFeatureValue(new InputFeatureUsage <Vector2>(info.name), out Vector2 value))
            {
                float threshold = (pressThreshold >= 0.0f) ? pressThreshold : s_DefaultPressThreshold;
                isPressed = value.x <= -threshold;
                return(true);
            }
        }
        break;

        case ButtonReadType.Axis2DRight:
        {
            if (device.TryGetFeatureValue(new InputFeatureUsage <Vector2>(info.name), out Vector2 value))
            {
                float threshold = (pressThreshold >= 0.0f) ? pressThreshold : s_DefaultPressThreshold;
                isPressed = value.x >= threshold;
                return(true);
            }
        }
        break;

        default:
            break;
        }
        isPressed = false;
        return(false);
    }
Exemplo n.º 60
0
 private void checkActiveDeviceController(InputDevice device)
 {
     //_inputModule.allowMouseInput = !deviceIsController(InputManager.ActiveDevice);
 }