/// <summary>Creates an axis reader for the specified object</summary> /// <param name="joystick">Joystick providing the control object</param> /// <param name="axis">Axis a reader will be created for</param> /// <param name="control">Control description for the axis</param> /// <returns>A new axis reader for the specified axis</returns> private static IAxisReader createAxisReader( Joystick joystick, ExtendedAxes axis, DeviceObjectInstance control ) { int id = (int)control.ObjectType; ObjectProperties properties = joystick.GetObjectPropertiesById(id); int min = properties.LowerRange; int max = properties.UpperRange; switch (axis) { case ExtendedAxes.X: { return new XAxisReader(min, max); } case ExtendedAxes.Y: { return new YAxisReader(min, max); } case ExtendedAxes.Z: { return new ZAxisReader(min, max); } case ExtendedAxes.VelocityX: { return new VelocityXAxisReader(min, max); } case ExtendedAxes.VelocityY: { return new VelocityYAxisReader(min, max); } case ExtendedAxes.VelocityZ: { return new VelocityZAxisReader(min, max); } case ExtendedAxes.AccelerationX: { return new AccelerationXAxisReader(min, max); } case ExtendedAxes.AccelerationY: { return new AccelerationYAxisReader(min, max); } case ExtendedAxes.AccelerationZ: { return new AccelerationZAxisReader(min, max); } case ExtendedAxes.ForceX: { return new ForceXAxisReader(min, max); } case ExtendedAxes.ForceY: { return new ForceYAxisReader(min, max); } case ExtendedAxes.ForceZ: { return new ForceZAxisReader(min, max); } case ExtendedAxes.RotationX: { return new RotationXAxisReader(min, max); } case ExtendedAxes.RotationY: { return new RotationYAxisReader(min, max); } case ExtendedAxes.RotationZ: { return new RotationZAxisReader(min, max); } case ExtendedAxes.AngularVelocityX: { return new AngularVelocityXAxisReader(min, max); } case ExtendedAxes.AngularVelocityY: { return new AngularVelocityYAxisReader(min, max); } case ExtendedAxes.AngularVelocityZ: { return new AngularVelocityZAxisReader(min, max); } case ExtendedAxes.AngularAccelerationX: { return new AngularAccelerationXAxisReader(min, max); } case ExtendedAxes.AngularAccelerationY: { return new AngularAccelerationYAxisReader(min, max); } case ExtendedAxes.AngularAccelerationZ: { return new AngularAccelerationZAxisReader(min, max); } case ExtendedAxes.TorqueX: { return new TorqueXAxisReader(min, max); } case ExtendedAxes.TorqueY: { return new TorqueYAxisReader(min, max); } case ExtendedAxes.TorqueZ: { return new TorqueZAxisReader(min, max); } default: { return null; } } }
/// <summary>Creates a slider reader for the specified object</summary> /// <param name="joystick">Joystick providing the control object</param> /// <param name="slider">Slider a reader will be created for</param> /// <param name="control">Control description for the axis</param> /// <returns>A new slider reader for the specified axis</returns> private static ISliderReader createSliderReader( Joystick joystick, ExtendedSliders slider, DeviceObjectInstance control ) { int id = (int)control.ObjectType; ObjectProperties properties = joystick.GetObjectPropertiesById(id); int min = properties.LowerRange; int max = properties.UpperRange; switch (slider) { case ExtendedSliders.Slider1: { return new SliderReader(0, min, max); } case ExtendedSliders.Slider2: { return new SliderReader(1, min, max); } case ExtendedSliders.Velocity1: { return new VelocitySliderReader(0, min, max); } case ExtendedSliders.Velocity2: { return new VelocitySliderReader(1, min, max); } case ExtendedSliders.Acceleration1: { return new AccelerationSliderReader(0, min, max); } case ExtendedSliders.Acceleration2: { return new AccelerationSliderReader(1, min, max); } case ExtendedSliders.Force1: { return new ForceSliderReader(0, min, max); } case ExtendedSliders.Force2: { return new ForceSliderReader(1, min, max); } default: { return null; } } }