Unit Joystick
Return to Unit Reference
Description
Ultibo Joystick and Gamepad Interface unit
Gamepads are almost universally used to control game consoles and other gaming platforms as they provide an easy way to interact with many different types of movement in gaming scenarios.
They range from simple devices with a 4 way rocker switch (often known as the D-pad) and a small number of push buttons to elaborate units with multi-axis controls and buttons that cover a whole range of uses.
Joysticks are used for more than just gaming, many modern industrial machines use a joystick as the primary control interface. Even common machines like ride on lawn mowers and earth moving equipment often feature a joystick type of control mechanism.
Devices such as flight simulator yokes will often also appear as a joystick to the system as the available ranges of movement and the reported axes are the same.
Constants
To be documented
Type definitions
Joystick data
PJoystickData = ^TJoystickData;
TJoystickData = record
AxisCount:LongInt;
|
The number of Axes reported by this device |
Axes:array[0..JOYSTICK_MAX_AXIS - 1] of SmallInt;
|
The currently reported value of each Axis |
HatCount:LongInt;
|
The number of Hats reported by this device |
Hats:array[0..JOYSTICK_MAX_HAT - 1] of SmallInt;
|
The currently reported value of each Hat |
ButtonCount:LongInt;
|
The number of Buttons reported by this device |
Buttons:LongWord;
|
The currently reported state of each Button |
Parameter:Pointer;
|
The parameter for the event callback (If applicable) |
Joystick buffer
PJoystickBuffer = ^TJoystickBuffer;
TJoystickBuffer = record
Wait:TSemaphoreHandle;
|
Buffer ready semaphore |
Start:LongWord;
|
Index of first buffer ready |
Count:LongWord;
|
Number of entries ready in buffer |
Buffer:array[0..(JOYSTICK_BUFFER_SIZE - 1)] of TJoystickData;
|
Joystick extent
PJoystickExtent = ^TJoystickExtent;
TJoystickExtent = record
Minimum:LongInt;
|
The minimum value for this extent |
Maximum:LongInt;
|
The maximum value for this extent |
Joystick axis
PJoystickAxis = ^TJoystickAxis;
TJoystickAxis = record
Name:LongWord;
|
The associated name (identifier) for this Axis |
Logical:TJoystickExtent;
|
The minimum and maximum logical values for this Axis |
Physical:TJoystickExtent;
|
The minimum and maximum physical values for this Axis |
Multiplier:Double;
|
The conversion multiplier for this Axis from logical to physical units |
Resolution:Double;
|
The unit resolution for this Axis in counts per physical unit |
Joystick hat
PJoystickHat = ^TJoystickHat;
TJoystickHat = record
Name:LongWord;
|
The associated name (identifier) for this Hat |
Logical:TJoystickExtent;
|
The minimum and maximum logical values for this Hat |
Physical:TJoystickExtent;
|
The minimum and maximum physical values for this Hat |
Multiplier:Double;
|
The conversion multiplier for this Hat from logical to physical units |
Resolution:Double;
|
The unit resolution for this Hat in counts per physical unit |
Joystick properties
PJoystickProperties = ^TJoystickProperties;
TJoystickProperties = record
Flags:LongWord;
|
Device flags (eg JOYSTICK_FLAG_LED) |
AxisCount:LongWord;
|
The number of Axes reported by this device |
Axes:array[0..JOYSTICK_MAX_AXIS - 1] of TJoystickAxis;
|
The current properties of each Axis |
HatCount:LongWord;
|
The number of Hats reported by this device |
Hats:array[0..JOYSTICK_MAX_HAT - 1] of TJoystickHat;
|
The current properties of each Hat |
ButtonCount:LongWord;
|
The number of Buttons reported by this device |
Buttons:array[0..JOYSTICK_MAX_BUTTON - 1] of LongWord;
|
The current name (identifier) of each Button |
Joystick event callback
TJoystickEvent = function(Joystick:PJoystickDevice; Data:PJoystickData):LongWord;
|
Joystick enumeration callback
TJoystickEnumerate = function(Joystick:PJoystickDevice; Data:Pointer):LongWord;
|
Joystick notification callback
TJoystickNotification = function(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;
|
Joystick device start
TJoystickDeviceStart = function(Joystick:PJoystickDevice):LongWord;
|
Joystick device stop
TJoystickDeviceStop = function(Joystick:PJoystickDevice):LongWord;
|
Joystick device peek
TJoystickDevicePeek = function(Joystick:PJoystickDevice):LongWord;
|
Joystick device read
TJoystickDeviceRead = function(Joystick:PJoystickDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
|
Joystick device write
TJoystickDeviceWrite = function(Joystick:PJoystickDevice; Buffer:Pointer; Size,Count:LongWord):LongWord;
|
Joystick device flush
TJoystickDeviceFlush = function(Joystick:PJoystickDevice):LongWord;
|
Joystick device update
TJoystickDeviceUpdate = function(Joystick:PJoystickDevice):LongWord;
|
Joystick device control
TJoystickDeviceControl = function(Joystick:PJoystickDevice; Request:Integer; Argument1:PtrUInt; var Argument2:PtrUInt):LongWord;
|
Joystick device get properties
TJoystickDeviceGetProperties = function(Joystick:PJoystickDevice; Properties:PJoystickProperties):LongWord;
|
Joystick device
PJoystickDevice = ^TJoystickDevice;
TJoystickDevice = record
Device Properties | |
Device:TDevice;
|
The Device entry for this Joystick device |
Joystick Properties | |
JoystickId:LongWord;
|
Unique Id of this Joystick device in the Joystick device table |
JoystickState:LongWord;
|
Joystick device state (eg JOYSTICK_STATE_ENABLED) |
DeviceStart:TJoystickDeviceStart;
|
A Device specific DeviceStart method implementing the standard Joystick device interface (Mandatory) |
DeviceStop:TJoystickDeviceStop;
|
A Device specific DeviceStop method implementing the standard Joystick device interface (Mandatory) |
DevicePeek:TJoystickDevicePeek;
|
A Device specific DevicePeek method implementing a standard Joystick device interface (Or nil if the default method is suitable) |
DeviceRead:TJoystickDeviceRead;
|
A Device specific DeviceRead method implementing a standard Joystick device interface (Or nil if the default method is suitable) |
DeviceWrite:TJoystickDeviceWrite;
|
A Device specific DeviceWrite method implementing a standard Joystick device interface (Or nil if the default method is suitable) |
DeviceFlush:TJoystickDeviceFlush;
|
A Device specific DeviceFlush method implementing a standard Joystick device interface (Or nil if the default method is suitable) |
DeviceUpdate:TJoystickDeviceUpdate;
|
A Device specific DeviceUpdate method implementing a standard Joystick device interface (Or nil if the default method is suitable) |
DeviceControl:TJoystickDeviceControl;
|
A Device specific DeviceControl method implementing a standard Joystick device interface (Or nil if the default method is suitable) |
DeviceGetProperties:TJoystickDeviceGetProperties;
|
A Device specific DeviceGetProperties method implementing a standard Joystick device interface (Or nil if the default method is suitable) |
Driver Properties | |
Lock:TMutexHandle;
|
Device lock |
Event:TJoystickEvent;
|
Event callback function (If assigned) |
Parameter:Pointer;
|
Parameter for the event callback (or nil) |
Buffer:TJoystickBuffer;
|
Joystick input buffer |
Properties:TJoystickProperties;
|
Device properties |
Statistics Properties | |
ReceiveCount:LongWord;
|
|
ReceiveErrors:LongWord;
|
|
BufferOverruns:LongWord;
|
|
Internal Properties | |
Prev:PJoystickDevice;
|
Previous entry in Joystick device table |
Next:PJoystickDevice;
|
Next entry in Joystick device table |
Public variables
Joystick logging
JOYSTICK_DEFAULT_LOG_LEVEL:LongWord = JOYSTICK_LOG_LEVEL_DEBUG;
|
Minimum level for Joystick messages. Only messages with level greater than or equal to this will be printed. |
JOYSTICK_LOG_ENABLED:Boolean;
|
Function declarations
To be documented
Return to Unit Reference