/// <summary>Adds the game pad converters for the sliders / triggers</summary> private void addSliderConverters() { IList <DeviceObjectInstance> axes = this.joystick.GetObjects( ObjectDeviceType.AbsoluteAxis ); int sliderCount = countInstances(axes, ObjectGuid.Slider); if (sliderCount < 2) { // Less than two sliders but an Rz axis? Rz axis is left trigger. if (countInstances(axes, ObjectGuid.RotationalZAxis) > 0) { int id = (int)getInstance(axes, ObjectGuid.RotationalZAxis, 0).ObjectType; ObjectProperties properties = this.joystick.GetObjectPropertiesById(id); convertDelegate += new RotationalZAxisLeftTriggerConverter( properties.LowerRange, properties.UpperRange ).Convert; // Rz axis plus one real slider? Make it the right trigger. if (sliderCount > 0) { id = (int)getInstance(axes, ObjectGuid.Slider, 0).ObjectType; properties = this.joystick.GetObjectPropertiesById(id); convertDelegate += new SliderRightTriggerConverter( 0, properties.LowerRange, properties.UpperRange ).Convert; } } else if (sliderCount > 0) // No Rz axis, only one slider. It's the left trigger. { int id = (int)getInstance(axes, ObjectGuid.Slider, 0).ObjectType; ObjectProperties properties = this.joystick.GetObjectPropertiesById(id); convertDelegate += new SliderLeftTriggerConverter( 0, properties.LowerRange, properties.UpperRange ).Convert; } } // Two sliders? Make them the left and right triggers. if (sliderCount >= 2) { int id = (int)getInstance(axes, ObjectGuid.Slider, 0).ObjectType; ObjectProperties properties = this.joystick.GetObjectPropertiesById(id); convertDelegate += new SliderLeftTriggerConverter( 0, properties.LowerRange, properties.UpperRange ).Convert; id = (int)getInstance(axes, ObjectGuid.Slider, 1).ObjectType; properties = this.joystick.GetObjectPropertiesById(id); convertDelegate += new SliderLeftTriggerConverter( 1, properties.LowerRange, properties.UpperRange ).Convert; } }
/// <summary>Adds the game pad converters for the sliders / triggers</summary> private void addSliderConverters() { IList<DeviceObjectInstance> axes = this.joystick.GetObjects( ObjectDeviceType.AbsoluteAxis ); int sliderCount = countInstances(axes, ObjectGuid.Slider); if (sliderCount < 2) { // Less than two sliders but an Rz axis? Rz axis is left trigger. if (countInstances(axes, ObjectGuid.RotationalZAxis) > 0) { int id = (int)getInstance(axes, ObjectGuid.RotationalZAxis, 0).ObjectType; ObjectProperties properties = this.joystick.GetObjectPropertiesById(id); convertDelegate += new RotationalZAxisLeftTriggerConverter( properties.LowerRange, properties.UpperRange ).Convert; // Rz axis plus one real slider? Make it the right trigger. if (sliderCount > 0) { id = (int)getInstance(axes, ObjectGuid.Slider, 0).ObjectType; properties = this.joystick.GetObjectPropertiesById(id); convertDelegate += new SliderRightTriggerConverter( 0, properties.LowerRange, properties.UpperRange ).Convert; } } else if (sliderCount > 0) { // No Rz axis, only one slider. It's the left trigger. int id = (int)getInstance(axes, ObjectGuid.Slider, 0).ObjectType; ObjectProperties properties = this.joystick.GetObjectPropertiesById(id); convertDelegate += new SliderLeftTriggerConverter( 0, properties.LowerRange, properties.UpperRange ).Convert; } } // Two sliders? Make them the left and right triggers. if (sliderCount >= 2) { int id = (int)getInstance(axes, ObjectGuid.Slider, 0).ObjectType; ObjectProperties properties = this.joystick.GetObjectPropertiesById(id); convertDelegate += new SliderLeftTriggerConverter( 0, properties.LowerRange, properties.UpperRange ).Convert; id = (int)getInstance(axes, ObjectGuid.Slider, 1).ObjectType; properties = this.joystick.GetObjectPropertiesById(id); convertDelegate += new SliderLeftTriggerConverter( 1, properties.LowerRange, properties.UpperRange ).Convert; } }