joy - Online Linux Manual PageSection : 3
Updated : version 4.4.3
Source : Allegro
Note : Allegro manual
NAMEjoy − Global array of joystick state information. Allegro game programming library.
SYNOPSIS#include <allegro.h> extern JOYSTICK_INFO joy[n];
DESCRIPTIONGlobal array of joystick state information, which is updated by the poll_joystick() function. Only the first num_joysticks elements will contain meaningful information. The JOYSTICK_INFO structure is defined as: typedef struct JOYSTICK_INFO
{
int flags; - status flags for this
joystick
int num_sticks; - how many stick inputs?
int num_buttons; - how many buttons?
JOYSTICK_STICK_INFO stick[n]; - stick state information
JOYSTICK_BUTTON_INFO button[n]; - button state information
} JOYSTICK_INFO;
The button status is stored in the structure: typedef struct JOYSTICK_BUTTON_INFO
{
int b; - boolean on/off flag
char *name; - description of this
button
} JOYSTICK_BUTTON_INFO;
You may wish to display the button names as part of an input configuration screen to let the user choose what game function will be performed by each button, but in simpler situations you can safely assume that the first two elements in the button array will always be the main trigger controls. Each joystick will provide one or more stick inputs, of varying types. These can be digital controls which snap to specific positions (eg. a gamepad controller, the coolie hat on a Flightstick Pro or Wingman Extreme, or a normal joystick which hasn't yet been calibrated), or they can be full analogue inputs with a smooth range of motion. Sticks may also have different numbers of axes, for example a normal directional control has two, but the Flightstick Pro throttle is only a single axis, and it is possible that the system could be extended in the future to support full 3d controllers. A stick input is described by the structure: typedef struct JOYSTICK_STICK_INFO
{
int flags; - status flags for this
input
int num_axis; - how many axes do we
have? (note the misspelling)
JOYSTICK_AXIS_INFO axis[n]; - axis state information
char *name; - description of this
input
} JOYSTICK_STICK_INFO;
A single joystick may provide several different stick inputs, but you can safely assume that the first element in the stick array will always be the main directional controller. Information about each of the stick axis is stored in the substructure: typedef struct JOYSTICK_AXIS_INFO
{
int pos; - analogue axis position
int d1, d2; - digital axis position
char *name; - description of this axis
} JOYSTICK_AXIS_INFO;
This provides both analogue input in the pos field (ranging from -128 to 128 or from 0 to 255, depending on the type of the control), and digital values in the d1 and d2 fields. For example, when describing the X-axis position, the pos field will hold the horizontal position of the joystick, d1 will be set if it is moved left, and d2 will be set if it is moved right. Allegro will fill in all these values regardless of whether it is using a digital or analogue joystick, emulating the pos field for digital inputs by snapping it to the min, middle, and maximum positions, and emulating the d1 and d2 values for an analogue stick by comparing the current position with the centre point. The joystick flags field may contain any combination of the bit flags: JOYFLAG_DIGITAL This control is currently providing digital input. JOYFLAG_ANALOGUE This control is currently providing analogue input. JOYFLAG_CALIB_DIGITAL This control will be capable of providing digital input once it has been calibrated, but is not doing this at the moment. JOYFLAG_CALIB_ANALOGUE This control will be capable of providing analogue input once it has been calibrated, but is not doing this at the moment. JOYFLAG_CALIBRATE Indicates that this control needs to be calibrated. Many devices require multiple calibration steps, so you should call the calibrate_joystick() function from a loop until this flag is cleared. JOYFLAG_SIGNED Indicates that the analogue axis position is in signed format, ranging from -128 to 128. This is the case for all 2d directional controls. JOYFLAG_UNSIGNED Indicates that the analogue axis position is in unsigned format, ranging from 0 to 255. This is the case for all 1d throttle controls. Note for people who spell funny: in case you don't like having to type "analogue", there are some #define aliases in allegro/joystick.h that will allow you to write "analog" instead.
SEE ALSOinstall_joystick(3), poll_joystick(3), num_joysticks(3), calibrate_joystick(3), calibrate_joystick_name(3), exjoy(3) 0
Johanes Gumabo
Data Size : 9,148 byte
man-joy.3Build : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 4 / 165,332
Visitor ID : :
Visitor IP : 3.139.93.168 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.