コード例 #1
0
        /// <summary>
        /// Raises the thumbstick changed event.
        /// </summary>
        /// <param name="thumbstick">The thumbstick.</param>
        /// <param name="horizontal">The position along the horizontal-axis.</param>
        /// <param name="vertical">The position along the vertical-axis.</param>
        protected virtual void OnThumbstickChanged(LogitechF710Thumbstick thumbstick, long horizontal, long vertical)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException(nameof(LogitechF710));
            }

            ThumbstickChanged?.Invoke(this, new LogitechF710ThumbstickEventArgs(thumbstick, horizontal, vertical));
        }
コード例 #2
0
        private void LogitechF710ThumbstickChanged(object sender, LogitechF710ThumbstickEventArgs e)
        {
            GamepadThumbstick thumbstick;

            switch (e.Thumbstick)
            {
            case LogitechF710Thumbstick.Left:
                thumbstick = GamepadThumbstick.Left;
                break;

            case LogitechF710Thumbstick.Right:
                thumbstick = GamepadThumbstick.Right;
                break;

            default:
                throw new NotSupportedException();
            }

            double horizontal = Math.Min(Math.Max((e.Horizontal - 128L) / 127d, -1d), 1d);
            double vertical   = Math.Min(Math.Max((e.Vertical - 128L) / 127d, -1d), 1d);

            ThumbstickChanged?.Invoke(this, new GamepadThumbstickEventArgs(thumbstick, horizontal, vertical));
        }