.\" Generated by the Allegro makedoc utility .TH mouse_x 3alleg4 "version 4.4.3" "Allegro" "Allegro manual" .SH NAME mouse_x, mouse_y, mouse_z, mouse_w, mouse_b, mouse_pos \- Global variable with the mouse position/button state. Allegro game programming library.\& .SH SYNOPSIS .B #include .sp .B extern volatile int mouse_x; .B extern volatile int mouse_y; .B extern volatile int mouse_z; .B extern volatile int mouse_w; .B extern volatile int mouse_b; .B extern volatile int mouse_pos; .SH DESCRIPTION Global variables containing the current mouse position and button state. Wherever possible these values will be updated asynchronously, but if mouse_needs_poll() returns TRUE, you must manually call poll_mouse() to update them with the current input state. The `mouse_x' and `mouse_y' positions are integers ranging from zero to the bottom right corner of the screen. The `mouse_z' and `mouse_w' variables hold the current vertical and horizontal wheel position, when using an input driver that supports wheel mice. The `mouse_b' variable is a bitfield indicating the state of each button: bit 0 is the left button, bit 1 the right, and bit 2 the middle button. Additional non standard mouse buttons might be available as higher bits in this variable. Usage example: .nf if (mouse_b & 1) printf("Left button is pressed\\n"); if (!(mouse_b & 2)) printf("Right button is not pressed\\n"); .fi The `mouse_pos' variable has the current X coordinate in the upper 16 bits and the Y in the lower 16 bits. This may be useful in tight polling loops where a mouse interrupt could occur between your reading of the two separate variables, since you can copy this value into a local variable with a single instruction and then split it up at your leisure. Example: .nf int pos, x, y; pos = mouse_pos; x = pos >> 16; y = pos & 0x0000ffff; .fi .SH SEE ALSO .BR install_mouse (3alleg4), .BR poll_mouse (3alleg4), .BR mouse_needs_poll (3alleg4), .BR exalpha (3alleg4), .BR exlights (3alleg4), .BR exmouse (3alleg4), .BR exshade (3alleg4), .BR exspline (3alleg4), .BR extrans (3alleg4)