本文整理汇总了C#中JoystickState.GetPointOfViewControllers方法的典型用法代码示例。如果您正苦于以下问题:C# JoystickState.GetPointOfViewControllers方法的具体用法?C# JoystickState.GetPointOfViewControllers怎么用?C# JoystickState.GetPointOfViewControllers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JoystickState
的用法示例。
在下文中一共展示了JoystickState.GetPointOfViewControllers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetValue
public double GetValue(JoystickState joystickState, int povIndex)
{
// Position is quantized degrees from North quantized to the four cardinal directions.
int position = joystickState.GetPointOfViewControllers()[povIndex];
foreach(Range range in _directionRanges) {
if(range.Contains(position)) {
return range.Value / 100d;
}
}
return -1;
}
示例2: 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])
{
//.........这里部分代码省略.........
示例3: GamePadState
//.........这里部分代码省略.........
{
this.Slider2 = sliderReaders[1].GetValue(ref joystickState);
}
else
{
this.Slider2 = 0.0f;
}
if (sliderReaders[2] != null)
{
this.VelocitySlider1 = sliderReaders[2].GetValue(ref joystickState);
}
else
{
this.VelocitySlider1 = 0.0f;
}
if (sliderReaders[3] != null)
{
this.VelocitySlider2 = sliderReaders[3].GetValue(ref joystickState);
}
else
{
this.VelocitySlider2 = 0.0f;
}
if (sliderReaders[4] != null)
{
this.AccelerationSlider1 = sliderReaders[4].GetValue(ref joystickState);
}
else
{
this.AccelerationSlider1 = 0.0f;
}
if (sliderReaders[5] != null)
{
this.AccelerationSlider2 = sliderReaders[5].GetValue(ref joystickState);
}
else
{
this.AccelerationSlider2 = 0.0f;
}
if (sliderReaders[6] != null)
{
this.ForceSlider1 = sliderReaders[6].GetValue(ref joystickState);
}
else
{
this.ForceSlider1 = 0.0f;
}
if (sliderReaders[7] != null)
{
this.ForceSlider2 = sliderReaders[7].GetValue(ref joystickState);
}
else
{
this.ForceSlider2 = 0.0f;
}
}
// Take over the joystick's Point-of-View controllers
{
this.PovCount = converter.PovCount;
int[] povs = null;
if (this.PovCount >= 1)
{
povs = joystickState.GetPointOfViewControllers();
this.Pov1 = povs[0];
}
else
{
this.Pov1 = -1;
}
if (this.PovCount >= 2)
{
this.Pov2 = povs[1];
}
else
{
this.Pov2 = -1;
}
if (this.PovCount >= 3)
{
this.Pov3 = povs[2];
}
else
{
this.Pov3 = -1;
}
if (this.PovCount >= 4)
{
this.Pov4 = povs[3];
}
else
{
this.Pov4 = -1;
}
}
}
示例4: GetValue
public double GetValue(JoystickState joystickState, int povIndex)
{
// Position is degrees from North.
return joystickState.GetPointOfViewControllers()[povIndex] / 100d;
}