Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mouse button constants #1584

Merged
merged 3 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions docs/src/refman/events.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,10 @@ mouse.w (int)
: w-coordinate

mouse.button (unsigned)
: The mouse button which was pressed, numbering from 1.
: The mouse button which was pressed, numbering from 1. As a convenience, the constants
ALLEGRO_MOUSE_BUTTON_LEFT, ALLEGRO_MOUSE_BUTTON_RIGHT, ALLEGRO_MOUSE_BUTTON_MIDDLE are provided.
However, depending on the hardware there may be more or fewer mouse buttons. You can check
[al_get_mouse_num_buttons] if you want to be sure.

mouse.pressure (float)
: Pressure, ranging from `0.0` to `1.0`.
Expand All @@ -243,7 +246,10 @@ mouse.w (int)
: w-coordinate

mouse.button (unsigned)
: The mouse button which was released, numbering from 1.
: The mouse button which was released, numbering from 1. As a convenience, the constants
ALLEGRO_MOUSE_BUTTON_LEFT, ALLEGRO_MOUSE_BUTTON_RIGHT, ALLEGRO_MOUSE_BUTTON_MIDDLE are provided.
However, depending on the hardware there may be more or fewer mouse buttons. You can check
[al_get_mouse_num_buttons] if you want to be sure.

mouse.pressure (float)
: Pressure, ranging from `0.0` to `1.0`.
Expand Down
4 changes: 2 additions & 2 deletions docs/src/refman/keyboard.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ pressed_keys[key_code] = true;
~~~~

These are the list of key codes used by Allegro, which are returned in
the event.keyboard.keycode field of the ALLEGRO_KEY_DOWN and
ALLEGRO_KEY_UP events and which you can pass to [al_key_down]:
the event.keyboard.keycode field of the ALLEGRO_EVENT_KEY_DOWN and
ALLEGRO_EVENT_KEY_UP events and which you can pass to [al_key_down]:

ALLEGRO_KEY_A ... ALLEGRO_KEY_Z
ALLEGRO_KEY_0 ... ALLEGRO_KEY_9
Expand Down
30 changes: 29 additions & 1 deletion docs/src/refman/mouse.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,29 @@ Public fields (read only):

See also: [al_get_mouse_state], [al_get_mouse_state_axis], [al_mouse_button_down]

## Mouse button constants

Unlike other indexes, the first mouse button is numbered 1 when returned in
the event.mouse.button field of ALLEGRO_EVENT_MOUSE_BUTTON_UP and
ALLEGRO_EVENT_MOUSE_BUTTON_DOWN events.

As a convenience, the following ALLEGRO_MOUSE_BUTTON constants are provided below.
However, depending on the hardware there may be more or fewer mouse buttons. You
can check [al_get_mouse_num_buttons] if you want to be sure.

~~~~c
typedef enum ALLEGRO_MOUSE_BUTTON
{
ALLEGRO_MOUSE_BUTTON_LEFT = 1,
ALLEGRO_MOUSE_BUTTON_RIGHT = 2,
ALLEGRO_MOUSE_BUTTON_MIDDLE = 3
} ALLEGRO_MOUSE_BUTTON;
~~~~

Since: 5.2.10

See also: [al_get_mouse_num_buttons], [al_mouse_button_down]

## API: al_install_mouse

Install a mouse driver.
Expand Down Expand Up @@ -93,7 +116,12 @@ See also: [ALLEGRO_MOUSE_STATE], [al_get_mouse_state], [al_mouse_button_down]
## API: al_mouse_button_down

Return true if the mouse button specified was held down in the state
specified. Unlike most things, the first mouse button is numbered 1.
specified.

Unlike most things, the first mouse button is numbered 1. As a convenience, the constants
ALLEGRO_MOUSE_BUTTON_LEFT, ALLEGRO_MOUSE_BUTTON_RIGHT, ALLEGRO_MOUSE_BUTTON_MIDDLE are provided.
However, depending on the hardware there may be more or fewer mouse buttons. You can check
[al_get_mouse_num_buttons] if you want to be sure.

See also: [ALLEGRO_MOUSE_STATE], [al_get_mouse_state], [al_get_mouse_state_axis]

Expand Down
8 changes: 8 additions & 0 deletions include/allegro5/mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ struct ALLEGRO_MOUSE_STATE
};


typedef enum ALLEGRO_MOUSE_BUTTON
{
ALLEGRO_MOUSE_BUTTON_LEFT = 1,
ALLEGRO_MOUSE_BUTTON_RIGHT = 2,
ALLEGRO_MOUSE_BUTTON_MIDDLE = 3,
} ALLEGRO_MOUSE_BUTTON;


AL_FUNC(bool, al_is_mouse_installed, (void));
AL_FUNC(bool, al_install_mouse, (void));
AL_FUNC(void, al_uninstall_mouse, (void));
Expand Down
Loading