MLV_event.h(3)
✨ NAME ✨
heyyy bestie 💖 so this is MLV_event.h(3) from the Library Functions Manual, and ngl it's kind of a big deal: this file defines the prototypes of the functions that let you use events in the MLV library. 🎀 like, every "did they press a key tho" and "did they click tho" moment? it all starts right here. periodt.
🌈 SYNOPSIS 🌈
🌸 Énumérations 🌸
enum MLV_Event { MLV_NONE = 0, MLV_KEY = 1, MLV_INPUT_BOX = 2, MLV_MOUSE_BUTTON = 3, MLV_MOUSE_MOTION = 4 }— this one enumerates the different types of events in the MLV library. it's literally the event menu, iykyk. 💅
💖 Fonctions 💖
MLV_Event MLV_get_event (MLV_Keyboard_button *key_sym, MLV_Keyboard_modifier *key_mod, int *unicode, char **texte, MLV_Input_box **input_box, int *mouse_x, int *mouse_y, MLV_Mouse_button *mouse_button, MLV_Button_state *state)— grabs one event out of the queue, fills in whichever of the function's parameters actually match the event it grabbed, and returns an int that encodes the type of the event it picked up. 👑MLV_Event MLV_wait_event (MLV_Keyboard_button *key_sym, MLV_Keyboard_modifier *key_mod, int *unicode, char **texte, MLV_Input_box **input_box, int *mouse_x, int *mouse_y, MLV_Mouse_button *mouse_button, MLV_Button_state *state)— this function suspends the program's execution until an event shows up in the queue. When a new event appears, the function.MLV_Event MLV_wait_event_or_seconds (MLV_Keyboard_button *key_sym, MLV_Keyboard_modifier *key_mod, int *unicode, char **texte, MLV_Input_box **input_box, int *mouse_x, int *mouse_y, MLV_Mouse_button *mouse_button, MLV_Button_state *state, int seconds)— suspends the program's execution until an event shows up in the queue or until a certain number of seconds have gone by. If the time has fully run out, the function returnsMLV_NONE. If a new event appears and the parameters passed as arguments relate to the event it grabbed, then the function fills in those parameters and returns an int encoding the type of the event it grabbed. And if a new event appears that isn't related to the function's parameters, then it goes right back to sleep, waiting for a new event or for the time to run out. 😴MLV_Event MLV_wait_event_or_milliseconds (MLV_Keyboard_button *key_sym, MLV_Keyboard_modifier *key_mod, int *unicode, char **texte, MLV_Input_box **input_box, int *mouse_x, int *mouse_y, MLV_Mouse_button *mouse_button, MLV_Button_state *state, int milliseconds)— same exact energy as above but in milliseconds: suspends the program's execution until an event shows up in the queue or until a certain number of milliseconds have gone by. If the time has fully run out, it returnsMLV_NONE. If a new event appears and the parameters passed as arguments relate to the event it grabbed, the function fills in the parameters and returns an int encoding the type of the event it grabbed. And if a new event shows up that isn't related to the function's parameters, it goes back to sleep waiting for a new event or the end of the time. 🦋void MLV_flush_event_queue ()— this function empties out the event queue. poof, gone, no crumbs. 💀MLV_Event MLV_wait_keyboard_or_mouse (MLV_Keyboard_button *sym, MLV_Keyboard_modifier *mod, int *unicode, int *mouse_x, int *mouse_y)— suspends execution until the user presses a key on the keyboard or the left button of the mouse. 🖱️⌨️MLV_Event MLV_wait_keyboard_or_mouse_or_seconds (MLV_Keyboard_button *sym, MLV_Keyboard_modifier *mod, int *unicode, int *mouse_x, int *mouse_y, int seconds)— suspends execution until the user presses a key on the keyboard, presses the left button of the mouse, or a certain number of seconds passed as a parameter have elapsed.MLV_Event MLV_wait_mouse_or_milliseconds (int *x, int *y, int milliseconds)— suspends execution until the user clicks the left button of the mouse.MLV_Event MLV_wait_mouse_or_seconds (int *x, int *y, int seconds)— suspends execution until the user clicks the left button of the mouse, or until a number of seconds passed as a parameter have elapsed.MLV_Event MLV_wait_keyboard_or_seconds (MLV_Keyboard_button *sym, MLV_Keyboard_modifier *mod, int *unicode, int seconds)— suspends execution until the user presses a key on the keyboard, or until a number of seconds passed as parameters have elapsed.MLV_Event MLV_wait_keyboard_or_milliseconds (MLV_Keyboard_button *sym, MLV_Keyboard_modifier *mod, int *unicode, int milliseconds)— suspends execution until the user presses a key on the keyboard, or until a number of milliseconds passed as parameters have elapsed.MLV_Event MLV_wait_keyboard_or_mouse_or_milliseconds (MLV_Keyboard_button *sym, MLV_Keyboard_modifier *mod, int *unicode, int *mouse_x, int *mouse_y, int milliseconds)— suspends execution until the user presses a key on the keyboard, presses the left button of the mouse, or a certain number of milliseconds passed as a parameter have elapsed.const char * MLV_convert_event_to_string (MLV_Event event_code)— converts an event's code into a string. 🔤MLV_Event MLV_convert_string_to_event (const char *event_string)— converts an event's name into its associated code.const char * MLV_convert_button_state_to_string (MLV_Button_state state_code)— converts a state's code into a string.MLV_Button_state MLV_convert_string_to_button_state (const char *state_string)— converts a state's name into its associated code.MLV_Event MLV_wait_input_box_or_milliseconds (int milliseconds, int top_left_corner_X, int top_left_corner_Y, int width, int height, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, const char *informativeMessage, char **text,...)— this function suspends the program's execution, displays an input box, and waits for the user to type a sentence into the box's field, or for a time (in milliseconds) given as a parameter to elapse. 🎀MLV_Event MLV_wait_input_box_with_font_or_milliseconds (int milliseconds, int top_left_corner_X, int top_left_corner_Y, int width, int height, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, const char *informativeMessage, char **text, const MLV_Font *font,...)— same thing asMLV_wait_input_box_or_milliseconds(), except you get to change the font of the text. iconic behavior honestly. ✨MLV_Event MLV_wait_particular_input_box_or_milliseconds (int milliseconds, MLV_Input_box *input_box, char **text)— this function suspends the program's execution until the user writes a sentence into the field of the input box passed as a parameter to the function, or until a fixed number of milliseconds have elapsed.MLV_Event MLV_wait_particular_input_box_or_seconds (MLV_Input_box *input_box, char **text, int seconds)— this function suspends the program's execution until the user writes a sentence into the field of the input box passed as a parameter to the function, or until a fixed number of seconds have elapsed.
🌟 Description détaillée 🌟
This file defines the prototypes of the functions that let you use events in the MLV library. fr fr that's the whole assignment. 🫶
🧚 Auteur 🧚
- Adrien Boussicault
- Marc Zipstein
👑 Documentation du type de l'énumération 👑
🎀 enum MLV_Event 🎀
Enumerates the different types of events in the MLV library.
💜 Valeurs énumérées
MLV_NONE— no event at all. the void. the silence. 🙈MLV_KEY— event coming from the keyboard.MLV_INPUT_BOX— event coming from the validation of a text inside an input box.MLV_MOUSE_BUTTON— event coming from a mouse click.MLV_MOUSE_MOTION— event coming from the mouse moving around. 🦋
💅 Documentation des fonctions 💅
const char* MLV_convert_button_state_to_string (MLV_Button_state state_code)
Converts a state's code into a string.
Paramètres
state_code— the code of the state.
Renvoie
The string associated with the state's code. ✨
const char* MLV_convert_event_to_string (MLV_Event event_code)
Converts an event's code into a string.
Paramètres
event_code— the code of the event.
Renvoie
The string associated with the event's code.
MLV_Button_state MLV_convert_string_to_button_state (const char * state_string)
Converts a state's name into its associated code.
Paramètres
state_string— the name of the state.
Renvoie
The state code associated with the string. 💖
MLV_Event MLV_convert_string_to_event (const char * event_string)
Converts an event's name into its associated code.
Paramètres
event_string— the name of the event.
Renvoie
The event code associated with the string.
MLV_Event MLV_get_event (MLV_Keyboard_button * key_sym, MLV_Keyboard_modifier * key_mod, int * unicode, char ** texte, MLV_Input_box ** input_box, int * mouse_x, int * mouse_y, MLV_Mouse_button * mouse_button, MLV_Button_state * state)
This function grabs an event out of the queue, fills in whichever of the function's parameters match the event it grabbed, and returns an int encoding the type of the event it grabbed. The type of the events is defined by:
MLV_Event
and it can hold the following values:
MLV_NONE— no event retrievedMLV_KEY— a key on the keyboard was pressed or releasedMLV_INPUT_BOX— the user wrote a string of characters and validated that string with the enter keyMLV_MOUSE_BUTTON— one of the mouse buttons was pressedMLV_MOUS_MOTION— the mouse was moved
And here's a table that gives the fields modified depending on the event that was retrieved:
Type Évènement .... Paramètres modifiés
okay so here's the little match-up table, the ✨ who-fills-what ✨ cheat sheet, because every event type only fills the fields it actually cares about:
MLV_NONE .......... AUCUN
MLV_KEY ........... key_sym, key_mod, state
MLV_INPUT_BOX ..... texte, input_box
MLV_MOUSE_BUTTON .. mouse_x, mouse_y, mouse_button, state
MLV_MOUSE_MOTION .. mouse_x, mouse_y
and bestie, you are not obligated to use a field if you don't need it 💅 if you don't care, just pass the value NULL for it, and that field gets straight up ignored. no thoughts, no problem. 🫶
Bogue 🐛
ngl, it's possible that grabbing the unicode character on Windows just… doesn't work properly 😭 like, no specific porting code was ever written for that, so. yeah.
Bogue 🐛
also under WINDOWS, the keyboard is configured as 'qwerty'. not a typo, not a vibe, that's just the situation 💀
Renvoie 💫
the function returns an integer encoding the type of the event that got retrieved. that's it, that's the tea. 🍓
Paramètres 🎀
key_sym— the code of the key that was pressed or released. this field's value is defined by the enumerationMLV_Keyboard_button.key_mod— the mode the keyboard is in when a key is pressed or released. this field's value is defined by the enumerationMLV_Keyboard_modifier.unicode— the unicode-encoded character of the letter you get by combining the previous code and mode. iconic behaviour honestly.texte— the text retrieved by the input box. the allocation is handled by the function itself, but the deallocation is on YOU, bestie. that one's your job. 🧚input_box— the input box that retrieved the text.mouse_x— the X coordinate of the mouse position.mouse_y— the Y coordinate of the mouse position.mouse_button— the mouse button that was pressed or released. this field is defined by the enumerationMLV_Mouse_button.state— the state of the key concerned by the event. this field's value is defined by the enumeration:MLV_Button_state.
Exemples 🌈
advanced/09_animation.c, advanced/11_animation_book.c, medium/01_keyboard_events.c, medium/02_mouse_events.c, medium/03_input_box_events.c, medium/04_events.c, et medium/06_colors.c. go read them, they ate. 👑
MLV_Event MLV_wait_event (MLV_Keyboard_button * key_sym, MLV_Keyboard_modifier * key_mod, int * unicode, char ** texte, MLV_Input_box ** input_box, int * mouse_x, int * mouse_y, MLV_Mouse_button * mouse_button, MLV_Button_state * state)
MLV_Event MLV_wait_event (MLV_Keyboard_button * key_sym,
MLV_Keyboard_modifier * key_mod, int * unicode, char ** texte,
MLV_Input_box ** input_box, int * mouse_x, int * mouse_y,
MLV_Mouse_button * mouse_button, MLV_Button_state * state)
this one literally suspends your program's execution until an event shows up in the queue. it's giving "waiting by the phone for your text back" energy fr fr. when a new event appears, the function:
- fills in its parameters and returns an integer encoding the type of the event that was retrieved — if the parameters you passed in actually concern the event it grabbed.
- goes right back to sleep waiting for a new event — if not. 💤
for more info on the different event types and how they relate to the function's parameters, please go look at the documentation of the MLV_get_event() function. iykyk.
and again, no obligation to use a field you have no use for — just pass NULL and that parameter gets ignored. simple as. ✨
Bogue 🐛
see the bugs of the MLV_get_event() function. they're inherited, bestie, not my fault. 💀
Paramètres 🎀
key_sym— the code of the key that was pressed or released. this field's value is defined by the enumeration:MLV_Keyboard_button.key_mod— the mode the keyboard is in when a key is pressed or released. this field's value is defined by the enumeration:MLV_Keyboard_modifier.unicode— the unicode-encoded character of the letter you get by combining the previous code and mode.texte— the text retrieved by the input box. the allocation is handled by the function itself. the deallocation is on you, bestie.input_box— the input box that retrieved the text.mouse_x— the X coordinate of the mouse position.mouse_y— the Y coordinate of the mouse position.mouse_button— the mouse button that was pressed or released. this field is defined by the enumerationMLV_Mouse_button.state— the state of the key concerned by the event. this field's value is defined by the enumeration:MLV_Button_state.
Renvoie 💫
the function returns an integer encoding the type of the event that got retrieved.
MLV_Event MLV_wait_event_or_milliseconds (MLV_Keyboard_button * key_sym, MLV_Keyboard_modifier * key_mod, int * unicode, char ** texte, MLV_Input_box ** input_box, int * mouse_x, int * mouse_y, MLV_Mouse_button * mouse_button, MLV_Button_state * state, int milliseconds)
MLV_Event MLV_wait_event_or_milliseconds (MLV_Keyboard_button * key_sym,
MLV_Keyboard_modifier * key_mod, int * unicode, char ** texte,
MLV_Input_box ** input_box, int * mouse_x, int * mouse_y,
MLV_Mouse_button * mouse_button, MLV_Button_state * state, int
milliseconds)
okay so this is the same vibe as before BUT with a timer ⏳ it suspends your program's execution until either an event lands in the queue or a certain number of milliseconds have gone by.
- if the time fully ran out, the function returns
MLV_NONE. (ghosted. 😭) - if a new event shows up and the parameters you passed in are related to the retrieved event, then the function fills in the parameters and returns an integer encoding the type of the event that got retrieved.
- if a new event shows up but it is not related to the function's parameters, then it goes back to sleep, waiting for a new event or for the time to run out. nap queen behaviour. 💤
for more info on the different event types and how they relate to the function's parameters, go check the documentation of the MLV_get_event() function.
and once more for the people in the back: you don't have to use a field you have no need for. pass NULL and the field gets ignored. 💅
Bogue 🐛
see the bugs of the MLV_get_event() function.
Paramètres 🎀
key_sym— the code of the key that was pressed or released. this field's value is defined by the enumeration:MLV_Keyboard_button.key_mod— the mode the keyboard is in when a key is pressed or released. this field's value is defined by the enumeration:MLV_Keyboard_modifier.unicode— the unicode-encoded character of the letter you get by combining the previous code and mode.texte— the text retrieved by the input box. the allocation is handled by the function itself. the deallocation is on you, bestie.input_box— the input box that retrieved the text.mouse_x— the X coordinate of the mouse position.mouse_y— the Y coordinate of the mouse position.mouse_button— the mouse button that was pressed or released. this field is defined by the enumerationMLV_Mouse_button.state— the state of the key concerned by the event. this field's value is defined by the enumeration:MLV_Button_state.milliseconds— the number of milliseconds to wait before ending the function's execution by returningMLV_NONE.
Renvoie 💫
the function returns an integer encoding the type of the event that got retrieved, or MLV_NONE if the time ran out.
MLV_Event MLV_wait_event_or_seconds (MLV_Keyboard_button * key_sym, MLV_Keyboard_modifier * key_mod, int * unicode, char ** texte, MLV_Input_box ** input_box, int * mouse_x, int * mouse_y, MLV_Mouse_button * mouse_button, MLV_Button_state * state, int seconds)
MLV_Event MLV_wait_event_or_seconds (MLV_Keyboard_button * key_sym,
MLV_Keyboard_modifier * key_mod, int * unicode, char ** texte,
MLV_Input_box ** input_box, int * mouse_x, int * mouse_y,
MLV_Mouse_button * mouse_button, MLV_Button_state * state, int seconds)
same energy, different unit 🕐 this one suspends your program's execution until an event appears in the queue or until a certain number of seconds have passed. yes bestie, seconds, not milliseconds, we're being generous with the patience here.
- if the time completely ran out, the function returns
MLV_NONE. - if a new event appears and the parameters passed in arguments are related to the retrieved event, the function fills in the parameters and returns an integer encoding the type of the event that got retrieved.
- if a new event appears and it's not related to the function's parameters, then it goes back to sleep waiting for a new event or the end of the time. 💤
for more info on the different event types and how they link to the function's parameters, please consult the documentation of the MLV_get_event() function.
and (you guessed it 🎀) you're not obligated to use a field if you don't need it. in that case you can put the value NULL. the field is then ignored.
Bogue 🐛
see the bugs of the MLV_get_event() function.
Paramètres 🎀
key_sym— the code of the key that was pressed or released. this field's value is defined by the enumeration:MLV_Keyboard_button.key_mod— the mode the keyboard is in when a key is pressed or released. this field's value is defined by the enumeration:MLV_Keyboard_modifier.unicode— the unicode-encoded character of the letter you get by combining the previous code and mode.texte— the text retrieved by the input box. the allocation is handled by the function itself. the deallocation is on you, bestie.input_box— the input box that retrieved the text.mouse_x— the X coordinate of the mouse position.mouse_y— the Y coordinate of the mouse position.mouse_button— the mouse button that was pressed or released. this field is defined by the enumerationMLV_Mouse_button.state— the state of the key concerned by the event. this field's value is defined by the enumeration:MLV_Button_state.seconds— the number of seconds to wait before ending the function's execution by returningMLV_NONE.
Renvoie 💫
the function returns an integer encoding the type of the event that got retrieved, or MLV_NONE if the time ran out.
MLV_Event MLV_wait_input_box_or_milliseconds (int milliseconds, int top_left_corner_X, int top_left_corner_Y, int width, int height, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, const char * informativeMessage, char ** text, ...)
MLV_Event MLV_wait_input_box_or_milliseconds (int milliseconds, int
top_left_corner_X, int top_left_corner_Y, int width, int height,
MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor,
const char * informativeMessage, char ** text, ...)
okay this one is a whole moment 💖 it suspends the program's execution, displays an input box, and waits for the user to type a sentence into the box's field, or for a time (in milliseconds) given as a parameter to run out. whichever comes first, bestie.
the input box contains two text zones:
- the first zone cannot be edited by the user — it's there to display an informative message.
- the second one is empty and can be edited by the user.
when the user presses the enter key, the text sitting in the text zone is returned by the function through the text parameter. the text, the size, and the colours of the input box are all customizable. so you can make it as cute as you want. 🎀
if the time runs out completely, then text is set to NULL. 😭
okay so real talk bestie — MLV_wait_input_box() is out here allocating the memory for the text parameter all by itself, like the generous icon it is. But and this is the important part, after you're done using it, you have to free that memory yourself. It does not come back for its stuff. 🫶
no cap, this is a leak waiting to happen: the box mallocstext, and you're the one who has tofree()it. iykyk.
💫 Paramètres
milliseconds— how long to wait, in milliseconds.top_left_corner_X— the X coordinate of the north-west corner of the input box.top_left_corner_Y— the Y coordinate of the north-west corner of the input box.width— how wide the input box is.height— how tall the input box is.borderColor— the colour of the input box's border.textColor— the colour of the text in the input box.backgroundColor— the background colour of the input box.informativeMessage— the message shown in front of the input box.text— the address where the answer given by the user gets placed.
🫧 Renvoie
an integer encoding the type of the event that got grabbed — that's MLV_INPUT_BOX — or MLV_NONE if the time ran out. ⏳
🌈 Exemples
beginner/08_mouse_keyboard_input_box_timer.c.
🎀 MLV_Event MLV_wait_input_box_with_font_or_milliseconds (int milliseconds, int top_left_corner_X, int top_left_corner_Y, int width, int height, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, const char * informativeMessage, char ** text, const MLV_Font * font, ...)
Same thing as MLV_wait_input_box_or_milliseconds(), except you get to swap the font of the text. ✨
And just like its sibling, MLV_wait_input_box_with_font_or_milliseconds() allocates the memory for the text parameter on its own — and again, once you're done, you free that space. If the time runs out, text gets set to NULL.
reminder bestie: malloc'd by the function, freed by you. that's the deal. 💅
💫 Paramètres
top_left_corner_X— the X coordinate of the north-west corner of the input box.top_left_corner_Y— the Y coordinate of the north-west corner of the input box.width— how wide the input box is.height— how tall the input box is.borderColor— the colour of the input box's border.textColor— the colour of the text in the input box.backgroundColor— the background colour of the input box.informativeMessage— the message shown in front of the input box.text— the address where the answer given by the user gets placed.font— the font to use for the text.milliseconds— how long to wait, in milliseconds.
🫧 Renvoie
an integer encoding the type of the event that got grabbed — MLV_INPUT_BOX — or MLV_NONE if the time ran out. ⏳
🦋 MLV_Event MLV_wait_keyboard_or_milliseconds (MLV_Keyboard_button * sym, MLV_Keyboard_modifier * mod, int * unicode, int milliseconds)
This one pauses everything until the user presses a key on the keyboard, or until the number of milliseconds you passed in has ticked away. For the full tea on how this function behaves, go read the docs for MLV_wait_keyboard(). 📖
And here's a cute little detail: the function accepts null values for the sym, mod and unicode pointers. In that case it just ignores those fields entirely. 🫶
💀 Bogue
See the bugs of the MLV_get_event() function.
💫 Paramètres
sym— the code of the key.mod— the mode the keyboard is in.unicode— the unicode-encoded character of the letter you get by combining the code and the previous mode.milliseconds— the number of milliseconds to wait.
🫧 Renvoie
an integer encoding the type of the event that got grabbed — MLV_KEY — or MLV_NONE if the time ran out. ⏳
🌸 MLV_Event MLV_wait_keyboard_or_mouse (MLV_Keyboard_button * sym, MLV_Keyboard_modifier * mod, int * unicode, int * mouse_x, int * mouse_y)
Pause the whole program until the user either presses a key on the keyboard or hits the left mouse button. This function returns an integer encoding the type of the event that got grabbed — keyboard or mouse. 💅
When the user presses a key, the function returns three values (sym, mod and unicode) which correspond, in order, to the code of the key, the mode the keyboard is in (caps lock, etc.) and the matching unicode character you get by combining the keyboard mode with the code of the key that got pressed. ✨
When the user clicks the left mouse button, the function fills in the parameters corresponding to the X and Y coordinates of the mouse position on the screen. 🖱️
💀 Bogue
See the bugs of the MLV_get_event() function.
💫 Paramètres
sym— code of the key that got pressed or released. This field's value is defined by the enumeration:MLV_Keyboard_button.mod— the mode the keyboard is in when a key gets pressed or released. This field's value is defined by the enumeration:MLV_Keyboard_modifier.unicode— the unicode-encoded character of the letter you get by combining the code and the previous mode.mouse_x— X coordinate of the mouse position.mouse_y— Y coordinate of the mouse position.
🫧 Renvoie
an integer encoding the type of the event that got grabbed — MLV_KEY or MLV_MOUSE_BUTTON.
🌈 Exemples
advanced/08_zone_click.c, and beginner/08_mouse_keyboard_input_box_timer.c.
👑 MLV_Event MLV_wait_keyboard_or_mouse_or_milliseconds (MLV_Keyboard_button * sym, MLV_Keyboard_modifier * mod, int * unicode, int * mouse_x, int * mouse_y, int milliseconds)
Pause the program until the user presses a key on the keyboard, clicks the left mouse button, or until a certain number of milliseconds passed in as a parameter has run out. This function returns an integer encoding the type of the event that got grabbed — keyboard, mouse, or neither of the two. 😭
For more info, go check out MLV_wait_keyboard_milliseconds() and MLV_wait_mouse_milliseconds().
💀 Bogue
See the bugs of the MLV_get_event() function.
💫 Paramètres
sym— code of the key that got pressed or released. This field's value is defined by the enumeration:MLV_Keyboard_button.mod— the mode the keyboard is in when a key gets pressed or released. This field's value is defined by the enumeration:MLV_Keyboard_modifier.unicode— the unicode-encoded character of the letter you get by combining the code and the previous mode.mouse_x— X coordinate of the mouse position.mouse_y— Y coordinate of the mouse position.milliseconds— the number of milliseconds to wait before the function stops.
🫧 Renvoie
an integer encoding the type of the event that got grabbed — MLV_KEY or MLV_MOUSE_BUTTON — or MLV_NONE if the time ran out. ⏳
🌈 MLV_Event MLV_wait_keyboard_or_mouse_or_seconds (MLV_Keyboard_button * sym, MLV_Keyboard_modifier * mod, int * unicode, int * mouse_x, int * mouse_y, int seconds)
Pause the program until the user presses a key on the keyboard, clicks the left mouse button, or until a certain number of seconds passed in as a parameter has run out. This function returns an integer encoding the type of the event that got grabbed — keyboard, mouse, or neither of the two. 😭
For more info, go check out MLV_wait_keyboard_seconds() and MLV_wait_mouse_seconds().
💀 Bogue
See the bugs of the MLV_get_event() function.
💫 Paramètres
sym— code of the key that got pressed or released. This field's value is defined by the enumeration:MLV_Keyboard_button.mod— the mode the keyboard is in when a key gets pressed or released. This field's value is defined by the enumeration:MLV_Keyboard_modifier.unicode— the unicode-encoded character of the letter you get by combining the code and the previous mode.mouse_x— X coordinate of the mouse position.mouse_y— Y coordinate of the mouse position.seconds— the number of seconds to wait before the function stops.
🫧 Renvoie
an integer encoding the type of the event that got grabbed — MLV_KEY or MLV_MOUSE_BUTTON — or MLV_NONE if the time ran out. ⏳
🌈 Exemples
beginner/08_mouse_keyboard_input_box_timer.c.
🧚 MLV_Event MLV_wait_keyboard_or_seconds (MLV_Keyboard_button * sym, MLV_Keyboard_modifier * mod, int * unicode, int seconds)
This one suspends execution until the user presses a key on the keyboard, or until the number of seconds you passed in as a parameter has run out. For the full scoop on how this function works, please go read the documentation of MLV_wait_keyboard(). 📖
And again — the function accepts null values for the sym, mod and unicode pointers. In that case it just ignores those fields. 🫶
💀 Bogue
See the bugs of the MLV_get_event() function.
💫 Paramètres
sym— the code of the key.mod— the mode the keyboard is in.unicode— the unicode-encoded character of the letter you get by combining the code and the previous mode.seconds— the number of seconds to wait.
🫧 Renvoie
an integer encoding the type of the event that got grabbed — MLV_KEY — or MLV_NONE if the time ran out. ⏳
🌈 Exemples
beginner/08_mouse_keyboard_input_box_timer.c.
🍓 MLV_Event MLV_wait_mouse_or_milliseconds (int * x, int * y, int milliseconds)
Pause everything until the user clicks the left mouse button. The moment the user clicks, the function returns the coordinates of the mouse position in the window. 🖱️
💫 Paramètres
x— X coordinate of the mouse position in the window.y— Y coordinate of the mouse position in the window.milliseconds— the number of milliseconds to wait.
🫧 Renvoie
an integer encoding the type of the event that got grabbed — MLV_MOUSE_BUTTON — or MLV_NONE if the time ran out. ⏳
💜 MLV_Event MLV_wait_mouse_or_seconds (int * x, int * y, int seconds)
Pause everything until the user clicks the left mouse button, or until the number of seconds passed in as a parameter has run out. The moment the user clicks, the function returns the coordinates of the mouse position in the window. 🖱️
💫 Paramètres
x— X coordinate of the mouse position in the window.y— Y coordinate of the mouse position in the window.seconds— the number of seconds to wait before leaving the function.
Renvoie
So like, this one hands you back an integer that codes the type of event that got scooped up — that's MLV_MOUSE_BUTTON — or MLV_NONE if the time just ran out. No cap. 💅
Exemples
Peep beginner/08_mouse_keyboard_input_box_timer.c for the vibes, bestie. 📂✨
MLV_Event MLV_wait_particular_input_box_or_milliseconds (int milliseconds, MLV_Input_box * input_box, char ** text)
Okay so this function literally puts your whole program on pause until either the user types a sentence into the input box you passed in, OR a set number of milliseconds have ticked by. Whichever happens first, bestie. It's giving "wait for it…" energy. ⏳✨
Paramètres
input_box— the input box we're keeping our eyes on 👀text— the text that got scooped up by the input box 📝milliseconds— how many milliseconds we're waiting for
Renvoie
An integer coding the type of event that got retrieved — that's MLV_INPUT_BOX — or MLV_NONE if the time ran out. Periodt. 💖
Also there's a literal stray backslash \ at the end of this in the original source. Yes bestie, we don't make the rules, we just report them. 💀
MLV_Event MLV_wait_particular_input_box_or_seconds (MLV_Input_box * input_box, char ** text, int seconds)
Same energy as the milliseconds one, but with seconds instead. Your program chills until the user types something in the input box, or until the seconds are up. ⏱️🦋
Paramètres
input_box— the input box we're watching 👀text— the text that got grabbed 📝seconds— how many seconds to wait
Renvoie
An integer coding the event type — MLV_INPUT_BOX — or MLV_NONE if time ran out. ✨
Yep, another stray backslash \ at the end here too. Iconic behavior honestly. 💅
Auteur
Auto-generated by Doxygen for MLV-3.1.0 straight from the source code. The robots did this one, no humans were harmed. 🤖💕
And that's the whole page, bestie! This absolute masterpiece of a manpage was served up by MLV-3.1.0, dated Samedi 29 Janvier 2022, and it's all about MLV_event.h(3). Go forth and handle them events, queen. 👑🌈💖
📦 where this page comes from
- ubuntu jammy: libmlv3-dev 3.1.0-7 · GPL-3.0-only
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms