Exemplo n.º 1
0
        public static DirectInputSource FromAxis(IInputDevice device, DeviceObjectInstance instance)
        {
            SourceTypes type = SourceTypes.AxisX;

            if (instance.ObjectType == ObjectGuid.XAxis || instance.ObjectType == ObjectGuid.RxAxis)
            {
                type = SourceTypes.AxisX;
            }
            else if (instance.ObjectType == ObjectGuid.YAxis || instance.ObjectType == ObjectGuid.RyAxis)
            {
                type = SourceTypes.AxisY;
            }
            else if (instance.ObjectType == ObjectGuid.ZAxis || instance.ObjectType == ObjectGuid.RzAxis)
            {
                type = SourceTypes.AxisZ;
            }
            int axisCount;

            if (instance.Usage >= 48)
            {
                axisCount = instance.Usage - 48;
            }
            else
            {
                axisCount = instance.ObjectId.InstanceNumber;
            }
            string name = instance.Name;

            return(new DirectInputSource(device, name, type, instance.Offset, state => GetAxisValue(state, axisCount) / (double)ushort.MaxValue));
        }
Exemplo n.º 2
0
 protected void OnDeviceFound(DeviceType t, DeviceObjectInstance i)
 {
     if (DeviceFound != null)
     {
         DeviceFound(this, new DeviceFoundArguments(t, i));
     }
 }
Exemplo n.º 3
0
 /// <summary>
 ///     Creates a new DIPhysicalControlInfo object.
 /// </summary>
 /// <param name="parent">
 ///     a DIPhysicalDeviceInfo object representing
 ///     the physical device on which this control appears
 /// </param>
 /// <param name="deviceObjectInstance">
 ///     this control's DeviceObjectInstance
 ///     structure, as obtained from DirectInput
 /// </param>
 /// <param name="controlNum">
 ///     an integer indicating the relative zero-based
 ///     "offset" of this control in the collection of similar controls on the
 ///     same device.  Button 1 would be controlNum=0; the first slider would
 ///     similarily be controlNum=0; as would the first Pov control, etc.
 /// </param>
 /// <param name="alias">
 ///     A string containing a "friendly name" (alias) to
 ///     associate with this control.
 /// </param>
 public DIPhysicalControlInfo(DIPhysicalDeviceInfo parent, DeviceObjectInstance deviceObjectInstance,
                              int controlNum, string alias)
     : base(parent, controlNum, ControlType.Unknown, AxisType.Unknown, alias)
 {
     _objectType    = deviceObjectInstance.ObjectType;
     _doiObjectGuid = deviceObjectInstance.ObjectTypeGuid;
 }
 internal void ClearJoystickSelection()
 {
     lock (LockObj)
     {
         JoyStick = null;
         JoyAxisForMechXAxisTilt                   = null;
         JoyAxisForMechYAxisTilt                   = null;
         JoyAxisForMechZAxisTilt                   = null;
         JoyAxisForMechBaseHeight                  = null;
         JoyAxisForMechSensitivity                 = null;
         JoyButtonForMechBackStateTrigger          = null;
         JoyButtonForMechBubblesStateTrigger       = null;
         JoyButtonForMechFlameStateTrigger         = null;
         JoyButtonForMechJetStateTrigger           = null;
         JoyButtonForMechLightningStateTrigger     = null;
         JoyButtonForMechRainStateTrigger          = null;
         JoyButtonForMechSmokeStateTrigger         = null;
         JoyButtonForMechSnowflakeStateTrigger     = null;
         JoyButtonForMechSpare1StateTrigger        = null;
         JoyButtonForMechSpare2StateTrigger        = null;
         JoyButtonForMechSpare3StateTrigger        = null;
         JoyButtonForMechSweepingLegs1StateTrigger = null;
         JoyButtonForMechSweepingLegs2StateTrigger = null;
         JoyButtonForMechVibrationStateTrigger     = null;
         JoyButtonForMechWaterSprayStateTrigger    = null;
         JoyButtonForMechWindStateTrigger          = null;
     }
 }
Exemplo n.º 5
0
        /// <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, Sliders slider, DeviceObjectInstance control
            )
        {
            int id = (int)control.ObjectType;
            ObjectProperties properties = joystick.GetObjectPropertiesById(id);

            int min = properties.LowerRange;
            int max = properties.UpperRange;

            switch (slider)
            {
            case Sliders.Slider1:
            {
                return(new SliderReader(0, min, max));
            }

            case Sliders.Slider2:
            {
                return(new SliderReader(1, min, max));
            }

            case Sliders.Velocity1:
            {
                return(new VelocitySliderReader(0, min, max));
            }

            case Sliders.Velocity2:
            {
                return(new VelocitySliderReader(1, min, max));
            }

            case Sliders.Acceleration1:
            {
                return(new AccelerationSliderReader(0, min, max));
            }

            case Sliders.Acceleration2:
            {
                return(new AccelerationSliderReader(1, min, max));
            }

            case Sliders.Force1:
            {
                return(new ForceSliderReader(0, min, max));
            }

            case Sliders.Force2:
            {
                return(new ForceSliderReader(1, min, max));
            }

            default:
            {
                return(null);
            }
            }
        }
Exemplo n.º 6
0
        private JoystickInput _CreateRotationAxis(DeviceObjectInstance deviceObjectInstance)
        {
            switch (char.ToLower(deviceObjectInstance.Name[0]))
            {
            case 'x':
                return(new XRotationalAxis(deviceObjectInstance.Name));

            case 'y':
                return(new YRotationalAxis(deviceObjectInstance.Name));

            case 'z':
                return(new ZRotationalAxis(deviceObjectInstance.Name));
            }
            return(null);
        }
Exemplo n.º 7
0
 void UpdateControl(DeviceObjectInstance d)
 {
     if (ObjectGuid.Button == d.ObjectType)
     {
         OnDeviceFound(DeviceType.Button, d);
         return;
     }
     else if (ObjectGuid.PovController == d.ObjectType)
     {
         OnDeviceFound(DeviceType.Pov, d);
         return;
     }
     else if (ObjectGuid.Slider == d.ObjectType)
     {
         OnDeviceFound(DeviceType.Slider, d);
     }
     else
     {
         OnDeviceFound(DeviceType.Unknown, d);
     }
 }
        /// <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;
            }
              }
        }
