コード例 #1
0
        private void SetupAnalogAxisInput(GCControllerAxisInput axis, string name)
        {
            axis.ValueChangedHandler = (ax, value) =>
            {
                value = AdjustControllerValue(value);

                if (!_lastControllerEventValueMap.ContainsKey(name) || !AreAlmostEqual(_lastControllerEventValueMap[name], value))
                {
                    GameControllerEventInternal?.Invoke(this, new GameControllerEventArgs(GameControllerEventType.Axis, name, value));
                    _lastControllerEventValueMap[name] = value;
                }
            };
        }
コード例 #2
0
        private void SetupDigitalAxisInput(GCControllerAxisInput axis, string name)
        {
            axis.ValueChangedHandler = (ax, value) =>
            {
                if (value < -0.1F)
                {
                    value = -1.0F;
                }
                else if (value > 0.1F)
                {
                    value = 1.0F;
                }
                else
                {
                    value = 0.0F;
                }

                if (!_lastControllerEventValueMap.ContainsKey(name) || !AreAlmostEqual(_lastControllerEventValueMap[name], value))
                {
                    GameControllerEventInternal?.Invoke(this, new GameControllerEventArgs(GameControllerEventType.Axis, name, value));
                    _lastControllerEventValueMap[name] = value;
                }
            };
        }