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
[Expand]
Joystick specific constants JOYSTICK_*
JOYSTICK_NAME_PREFIX = 'Joystick';
|
Name prefix for Joystick Devices
|
[Expand]
Joystick device types JOYSTICK_TYPE_*
JOYSTICK_TYPE_NONE = 0;
|
|
JOYSTICK_TYPE_JOYSTICK = 1;
|
|
JOYSTICK_TYPE_GAMEPAD = 2;
|
|
|
JOYSTICK_TYPE_MAX = 2;
|
|
Joystick Type Names
|
JOYSTICK_TYPE_NAMES:array[JOYSTICK_TYPE_NONE..JOYSTICK_TYPE_MAX] of String = ('JOYSTICK_TYPE_NONE', 'JOYSTICK_TYPE_JOYSTICK', 'JOYSTICK_TYPE_GAMEPAD');
|
[Expand]
Joystick device states JOYSTICK_STATE_*
JOYSTICK_STATE_DISABLED = 0;
|
|
JOYSTICK_STATE_ENABLED = 1;
|
|
|
JOYSTICK_STATE_MAX = 1;
|
|
Joystick State Names
|
JOYSTICK_TYPE_NAMES:array[JOYSTICK_TYPE_NONE..JOYSTICK_TYPE_MAX] of String = ('JOYSTICK_TYPE_NONE', 'JOYSTICK_TYPE_JOYSTICK', 'JOYSTICK_TYPE_GAMEPAD');
|
[Expand]
Joystick device flags JOYSTICK_FLAG_*
JOYSTICK_FLAG_NONE = $00000000;
|
|
JOYSTICK_FLAG_NON_BLOCK = $00000001;
|
If set device reads are non blocking (Also supported in Flags parameter of JoystickDeviceRead)
|
JOYSTICK_FLAG_PEEK_BUFFER = $00000002;
|
Peek at the buffer to see if any data is available, don't remove it (Used only in Flags parameter of JoystickDeviceRead)
|
JOYSTICK_FLAG_LED = $00000004;
|
If set the device contains one or more LEDs
|
JOYSTICK_FLAG_RGBLED = $00000008;
|
If set the device contains one or more RGB LEDs
|
JOYSTICK_FLAG_RUMBLE = $00000010;
|
If set the device has rumble or force feedback
|
JOYSTICK_FLAG_GYROSCOPE = $00000020;
|
If set the device contains a gyroscope
|
JOYSTICK_FLAG_TOUCHPAD = $00000040;
|
If set the device contains a touchpad
|
|
Flags supported by JOYSTICK_CONTROL_GET/SET/CLEAR_FLAG
|
JOYSTICK_FLAG_MASK = JOYSTICK_FLAG_NON_BLOCK or JOYSTICK_FLAG_LED or JOYSTICK_FLAG_RGBLED or JOYSTICK_FLAG_RUMBLE or JOYSTICK_FLAG_GYROSCOPE or JOYSTICK_FLAG_TOUCHPAD;
|
[Expand]
Joystick device control codes JOYSTICK_CONTROL_*
JOYSTICK_CONTROL_GET_FLAG = 1;
|
Get Flag
|
JOYSTICK_CONTROL_SET_FLAG = 2;
|
Set Flag
|
JOYSTICK_CONTROL_CLEAR_FLAG = 3;
|
Clear Flag
|
JOYSTICK_CONTROL_FLUSH_BUFFER = 4;
|
Flush Buffer
|
JOYSTICK_CONTROL_GET_HAT = 5;
|
Get the name (identifier) associated with a Hat
|
JOYSTICK_CONTROL_SET_HAT = 6;
|
Set the name (identifier) associated with a Hat
|
JOYSTICK_CONTROL_GET_AXIS = 7;
|
Get the name (identifier) associated with an Axis
|
JOYSTICK_CONTROL_SET_AXIS = 8;
|
Set the name (identifier) associated with an Axis
|
JOYSTICK_CONTROL_GET_BUTTON = 9;
|
Get the name (identifier) associated with a Button
|
JOYSTICK_CONTROL_SET_BUTTON = 10;
|
Set the name (identifier) associated with a Button
|
JOYSTICK_CONTROL_GET_CALLBACK = 11;
|
Get the registered callback function for joystick events
|
JOYSTICK_CONTROL_SET_CALLBACK = 12;
|
Set the registered callback function for joystick events
|
[Expand]
Joystick buffer size JOYSTICK_BUFFER_*
JOYSTICK_BUFFER_SIZE = 2048;
|
|
[Expand]
Joystick axis, hat and button maximum JOYSTICK_MAX_*
JOYSTICK_MAX_AXIS = 16;
|
|
JOYSTICK_MAX_HAT = 4;
|
|
JOYSTICK_MAX_BUTTON = 32;
|
|
[Expand]
Joystick default minimum and maximum JOYSTICK_DEFAULT_*
JOYSTICK_DEFAULT_MINIMUM = 0;
|
|
JOYSTICK_DEFAULT_MAXIMUM = 255;
|
|
[Expand]
Joystick and Gamepad axis names JOYSTICK_AXIS_*
Includes Buttons, Sliders, Wheels etc that report an analog value)
|
JOYSTICK_AXIS_NONE = 0;
|
|
JOYSTICK_AXIS_1 = 1;
|
|
JOYSTICK_AXIS_2 = 2;
|
|
JOYSTICK_AXIS_3 = 3;
|
|
JOYSTICK_AXIS_4 = 4;
|
|
JOYSTICK_AXIS_5 = 5;
|
|
JOYSTICK_AXIS_6 = 6;
|
|
JOYSTICK_AXIS_7 = 7;
|
|
JOYSTICK_AXIS_8 = 8;
|
|
JOYSTICK_AXIS_9 = 9;
|
|
JOYSTICK_AXIS_10 = 10;
|
|
JOYSTICK_AXIS_11 = 11;
|
|
JOYSTICK_AXIS_12 = 12;
|
|
JOYSTICK_AXIS_13 = 13;
|
|
JOYSTICK_AXIS_14 = 14;
|
|
JOYSTICK_AXIS_15 = 15;
|
|
JOYSTICK_AXIS_16 = 16;
|
|
|
JOYSTICK_AXIS_X = 17;
|
X
|
JOYSTICK_AXIS_Y = 18;
|
Y
|
JOYSTICK_AXIS_Z = 19;
|
Z
|
JOYSTICK_ROTATION_X = 20;
|
Rotation X
|
JOYSTICK_ROTATION_Y = 21;
|
Rotation Y
|
JOYSTICK_ROTATION_Z = 22;
|
Rotation Z
|
JOYSTICK_SLIDER = 23;
|
Slider
|
|
GAMEPAD_AXIS_LEFT_X = 24;
|
Left X
|
GAMEPAD_AXIS_LEFT_Y = 25;
|
Left Y
|
GAMEPAD_AXIS_X = GAMEPAD_AXIS_LEFT_X;
|
|
GAMEPAD_AXIS_Y = GAMEPAD_AXIS_LEFT_Y;
|
|
GAMEPAD_AXIS_RIGHT_X = 26;
|
Right X
|
GAMEPAD_AXIS_RIGHT_Y = 27;
|
Right Y
|
GAMEPAD_CONTROL_LT = 28;
|
Left Trigger analog button
|
GAMEPAD_CONTROL_L2 = GAMEPAD_CONTROL_LT;
|
|
GAMEPAD_CONTROL_RT = 29;
|
Right Trigger analog button
|
GAMEPAD_CONTROL_R2 = GAMEPAD_CONTROL_RT;
|
|
GAMEPAD_CONTROL_UP = 30;
|
Up analog button
|
GAMEPAD_CONTROL_RIGHT = 31;
|
Right analog button
|
GAMEPAD_CONTROL_DOWN = 32;
|
Down analog button
|
GAMEPAD_CONTROL_LEFT = 33;
|
Left analog button
|
GAMEPAD_CONTROL_L1 = 34;
|
L1 analog button
|
GAMEPAD_CONTROL_R1 = 35;
|
R1 analog button
|
GAMEPAD_CONTROL_TRIANGLE = 36;
|
Triangle analog button
|
GAMEPAD_CONTROL_CIRCLE = 37;
|
Circle analog button
|
GAMEPAD_CONTROL_CROSS = 38;
|
Cross analog button
|
GAMEPAD_CONTROL_SQUARE = 39;
|
Square analog button
|
|
JOYSTICK_AXIS_MAX = 39;
|
|
|
Joystick and Gamepad Axis Names
|
JOYSTICK_AXIS_NAMES:array[JOYSTICK_AXIS_NONE..JOYSTICK_AXIS_MAX] of String = (
|
|
'JOYSTICK_AXIS_NONE',
|
|
'JOYSTICK_AXIS_1',
|
|
'JOYSTICK_AXIS_2',
|
|
'JOYSTICK_AXIS_3',
|
|
'JOYSTICK_AXIS_4',
|
|
'JOYSTICK_AXIS_5',
|
|
'JOYSTICK_AXIS_6',
|
|
'JOYSTICK_AXIS_7',
|
|
'JOYSTICK_AXIS_8',
|
|
'JOYSTICK_AXIS_9',
|
|
'JOYSTICK_AXIS_10',
|
|
'JOYSTICK_AXIS_11',
|
|
'JOYSTICK_AXIS_12',
|
|
'JOYSTICK_AXIS_13',
|
|
'JOYSTICK_AXIS_14',
|
|
'JOYSTICK_AXIS_15',
|
|
'JOYSTICK_AXIS_16',
|
|
|
'JOYSTICK_AXIS_X',
|
|
'JOYSTICK_AXIS_Y',
|
|
'JOYSTICK_AXIS_Z',
|
|
'JOYSTICK_ROTATION_X',
|
|
'JOYSTICK_ROTATION_Y',
|
|
'JOYSTICK_ROTATION_Z',
|
|
'JOYSTICK_SLIDER',
|
|
|
'GAMEPAD_AXIS_LEFT_X',
|
|
'GAMEPAD_AXIS_LEFT_Y',
|
|
'GAMEPAD_AXIS_RIGHT_X',
|
|
'GAMEPAD_AXIS_RIGHT_Y',
|
|
'GAMEPAD_CONTROL_LT',
|
|
'GAMEPAD_CONTROL_RT',
|
|
'GAMEPAD_CONTROL_UP',
|
|
'GAMEPAD_CONTROL_RIGHT',
|
|
'GAMEPAD_CONTROL_DOWN',
|
|
'GAMEPAD_CONTROL_LEFT',
|
|
'GAMEPAD_CONTROL_L1',
|
|
'GAMEPAD_CONTROL_R1',
|
|
'GAMEPAD_CONTROL_TRIANGLE',
|
|
'GAMEPAD_CONTROL_CIRCLE',
|
|
'GAMEPAD_CONTROL_CROSS',
|
|
'GAMEPAD_CONTROL_SQUARE');
|
|
[Expand]
Joystick and Gamepad hat names JOYSTICK_HAT*
JOYSTICK_HAT_NONE = 0;
|
|
JOYSTICK_HAT_1 = 1;
|
|
JOYSTICK_HAT_2 = 2;
|
|
JOYSTICK_HAT_3 = 3;
|
|
JOYSTICK_HAT_4 = 4;
|
|
|
JOYSTICK_HAT_POV = 5;
|
Point of View (POV)
|
|
JOYSTICK_HAT_MAX = 5;
|
|
|
Joystick and Gamepad Hat Names
|
JOYSTICK_HAT_NAMES:array[JOYSTICK_HAT_NONE..JOYSTICK_HAT_MAX] of String = (
|
|
'JOYSTICK_HAT_NONE',
|
|
'JOYSTICK_HAT_1',
|
|
'JOYSTICK_HAT_2',
|
|
'JOYSTICK_HAT_3',
|
|
'JOYSTICK_HAT_4',
|
|
|
'JOYSTICK_HAT_POV');
|
|
[Expand]
Joystick and Gamepad button names JOYSTICK_BUTTON_*
JOYSTICK_BUTTON_NONE = 0;
|
|
JOYSTICK_BUTTON_1 = 1;
|
|
JOYSTICK_BUTTON_2 = 2;
|
|
JOYSTICK_BUTTON_3 = 3;
|
|
JOYSTICK_BUTTON_4 = 4;
|
|
JOYSTICK_BUTTON_5 = 5;
|
|
JOYSTICK_BUTTON_6 = 6;
|
|
JOYSTICK_BUTTON_7 = 7;
|
|
JOYSTICK_BUTTON_8 = 8;
|
|
JOYSTICK_BUTTON_9 = 9;
|
|
JOYSTICK_BUTTON_10 = 10;
|
|
JOYSTICK_BUTTON_11 = 11;
|
|
JOYSTICK_BUTTON_12 = 12;
|
|
JOYSTICK_BUTTON_13 = 13;
|
|
JOYSTICK_BUTTON_14 = 14;
|
|
JOYSTICK_BUTTON_15 = 15;
|
|
JOYSTICK_BUTTON_16 = 16;
|
|
JOYSTICK_BUTTON_17 = 17;
|
|
JOYSTICK_BUTTON_18 = 18;
|
|
JOYSTICK_BUTTON_19 = 19;
|
|
JOYSTICK_BUTTON_20 = 20;
|
|
JOYSTICK_BUTTON_21 = 21;
|
|
JOYSTICK_BUTTON_22 = 22;
|
|
JOYSTICK_BUTTON_23 = 23;
|
|
JOYSTICK_BUTTON_24 = 24;
|
|
JOYSTICK_BUTTON_25 = 25;
|
|
JOYSTICK_BUTTON_26 = 26;
|
|
JOYSTICK_BUTTON_27 = 27;
|
|
JOYSTICK_BUTTON_28 = 28;
|
|
JOYSTICK_BUTTON_29 = 29;
|
|
JOYSTICK_BUTTON_30 = 30;
|
|
JOYSTICK_BUTTON_31 = 31;
|
|
JOYSTICK_BUTTON_32 = 32;
|
|
|
GAMEPAD_BUTTON_HOME = 33;
|
Home or special function button
|
GAMEPAD_BUTTON_PS = GAMEPAD_BUTTON_HOME;
|
Playstation button
|
GAMEPAD_BUTTON_XBOX = GAMEPAD_BUTTON_HOME;
|
XBox button
|
GAMEPAD_BUTTON_GUIDE = GAMEPAD_BUTTON_HOME;
|
Guide button
|
GAMEPAD_BUTTON_LT = 34;
|
Left Trigger button
|
GAMEPAD_BUTTON_L2 = GAMEPAD_BUTTON_LT;
|
|
GAMEPAD_BUTTON_LZ = GAMEPAD_BUTTON_LT;
|
|
GAMEPAD_BUTTON_RT = 35;
|
Right Trigger button
|
GAMEPAD_BUTTON_R2 = GAMEPAD_BUTTON_RT;
|
|
GAMEPAD_BUTTON_RZ = GAMEPAD_BUTTON_RT;
|
|
GAMEPAD_BUTTON_LB = 36;
|
Left Bumper button
|
GAMEPAD_BUTTON_L1 = GAMEPAD_BUTTON_LB;
|
|
GAMEPAD_BUTTON_L = GAMEPAD_BUTTON_LB;
|
|
GAMEPAD_BUTTON_RB = 37;
|
Right Bumper button
|
GAMEPAD_BUTTON_R1 = GAMEPAD_BUTTON_RB;
|
|
GAMEPAD_BUTTON_R = GAMEPAD_BUTTON_RB;
|
|
GAMEPAD_BUTTON_Y = 38;
|
Y button
|
GAMEPAD_BUTTON_TRIANGLE = GAMEPAD_BUTTON_Y;
|
Triangle button
|
GAMEPAD_BUTTON_B = 39;
|
B button
|
GAMEPAD_BUTTON_CIRCLE = GAMEPAD_BUTTON_B;
|
Circle button
|
GAMEPAD_BUTTON_A = 40;
|
A button
|
GAMEPAD_BUTTON_CROSS = GAMEPAD_BUTTON_A;
|
Cross button
|
GAMEPAD_BUTTON_X = 41;
|
X button
|
GAMEPAD_BUTTON_SQUARE = GAMEPAD_BUTTON_X;
|
Square button
|
GAMEPAD_BUTTON_SELECT = 42;
|
Select button
|
GAMEPAD_BUTTON_BACK = GAMEPAD_BUTTON_SELECT;
|
Back button
|
GAMEPAD_BUTTON_SHARE = GAMEPAD_BUTTON_SELECT;
|
Share button
|
GAMEPAD_BUTTON_CAPTURE = GAMEPAD_BUTTON_SELECT;
|
Capture button
|
GAMEPAD_BUTTON_L3 = 43;
|
Left Stick or Left Axis button
|
GAMEPAD_BUTTON_SL = GAMEPAD_BUTTON_L3;
|
|
GAMEPAD_BUTTON_R3 = 44;
|
Right Stick or Right Axis button
|
GAMEPAD_BUTTON_SR = GAMEPAD_BUTTON_R3;
|
|
GAMEPAD_BUTTON_START = 45;
|
Start button
|
GAMEPAD_BUTTON_OPTIONS = GAMEPAD_BUTTON_START;
|
|
GAMEPAD_BUTTON_UP = 46;
|
Up button
|
GAMEPAD_BUTTON_RIGHT = 47;
|
Right button
|
GAMEPAD_BUTTON_DOWN = 48;
|
Down button
|
GAMEPAD_BUTTON_LEFT = 49;
|
Left button
|
GAMEPAD_BUTTON_PLUS = 50;
|
Plus button
|
GAMEPAD_BUTTON_MINUS = 51;
|
Minus button
|
GAMEPAD_BUTTON_TOUCHPAD = 52;
|
Touchpad button
|
|
JOYSTICK_BUTTON_MAX = 52;
|
|
|
Joystick and Gamepad Button Names
|
JOYSTICK_BUTTON_NAMES:array[JOYSTICK_BUTTON_NONE..JOYSTICK_BUTTON_MAX] of String = (
|
|
'JOYSTICK_BUTTON_NONE',
|
|
'JOYSTICK_BUTTON_1',
|
|
'JOYSTICK_BUTTON_2',
|
|
'JOYSTICK_BUTTON_3',
|
|
'JOYSTICK_BUTTON_4',
|
|
'JOYSTICK_BUTTON_5',
|
|
'JOYSTICK_BUTTON_6',
|
|
'JOYSTICK_BUTTON_7',
|
|
'JOYSTICK_BUTTON_8',
|
|
'JOYSTICK_BUTTON_9',
|
|
'JOYSTICK_BUTTON_10',
|
|
'JOYSTICK_BUTTON_11',
|
|
'JOYSTICK_BUTTON_12',
|
|
'JOYSTICK_BUTTON_13',
|
|
'JOYSTICK_BUTTON_14',
|
|
'JOYSTICK_BUTTON_15',
|
|
'JOYSTICK_BUTTON_16',
|
|
'JOYSTICK_BUTTON_17',
|
|
'JOYSTICK_BUTTON_18',
|
|
'JOYSTICK_BUTTON_19',
|
|
'JOYSTICK_BUTTON_20',
|
|
'JOYSTICK_BUTTON_21',
|
|
'JOYSTICK_BUTTON_22',
|
|
'JOYSTICK_BUTTON_23',
|
|
'JOYSTICK_BUTTON_24',
|
|
'JOYSTICK_BUTTON_25',
|
|
'JOYSTICK_BUTTON_26',
|
|
'JOYSTICK_BUTTON_27',
|
|
'JOYSTICK_BUTTON_28',
|
|
'JOYSTICK_BUTTON_29',
|
|
'JOYSTICK_BUTTON_30',
|
|
'JOYSTICK_BUTTON_31',
|
|
'JOYSTICK_BUTTON_32',
|
|
|
'GAMEPAD_BUTTON_HOME',
|
|
'GAMEPAD_BUTTON_LT',
|
|
'GAMEPAD_BUTTON_RT',
|
|
'GAMEPAD_BUTTON_LB',
|
|
'GAMEPAD_BUTTON_RB',
|
|
'GAMEPAD_BUTTON_Y',
|
|
'GAMEPAD_BUTTON_B',
|
|
'GAMEPAD_BUTTON_A',
|
|
'GAMEPAD_BUTTON_X',
|
|
'GAMEPAD_BUTTON_SELECT',
|
|
'GAMEPAD_BUTTON_L3',
|
|
'GAMEPAD_BUTTON_R3',
|
|
'GAMEPAD_BUTTON_START',
|
|
'GAMEPAD_BUTTON_UP',
|
|
'GAMEPAD_BUTTON_RIGHT',
|
|
'GAMEPAD_BUTTON_DOWN',
|
|
'GAMEPAD_BUTTON_LEFT',
|
|
'GAMEPAD_BUTTON_PLUS',
|
|
'GAMEPAD_BUTTON_MINUS',
|
|
'GAMEPAD_BUTTON_TOUCHPAD');
|
|
[Expand]
Joystick logging JOYSTICK_LOG_*
JOYSTICK_LOG_LEVEL_DEBUG = LOG_LEVEL_DEBUG;
|
Joystick debugging messages
|
JOYSTICK_LOG_LEVEL_INFO = LOG_LEVEL_INFO;
|
Joystick informational messages, such as a device being attached or detached.
|
JOYSTICK_LOG_LEVEL_WARN = LOG_LEVEL_WARN;
|
Joystick warning messages
|
JOYSTICK_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR;
|
Joystick error messages
|
JOYSTICK_LOG_LEVEL_NONE = LOG_LEVEL_NONE;
|
No Joystick messages
|
Type definitions
Joystick data
[Expand]
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
[Expand]
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
[Expand]
PJoystickExtent = ^TJoystickExtent;
TJoystickExtent = record
Minimum:LongInt;
|
The minimum value for this extent
|
Maximum:LongInt;
|
The maximum value for this extent
|
Joystick axis
[Expand]
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
[Expand]
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
[Expand]
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
[Expand]
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
Initialization functions
[Expand]
procedure JoystickInit;
Description: Initialize the Joystick unit and Joystick device table
Note
|
Called only during system startup
|
Joystick functions
[Expand]
function JoystickDeviceStart(Joystick:PJoystickDevice):LongWord;
Description: Start the specified Joystick device ready for receiving events
Joystick
|
The Joystick device to start
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function JoystickDeviceStop(Joystick:PJoystickDevice):LongWord;
Description: Stop the specified Joystick device and terminate receiving events
Joystick
|
The Joystick device to stop
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function JoystickDevicePeek(Joystick:PJoystickDevice):LongWord;
Description: Peek at the buffer of the specified joystick device to see if any data packets are ready
Joystick
|
The Joystick device to peek at
|
Return
|
ERROR_SUCCESS if packets are ready, ERROR_NO_MORE_ITEMS if not or another error code on failure.
|
[Expand]
function JoystickDeviceRead(Joystick:PJoystickDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
Description: Read joystick data packets from the buffer of the specified joystick device
Joystick
|
The Joystick device to read from
|
Buffer
|
Pointer to a buffer to copy the joystick data packets to
|
Size
|
The size of the buffer in bytes (Must be at least TJoystickData or greater)
|
Flags
|
The flags for the behaviour of the read (eg JOYSTICK_FLAG_NON_BLOCK)
|
Count
|
The number of joystick data packets copied to the buffer
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function JoystickDeviceWrite(Joystick:PJoystickDevice; Buffer:Pointer; Size,Count:LongWord):LongWord;
Description: Write joystick data packets to the buffer of the specified joystick device
Joystick
|
The Joystick device to write to
|
Buffer
|
Pointer to a buffer to copy the joystick data packets from
|
Size
|
The size of the buffer in bytes (Must be at least TJoystickData or greater)
|
Count
|
The number of joystick data packets to copy from the buffer
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function JoystickDeviceFlush(Joystick:PJoystickDevice):LongWord;
Description: Flush the contents of the buffer of the specified joystick device
Joystick
|
The Joystick device to flush
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function JoystickDeviceUpdate(Joystick:PJoystickDevice):LongWord;
Description: Request the specified Joystick device to update the current configuration
Joystick
|
The Joystick device to update
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
Note
|
Items updated can include rotation, maximum X and Y and flags (If supported)
|
[Expand]
function JoystickDeviceControl(Joystick:PJoystickDevice; Request:Integer; Argument1:PtrUInt; var Argument2:PtrUInt):LongWord;
Description: Perform a control request on the specified Joystick device
Joystick
|
The Joystick device to control
|
Request
|
The request code for the operation (eg JOYSTICK_CONTROL_GET_FLAG)
|
Argument1
|
The first argument for the operation (Dependent on request code)
|
Argument2
|
The second argument for the operation (Dependent on request code)
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function JoystickDeviceGetProperties(Joystick:PJoystickDevice; Properties:PJoystickProperties):LongWord;
Description: Get the properties for the specified Joystick device
Joystick
|
The Joystick device to get properties from
|
Properties
|
Pointer to a TJoystickProperties structure to fill in
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function JoystickDeviceSetState(Joystick:PJoystickDevice; State:LongWord):LongWord;
Description: Set the state of the specified joystick and send a notification
Joystick
|
The joystick to set the state for
|
State
|
The new state to set and notify
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function JoystickDeviceCreate:PJoystickDevice;
Description: Create a new Joystick device entry
Return
|
Pointer to new Joystick device entry or nil if Joystick device could not be created
|
[Expand]
function JoystickDeviceCreateEx(Size:LongWord):PJoystickDevice;
Description: Create a new Joystick device entry
Size
|
Size in bytes to allocate for new Joystick device (Including the Joystick device entry)
|
Return
|
Pointer to new Joystick device entry or nil if Joystick device could not be created
|
[Expand]
function JoystickDeviceDestroy(Joystick:PJoystickDevice):LongWord;
Description: Destroy an existing Joystick device entry
Joystick
|
The Joystick device to destroy
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function JoystickDeviceRegister(Joystick:PJoystickDevice):LongWord;
Description: Register a new Joystick device in the Joystick device table
Joystick
|
The Joystick device to register
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function JoystickDeviceDeregister(Joystick:PJoystickDevice):LongWord;
Description: Deregister a Joystick device from the Joystick device table
Joystick
|
The Joystick device to deregister
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function JoystickDeviceFind(JoystickId:LongWord):PJoystickDevice;
Description: Find a Joystick device by ID in the Joystick device table
JoystickId
|
The ID number of the Joystick device to find
|
Return
|
Pointer to Joystick device entry or nil if not found
|
[Expand]
function JoystickDeviceFindByName(const Name:String):PJoystickDevice; inline;
Description: Find a Joystick device by name in the device table
Name
|
The name of the Joystick device to find (eg Joystick0)
|
Return
|
Pointer to Joystick device entry or nil if not found
|
[Expand]
function JoystickDeviceFindByDescription(const Description:String):PJoystickDevice; inline;
Description: Find a Joystick device by description in the device table
Description
|
The description of the Joystick to find (eg USB Gamepad)
|
Return
|
Pointer to Joystick device entry or nil if not found
|
[Expand]
function JoystickDeviceEnumerate(Callback:TJoystickEnumerate; Data:Pointer):LongWord;
Description: Enumerate all Joystick devices in the Joystick device table
Callback
|
The callback function to call for each Joystick device in the table
|
Data
|
A private data pointer to pass to callback for each Joystick device in the table
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function JoystickDeviceNotification(Joystick:PJoystickDevice; Callback:TJoystickNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Description: Register a notification for Joystick device changes
Joystick
|
The Joystick device to notify changes for (Optional, pass nil for all Joystick devices)
|
Callback
|
The function to call when a notification event occurs
|
Data
|
A private data pointer to pass to callback when a notification event occurs
|
Notification
|
The events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER)
|
Flags
|
The flags to control the notification (eg NOTIFIER_FLAG_WORKER)
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
Joystick helper functions
[Expand]
function JoystickGetCount:LongWord;
Description: Get the current Joystick device count
Return
|
The number of Joystick devices
|
[Expand]
function JoystickDeviceGetDefault:PJoystickDevice;
Description: Get the current default Joystick device
Return
|
Pointer to default Joystick device entry
|
[Expand]
function JoystickDeviceSetDefault(Joystick:PJoystickDevice):LongWord;
Description: Set the current default Joystick device
Joystick
|
The Joystick device to set as default
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function JoystickDeviceCheck(Joystick:PJoystickDevice):PJoystickDevice;
Description: Check if the supplied Joystick device is in the Joystick device table
Joystick
|
The Joystick device to check
|
Return
|
Pointer to Joystick device entry or nil if not found
|
[Expand]
function JoystickDeviceAxisToString(Name:LongWord):String;
Description: Return a string describing a Joystick or Gamepad Axis (eg JOYSTICK_AXIS_X)
[Expand]
function JoystickDeviceHatToString(Name:LongWord):String;
Description: Return a string describing a Joystick or Gamepad Hat (eg JOYSTICK_HAT_POV)
[Expand]
function JoystickDeviceButtonToString(Name:LongWord):String;
Description: Return a string describing a Joystick or Gamepad Button (eg GAMEPAD_BUTTON_UP)
[Expand]
function JoystickDeviceTypeToString(JoystickType:LongWord):String;
Description: Return a string describing the Joystick device type (eg JOYSTICK_TYPE_JOYSTICK)
[Expand]
function JoystickDeviceStateToString(JoystickState:LongWord):String;
Description: Return a string describing the Joystick device state (eg JOYSTICK_STATE_ENABLED)
[Expand]
function JoystickDeviceStateToNotification(State:LongWord):LongWord;
Description: Convert a Joystick state value into the notification code for device notifications
[Expand]
function JoystickDeviceGetAxis(Joystick:PJoystickDevice; Index:LongWord):LongWord;
Description: Get the name (identifier) of an Axis on the specified Joystick
Joystick
|
The Joystick device to get the name from
|
Index
|
The index of the Axis in the Joystick properties (First Axis is 0)
|
Return
|
The current name of the Axis (eg GAMEPAD_AXIS_LEFT_X)
|
[Expand]
function JoystickDeviceSetAxis(Joystick:PJoystickDevice; Index,Name:LongWord):LongWord;
Description: Set the name (identifier) of an Axis on the specified Joystick
Joystick
|
The Joystick device to set the name for
|
Index
|
The index of the Axis in the Joystick properties (First Axis is 0)
|
Name
|
The name (identifier) to set for the Axis (eg JOYSTICK_AXIS_X)
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function JoystickDeviceGetHat(Joystick:PJoystickDevice; Index:LongWord):LongWord;
Description: Get the name (identifier) of a Hat on the specified Joystick
Joystick
|
The Joystick device to get the name from
|
Index
|
The index of the Hat in the Joystick properties (First Hat is 0)
|
Return
|
The current name of the Hat (eg GAMEPAD_HAT_POV)
|
[Expand]
function JoystickDeviceSetHat(Joystick:PJoystickDevice; Index,Name:LongWord):LongWord;
Description: Set the name (identifier) of a Hat on the specified Joystick
Joystick
|
The Joystick device to set the name for
|
Index
|
The index of the Hat in the Joystick properties (First Hat is 0)
|
Name
|
The name (identifier) to set for the Hat (eg JOYSTICK_HAT_POV)
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function JoystickDeviceGetButton(Joystick:PJoystickDevice; Index:LongWord):LongWord;
Description: Get the name (identifier) of a Button on the specified Joystick
Joystick
|
The Joystick device to get the name from
|
Index
|
The index of the Button in the Joystick properties (First Button is 0)
|
Return
|
The current name of the Button (eg GAMEPAD_BUTTON_B)
|
[Expand]
function JoystickDeviceSetButton(Joystick:PJoystickDevice; Index,Name:LongWord):LongWord;
Description: Set the name (identifier) of a Button on the specified Joystick
Joystick
|
The Joystick device to set the name for
|
Index
|
The index of the Button in the Joystick properties (First Button is 0)
|
Name
|
The name (identifier) to set for the Button (eg GAMEPAD_BUTTON_LT)
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function JoystickDeviceSetCallback(Joystick:PJoystickDevice; Event:TJoystickEvent; Parameter:Pointer):LongWord;
Description: Set the event callback function for the specified Joystick
Joystick
|
The Joystick device to set the event callback for
|
Event
|
The event callback function to be called when Joystick data is received
|
Parameter
|
A pointer to private data to be passed to the callback with each event
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function JoystickInsertData(Joystick:PJoystickDevice; Data:PJoystickData; Signal:Boolean):LongWord;
Description: Insert a TJoystickData entry into the joystick device buffer
Joystick
|
The joystick device to insert data for
|
Data
|
The TJoystickData entry to insert
|
Signal
|
If True then signal that new data is available in the buffer
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
Note
|
Caller must hold the joystick device lock
|
[Expand]
procedure JoystickLog(Level:LongWord; Joystick:PJoystickDevice; const AText:String);
Description: To be documented
[Expand]
procedure JoystickLogInfo(Joystick:PJoystickDevice; const AText:String); inline;
Description: To be documented
[Expand]
procedure JoystickLogWarn(Joystick:PJoystickDevice; const AText:String); inline;
Description: To be documented
[Expand]
procedure JoystickLogError(Joystick:PJoystickDevice; const AText:String); inline;
Description: To be documented
[Expand]
procedure JoystickLogDebug(Joystick:PJoystickDevice; const AText:String); inline;
Description: To be documented
Return to Unit Reference