Exemplo n.º 9
0
        void UpdateControl(DeviceObjectInstance d)
        {
            if (ObjectGuid.XAxis == d.ObjectTypeGuid)
            {
                label_XAxis.Enabled = true;
                label_X.Enabled = true;
            }
            if (ObjectGuid.YAxis == d.ObjectTypeGuid)
            {
                label_YAxis.Enabled = true;
                label_Y.Enabled = true;
            }
            if (ObjectGuid.ZAxis == d.ObjectTypeGuid)
            {
                label_ZAxis.Enabled = true;
                label_Z.Enabled = true;
            }
            if (ObjectGuid.RotationalXAxis == d.ObjectTypeGuid)
            {
                label_XRotation.Enabled = true;
                label_XRot.Enabled = true;
            }
            if (ObjectGuid.RotationalYAxis == d.ObjectTypeGuid)
            {
                label_YRotation.Enabled = true;
                label_YRot.Enabled = true;
            }
            if (ObjectGuid.RotationalZAxis == d.ObjectTypeGuid)
            {
                label_ZRotation.Enabled = true;
                label_ZRot.Enabled = true;
            }

            if (ObjectGuid.Slider == d.ObjectTypeGuid)
            {
                switch (SliderCount++)
                {
                    case 0:
                        label_Slider0.Enabled = true;
                        label_S0.Enabled = true;
                        break;

                    case 1:
                        label_Slider1.Enabled = true;
                        label_S1.Enabled = true;
                        break;
                }
            }

            if (ObjectGuid.PovController == d.ObjectTypeGuid)
            {
                switch (numPOVs++)
                {
                    case 0:
                        label_POV0.Enabled = true;
                        label_P0.Enabled = true;
                        break;

                    case 1:
                        label_POV1.Enabled = true;
                        label_P1.Enabled = true;
                        break;

                    case 2:
                        label_POV2.Enabled = true;
                        label_P2.Enabled = true;
                        break;

                    case 3:
                        label_POV3.Enabled = true;
                        label_P3.Enabled = true;
                        break;
                }
            }
        }
Exemplo n.º 10
0
		private bool _IsDeviceType(DeviceObjectInstance deviceObjectInstance, ObjectDeviceType objectDeviceType)
		{
			return (deviceObjectInstance.ObjectType & objectDeviceType) != 0;
		}
Exemplo n.º 11
0
			 public void UpdateControls(DeviceObjectInstance d)
			{
				//this is where'd you'd check for stuff that the joystick has, but we don't need it.		
			}
Exemplo n.º 12
0
 private bool _IsAxis(DeviceObjectInstance deviceObjectInstance)
 {
     return(_IsDeviceType(deviceObjectInstance, ObjectDeviceType.Axis));
 }
Exemplo n.º 13
0
 private bool _IsPov(DeviceObjectInstance deviceObjectInstance)
 {
     return(_IsDeviceType(deviceObjectInstance, ObjectDeviceType.PointOfViewController));
 }
Exemplo n.º 14
0
Arquivo: Main.cs Projeto: sjk7/DX90SDK
        public void UpdateControls(DeviceObjectInstance d)
        {
            // Set the UI to reflect what objects the joystick supports.
            if (ObjectTypeGuid.XAxis == d.ObjectType)
            {
                labelXAxis.Enabled     = true;
                labelXAxisText.Enabled = true;
            }
            if (ObjectTypeGuid.YAxis == d.ObjectType)
            {
                labelYAxis.Enabled     = true;
                labelYAxisText.Enabled = true;
            }
            if (ObjectTypeGuid.ZAxis == d.ObjectType)
            {
                labelZAxis.Enabled     = true;
                labelZAxisText.Enabled = true;
            }
            if (ObjectTypeGuid.RxAxis == d.ObjectType)
            {
                labelXRotation.Enabled     = true;
                labelXRotationText.Enabled = true;
            }
            if (ObjectTypeGuid.RyAxis == d.ObjectType)
            {
                labelYRotation.Enabled     = true;
                labelYRotationText.Enabled = true;
            }
            if (ObjectTypeGuid.RzAxis == d.ObjectType)
            {
                labelZRotation.Enabled     = true;
                labelZRotationText.Enabled = true;
            }
            if (ObjectTypeGuid.Slider == d.ObjectType)
            {
                switch (SliderCount++)
                {
                case 0:
                    labelSlider0.Enabled     = true;
                    labelSlider0Text.Enabled = true;
                    break;

                case 1:
                    labelSlider1.Enabled     = true;
                    labelSlider1Text.Enabled = true;
                    break;
                }
            }
            if (ObjectTypeGuid.PointOfView == d.ObjectType)
            {
                switch (numPOVs++)
                {
                case 0:
                    labelPOV0.Enabled     = true;
                    labelPOV0Text.Enabled = true;
                    break;

                case 1:
                    labelPOV1.Enabled     = true;
                    labelPOV1Text.Enabled = true;
                    break;

                case 2:
                    labelPOV2.Enabled     = true;
                    labelPOV2Text.Enabled = true;
                    break;

                case 3:
                    labelPOV3.Enabled     = true;
                    labelPOV3Text.Enabled = true;
                    break;
                }
            }
        }
Exemplo n.º 15
0
 private bool _IsRotationAxis(DeviceObjectInstance deviceObjectInstance)
 {
     return(deviceObjectInstance.Name.ContainsString("rotation"));
 }
Exemplo n.º 16
0
		private JoystickInput _CreateRotationAxis(DeviceObjectInstance deviceObjectInstance)
		{
			switch (char.ToLower(deviceObjectInstance.Name[0])) {
				case 'x':
					return new XRotationalAxis(deviceObjectInstance.Name);
				case 'y':
					return new YRotationalAxis(deviceObjectInstance.Name);
				case 'z':
					return new ZRotationalAxis(deviceObjectInstance.Name);
			}
			return null;
		}
Exemplo n.º 17
0
		private bool _IsRotationAxis(DeviceObjectInstance deviceObjectInstance)
		{
			return deviceObjectInstance.Name.ContainsString("rotation");
		}
Exemplo n.º 18
0
		private bool _IsPov(DeviceObjectInstance deviceObjectInstance)
		{
			return _IsDeviceType(deviceObjectInstance, ObjectDeviceType.PointOfViewController);
		}
Exemplo n.º 19
0
		private bool _IsButton(DeviceObjectInstance deviceObjectInstance)
		{
			return _IsDeviceType(deviceObjectInstance, ObjectDeviceType.Button);
		}
Exemplo n.º 20
0
		private bool _IsAxis(DeviceObjectInstance deviceObjectInstance)
		{
			return _IsDeviceType(deviceObjectInstance, ObjectDeviceType.Axis);
		}
        /// <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;
            }
              }
        }
