当前位置: 首页>>代码示例>>C#>>正文


C# JoystickState.Equals方法代码示例

本文整理汇总了C#中JoystickState.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# JoystickState.Equals方法的具体用法?C# JoystickState.Equals怎么用?C# JoystickState.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JoystickState的用法示例。


在下文中一共展示了JoystickState.Equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowDirectInputState

        /// <summary>
        /// Update DirectInput control from DirectInput device.
        /// </summary>
        /// <param name="device">DirectInput device.</param>
        /// <returns>List of buttons/DPad pressed, axis/sliders turned.</returns>
        void ShowDirectInputState(JoystickState state)
        {
            if (state == null || state.Equals(oldState)) return;

            // Fill axis.
            Axis[0] = state.X;
            Axis[1] = state.Y;
            Axis[2] = state.Z;
            Axis[3] = state.RotationX;
            Axis[4] = state.RotationY;
            Axis[5] = state.RotationZ;

            oldState = state;
            //actions.Clear();
            // X-axis.
            DiAxisTable.Rows[0][1] = state.X;
            DiAxisTable.Rows[0][2] = state.RotationX;
            DiAxisTable.Rows[0][3] = state.AccelerationX;
            DiAxisTable.Rows[0][4] = state.AngularAccelerationX;
            DiAxisTable.Rows[0][5] = state.ForceX;
            DiAxisTable.Rows[0][6] = state.TorqueX;
            DiAxisTable.Rows[0][7] = state.VelocityX;
            DiAxisTable.Rows[0][8] = state.AngularVelocityX;
            // Y-axis.
            DiAxisTable.Rows[1][1] = state.Y;
            DiAxisTable.Rows[1][2] = state.RotationY;
            DiAxisTable.Rows[1][3] = state.AccelerationY;
            DiAxisTable.Rows[1][4] = state.AngularAccelerationY;
            DiAxisTable.Rows[1][5] = state.ForceY;
            DiAxisTable.Rows[1][6] = state.TorqueY;
            DiAxisTable.Rows[1][7] = state.VelocityY;
            DiAxisTable.Rows[1][8] = state.AngularVelocityY;
            // Z-axis.
            DiAxisTable.Rows[2][1] = state.Z;
            DiAxisTable.Rows[2][2] = state.RotationZ;
            DiAxisTable.Rows[2][3] = state.AccelerationZ;
            DiAxisTable.Rows[2][4] = state.AngularAccelerationZ;
            DiAxisTable.Rows[2][5] = state.ForceZ;
            DiAxisTable.Rows[2][6] = state.TorqueZ;
            DiAxisTable.Rows[2][7] = state.VelocityZ;
            DiAxisTable.Rows[2][8] = state.AngularVelocityZ;

            var rows = DiAxisTable.Rows;
            var cols = DiAxisTable.Columns;
            int v;
            int axisNum;
            for (int r = 0; r < rows.Count; r++)
            {
                for (int c = 1; c < cols.Count; c++)
                {
                    if (System.DBNull.Value == rows[r][c]) continue;
                    v = (int)rows[r][c];
                    axisNum = (c - 1) * rows.Count + r + 1;
                    //addAction(actions, v, "Axis", axisNum);
                }
            }

            bool[] buttons = state.Buttons;
            DiButtonsTextBox.Text = "";
            if (buttons != null)
            {
                for (int i = 0; i < buttons.Length; i++)
                {
                    if (buttons[i])
                    {
                        //actions.Add(string.Format("Button {0}", i + 1));
                        if (DiButtonsTextBox.Text.Length > 0) DiButtonsTextBox.Text += " ";
                        DiButtonsTextBox.Text += (i + 1).ToString("00");
                    }
                }
            }
            // Sliders
            ProcessSlider(state.Sliders, DiUvSliderTextBox);
            ProcessSlider(state.AccelerationSliders, DiASliderTextBox);
            ProcessSlider(state.ForceSliders, DiFSliderTextBox);
            ProcessSlider(state.VelocitySliders, DiVSliderTextBox);

            // Point of view buttons
            int[] dPad = state.PointOfViewControllers;
            DiDPadTextBox.Text = "";
            if (dPad != null)
            {
                for (int i = 0; i < dPad.Length; i++)
                {
                    v = dPad[i];
                    if (DiDPadTextBox.Text.Length > 0) DiDPadTextBox.Text += " ";
                    if (v != -1)
                    {
                        DiDPadTextBox.Text += "[" + i + "," + v.ToString() + "]";
                        //if ((DPadEnum)v == DPadEnum.Up) actions.Add(string.Format("DPad {0} {1}", i + 1, DPadEnum.Up.ToString()));
                        //if ((DPadEnum)v == DPadEnum.Right) actions.Add(string.Format("DPad {0} {1}", i + 1, DPadEnum.Right.ToString()));
                        //if ((DPadEnum)v == DPadEnum.Down) actions.Add(string.Format("DPad {0} {1}", i + 1, DPadEnum.Down.ToString()));
                        //if ((DPadEnum)v == DPadEnum.Left) actions.Add(string.Format("DPad {0} {1}", i + 1, DPadEnum.Left.ToString()));
                    }
                }
//.........这里部分代码省略.........
开发者ID:suvjunmd,项目名称:x360ce,代码行数:101,代码来源:DirectInputControl.cs


注:本文中的JoystickState.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。