Microsoft DirectX 8.1 (Visual Basic) |
Properties of Microsoft® DirectInput® devices include the size of the data buffer, the range and granularity of values returned from an axis, whether axis data is relative or absolute, and the dead zone and saturation values for a joystick axis. Specialized devices can have other properties as well. For a list of properties defined by DirectInput, see DirectInputDevice8.GetProperty.
With one exception—the gain property of a force-feedback device—properties can be changed only when the device is in an unacquired state.
The DirectInputDevice8.SetProperty and DirectInputDevice8.GetProperty methods take two parameters: a GUID alias in string form that identifies the property being set, and data of type Any. The data is actually passed in one of the following types:
For SetProperty, the data members of the property types are the values you want to set. For GetProperty, the current value is returned in these members.
In addition to the actual property data, both these types contain two other members: lHow and lObj.
The values in lHow and lObj work together, with lHow signifying the system that is used to identify the device object whose property is being set or retrieved, and lObj identifying the device object.
If lHow is DIPH_BYID, the device object is described by a unique numerical identifier in lObj. This ID can be extracted from the value returned by DirectInputDeviceObjectInstance.GetType after device objects have been enumerated.
For most applications, it is simpler to identify the device object by its offset within the data structure established by DirectInputDevice8.SetCommonDataFormat or DirectInputDevice8.SetDataFormat. In this case, lHow is DIPH_BYOFFSET, and lObj is the offset, in bytes. For the keyboard, mouse, and any game controller whose data can be returned in a DIJOYSTATE or DIJOYSTATE2 type, the device object can be identified by a predefined constant. See CONST_DIKEYFLAGS, CONST_DIMOUSEOFS, and CONST_DIJOYSTICKOFS.
The lHow member can also contain DIPH_DEVICE, which means that the property belongs to the entire device, rather than a single device object. Buffer size is an example of such a property. When lHow is DIPH_DEVICE, lObj is 0.
The following strings are used to identify the property passed to SetProperty and GetProperty. For more information, see DirectInputDevice8.GetProperty.
For more information about dead zone, range, and saturation, see also Interpreting Joystick Axis Data.
The following code example sets the buffer size for a device:
' diDev is a DirectInputDevice whose data format has been set. Dim diProp As DIPROPLONG diProp.lHow = DIPH_DEVICE diProp.lObj = 0 diProp.lData = 10 Call diDev.SetProperty("DIPROP_BUFFERSIZE", diProp)