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


C# JoystickState.GetSliders方法代码示例

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


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

示例1: Convert

 /// <summary>Retrieves the current value of the axis</summary>
 /// <param name="gamePadState">Game pad state that will receive the value</param>
 /// <param name="joystickState">State from which the axis is retrieved</param>
 public void Convert(
   FlatGamePadState gamePadState, ref JoystickState joystickState
 ) {
   int slider = joystickState.GetSliders()[this.sliderIndex];
   gamePadState.RightTrigger = (float)(slider - this.min) / this.max;
 }
开发者ID:pr0gramm3r1,项目名称:AngryTanks,代码行数:9,代码来源:GamePadConverter.Converters.cs

示例2: Read

 /// <summary>Reads the raw value from the joystick state</summary>
 /// <param name="state">Joystick state the value is read from</param>
 /// <returns>The raw value of the axis in the joystick state</returns>
 protected virtual int Read(ref JoystickState state)
 {
   return state.GetSliders()[this.Index];
 }
开发者ID:Azzuro,项目名称:IR-Server-Suite,代码行数:7,代码来源:DirectInputConverter.SliderReaders.cs

示例3: ReadImmediateData

        void ReadImmediateData()
        {
            if (joysticks[cj].Acquire().IsFailure)
                return;

            if (joysticks[cj].Poll().IsFailure)
                return;

            state = joysticks[cj].GetCurrentState();
            if (Result.Last.IsFailure)
                return;

            //All we need for now, X, Y, Z-rotation and throttle.
            LXAxis.Text = state.X.ToString(CultureInfo.CurrentCulture);
            LYAxis.Text = state.Y.ToString(CultureInfo.CurrentCulture);
            LZRotation.Text = state.RotationZ.ToString(CultureInfo.CurrentCulture);
            int[] slider = state.GetSliders();
            LThrottle.Text = slider[0].ToString(CultureInfo.CurrentCulture);
            //tell PPM stuff what to do
            if (playing)
            {
                lock (sndplay.channels_lock)
                {
                    int Xval, Yval, Zval = 0;
                    sndplay.PPMchannels[1] = 100-(slider[0]/10);

                    Int32.TryParse(EDeadX.Text, out Xval);
                    Int32.TryParse(EDeadY.Text, out Yval);
                    Int32.TryParse(EDeadZ.Text, out Zval);

                    if ((state.X > 500+Xval) || (state.X < 500-Xval))
                        sndplay.PPMchannels[2] = 100-(state.X/10);
                    if ((state.Y > 500+Yval) || (state.Y < 500-Yval))
                        sndplay.PPMchannels[3] = 100-(state.Y/10);
                    if ((state.RotationZ > 500+Zval) || (state.RotationZ < 500-Zval))
                        sndplay.PPMchannels[4] = 100-(state.RotationZ/10);
                }
            }
        }
开发者ID:kangsterizer,项目名称:Audio_PPM_Win,代码行数:39,代码来源:Form1.cs

示例4: StickHandlingLogic

        void StickHandlingLogic(Joystick stick, int id)
        {
            //Console.WriteLine("here2");
            // Creates an object from the class JoystickState.
            JoystickState state = new JoystickState();

            state = stick.GetCurrentState(); //Gets the state of the joystick
            //Console.WriteLine(state);
            //These are for the thumbstick readings
            yValue = -state.Y;
            xValue = state.X;
            zValue = state.Z;
            rotationZValue = state.RotationZ;
            rotationXValue = state.RotationY;
            rotationYValue = state.RotationX;

            int th = 0;
            int[] z = state.GetSliders();
            th= z[0];
            if (z[0] == 0 && isFirst)
            {
                th = 0;

            }
            else
            {
                if(isFirst) isFirst = false;
                if (th >= 0)
                {
                    th = 50 - th / 2;
                }
                else
                {
                    th = -th / 2 + 50;
                }
            }

            Console.Write("thrust = " + th);

            Console.WriteLine(" x = " + xValue + " y = " + yValue + " z = " + zValue + " rot x = " + rotationXValue + " rot y = " + rotationYValue + " rot Z = " + rotationZValue);

            bool[] buttons = state.GetButtons(); // Stores the number of each button on the gamepad into the bool[] butons.
               // Console.WriteLine("# of button = " + buttons.Length);
            //Here is an example on how to use this for the joystick in the first index of the array list
            if (id == 0)
            {
                // This is when button 0 of the gamepad is pressed, the label will change. Button 0 should be the square button.
                if (buttons[0])
                {

                }

            }
        }
