Unit Gamolf.RTL.Joystick

Description

***************************************************************************

Delphi Game Engine

Copyright 2021-2025 Patrick Prémartin under AGPL 3.0 license.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

***************************************************************************

Delphi Game Engine contains libraries and components to use in VCL or FireMonkey game (or classic) projects.

If you want to play sounds or musics, use game controllers, pilot your user interface with the keyboard or a game controller, it's the good place.

***************************************************************************

Author(s) : Patrick PREMARTIN

Site : https://delphigameengine.developpeur-pascal.fr

Project site : https://github.com/DeveloppeurPascal/Delphi-Game-Engine

*************************************************************************** File last update : 2025-01-14T16:49:54.000+01:00 Signature : 0a3039bc6cbb6f9bc6e520f43aaf3a70a9506728 ***************************************************************************

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Class EJoystickServiceException Base class for all Joystick exceptions
Class EJoystickUnpluggedException Raised if the controller is not available
Record TJoystickInfo Joystick/gamepad controller datas
Interface IGamolfJoystickService Platform service to access to joystick/gamepad controllers on a computer
Class TGamolfCustomJoystickService Platform service to access to joystick/gamepad controllers on a computer
Class TGamepadDevicesManager Gamepad manager class, to use as a singleton.
Class TDGEGamepadManager Gamepad manager component
Class TGamepadManagerList  
Class TGamepadDevice Gamepad class to access data from each gamepad detected on the system
Class TGamepadDeviceDict  
Class TDGEGamepad Gamepad component
Class TDGEGamepadList  

Functions and Procedures

procedure Register;

Types

TJoystickButtons = (...);
TJoystickButtonsSet = set of TJoystickButtons;
TJoystickDPad = (...);
TJoystickAxes = (...);
TJoystickAxesSet = set of TJoystickAxes;
TJoystickID = byte;
TButtonID = byte;
TJoystickInfosCallbackProc = reference to procedure(JoystickID: TJoystickID; var JoystickInfo: TJoystickInfo; hadError: boolean);
TJoystickInfosCallbackEvent = procedure(JoystickID: TJoystickID; var JoystickInfo: TJoystickInfo; hadError: boolean) of object;
TJoystickInfosConnectedCallbackProc = reference to procedure (JoystickID: TJoystickID; var JoystickInfo: TJoystickInfo);
TJoystickInfosConnectedCallbackEvent = procedure(JoystickID: TJoystickID; var JoystickInfo: TJoystickInfo) of object;
TJoystickErrorCallbackProc = reference to procedure(JoystickID: TJoystickID);
TJoystickErrorCallbackEvent = procedure(JoystickID: TJoystickID) of object;
TOnNewGamepadDetected = procedure(const GamepadID: integer) of object;
TOnGamepadLost = procedure(const GamepadID: integer) of object;
TOnGamepadButtonUp = procedure(const GamepadID: integer; const Button: TJoystickButtons) of object;
TOnGamepadButtonDown = procedure(const GamepadID: integer; const Button: TJoystickButtons) of object;
TOnGamepadAxesChange = procedure(const GamepadID: integer; const Axe: TJoystickAxes; const Value: single) of object;
TOnGamepadDirectionPadChange = procedure(const GamepadID: integer; const Value: TJoystickDPad) of object;

Description

Functions and Procedures

procedure Register;
 

Types

TJoystickButtons = (...);

ID for game controllers buttons (when it's know by the API)

Values
  • A
  • B
  • X
  • Y
  • LeftShoulder
  • RightShoulder
  • Options
  • Menu
  • LeftThumbStick
  • RightThumbStick
  • Home
  • LeftTrigger
  • RightTrigger
TJoystickButtonsSet = set of TJoystickButtons;
 
TJoystickDPad = (...);

DPad standard values (from 0 to 365° and 65535 when not value is selected)

Values
  • Top = 0
  • TopRight = 45
  • RightTop = 45
  • Right = 90
  • BottomRight = 135
  • RightBottom = 135
  • Bottom = 180
  • BottomLeft = 225
  • LeftBottom = 225
  • Left = 270
  • LeftTop = 315
  • TopLeft = 315
  • Center = 65535
TJoystickAxes = (...);
 
Values
  • LeftStickX = 0
  • X = 0
  • LeftStickY = 1
  • Y = 1
  • RightStickX = 2
  • U = 2
  • RightStickY = 3
  • R = 3
  • LeftTrigger = 4
  • Z = 4
  • RightTrigger = 5
  • V = 5
TJoystickAxesSet = set of TJoystickAxes;
 
TJoystickID = byte;

Type for Joystick ID

TButtonID = byte;

Type for Button ID

TJoystickInfosCallbackProc = reference to procedure(JoystickID: TJoystickID; var JoystickInfo: TJoystickInfo; hadError: boolean);

Signature for a callback procedure used to get game controller infos

TJoystickInfosCallbackEvent = procedure(JoystickID: TJoystickID; var JoystickInfo: TJoystickInfo; hadError: boolean) of object;

Signature for a callback method used to get game controller infos

TJoystickInfosConnectedCallbackProc = reference to procedure (JoystickID: TJoystickID; var JoystickInfo: TJoystickInfo);

Signature for a callback procedure used to get connected game controller infos

TJoystickInfosConnectedCallbackEvent = procedure(JoystickID: TJoystickID; var JoystickInfo: TJoystickInfo) of object;

Signature for a callback method used to get connected game controller infos

TJoystickErrorCallbackProc = reference to procedure(JoystickID: TJoystickID);

Signature for a callback procedure used to signal an error for the game controller JoystickID

TJoystickErrorCallbackEvent = procedure(JoystickID: TJoystickID) of object;

Signature for a callback method used to signal an error for the game controller JoystickID

TOnNewGamepadDetected = procedure(const GamepadID: integer) of object;
 
TOnGamepadLost = procedure(const GamepadID: integer) of object;
 
TOnGamepadButtonUp = procedure(const GamepadID: integer; const Button: TJoystickButtons) of object;
 
TOnGamepadButtonDown = procedure(const GamepadID: integer; const Button: TJoystickButtons) of object;
 
TOnGamepadAxesChange = procedure(const GamepadID: integer; const Axe: TJoystickAxes; const Value: single) of object;
 
TOnGamepadDirectionPadChange = procedure(const GamepadID: integer; const Value: TJoystickDPad) of object;
 
Delphi Game Engine (c) 2021-2025 Patrick PREMARTIN - Powered by PasDoc
Generated by PasDoc 0.16.0.