本文整理汇总了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;
}
示例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];
}
示例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);
}
}
}
示例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])
{
}
}
}
示例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])
{
//.........这里部分代码省略.........