mirror of
https://github.com/maoakeEnterprise/amazing.git
synced 2026-04-28 16:04:35 +02:00
a408004bd7
Basic main to display ascii print
155 lines
3.6 KiB
Plaintext
155 lines
3.6 KiB
Plaintext
.TH MiniLibX 3 "September 19, 2002"
|
|
.SH NAME
|
|
MiniLibX - Handle events
|
|
.SH SYNOPSYS
|
|
|
|
.nf
|
|
.I int
|
|
.fi
|
|
.B mlx_loop
|
|
(
|
|
.I void *mlx_ptr
|
|
);
|
|
|
|
.nf
|
|
.I int
|
|
.fi
|
|
.B mlx_key_hook
|
|
(
|
|
.I void *win_ptr, int (*funct_ptr)(), void *param
|
|
);
|
|
|
|
.nf
|
|
.I int
|
|
.fi
|
|
.B mlx_mouse_hook
|
|
(
|
|
.I void *win_ptr, int (*funct_ptr)(), void *param
|
|
);
|
|
|
|
.nf
|
|
.I int
|
|
.fi
|
|
.B mlx_expose_hook
|
|
(
|
|
.I void *win_ptr, int (*funct_ptr)(), void *param
|
|
);
|
|
|
|
.nf
|
|
.I int
|
|
.fi
|
|
.B mlx_loop_hook
|
|
(
|
|
.I void *mlx_ptr, int (*funct_ptr)(), void *param
|
|
);
|
|
|
|
.nf
|
|
.I int
|
|
.fi
|
|
.B mlx_loop_exit
|
|
(
|
|
.I void *mlx_ptr
|
|
);
|
|
|
|
.SH EVENTS
|
|
|
|
The graphical system is bi-directional. On one hand, the program sends orders to
|
|
the screen to display pixels, images, and so on. On the other hand,
|
|
it can get information from the keyboard and mouse associated to
|
|
the screen. To do so, the program receives "events" from the keyboard or the
|
|
mouse.
|
|
|
|
.SH DESCRIPTION
|
|
|
|
To receive events, you must use
|
|
.B mlx_loop
|
|
(). This function never returns, unless
|
|
.B mlx_loop_exit
|
|
is called. It is an
|
|
infinite loop that waits for an event, and then calls a user-defined
|
|
function associated with this event. A single parameter is needed,
|
|
the connection identifier
|
|
.I mlx_ptr
|
|
(see the
|
|
.B mlx manual).
|
|
|
|
You can assign different functions to the three following events:
|
|
.br
|
|
- A key is released
|
|
.br
|
|
- The mouse button is pressed
|
|
.br
|
|
- A part of the window should be re-drawn
|
|
(this is called an "expose" event, and it is your program's job to handle it in the
|
|
Unix/Linux X11 environment, but at the opposite it never happens on Unix/Linux Wayland-Vulkan nor on MacOS).
|
|
.br
|
|
|
|
Each window can define a different function for the same event.
|
|
|
|
The three functions
|
|
.B mlx_key_hook
|
|
(),
|
|
.B mlx_mouse_hook
|
|
() and
|
|
.B mlx_expose_hook
|
|
() work exactly the same way.
|
|
.I funct_ptr
|
|
is a pointer to the function you want to be called
|
|
when an event occurs. This assignment is specific to the window defined by the
|
|
.I win_ptr
|
|
identifier. The
|
|
.I param
|
|
address will be passed back to your function every time it is called, and should be
|
|
used to store the parameters it might need.
|
|
|
|
The syntax for the
|
|
.B mlx_loop_hook
|
|
() function is similar to the previous ones, but the given function will be
|
|
called when no event occurs, and is not bound to a specific window.
|
|
|
|
When it catches an event, the MiniLibX calls the corresponding function
|
|
with fixed parameters:
|
|
.nf
|
|
|
|
expose_hook(void *param);
|
|
key_hook(unsigned int keycode, void *param);
|
|
mouse_hook(unsigned int button, unsigned int x, unsigned int y, void *param);
|
|
loop_hook(void *param);
|
|
|
|
.fi
|
|
These function names are arbitrary. They here are used to distinguish
|
|
parameters according to the event. These functions are NOT part of the
|
|
MiniLibX.
|
|
|
|
.I param
|
|
is the address specified in the mlx_*_hook calls. This address is never
|
|
used nor modified by the MiniLibX. On key and mouse events, additional
|
|
information is passed:
|
|
.I keycode
|
|
tells you which key is pressed (just try to find out :) ),
|
|
(
|
|
.I x
|
|
,
|
|
.I y
|
|
) are the coordinates of the mouse click in the window, and
|
|
.I button
|
|
tells you which mouse button was pressed.
|
|
|
|
.SH GOING FURTHER WITH EVENTS
|
|
The MiniLibX provides a much generic access to other available events. The
|
|
.I mlx.h
|
|
include define
|
|
.B mlx_hook()
|
|
in the same manner mlx_*_hook functions work. The event and mask values
|
|
will be taken from the historical X11 include file "X.h". Some Wayland and MacOS events are mapped
|
|
to these values when it makes sense, and the mask may not be used in some configurations.
|
|
|
|
See source code of the MiniLibX to find out how it will
|
|
call your own function for a specific event.
|
|
|
|
.SH SEE ALSO
|
|
mlx(3), mlx_new_window(3), mlx_pixel_put(3), mlx_new_image(3), mlx_extra(3)
|
|
|
|
.SH AUTHOR
|
|
Copyright ol@ - 2002-2025 - Olivier Crouzet
|