开发者ID:ElliotHYLee,项目名称:JoyStick,代码行数:54,代码来源:Form1.cs

示例5: ComputeInputs

        private void ComputeInputs()
        {
            // Pull from joystick
            if (joystick != null)
            {
                joystick.Poll();
                state = joystick.GetCurrentState();
                pov_state = (POV_HAT_DIR)state.GetPointOfViewControllers()[0];
                button_state = state.GetButtons();
                control_x = state.X;
                control_y = state.Y;
                control_z = state.RotationZ;
                control_throttle = state.GetSliders()[0];
                if (control_x > 0 && control_x < JOYSTICK_XY_DEADBAND) { control_x = 0; }
                if (control_x < 0 && control_x > -JOYSTICK_XY_DEADBAND) { control_x = 0; }
                if (control_y > 0 && control_y < JOYSTICK_XY_DEADBAND) { control_y = 0; }
                if (control_y < 0 && control_y > -JOYSTICK_XY_DEADBAND) { control_y = 0; }
                if (control_z > 0 && control_z < JOYSTICK_Z_DEADBAND) { control_z = 0; }
                if (control_z < 0 && control_z > -JOYSTICK_Z_DEADBAND) { control_z = 0; }
            }
            else
            {
                state = new JoystickState();
                button_state = new bool[] { false, false, false, false };
                control_x = 0;
                control_y = 0;
                pov_state = POV_HAT_DIR.NONE;
            }

            // Turret
            switch (pov_state)
            {
                case POV_HAT_DIR.NW:
                    turret_vert_pwr = TURRET_VERT_SPEED_SLOW;
                    turret_vert_fwd = true;// down
                    turret_horiz_pwr = TURRET_VERT_SPEED_SLOW;
                    turret_horiz_fwd = true;// left
                    break;
                case POV_HAT_DIR.N:
                    turret_vert_pwr = TURRET_VERT_SPEED_MED;
                    turret_vert_fwd = true;// down
                    turret_horiz_pwr = 0;
                    turret_horiz_fwd = false;// right
                    break;
                case POV_HAT_DIR.NE:
                    turret_vert_pwr = TURRET_VERT_SPEED_SLOW;
                    turret_vert_fwd = true;// down
                    turret_horiz_pwr = TURRET_VERT_SPEED_SLOW;
                    turret_horiz_fwd = false;// right
                    break;
                case POV_HAT_DIR.E:
                    turret_vert_pwr = 0;
                    turret_vert_fwd = true;// down
                    turret_horiz_pwr = TURRET_VERT_SPEED_MED;
                    turret_horiz_fwd = false;// right
                    break;
                case POV_HAT_DIR.SE:
                    turret_vert_pwr = TURRET_VERT_SPEED_SLOW;
                    turret_vert_fwd = false;// up
                    turret_horiz_pwr = TURRET_VERT_SPEED_SLOW;
                    turret_horiz_fwd = false;// right
                    break;
                case POV_HAT_DIR.S:
                    turret_vert_pwr = TURRET_VERT_SPEED_MED;
                    turret_vert_fwd = false;// up
                    turret_horiz_pwr = 0;
                    turret_horiz_fwd = false;// right
                    break;
                case POV_HAT_DIR.SW:
                    turret_vert_pwr = TURRET_VERT_SPEED_SLOW;
                    turret_vert_fwd = false;// up
                    turret_horiz_pwr = TURRET_VERT_SPEED_SLOW;
                    turret_horiz_fwd = true;// left
                    break;
                case POV_HAT_DIR.W:
                    turret_vert_pwr = 0;
                    turret_vert_fwd = true;// down
                    turret_horiz_pwr = TURRET_VERT_SPEED_MED;
                    turret_horiz_fwd = true;// left
                    break;

                default:
                    turret_vert_pwr = 0;
                    turret_horiz_pwr = 0;
                    break;
            }

            // Normal weapons
            /*if (button_state[0])
            {
                weapon1_fwd = true;
                weapon1_pwr = 255;
            }
            else
            {
                weapon1_fwd = true;
                weapon1_pwr = 0;
            }
            if (button_state[1])
            {
//.........这里部分代码省略.........
开发者ID:jwalthour,项目名称:wamp,代码行数:101,代码来源:MainWindow.xaml.cs


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