Beispiel #1
0
        public static void ProcessMessage(Synchronizer synchronizer, InputInputMessage message)
        {
            foreach (StoredAxis axis in message.axes)
            {
                axes[synchronizer.relevantAxes[axis.id]] = axis.value;
            }

            var tempButtons = buttonsPressedLastFrame;

            buttonsPressedLastFrame = buttonsPressed;
            buttonsPressed          = tempButtons;

            var tempKeys = keysPressedLastFrame;

            keysPressedLastFrame = keysPressed;
            keysPressed          = tempKeys;

            buttonsPressed.Clear();
            keysPressed.Clear();
            foreach (StoredInput button in message.buttons)
            {
                if (button.inputType == (short)InputType.ButtonDown)
                {
                    buttonsPressed[synchronizer.relevantButtons[button.id]] = true;
                }
                else
                {
                    keysPressed[synchronizer.relevantKeys[button.id]] = true;
                }
            }
        }
Beispiel #2
0
        public static void BuildMessage(Synchronizer synchronizer, InputInputMessage message)
        {
            for (int i = 0; i < synchronizer.relevantAxes.Length; i++)
            {
                StoredAxis storedAxis = new StoredAxis();
                storedAxis.id    = i;
                storedAxis.value = Input.GetAxis(synchronizer.relevantAxes[i]);
                message.axes.Add(storedAxis);
            }

            for (int i = 0; i < synchronizer.relevantButtons.Length; i++)
            {
                if (Input.GetButton(synchronizer.relevantButtons[i]))
                {
                    StoredInput storedInput = new StoredInput();
                    storedInput.id        = i;
                    storedInput.inputType = (short)InputType.ButtonDown;
                    message.buttons.Add(storedInput);
                }
            }

            for (int i = 0; i < synchronizer.relevantKeys.Length; i++)
            {
                if (isKeyPressed(synchronizer, synchronizer.relevantKeys[i]))
                {
                    StoredInput storedInput = new StoredInput();
                    storedInput.id        = i;
                    storedInput.inputType = (short)InputType.KeyDown;
                    message.buttons.Add(storedInput);
                }
            }

            ProcessMessage(synchronizer, message);
        }
Beispiel #3
0
        public static void BuildMessage(Synchronizer synchronizer, InputInputMessage message)
        {
            for (int i = 0; i < synchronizer.relevantAxes.Length; i++)
            {
                StoredAxis storedAxis = new StoredAxis();
                storedAxis.id = i;
                if (synchronizer.relevantAxes [i] == "flystick horizontal")
                {
                    storedAxis.value = synchronizer.flyStick.GetComponent <TrackerSettings> ().getAnalog().x;
                }
                else if (synchronizer.relevantAxes[i] == "flystick vertical")
                {
                    storedAxis.value = synchronizer.flyStick.GetComponent <TrackerSettings> ().getAnalog().y;
                }
                else
                {
                    storedAxis.value = Input.GetAxis(synchronizer.relevantAxes[i]);
                }
                message.axes.Add(storedAxis);
            }

            for (int i = 0; i < synchronizer.relevantButtons.Length; i++)
            {
                if (Input.GetButton(synchronizer.relevantButtons[i]))
                {
                    StoredInput storedInput = new StoredInput();
                    storedInput.id        = i;
                    storedInput.inputType = (short)InputType.ButtonDown;
                    message.buttons.Add(storedInput);
                }
            }

            for (int i = 0; i < synchronizer.relevantKeys.Length; i++)
            {
                if (isKeyPressed(synchronizer, synchronizer.relevantKeys[i]))
                {
                    StoredInput storedInput = new StoredInput();
                    storedInput.id        = i;
                    storedInput.inputType = (short)InputType.KeyDown;
                    message.buttons.Add(storedInput);
                }
            }

            ProcessMessage(synchronizer, message);
        }