Exemplo n.º 22
0
        void InitializeCallbacks()
        {
            const int dzp = 400;
            const int dzn = -400;

            names.Clear();
            actions.Clear();
            NumButtons = 0;

            // populate DIAXISINFO
            devObList = (joystick.GetObjects()
                         .Where(a => a.UsagePage == 1 && a.Usage > 0 && a.Usage != 4)
                         .GroupBy(x => x.Name).Select(x => x.First())
                         .OrderBy(o => o.Usage)
                         .ThenBy(o2 => o2.Offset)).ToArray();

            for (int axis = 0; axis < devObList.Count(); axis++)
            {
                DeviceObjectInstance deviceObject = joystick.GetObjects()[axis];
                InputRange           diprg        = joystick.GetObjectPropertiesById((int)deviceObject.ObjectType).LogicalRange;
                int min = diprg.Minimum;
                int max = diprg.Maximum;

                if (min < max)
                {
                    di_axis_info dai = new di_axis_info();
                    dai.jd_logical_offset = axis;
                    dai.maximum           = max;
                    dai.minimum           = min;
                    dai.name         = deviceObject.Name;
                    dai.usage        = deviceObject.Usage;
                    dai.usagepage    = deviceObject.UsagePage;
                    dai.offset       = deviceObject.Offset / 4;
                    dai.offsetActual = deviceObject.Offset;
                    dai.device       = deviceObject;
                    DIAxisInfo.Add(dai);
                }

                //axis_config_type[axis] = 0;
            }


            num_rel_axes = 0;
            num_axes     = DIAxisInfo.Count(); // + joystick.Capabilities.PovCount * 2;
            num_buttons  = joystick.Capabilities.ButtonCount;

            /* States */
            axis_state.Resize(num_axes);
            rel_axis_state.Resize(num_rel_axes);
            button_state.Resize(num_buttons);

            // buttons
            for (int button = 0; button < joystick.Capabilities.ButtonCount; button++)
            {
                if (state.GetButtons()[button] == true)
                {
                    button_state[button] = true;
                }
                else
                {
                    button_state[button] = false;
                }
            }

            // axis
            unsafe
            {
                for (int axis = 0; axis < DIAxisInfo.Count; axis++)
                {
                    int   X  = state.X;
                    Int64 rv = (&X)[DIAxisInfo[axis].jd_logical_offset];

                    rv = (((rv - DIAxisInfo[axis].minimum) * 32767 * 2) / (DIAxisInfo[axis].maximum - DIAxisInfo[axis].minimum)) - 32767;
                    if (rv < -32767)
                    {
                        rv = -32767;
                    }

                    if (rv > 32767)
                    {
                        rv = 32767;
                    }
                    axis_state[axis] = Convert.ToInt16(rv);
                }
            }

            // hats

            /*
             * for (int hat = 0; hat < joystick.Capabilities.PovCount; hat++)
             * {
             *  uint hat_val = Convert.ToUInt32(state.GetPointOfViewControllers()[hat]);
             *
             *  if (hat_val >= 36000)
             *  {
             *      axis_state[(DIAxisInfo.Count + hat * 2) + 0] = 0;
             *      axis_state[(DIAxisInfo.Count + hat * 2) + 1] = 0;
             *  }
             *  else
             *  {
             *      int x = 0;
             *      int y = 0;
             *      uint octant = (hat_val / 4500) & 0x7;
             *      int octant_doff = Convert.ToInt32(hat_val) % 4500;
             *
             *      switch (octant)
             *      {
             *          case 0: x = octant_doff * 32767 / 4500; y = -32767; break;
             *          case 1: x = 32767; y = (-4500 + octant_doff) * 32767 / 4500; break;
             *
             *          case 2: x = 32767; y = octant_doff * 32767 / 4500; break;
             *          case 3: x = (4500 - octant_doff) * 32767 / 4500; y = 32767; break;
             *
             *          case 4: x = (-octant_doff) * 32767 / 4500; y = 32767; break;
             *          case 5: x = -32767; y = (4500 - octant_doff) * 32767 / 4500; break;
             *
             *          case 6: x = -32767; y = (-octant_doff) * 32767 / 4500; break;
             *          case 7: x = (-4500 + octant_doff) * 32767 / 4500; y = -32767; break;
             *      }
             *
             *      axis_state[(DIAxisInfo.Count + hat * 2) + 0] = Convert.ToInt16(x);
             *      axis_state[(DIAxisInfo.Count + hat * 2) + 1] = Convert.ToInt16(y);
             *  }
             *
             * }
             */

            //string iD = IdGenerator.CalcOldStyleID(DIAxisInfo.Count, 0, joystick.Capabilities.PovCount, joystick.Capabilities.ButtonCount).ToString();
            //string iD = IdGenerator.CalcOldStyleID(num_axes, 0, num_hats, num_buttons).ToString();

            /* populate objects */

            // buttons first

            if (VersionChecker.Instance.IsNewConfig)
            {
                // new stype
                for (int i = 0; i < num_buttons; i++)
                {
                    int    j            = i;
                    bool   button_state = state.GetButtons()[i];
                    UInt32 butnameint   = Convert.ToUInt32(i);
                    string buttStr      = "button_" + i;

                    BConfig.Add(butnameint);

                    AddItem("joystick " + id + " " + buttStr, () => state.IsPressed(j));
                }
            }
            else
            {
                // old style
                for (int i = 0; i < num_buttons; i++)
                {
                    int    j            = i;
                    bool   button_state = state.GetButtons()[i];
                    UInt32 butnameint   = Convert.ToUInt32(i);
                    string buttonnum    = butnameint.ToString("X8");

                    BConfig.Add(butnameint);

                    AddItem("joystick " + id + " " + butnameint.ToString("X8").ToLower(), () => state.IsPressed(j));
                }
            }

            Func <bool> cbPos;
            Func <bool> cbNeg;

            // names
            int buttNamePos;
            int buttNameNeg;

            string buttNamePosString;
            string buttNameNegString;

            // axis
            for (int axis = 0; axis < num_axes; axis++)
            {
                Int16 a_state           = axis_state[axis];
                DeviceObjectInstance di = devObList[axis];

                // dynamically create callback

                if (VersionChecker.Instance.IsNewConfig)
                {
                    // new style
                    string abs = "abs_";

                    // new config format
                    switch (di.Usage)
                    {
                    case 0x30:          // X Axis
                        cbPos             = () => state.X >= dzp;
                        cbNeg             = () => state.X <= dzn;
                        buttNamePosString = abs + axis + "+";
                        buttNameNegString = abs + axis + "-";
                        buttNamePos       = 0x8000 + axis;
                        buttNameNeg       = 0xc000 + axis;
                        AddItem("joystick " + id + " " + buttNamePosString, cbPos);
                        AddItem("joystick " + id + " " + buttNameNegString, cbNeg);
                        BConfig.Add(Convert.ToUInt32(buttNamePos));
                        BConfig.Add(Convert.ToUInt32(buttNameNeg));
                        break;

                    case 0x31:          // y Axis
                        cbPos             = () => state.Y >= dzp;
                        cbNeg             = () => state.Y <= dzn;
                        buttNamePosString = abs + axis + "+";
                        buttNameNegString = abs + axis + "-";
                        buttNamePos       = 0x8000 + axis;
                        buttNameNeg       = 0xc000 + axis;
                        AddItem("joystick " + id + " " + buttNamePosString, cbPos);
                        AddItem("joystick " + id + " " + buttNameNegString, cbNeg);
                        BConfig.Add(Convert.ToUInt32(buttNamePos));
                        BConfig.Add(Convert.ToUInt32(buttNameNeg));
                        break;

                    case 0x32:          // Z Axis
                        cbPos             = () => state.Z >= dzp;
                        cbNeg             = () => state.Z <= dzn;
                        buttNamePosString = abs + axis + "+";
                        buttNameNegString = abs + axis + "-";
                        buttNamePos       = 0x8000 + axis;
                        buttNameNeg       = 0xc000 + axis;
                        AddItem("joystick " + id + " " + buttNamePosString, cbPos);
                        AddItem("joystick " + id + " " + buttNameNegString, cbNeg);
                        BConfig.Add(Convert.ToUInt32(buttNamePos));
                        BConfig.Add(Convert.ToUInt32(buttNameNeg));
                        break;

                    case 0x33:          // X Rotation
                        cbPos             = () => state.RotationX >= dzp;
                        cbNeg             = () => state.RotationX <= dzn;
                        buttNamePosString = abs + axis + "+";
                        buttNameNegString = abs + axis + "-";
                        buttNamePos       = 0x8000 + axis;
                        buttNameNeg       = 0xc000 + axis;
                        AddItem("joystick " + id + " " + buttNamePosString, cbPos);
                        AddItem("joystick " + id + " " + buttNameNegString, cbNeg);
                        BConfig.Add(Convert.ToUInt32(buttNamePos));
                        BConfig.Add(Convert.ToUInt32(buttNameNeg));
                        break;

                    case 0x34:          // Y Rotation
                        cbPos             = () => state.RotationY >= dzp;
                        cbNeg             = () => state.RotationY <= dzn;
                        buttNamePosString = abs + axis + "+";
                        buttNameNegString = abs + axis + "-";
                        buttNamePos       = 0x8000 + axis;
                        buttNameNeg       = 0xc000 + axis;
                        AddItem("joystick " + id + " " + buttNamePosString, cbPos);
                        AddItem("joystick " + id + " " + buttNameNegString, cbNeg);
                        BConfig.Add(Convert.ToUInt32(buttNamePos));
                        BConfig.Add(Convert.ToUInt32(buttNameNeg));
                        break;

                    case 0x35:          // Z Rotation
                        cbPos             = () => state.RotationZ >= dzp;
                        cbNeg             = () => state.RotationZ <= dzn;
                        buttNamePosString = abs + axis + "+";
                        buttNameNegString = abs + axis + "-";
                        buttNamePos       = 0x8000 + axis;
                        buttNameNeg       = 0xc000 + axis;
                        AddItem("joystick " + id + " " + buttNamePosString, cbPos);
                        AddItem("joystick " + id + " " + buttNameNegString, cbNeg);
                        BConfig.Add(Convert.ToUInt32(buttNamePos));
                        BConfig.Add(Convert.ToUInt32(buttNameNeg));
                        break;

                    case 0x40:          // X Velocity
                        cbPos             = () => state.RotationZ >= dzp;
                        cbNeg             = () => state.RotationZ <= dzn;
                        buttNamePosString = abs + axis + "+";
                        buttNameNegString = abs + axis + "-";
                        buttNamePos       = 0x8000 + axis;
                        buttNameNeg       = 0xc000 + axis;
                        AddItem("joystick " + id + " " + buttNamePosString, cbPos);
                        AddItem("joystick " + id + " " + buttNameNegString, cbNeg);
                        BConfig.Add(Convert.ToUInt32(buttNamePos));
                        BConfig.Add(Convert.ToUInt32(buttNameNeg));
                        break;

                    case 0x41:          // Y Velocity
                        cbPos             = () => state.RotationZ >= dzp;
                        cbNeg             = () => state.RotationZ <= dzn;
                        buttNamePosString = abs + axis + "+";
                        buttNameNegString = abs + axis + "-";
                        buttNamePos       = 0x8000 + axis;
                        buttNameNeg       = 0xc000 + axis;
                        AddItem("joystick " + id + " " + buttNamePosString, cbPos);
                        AddItem("joystick " + id + " " + buttNameNegString, cbNeg);
                        BConfig.Add(Convert.ToUInt32(buttNamePos));
                        BConfig.Add(Convert.ToUInt32(buttNameNeg));
                        break;

                    case 0x42:          // Z Velocity
                        cbPos             = () => state.RotationZ >= dzp;
                        cbNeg             = () => state.RotationZ <= dzn;
                        buttNamePosString = abs + axis + "+";
                        buttNameNegString = abs + axis + "-";
                        buttNamePos       = 0x8000 + axis;
                        buttNameNeg       = 0xc000 + axis;
                        AddItem("joystick " + id + " " + buttNamePosString, cbPos);
                        AddItem("joystick " + id + " " + buttNameNegString, cbNeg);
                        BConfig.Add(Convert.ToUInt32(buttNamePos));
                        BConfig.Add(Convert.ToUInt32(buttNameNeg));
                        break;

                    case 0x39:          // Hat Switch (contains 2 actual axis)

                        // skip

                        /*
                         * povTmpCount++;
                         * // L - R
                         * buttNamePos = 0x8000 + axis;
                         * buttNameNeg = 0xc000 + axis;
                         * AddItem("joystick " + id + " " + buttNamePos.ToString("X8").ToLower(), () => { int t = state.GetPointOfViewControllers()[povTmpCount]; return t >= 22500 && t <= 31500; });
                         * AddItem("joystick " + id + " " + buttNameNeg.ToString("X8").ToLower(), () => { int t = state.GetPointOfViewControllers()[povTmpCount]; return t >= 4500 && t <= 13500; });
                         * BConfig.Add(Convert.ToUInt32(buttNamePos));
                         * BConfig.Add(Convert.ToUInt32(buttNameNeg));
                         *
                         * // U - D
                         * buttNamePos = 0x8000 + axis;
                         * buttNameNeg = 0xc000 + axis;
                         * AddItem("joystick " + id + " " + buttNamePos.ToString("X8").ToLower(), () => { int t = state.GetPointOfViewControllers()[povTmpCount]; return (t >= 0 && t <= 4500) || (t >= 31500 && t < 36000); });
                         * AddItem("joystick " + id + " " + buttNameNeg.ToString("X8").ToLower(), () => { int t = state.GetPointOfViewControllers()[povTmpCount]; return t >= 13500 && t <= 22500; });
                         * BConfig.Add(Convert.ToUInt32(buttNamePos));
                         * BConfig.Add(Convert.ToUInt32(buttNameNeg));
                         */
                        break;

                    default:
                        cbPos = null;
                        cbNeg = null;
                        break;
                    }
                }
                else
                {
                    // old style
                    switch (di.Usage)
                    {
                    case 0x30:          // X Axis
                        cbPos       = () => state.X >= dzp;
                        cbNeg       = () => state.X <= dzn;
                        buttNamePos = 0x8000 + axis;
                        buttNameNeg = 0xc000 + axis;
                        AddItem("joystick " + id + " " + buttNamePos.ToString("X8").ToLower(), cbPos);
                        AddItem("joystick " + id + " " + buttNameNeg.ToString("X8").ToLower(), cbNeg);
                        BConfig.Add(Convert.ToUInt32(buttNamePos));
                        BConfig.Add(Convert.ToUInt32(buttNameNeg));
                        break;

                    case 0x31:          // y Axis
                        cbPos       = () => state.Y >= dzp;
                        cbNeg       = () => state.Y <= dzn;
                        buttNamePos = 0x8000 + axis;
                        buttNameNeg = 0xc000 + axis;
                        AddItem("joystick " + id + " " + buttNamePos.ToString("X8").ToLower(), cbPos);
                        AddItem("joystick " + id + " " + buttNameNeg.ToString("X8").ToLower(), cbNeg);
                        BConfig.Add(Convert.ToUInt32(buttNamePos));
                        BConfig.Add(Convert.ToUInt32(buttNameNeg));
                        break;

                    case 0x32:          // Z Axis
                        cbPos       = () => state.Z >= dzp;
                        cbNeg       = () => state.Z <= dzn;
                        buttNamePos = 0x8000 + axis;
                        buttNameNeg = 0xc000 + axis;
                        AddItem("joystick " + id + " " + buttNamePos.ToString("X8").ToLower(), cbPos);
                        AddItem("joystick " + id + " " + buttNameNeg.ToString("X8").ToLower(), cbNeg);
                        BConfig.Add(Convert.ToUInt32(buttNamePos));
                        BConfig.Add(Convert.ToUInt32(buttNameNeg));
                        break;

                    case 0x33:          // X Rotation
                        cbPos       = () => state.RotationX >= dzp;
                        cbNeg       = () => state.RotationX <= dzn;
                        buttNamePos = 0x8000 + axis;
                        buttNameNeg = 0xc000 + axis;
                        AddItem("joystick " + id + " " + buttNamePos.ToString("X8").ToLower(), cbPos);
                        AddItem("joystick " + id + " " + buttNameNeg.ToString("X8").ToLower(), cbNeg);
                        BConfig.Add(Convert.ToUInt32(buttNamePos));
                        BConfig.Add(Convert.ToUInt32(buttNameNeg));
                        break;

                    case 0x34:          // Y Rotation
                        cbPos       = () => state.RotationY >= dzp;
                        cbNeg       = () => state.RotationY <= dzn;
                        buttNamePos = 0x8000 + axis;
                        buttNameNeg = 0xc000 + axis;
                        AddItem("joystick " + id + " " + buttNamePos.ToString("X8").ToLower(), cbPos);
                        AddItem("joystick " + id + " " + buttNameNeg.ToString("X8").ToLower(), cbNeg);
                        BConfig.Add(Convert.ToUInt32(buttNamePos));
                        BConfig.Add(Convert.ToUInt32(buttNameNeg));
                        break;

                    case 0x35:          // Z Rotation
                        cbPos       = () => state.RotationZ >= dzp;
                        cbNeg       = () => state.RotationZ <= dzn;
                        buttNamePos = 0x8000 + axis;
                        buttNameNeg = 0xc000 + axis;
                        AddItem("joystick " + id + " " + buttNamePos.ToString("X8").ToLower(), cbPos);
                        AddItem("joystick " + id + " " + buttNameNeg.ToString("X8").ToLower(), cbNeg);
                        BConfig.Add(Convert.ToUInt32(buttNamePos));
                        BConfig.Add(Convert.ToUInt32(buttNameNeg));
                        break;

                    case 0x40:          // X Velocity
                        cbPos       = () => state.RotationZ >= dzp;
                        cbNeg       = () => state.RotationZ <= dzn;
                        buttNamePos = 0x8000 + axis;
                        buttNameNeg = 0xc000 + axis;
                        AddItem("joystick " + id + " " + buttNamePos.ToString("X8").ToLower(), cbPos);
                        AddItem("joystick " + id + " " + buttNameNeg.ToString("X8").ToLower(), cbNeg);
                        BConfig.Add(Convert.ToUInt32(buttNamePos));
                        BConfig.Add(Convert.ToUInt32(buttNameNeg));
                        break;

                    case 0x41:          // Y Velocity
                        cbPos       = () => state.RotationZ >= dzp;
                        cbNeg       = () => state.RotationZ <= dzn;
                        buttNamePos = 0x8000 + axis;
                        buttNameNeg = 0xc000 + axis;
                        AddItem("joystick " + id + " " + buttNamePos.ToString("X8").ToLower(), cbPos);
                        AddItem("joystick " + id + " " + buttNameNeg.ToString("X8").ToLower(), cbNeg);
                        BConfig.Add(Convert.ToUInt32(buttNamePos));
                        BConfig.Add(Convert.ToUInt32(buttNameNeg));
                        break;

                    case 0x42:          // Z Velocity
                        cbPos       = () => state.RotationZ >= dzp;
                        cbNeg       = () => state.RotationZ <= dzn;
                        buttNamePos = 0x8000 + axis;
                        buttNameNeg = 0xc000 + axis;
                        AddItem("joystick " + id + " " + buttNamePos.ToString("X8").ToLower(), cbPos);
                        AddItem("joystick " + id + " " + buttNameNeg.ToString("X8").ToLower(), cbNeg);
                        BConfig.Add(Convert.ToUInt32(buttNamePos));
                        BConfig.Add(Convert.ToUInt32(buttNameNeg));
                        break;

                    case 0x39:          // Hat Switch (contains 2 actual axis)

                        // skip

                        /*
                         * povTmpCount++;
                         * // L - R
                         * buttNamePos = 0x8000 + axis;
                         * buttNameNeg = 0xc000 + axis;
                         * AddItem("joystick " + id + " " + buttNamePos.ToString("X8").ToLower(), () => { int t = state.GetPointOfViewControllers()[povTmpCount]; return t >= 22500 && t <= 31500; });
                         * AddItem("joystick " + id + " " + buttNameNeg.ToString("X8").ToLower(), () => { int t = state.GetPointOfViewControllers()[povTmpCount]; return t >= 4500 && t <= 13500; });
                         * BConfig.Add(Convert.ToUInt32(buttNamePos));
                         * BConfig.Add(Convert.ToUInt32(buttNameNeg));
                         *
                         * // U - D
                         * buttNamePos = 0x8000 + axis;
                         * buttNameNeg = 0xc000 + axis;
                         * AddItem("joystick " + id + " " + buttNamePos.ToString("X8").ToLower(), () => { int t = state.GetPointOfViewControllers()[povTmpCount]; return (t >= 0 && t <= 4500) || (t >= 31500 && t < 36000); });
                         * AddItem("joystick " + id + " " + buttNameNeg.ToString("X8").ToLower(), () => { int t = state.GetPointOfViewControllers()[povTmpCount]; return t >= 13500 && t <= 22500; });
                         * BConfig.Add(Convert.ToUInt32(buttNamePos));
                         * BConfig.Add(Convert.ToUInt32(buttNameNeg));
                         */
                        break;

                    default:
                        cbPos = null;
                        cbNeg = null;
                        break;
                    }
                }
            }


            /*
             *
             * AddItem("AccelerationX+", () => state.AccelerationX >= dzp);
             * AddItem("AccelerationX-", () => state.AccelerationX <= dzn);
             * AddItem("AccelerationY+", () => state.AccelerationY >= dzp);
             * AddItem("AccelerationY-", () => state.AccelerationY <= dzn);
             * AddItem("AccelerationZ+", () => state.AccelerationZ >= dzp);
             * AddItem("AccelerationZ-", () => state.AccelerationZ <= dzn);
             * AddItem("AngularAccelerationX+", () => state.AngularAccelerationX >= dzp);
             * AddItem("AngularAccelerationX-", () => state.AngularAccelerationX <= dzn);
             * AddItem("AngularAccelerationY+", () => state.AngularAccelerationY >= dzp);
             * AddItem("AngularAccelerationY-", () => state.AngularAccelerationY <= dzn);
             * AddItem("AngularAccelerationZ+", () => state.AngularAccelerationZ >= dzp);
             * AddItem("AngularAccelerationZ-", () => state.AngularAccelerationZ <= dzn);
             * AddItem("AngularVelocityX+", () => state.AngularVelocityX >= dzp);
             * AddItem("AngularVelocityX-", () => state.AngularVelocityX <= dzn);
             * AddItem("AngularVelocityY+", () => state.AngularVelocityY >= dzp);
             * AddItem("AngularVelocityY-", () => state.AngularVelocityY <= dzn);
             * AddItem("AngularVelocityZ+", () => state.AngularVelocityZ >= dzp);
             * AddItem("AngularVelocityZ-", () => state.AngularVelocityZ <= dzn);
             * AddItem("ForceX+", () => state.ForceX >= dzp);
             * AddItem("ForceX-", () => state.ForceX <= dzn);
             * AddItem("ForceY+", () => state.ForceY >= dzp);
             * AddItem("ForceY-", () => state.ForceY <= dzn);
             * AddItem("ForceZ+", () => state.ForceZ >= dzp);
             * AddItem("ForceZ-", () => state.ForceZ <= dzn);
             * AddItem("RotationX+", () => state.RotationX >= dzp);
             * AddItem("RotationX-", () => state.RotationX <= dzn);
             * AddItem("RotationY+", () => state.RotationY >= dzp);
             * AddItem("RotationY-", () => state.RotationY <= dzn);
             * AddItem("00008003", () => state.RotationZ >= dzp); //AddItem("RotationZ+", () => state.RotationZ >= dzp);
             * AddItem("0000c003", () => state.RotationZ <= dzn); //AddItem("RotationZ-", () => state.RotationZ <= dzn);
             * AddItem("TorqueX+", () => state.TorqueX >= dzp);
             * AddItem("TorqueX-", () => state.TorqueX <= dzn);
             * AddItem("TorqueY+", () => state.TorqueY >= dzp);
             * AddItem("TorqueY-", () => state.TorqueY <= dzn);
             * AddItem("TorqueZ+", () => state.TorqueZ >= dzp);
             * AddItem("TorqueZ-", () => state.TorqueZ <= dzn);
             * AddItem("VelocityX+", () => state.VelocityX >= dzp);
             * AddItem("VelocityX-", () => state.VelocityX <= dzn);
             * AddItem("VelocityY+", () => state.VelocityY >= dzp);
             * AddItem("VelocityY-", () => state.VelocityY <= dzn);
             * AddItem("VelocityZ+", () => state.VelocityZ >= dzp);
             * AddItem("VelocityZ-", () => state.VelocityZ <= dzn);
             * AddItem("00008000", () => state.X >= dzp); //AddItem("X+", () => state.X >= dzp);
             * AddItem("0000c000", () => state.X <= dzn); //AddItem("X-", () => state.X <= dzn);
             * AddItem("00008001", () => state.Y >= dzp); //AddItem("Y+", () => state.Y >= dzp);
             * AddItem("0000c001", () => state.Y <= dzn); //AddItem("Y-", () => state.Y <= dzn);
             * AddItem("00008002", () => state.Z >= dzp); //AddItem("Z+", () => state.Z >= dzp);
             * AddItem("0000c002", () => state.Z <= dzn); //AddItem("Z-", () => state.Z <= dzn);
             *
             */

            // i don't know what the "Slider"s do, so they're omitted for the moment

            for (int i = 0; i < state.GetButtons().Length; i++)
            {
                //int j = i;
                //AddItem(string.Format("B{0}", i + 1), () => state.IsPressed(j));
            }


            // add sliders
            int povCount  = state.GetPointOfViewControllers().Length;
            int nPovCount = joystick.Capabilities.PovCount;
            int axiscount = DevCaps.AxesCount;

            for (int i = 0; i < nPovCount; i++)
            {
                int j    = i;
                int axis = axiscount - nPovCount + i;

                if (VersionChecker.Instance.IsNewConfig)
                {
                    // new style

                    // L - R
                    buttNamePos = 0x8000 + axis;
                    buttNameNeg = 0xc000 + axis;

                    buttNamePosString = "abs_" + axis + "+";
                    buttNameNegString = "abs_" + axis + "-";

                    AddItem("joystick " + id + " " + buttNamePosString,
                            () => { int t = state.GetPointOfViewControllers()[j]; return(t >= 22500 && t <= 31500); });

                    AddItem("joystick " + id + " " + buttNameNegString,
                            () => { int t = state.GetPointOfViewControllers()[j]; return(t >= 4500 && t <= 13500); });

                    BConfig.Add(Convert.ToUInt32(buttNamePos));
                    BConfig.Add(Convert.ToUInt32(buttNameNeg));

                    // U - D
                    buttNamePos = 0x8000 + (axis + 1);
                    buttNameNeg = 0xc000 + (axis + 1);

                    buttNamePosString = "abs_" + (axis + 1) + "+";
                    buttNameNegString = "abs_" + (axis + 1) + "-";

                    AddItem("joystick " + id + " " + buttNamePosString,
                            () => { int t = state.GetPointOfViewControllers()[j]; return((t >= 0 && t <= 4500) || (t >= 31500 && t < 36000)); });

                    AddItem("joystick " + id + " " + buttNameNegString,
                            () => { int t = state.GetPointOfViewControllers()[j]; return(t >= 13500 && t <= 22500); });

                    BConfig.Add(Convert.ToUInt32(buttNamePos));
                    BConfig.Add(Convert.ToUInt32(buttNameNeg));

                    // increment axis count (as there are effectively two axis in a POV Hat)
                    axiscount++;
                }
                else
                {
                    // old style
                    // L - R
                    buttNamePos = 0x8000 + axis;
                    buttNameNeg = 0xc000 + axis;
                    //AddItem("joystick " + id + " " + buttNamePos.ToString("X8").ToLower(), () => { int t = state.GetPointOfViewControllers()[povTmpCount]; return t >= 22500 && t <= 31500; });
                    AddItem("joystick " + id + " " + buttNamePos.ToString("X8").ToLower(),  //string.Format("joystick " + id + " " + "POV{0}L", i + 1),
                            () => { int t = state.GetPointOfViewControllers()[j]; return(t >= 22500 && t <= 31500); });
                    //AddItem("joystick " + id + " " + buttNameNeg.ToString("X8").ToLower(), () => { int t = state.GetPointOfViewControllers()[povTmpCount]; return t >= 4500 && t <= 13500; });
                    AddItem("joystick " + id + " " + buttNameNeg.ToString("X8").ToLower(),  //string.Format("joystick " + id + " " + "POV{0}R", i + 1),
                            () => { int t = state.GetPointOfViewControllers()[j]; return(t >= 4500 && t <= 13500); });
                    BConfig.Add(Convert.ToUInt32(buttNamePos));
                    BConfig.Add(Convert.ToUInt32(buttNameNeg));

                    // U - D
                    buttNamePos = 0x8000 + (axis + 1);
                    buttNameNeg = 0xc000 + (axis + 1);
                    //AddItem("joystick " + id + " " + buttNamePos.ToString("X8").ToLower(), () => { int t = state.GetPointOfViewControllers()[povTmpCount]; return (t >= 0 && t <= 4500) || (t >= 31500 && t < 36000); });
                    AddItem("joystick " + id + " " + buttNamePos.ToString("X8").ToLower(),   //string.Format("joystick " + id + " " + "POV{0}U", i + 1),
                            () => { int t = state.GetPointOfViewControllers()[j]; return((t >= 0 && t <= 4500) || (t >= 31500 && t < 36000)); });
                    //AddItem("joystick " + id + " " + buttNameNeg.ToString("X8").ToLower(), () => { int t = state.GetPointOfViewControllers()[povTmpCount]; return t >= 13500 && t <= 22500; });
                    AddItem("joystick " + id + " " + buttNameNeg.ToString("X8").ToLower(),   //string.Format("joystick " + id + " " + "POV{0}D", i + 1),
                            () => { int t = state.GetPointOfViewControllers()[j]; return(t >= 13500 && t <= 22500); });
                    BConfig.Add(Convert.ToUInt32(buttNamePos));
                    BConfig.Add(Convert.ToUInt32(buttNameNeg));

                    // increment axis count (as there are effectively two axis in a POV Hat)
                    axiscount++;
                }
            }
        }
