/// <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; }
/// <summary> /// Hidden constructor -- forces callers to use one of the static factory methods /// on this class. /// Creates a new DIDeviceMonitor object /// </summary> /// <param name="device"> /// a DIPhysicalDeviceInfo object representing the /// DirectInput Device Instance to monitor /// </param> /// <param name="parentForm"> /// and an (optional) reference to a parent Windows Form /// which will receive events directly from DirectInput if eventing is enabled /// (currently, not implemented) /// </param> /// <param name="axisRangeMin"> /// Value to report when an axis is reporting its /// MINIMUM value /// </param> /// <param name="axisRangeMax"> /// Value to report when an axis is reporting its /// MAXIMUM value /// </param> private DIDeviceMonitor(DIPhysicalDeviceInfo device, Control parentForm, int axisRangeMin, int axisRangeMax) { DeviceInfo = device; _parentForm = parentForm; _axisRangeMin = axisRangeMin; _axisRangeMax = axisRangeMax; Prepare(); }
/// <summary> /// Factory method to create instances of this class. Stands in place of a constructor, /// in order to re-use instances /// when relevant constructor parameters are the same /// </summary> /// <param name="device"> /// a <see cfef="DIPhysicalDeviceInfo" /> object representing the /// DirectInput Device Instance to monitor /// </param> /// <param name="parentForm"> /// and an (optional) reference to a parent Windows Form /// which will receive events directly from DirectInput if eventing is enabled /// (currently, not implemented) /// </param> /// <param name="axisRangeMin"> /// Value to report when an axis is reporting its /// MINIMUM value /// </param> /// <param name="axisRangeMax"> /// Value to report when an axis is reporting its /// MAXIMUM value /// </param> /// <returns> /// a DIDeviceMonitor object representing the DirectInput device being /// monitored, either created newly from-scratch, or returned from this class's /// internal object pool if a monitor instance already exists /// </returns> public static DIDeviceMonitor GetInstance(DIPhysicalDeviceInfo device, Control parentForm, int axisRangeMin, int axisRangeMax) { var deviceId = new Guid(device.Key.ToString()); if (_monitors.ContainsKey(deviceId)) { return(_monitors[deviceId]); } var monitor = new DIDeviceMonitor(device, parentForm, axisRangeMin, axisRangeMax); _monitors.Add(deviceId, monitor); return(monitor); }