DirectInput.dlm Reference
General directinput.dlm Functions
di_InitInterface
The di_InitInterface function creates an instance of a DirectInput object This is the first step in providing IDL access to DirectInput devices. If
successful the function will return a byte array representing a pointer to
the directInput interface. If unsuccessful, the function returns a negative
scalar value.
diInterfaceID = di_InitInterface()
di_DestroyInterface
The di_DestroyInterface function releases the DirectInput object
represented by interface ID parameter. It is important to release any devices
that are acquired by the interface before destroying the interface itself.
Failing to destroy objects correctly will result in the loss of system resources
that will persist until your machine is restarted. The function will always
return TRUE.
ok = di_DestroyInterface(diInterfaceID)
directinput.dlm Keyboard Functions
di_AcquireKeyboard
The di_AcquireKeyboard function creates an instance of a DirectInput
keyboard device. Since devices are associated with windows, the function gets a
handle to the current active window and associates the device with that window.
Thus it is best to acquire the device immediately after you realize the top level
base you desire keyboard input from. Setting the /exclusive keyword
will acquire the device in exclusive mode denying all other windows access to the
device while it has focus. This includes all children of the top level base widget
window that is acquired. By default the keyboard is acquired in exclusive mode. If
successful the function will return a byte array representing a pointer to the
directInput interface. If unsuccessful, the function returns a negative scalar value.
diKbdID = di_AcquireKeyboard(diInterfaceID, $ EXCLUSIVE=0)
di_PollKeyboard
The di_PollKeyboard function returns a 256 element byte array containing the status of the 256 hardware keys. If the function is unable to poll the device (there is no keyboard device acquired or the device doesn't have focus) it will return 0. Use the where function to determine which keys were depressed at the time of the poll:
keys = WHERE(di_PollKeyboard(diKbdID) ne 0)
di_ReleaseKeyboard
The di_ReleaseKeyboard function releases the DirectInput keyboard device. The function will always return TRUE.
ok = di_ReleaseKeyboard(diKbdID)
directinput.dlm Mouse Functions
di_AcquireMouse
The di_AcquireMouse function creates an instance of a DirectInput mouse device. Since devices are associated with windows, the function gets a handle to the current active window and associates the device with that window. Thus it is best to acquire the device immediately after you realize the top level base you desire mouse input from. Setting the /exclusive keyword will acquire the device in exclusive mode denying all other windows access to the device while it has focus. This includes the windows desktop! Because of this, by default the mouse is acquired in nonexclusive mode. If successful the function will return a byte array representing a pointer to the mouse interface. If unsuccessful, the function returns a negative scalar value.
diMouseID = di_AcquireMouse(diInterfaceID, $ EXCLUSIVE=0)
di_ConfigureMouse
The di_ConfigureMouse function opens the Windows mouse properties control panel.
ok = di_ConfigureMouse(diMouseID)
di_PollMouse
The di_PollMouse function returns a structure containing the status of the acquired mouse. If the function is unable to poll the device (there is no mouse device acquired or the device doesn't have focus) it will return 0. The format of the returned structure is as follows:
mstate = {x:0L, $ y:0L, $ z:0L, $ buttons:BYTARR(8) $ }
where X and Y are the horizontal and vertical locations of the mouse relative to the last poll in pixels, Z is the position of the mouse scroll wheel relative to the last poll and buttons is the state of the 8 possible mouse buttons where 0 is up and 1 is down.
mstate = di_PollMouse(diMouseID)
di_ReleaseMouse
The di_ReleaseMouse function releases the DirectInput mouse device. The function will always return true.
ok = di_ReleaseMouse(diMouseID)
directinput.dlm Joystick Functions
di_AcquireJoystick
The di_AcquireJoystick function creates an instance of a DirectInput joystick device. Since devices are associated with windows, the function gets a handle to the current active window and associates the device with that window. Thus it is best to acquire the device immediately after you realize the top level base you desire joystick input from. Upon acquisition, the function enumerates all of the game devices attached to the system but currently acquires the first device it finds. It is generally safe and desirable to acquire the joystick in exclusive mode so by default exclusive is set to true.
If successful the function will return a byte array representing a pointer to the joystick interface. If unsuccessful, the function returns a negative scalar value.
diJoyID = di_AcquireJoystick(diInterfaceID, $ /EXCLUSIVE)
di_ConfigureJoystick
The di_ConfigureJoystick function opens the windows Gaming Devices control panel. This control panel can be used to add or configure joystick devices.
ok = di_ConfigureJoystick(diJoyID)
di_PollJoystick
The di_PollJoystick function returns a structure containing the status of the acquired joystick. If the function is unable to poll the device (there is no joystick device acquired or the device doesn't have focus) it will return 0. The format of the returned structure is as follows:
jstate = {x:0L, $ y:0L, $ z:0L, $ rx:0L, $ ry:0L, $ rz:0L, $ slider:LONARR(2), $ pov:INTARR(4), $ buttons:BYTARR(16) $ }where X, Y and Z are the X, Y, and Z positions of the jostick; rX, rY, and rZ are the X, Y, and Z axis rotations; slider is the status of two additional axes; pov is the position of the Point-of-View or "Top Hat" controller where the value is the position in degrees clockwise from north (away from the user) and the center is -1; buttons is the state of the first 16 buttons on the device where 0 is up and 1 is down.
jstate = di_PollJoystick(diJoyID)
di_ReleaseJoystick
The di_ReleaseJoystick function releases the DirectInput joystick device. The function will always return true.
ok = di_ReleaseJoystick(diJoyID)