Exemplo n.º 23
0
 private bool _IsDeviceType(DeviceObjectInstance deviceObjectInstance, ObjectDeviceType objectDeviceType)
 {
     return((deviceObjectInstance.ObjectType & objectDeviceType) != 0);
 }
Exemplo n.º 24
0
        private void UpdateControl(DeviceObjectInstance d)
        {
            if (ObjectGuid.XAxis == d.ObjectTypeGuid)
            {
                XaxisValueLabel.IsEnabled = true;
                XaxisValue.IsEnabled = true;
            }
            else if (ObjectGuid.YAxis == d.ObjectTypeGuid)
            {
                YaxisValueLabel.IsEnabled = true;
                YaxisValue.IsEnabled = true;
            }

            //if (ObjectGuid.ZAxis == d.ObjectTypeGuid)
            //{
            //    label_ZAxis.Enabled = true;
            //    label_Z.Enabled = true;
            //}
            //if (ObjectGuid.RotationalXAxis == d.ObjectTypeGuid)
            //{
            //    label_XRotation.Enabled = true;
            //    label_XRot.Enabled = true;
            //}
            //if (ObjectGuid.RotationalYAxis == d.ObjectTypeGuid)
            //{
            //    label_YRotation.Enabled = true;
            //    label_YRot.Enabled = true;
            //}
            //if (ObjectGuid.RotationalZAxis == d.ObjectTypeGuid)
            //{
            //    label_ZRotation.Enabled = true;
            //    label_ZRot.Enabled = true;
            //}

            //if (ObjectGuid.Slider == d.ObjectTypeGuid)
            //{
            //    switch (SliderCount++)
            //    {
            //        case 0:
            //            label_Slider0.Enabled = true;
            //            label_S0.Enabled = true;
            //            break;

            //        case 1:
            //            label_Slider1.Enabled = true;
            //            label_S1.Enabled = true;
            //            break;
            //    }
            //}

            //if (ObjectGuid.PovController == d.ObjectTypeGuid)
            //{
            //    switch (numPOVs++)
            //    {
            //        case 0:
            //            label_POV0.Enabled = true;
            //            label_P0.Enabled = true;
            //            break;

            //        case 1:
            //            label_POV1.Enabled = true;
            //            label_P1.Enabled = true;
            //            break;

            //        case 2:
            //            label_POV2.Enabled = true;
            //            label_P2.Enabled = true;
            //            break;

            //        case 3:
            //            label_POV3.Enabled = true;
            //            label_P3.Enabled = true;
            //            break;
            //    }
            //}
        }
