joystick object
This function checks if a particular button on the joystick is currently being held down.
bool button_down(int button)
Parameters:
button
The ID of a joystick button to check (see remarks).
Return value:
true if the button is held down, false if it is not or if an error occurs.
Remarks:
The difference between button_down and button_pressed is that button_pressed will only return true when the user first pushes down the button, while button_down will continue returning true until the button is released again.
The joystick object supports up to 128 buttons, ranging from 0 to 127. However the actual maximum button is determined by the buttons property for the given device, ranging from 0 to buttons minus 1.
It is important to remember when mapping functions to joystick buttons that devices can vary greatly between models, supporting anything between 3 and 15 buttons, and therefore it is always a good idea to map the most common activities to buttons with lower numbers.
Example:

    // The program will exit when the user holds down button 1 and presses button 2. Of course, we shall allow escape as well, just in case this combination should prove difficult with some models.

    void main()
    {
    joystick stick;
    show_game_window("Joystick Test");
    if(stick.joysticks==0)
    {
    alert("Error", "No joysticks seem to be attached.");
    exit();
    }
    while(!key_pressed(KEY_ESCAPE))
    {
    if(stick.button_down(1)&&(stick.button_pressed(2)))
    {
    exit();
    }
    }
    }