Modules | Functions

Modules

 libcaca process management
 

Functions

__extern int caca_get_event (caca_display_t *, int, caca_event_t *, int)
 Get the next mouse or keyboard input event. More...
 
__extern int caca_get_mouse_x (caca_display_t const *)
 Return the X mouse coordinate. More...
 
__extern int caca_get_mouse_y (caca_display_t const *)
 Return the Y mouse coordinate. More...
 
__extern enum caca_event_type caca_get_event_type (caca_event_t const *)
 Return an event's type. More...
 
__extern int caca_get_event_key_ch (caca_event_t const *)
 Return a key press or key release event's value. More...
 
__extern uint32_t caca_get_event_key_utf32 (caca_event_t const *)
 Return a key press or key release event's Unicode value. More...
 
__extern int caca_get_event_key_utf8 (caca_event_t const *, char *)
 Return a key press or key release event's UTF-8 value. More...
 
__extern int caca_get_event_mouse_button (caca_event_t const *)
 Return a mouse press or mouse release event's button. More...
 
__extern int caca_get_event_mouse_x (caca_event_t const *)
 Return a mouse motion event's X coordinate. More...
 
__extern int caca_get_event_mouse_y (caca_event_t const *)
 Return a mouse motion event's Y coordinate. More...
 
__extern int caca_get_event_resize_width (caca_event_t const *)
 Return a resize event's display width value. More...
 
__extern int caca_get_event_resize_height (caca_event_t const *)
 Return a resize event's display height value. More...
 

Detailed Description

These functions handle user events such as keyboard input and mouse clicks.

Function Documentation

◆ caca_get_event()

__extern int caca_get_event ( caca_display_t dp,
int  event_mask,
caca_event_t ev,
int  timeout 
)

Poll the event queue for mouse or keyboard events matching the event mask and return the first matching event. Non-matching events are discarded. If event_mask is zero, the function returns immediately.

The timeout value tells how long this function needs to wait for an event. A value of zero returns immediately and the function returns zero if no more events are pending in the queue. A negative value causes the function to wait indefinitely until a matching event is received.

If not null, ev will be filled with information about the event received. If null, the function will return but no information about the event will be sent.

This function never fails.

Parameters
dpThe libcaca graphical context.
event_maskBitmask of requested events.
timeoutA timeout value in microseconds, -1 for blocking behaviour
evA pointer to a caca_event structure, or NULL.
Returns
1 if a matching event was received, or 0 if the wait timeouted.

References CACA_EVENT_NONE.

Referenced by caca_conio_getch(), and caca_conio_kbhit().

◆ caca_get_mouse_x()

__extern int caca_get_mouse_x ( caca_display_t const *  dp)

Return the X coordinate of the mouse position last time it was detected. This function is not reliable if the ncurses or S-Lang drivers are being used, because mouse position is only detected when the mouse is clicked. Other drivers such as X11 work well.

This function never fails.

Parameters
dpThe libcaca graphical context.
Returns
The X mouse coordinate.

References caca_get_canvas_width().

◆ caca_get_mouse_y()

__extern int caca_get_mouse_y ( caca_display_t const *  dp)

Return the Y coordinate of the mouse position last time it was detected. This function is not reliable if the ncurses or S-Lang drivers are being used, because mouse position is only detected when the mouse is clicked. Other drivers such as X11 work well.

This function never fails.

Parameters
dpThe libcaca graphical context.
Returns
The Y mouse coordinate.

◆ caca_get_event_type()

__extern enum caca_event_type caca_get_event_type ( caca_event_t const *  ev)

Return the type of an event. This function may always be called on an event after caca_get_event() was called, and its return value indicates which other functions may be called:

This function never fails.

Parameters
evThe libcaca event.
Returns
The event's type.

References caca_get_canvas_height().

◆ caca_get_event_key_ch()

__extern int caca_get_event_key_ch ( caca_event_t const *  ev)

Return either the ASCII value for an event's key, or if the key is not an ASCII character, an appropriate enum caca_key value.

This function never fails, but must only be called with a valid event of type CACA_EVENT_KEY_PRESS or CACA_EVENT_KEY_RELEASE, or the results will be undefined. See caca_get_event_type() for more information.

Parameters
evThe libcaca event.
Returns
The key value.

Referenced by caca_conio_getch(), and caca_conio_kbhit().

◆ caca_get_event_key_utf32()

__extern uint32_t caca_get_event_key_utf32 ( caca_event_t const *  ev)

Return the UTF-32/UCS-4 value for an event's key if it resolves to a printable character.

This function never fails, but must only be called with a valid event of type CACA_EVENT_KEY_PRESS or CACA_EVENT_KEY_RELEASE, or the results will be undefined. See caca_get_event_type() for more information.

Parameters
evThe libcaca event.
Returns
The key's Unicode value.

◆ caca_get_event_key_utf8()

__extern int caca_get_event_key_utf8 ( caca_event_t const *  ev,
char *  utf8 
)

Write the UTF-8 value for an event's key if it resolves to a printable character. Up to 6 UTF-8 bytes and a null termination are written.

This function never fails, but must only be called with a valid event of type CACA_EVENT_KEY_PRESS or CACA_EVENT_KEY_RELEASE, or the results will be undefined. See caca_get_event_type() for more information.

Parameters
evThe libcaca event.
utf8A string buffer with enough bytes to hold the pressed key value in UTF-8. Though fewer bytes may be written to it, 7 bytes is the minimum safe size.
Returns
This function always returns 0.

◆ caca_get_event_mouse_button()

__extern int caca_get_event_mouse_button ( caca_event_t const *  ev)

Return the mouse button index for an event.

This function never fails, but must only be called with a valid event of type CACA_EVENT_MOUSE_PRESS or CACA_EVENT_MOUSE_RELEASE, or the results will be undefined. See caca_get_event_type() for more information.

This function returns 1 for the left mouse button, 2 for the right mouse button, and 3 for the middle mouse button.

Parameters
evThe libcaca event.
Returns
The event's mouse button.

◆ caca_get_event_mouse_x()

__extern int caca_get_event_mouse_x ( caca_event_t const *  ev)

Return the X coordinate for a mouse motion event.

This function never fails, but must only be called with a valid event of type CACA_EVENT_MOUSE_MOTION, or the results will be undefined. See caca_get_event_type() for more information.

Parameters
evThe libcaca event.
Returns
The event's X mouse coordinate.

◆ caca_get_event_mouse_y()

__extern int caca_get_event_mouse_y ( caca_event_t const *  ev)

Return the Y coordinate for a mouse motion event.

This function never fails, but must only be called with a valid event of type CACA_EVENT_MOUSE_MOTION, or the results will be undefined. See caca_get_event_type() for more information.

Parameters
evThe libcaca event.
Returns
The event's Y mouse coordinate.

◆ caca_get_event_resize_width()

__extern int caca_get_event_resize_width ( caca_event_t const *  ev)

Return the width value for a display resize event.

This function never fails, but must only be called with a valid event of type CACA_EVENT_RESIZE, or the results will be undefined. See caca_get_event_type() for more information.

Parameters
evThe libcaca event.
Returns
The event's new display width value.

◆ caca_get_event_resize_height()

__extern int caca_get_event_resize_height ( caca_event_t const *  ev)

Return the height value for a display resize event.

This function never fails, but must only be called with a valid event of type CACA_EVENT_RESIZE, or the results will be undefined. See caca_get_event_type() for more information.

Parameters
evThe libcaca event.
Returns
The event's new display height value.