libcaca  0.99.beta19
About: libcaca is a graphics library that outputs text instead of pixels, so that it can work on older video cards or text terminals (something like an advanced AAlib library).
  Fossies Dox: libcaca-0.99.beta19.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

libcaca event handling

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

Functions

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

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

Get the next mouse or keyboard input event.

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.

Definition at line 63 of file event.c.

References _caca_getticks(), _caca_sleep(), _get_next_event(), CACA_EVENT_NONE, dp, STAT_IADD, timer, and caca_privevent::type.

◆ caca_get_event_key_ch()

int caca_get_event_key_ch ( caca_event_t const *  ev)

Return a key press or key release event's value.

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.

Definition at line 219 of file event.c.

Referenced by __caca0_get_event(), caca_conio_getch(), caca_conio_kbhit(), game(), get_event(), Java_org_zoy_caca_Event_getEventKeyCh(), and main().

◆ caca_get_event_key_utf32()

uint32_t caca_get_event_key_utf32 ( caca_event_t const *  ev)

Return a key press or key release event's Unicode value.

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.

Definition at line 236 of file event.c.

Referenced by get_event(), and Java_org_zoy_caca_Event_getEventKeyUtf32().

◆ caca_get_event_key_utf8()

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

Return a key press or key release event's UTF-8 value.

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.

Definition at line 256 of file event.c.

Referenced by get_event(), and Java_org_zoy_caca_Event_getEventKeyUtf8().

◆ caca_get_event_mouse_button()

int caca_get_event_mouse_button ( caca_event_t const *  ev)

Return a mouse press or mouse release event's button.

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.

Definition at line 276 of file event.c.

Referenced by __caca0_get_event(), get_event(), Java_org_zoy_caca_Event_getEventMouseButton(), and main().

◆ caca_get_event_mouse_x()

int caca_get_event_mouse_x ( caca_event_t const *  ev)

Return a mouse motion event's X coordinate.

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.

Definition at line 292 of file event.c.

Referenced by __caca0_get_event(), get_event(), and Java_org_zoy_caca_Event_getEventMouseX().

◆ caca_get_event_mouse_y()

int caca_get_event_mouse_y ( caca_event_t const *  ev)

Return a mouse motion event's Y coordinate.

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.

Definition at line 308 of file event.c.

Referenced by __caca0_get_event(), get_event(), and Java_org_zoy_caca_Event_getEventMouseY().

◆ caca_get_event_resize_height()

int caca_get_event_resize_height ( caca_event_t const *  ev)

Return a resize event's display height value.

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.

Definition at line 340 of file event.c.

Referenced by get_event(), Java_org_zoy_caca_Event_getEventResizeHeight(), and main().

◆ caca_get_event_resize_width()

int caca_get_event_resize_width ( caca_event_t const *  ev)

Return a resize event's display width value.

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.

Definition at line 324 of file event.c.

Referenced by get_event(), Java_org_zoy_caca_Event_getEventResizeWidth(), and main().

◆ caca_get_event_type()

enum caca_event_type caca_get_event_type ( caca_event_t const *  ev)

Return an event's type.

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.

Definition at line 202 of file event.c.

Referenced by __caca0_get_event(), game(), get_event(), Java_org_zoy_caca_Event_getEventType(), and main().

◆ caca_get_mouse_x()

int caca_get_mouse_x ( caca_display_t const *  dp)

Return the X mouse coordinate.

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.

Definition at line 148 of file event.c.

References caca_get_canvas_width(), caca_display::cv, dp, caca_display::mouse, and caca_display::mouse::x.

◆ caca_get_mouse_y()

int caca_get_mouse_y ( caca_display_t const *  dp)

Return the Y mouse coordinate.

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.

Definition at line 170 of file event.c.

References caca_get_canvas_height(), caca_display::cv, dp, caca_display::mouse, and caca_display::mouse::y.