Exemplo n.º 25
0
 private bool _IsButton(DeviceObjectInstance deviceObjectInstance)
 {
     return(_IsDeviceType(deviceObjectInstance, ObjectDeviceType.Button));
 }
Exemplo n.º 26
0
        public static DirectInputSource FromSlider(IInputDevice device, DeviceObjectInstance instance, int index)
        {
            string name = instance.Name;

            return(new DirectInputSource(device, name, SourceTypes.Slider, instance.Offset, state => GetSliderValue(state, index + 1) / (double)ushort.MaxValue));
        }
Exemplo n.º 27
0
        /// <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);
            }
            }
        }
Exemplo n.º 28
0
 public void UpdateControls(DeviceObjectInstance d)
 {
     //this is where'd you'd check for stuff that the joystick has, but we don't need it.
 }
Exemplo n.º 29
0
        /// <summary>
        /// Enable the properties that are supported by the device
        /// </summary>
        /// <param name="d"></param>
        private void UpdateControls(DeviceObjectInstance d)
        {
            // Set the UI to reflect what objects the joystick supports.
            if (ObjectGuid.XAxis == d.ObjectType)
            {
                m_jPanel.Xe    = true;
                m_jPanel.Xname = d.Name + ":";
            }
            if (ObjectGuid.YAxis == d.ObjectType)
            {
                m_jPanel.Ye    = true;
                m_jPanel.Yname = d.Name + ":";
            }
            if (ObjectGuid.ZAxis == d.ObjectType)
            {
                m_jPanel.Ze    = true;
                m_jPanel.Zname = d.Name + ":";
            }
            if (ObjectGuid.RxAxis == d.ObjectType)
            {
                m_jPanel.Xre    = true;
                m_jPanel.Xrname = d.Name + ":";
            }
            if (ObjectGuid.RyAxis == d.ObjectType)
            {
                m_jPanel.Yre    = true;
                m_jPanel.Yrname = d.Name + ":";
            }
            if (ObjectGuid.RzAxis == d.ObjectType)
            {
                m_jPanel.Zre    = true;
                m_jPanel.Zrname = d.Name + ":";
            }
            if (ObjectGuid.Slider == d.ObjectType)
            {
                switch (m_sliderCount++)
                {
                case 0:
                    m_jPanel.S1e    = true;
                    m_jPanel.S1name = d.Name + ":";
                    break;

                case 1:
                    m_jPanel.S2e    = true;
                    m_jPanel.S2name = d.Name + ":";
                    break;
                }
            }
            if (ObjectGuid.PovController == d.ObjectType)
            {
                switch (m_numPOVs++)
                {
                case 0:
                    m_jPanel.H1e    = true;
                    m_jPanel.H1name = d.Name + ":";
                    break;

                case 1:
                    m_jPanel.H2e    = true;
                    m_jPanel.H2name = d.Name + ":";
                    break;

                case 2:
                    m_jPanel.H3e    = true;
                    m_jPanel.H3name = d.Name + ":";
                    break;

                case 3:
                    m_jPanel.H4e    = true;
                    m_jPanel.H4name = d.Name + ":";
                    break;
                }
            }
        }
