joystick object
This function checks if a particular button on the joystick has been released.
bool button_released(int button)
Parameters:
button
The ID of a joystick button to check (see remarks).
Return value:
true if the button has been released, false if it has not or if an error occurs.
Remarks:
The difference between button_up and button_released is that button_released will only return true when the user first releases the button, while button_up will continue returning true until the button is pushed down 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, meaning that the allowed range is 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:

    // Play a looping sound whenever a button is pushed down, stopping it when the button is released.

    void main()
    {
    sound loop;
    joystick stick;
    int current_loop=-1;
    show_game_window("Joystick Test");
    if(stick.joysticks==0)
    {
    alert("Error", "No joysticks seem to be attached.");
    exit();
    }
    while(!key_pressed(KEY_ESCAPE))
    {
    for(int counter=0; counter<stick.buttons; counter++)
    {
    if(stick.button_pressed(counter))
    {
    if(current_loop!=counter)
    {
    loop.load("loop"+counter+".wav");
    current_loop=counter;
    }
    loop.play_looped();
    }
    if(stick.button_released(counter))
    {
    loop.stop();
    }
    }
    }
    }