1mouse_x(3) Allegro manual mouse_x(3)
2
3
4
6 mouse_x, mouse_y, mouse_z, mouse_w, mouse_b, mouse_pos - Global vari‐
7 able with the mouse position/button state. Allegro game programming
8 library.
9
11 #include <allegro.h>
12
13
14 extern volatile int mouse_x;
15
16 extern volatile int mouse_y;
17
18 extern volatile int mouse_z;
19
20 extern volatile int mouse_w;
21
22 extern volatile int mouse_b;
23
24 extern volatile int mouse_pos;
25
27 Global variables containing the current mouse position and button
28 state. Wherever possible these values will be updated asynchronously,
29 but if mouse_needs_poll() returns TRUE, you must manually call
30 poll_mouse() to update them with the current input state. The `mouse_x'
31 and `mouse_y' positions are integers ranging from zero to the bottom
32 right corner of the screen. The `mouse_z' and `mouse_w' variables hold
33 the current vertical and horizontal wheel position, when using an input
34 driver that supports wheel mice. The `mouse_b' variable is a bitfield
35 indicating the state of each button: bit 0 is the left button, bit 1
36 the right, and bit 2 the middle button. Additional non standard mouse
37 buttons might be available as higher bits in this variable. Usage exam‐
38 ple:
39
40 if (mouse_b & 1)
41 printf("Left button is pressed\n");
42
43 if (!(mouse_b & 2))
44 printf("Right button is not pressed\n");
45
46 The `mouse_pos' variable has the current X coordinate in the upper 16
47 bits and the Y in the lower 16 bits. This may be useful in tight
48 polling loops where a mouse interrupt could occur between your reading
49 of the two separate variables, since you can copy this value into a
50 local variable with a single instruction and then split it up at your
51 leisure. Example:
52
53 int pos, x, y;
54
55 pos = mouse_pos;
56 x = pos >> 16;
57 y = pos & 0x0000ffff;
58
59
60
61
63 install_mouse(3), poll_mouse(3), mouse_needs_poll(3), exalpha(3),
64 exlights(3), exmouse(3), exshade(3), exspline(3), extrans(3)
65
66
67
68Allegro version 4.4.3 mouse_x(3)