Exemplo n.º 30
0
        void UpdateControl(DeviceObjectInstance d)
        {
            if (ObjectGuid.XAxis == d.ObjectTypeGuid)
            {
                label_XAxis.Enabled = true;
                label_X.Enabled     = true;
            }
            if (ObjectGuid.YAxis == d.ObjectTypeGuid)
            {
                label_YAxis.Enabled = true;
                label_Y.Enabled     = true;
            }
            if (ObjectGuid.ZAxis == d.ObjectTypeGuid)
            {
                label_ZAxis.Enabled = true;
                label_Z.Enabled     = true;
            }
            if (ObjectGuid.RotationalXAxis == d.ObjectTypeGuid)
            {
                label_XRotation.Enabled = true;
                label_XRot.Enabled      = true;
            }
            if (ObjectGuid.RotationalYAxis == d.ObjectTypeGuid)
            {
                label_YRotation.Enabled = true;
                label_YRot.Enabled      = true;
            }
            if (ObjectGuid.RotationalZAxis == d.ObjectTypeGuid)
            {
                label_ZRotation.Enabled = true;
                label_ZRot.Enabled      = true;
            }

            if (ObjectGuid.Slider == d.ObjectTypeGuid)
            {
                switch (SliderCount++)
                {
                case 0:
                    label_Slider0.Enabled = true;
                    label_S0.Enabled      = true;
                    break;

                case 1:
                    label_Slider1.Enabled = true;
                    label_S1.Enabled      = true;
                    break;
                }
            }

            if (ObjectGuid.PovController == d.ObjectTypeGuid)
            {
                switch (numPOVs++)
                {
                case 0:
                    label_POV0.Enabled = true;
                    label_P0.Enabled   = true;
                    break;

                case 1:
                    label_POV1.Enabled = true;
                    label_P1.Enabled   = true;
                    break;

                case 2:
                    label_POV2.Enabled = true;
                    label_P2.Enabled   = true;
                    break;

                case 3:
                    label_POV3.Enabled = true;
                    label_P3.Enabled   = true;
                    break;
                }
            }
        }
 public AxisInformation(DeviceObjectInstance axisObject)
 {
     Name            = axisObject.Name;
     MaxForce        = axisObject.MaxForce;
     ForceResolution = axisObject.ForceResolution;
 }
Exemplo n.º 32
0
 public static DirectInputSource FromButton(IInputDevice device, DeviceObjectInstance instance, int index)
 {
     return(new DirectInputSource(device, "Button " + instance.Usage, SourceTypes.Button, instance.Offset, state => state.Buttons[index] ? 1 : 0));
 }