Browse Source

* Allow the caca_event_t *ev argument for caca_get_event() to be NULL.

tags/v0.99.beta14
Sam Hocevar sam 19 years ago
parent
commit
6c0e8da858
10 changed files with 30 additions and 20 deletions
  1. +10
    -2
      caca/event.c
  2. +2
    -2
      doc/migrating.dox
  3. +1
    -2
      test/colors.c
  4. +3
    -2
      test/dithering.c
  5. +1
    -2
      test/font.c
  6. +3
    -2
      test/frames.c
  7. +3
    -2
      test/hsv.c
  8. +1
    -2
      test/transform.c
  9. +3
    -2
      test/truecolor.c
  10. +3
    -2
      test/unicode.c

+ 10
- 2
caca/event.c View File

@@ -50,15 +50,20 @@ static int _lowlevel_event(caca_display_t *, caca_event_t *);
* if no more events are pending in the queue. A negative value causes the * if no more events are pending in the queue. A negative value causes the
* function to wait indefinitely until a matching event is received. * function to wait indefinitely until a matching event is received.
* *
* If not null, \c 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.
*
* \param dp The libcaca graphical context. * \param dp The libcaca graphical context.
* \param event_mask Bitmask of requested events. * \param event_mask Bitmask of requested events.
* \param timeout A timeout value in microseconds * \param timeout A timeout value in microseconds
* \param ev A pointer to a caca_event structure.
* \return The next matching event in the queue, or 0 if no event is pending.
* \param ev A pointer to a caca_event structure, or NULL.
* \return 1 if a matching event was received, or 0 if the wait timeouted.
*/ */
int caca_get_event(caca_display_t *dp, unsigned int event_mask, int caca_get_event(caca_display_t *dp, unsigned int event_mask,
caca_event_t *ev, int timeout) caca_event_t *ev, int timeout)
{ {
caca_event_t dummy_event;
caca_timer_t timer; caca_timer_t timer;
int usec = 0; int usec = 0;


@@ -68,6 +73,9 @@ int caca_get_event(caca_display_t *dp, unsigned int event_mask,
if(timeout > 0) if(timeout > 0)
_caca_getticks(&timer); _caca_getticks(&timer);


if(ev == NULL)
ev = &dummy_event;

for( ; ; ) for( ; ; )
{ {
int ret = _get_next_event(dp, ev); int ret = _get_next_event(dp, ev);


+ 2
- 2
doc/migrating.dox View File

@@ -47,7 +47,7 @@ int main(void)
{ {
/* Initialise libcaca */ /* Initialise libcaca */
cucul_canvas_t *cv; cucul_canvas_t *cv;
caca_display_t *dp; caca_event_t ev;
caca_display_t *dp;
cv = cucul_create_canvas(0, 0); cv = cucul_create_canvas(0, 0);
dp = caca_create_display(cv); dp = caca_create_display(cv);
/* Set window title */ /* Set window title */
@@ -61,7 +61,7 @@ int main(void)
caca_refresh_display(); caca_refresh_display();
/* Wait for a key press event */ /* Wait for a key press event */
caca_get_event(dp, CACA_EVENT_KEY_PRESS, caca_get_event(dp, CACA_EVENT_KEY_PRESS,
&ev, -1);
NULL, -1);
/* Clean up library */ /* Clean up library */
caca_free_display(dp); caca_free_display(dp);
cucul_free_canvas(cv); cucul_free_canvas(cv);


+ 1
- 2
test/colors.c View File

@@ -24,7 +24,6 @@ int main(int argc, char **argv)
{ {
cucul_canvas_t *cv; cucul_canvas_t *cv;
caca_display_t *dp; caca_display_t *dp;
caca_event_t ev;
int i, j; int i, j;


cv = cucul_create_canvas(0, 0); cv = cucul_create_canvas(0, 0);
@@ -51,7 +50,7 @@ int main(int argc, char **argv)
} }


caca_refresh_display(dp); caca_refresh_display(dp);
caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, -1);
caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);


caca_free_display(dp); caca_free_display(dp);
cucul_free_canvas(cv); cucul_free_canvas(cv);


+ 3
- 2
test/dithering.c View File

@@ -13,6 +13,8 @@


#include "config.h" #include "config.h"


#include <stdio.h>

#include "cucul.h" #include "cucul.h"
#include "caca.h" #include "caca.h"


@@ -34,7 +36,6 @@ char density[] = " ',+:;o&%w$W@#";


int main(void) int main(void)
{ {
caca_event_t ev;
cucul_canvas_t *cv; cucul_canvas_t *cv;
caca_display_t *dp; caca_display_t *dp;
int neara, dista, nearb, distb, dist; int neara, dista, nearb, distb, dist;
@@ -124,7 +125,7 @@ int main(void)


caca_refresh_display(dp); caca_refresh_display(dp);


caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, -1);
caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);


caca_free_display(dp); caca_free_display(dp);
cucul_free_canvas(cv); cucul_free_canvas(cv);


+ 1
- 2
test/font.c View File

@@ -38,7 +38,6 @@ int main(int argc, char *argv[])
caca_display_t *dp; caca_display_t *dp;
cucul_font_t *f; cucul_font_t *f;
cucul_dither_t *d; cucul_dither_t *d;
caca_event_t ev;
unsigned char *buf; unsigned char *buf;
unsigned int w, h; unsigned int w, h;
char const * const * fonts; char const * const * fonts;
@@ -97,7 +96,7 @@ int main(int argc, char *argv[])
cucul_get_canvas_height(cv), d, buf); cucul_get_canvas_height(cv), d, buf);
caca_refresh_display(dp); caca_refresh_display(dp);


caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, -1);
caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);


/* Free everything */ /* Free everything */
caca_free_display(dp); caca_free_display(dp);


+ 3
- 2
test/frames.c View File

@@ -21,12 +21,13 @@ typedef unsigned short uint16_t;
typedef unsigned int uint32_t; typedef unsigned int uint32_t;
#endif #endif


#include <stdio.h>

#include "cucul.h" #include "cucul.h"
#include "caca.h" #include "caca.h"


int main(void) int main(void)
{ {
caca_event_t ev;
cucul_canvas_t *cv; cucul_canvas_t *cv;
caca_display_t *dp; caca_display_t *dp;


@@ -57,7 +58,7 @@ int main(void)
} }


n = 0; n = 0;
while(!caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, 0))
while(!caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, 0))
{ {
cucul_set_canvas_frame(cv, n % 16); cucul_set_canvas_frame(cv, n % 16);
caca_refresh_display(dp); caca_refresh_display(dp);


+ 3
- 2
test/hsv.c View File

@@ -21,6 +21,8 @@ typedef unsigned short uint16_t;
typedef unsigned int uint32_t; typedef unsigned int uint32_t;
#endif #endif


#include <stdio.h>

#include "cucul.h" #include "cucul.h"
#include "caca.h" #include "caca.h"


@@ -28,7 +30,6 @@ uint32_t buffer[256*256];


int main(void) int main(void)
{ {
caca_event_t ev;
cucul_canvas_t *cv; cucul_canvas_t *cv;
caca_display_t *dp; caca_display_t *dp;


@@ -52,7 +53,7 @@ int main(void)


caca_refresh_display(dp); caca_refresh_display(dp);


caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, -1);
caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);


caca_free_display(dp); caca_free_display(dp);
cucul_free_canvas(cv); cucul_free_canvas(cv);


+ 1
- 2
test/transform.c View File

@@ -49,7 +49,6 @@ static char const *duck[] =


int main(void) int main(void)
{ {
caca_event_t ev;
cucul_canvas_t *cv, *normal, *flip, *flop, *rotate; cucul_canvas_t *cv, *normal, *flip, *flop, *rotate;
caca_display_t *dp; caca_display_t *dp;
int i; int i;
@@ -108,7 +107,7 @@ int main(void)


caca_refresh_display(dp); caca_refresh_display(dp);


caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, -1);
caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);


caca_free_display(dp); caca_free_display(dp);
cucul_free_canvas(rotate); cucul_free_canvas(rotate);


+ 3
- 2
test/truecolor.c View File

@@ -21,12 +21,13 @@ typedef unsigned short uint16_t;
typedef unsigned int uint32_t; typedef unsigned int uint32_t;
#endif #endif


#include <stdio.h>

#include "cucul.h" #include "cucul.h"
#include "caca.h" #include "caca.h"


int main(void) int main(void)
{ {
caca_event_t ev;
cucul_canvas_t *cv; cucul_canvas_t *cv;
caca_display_t *dp; caca_display_t *dp;


@@ -50,7 +51,7 @@ int main(void)


caca_refresh_display(dp); caca_refresh_display(dp);


caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, -1);
caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);


caca_free_display(dp); caca_free_display(dp);
cucul_free_canvas(cv); cucul_free_canvas(cv);


+ 3
- 2
test/unicode.c View File

@@ -21,12 +21,13 @@ typedef unsigned short uint16_t;
typedef unsigned int uint32_t; typedef unsigned int uint32_t;
#endif #endif


#include <stdio.h>

#include "cucul.h" #include "cucul.h"
#include "caca.h" #include "caca.h"


int main(void) int main(void)
{ {
caca_event_t ev;
cucul_canvas_t *cv; cucul_canvas_t *cv;
caca_display_t *dp; caca_display_t *dp;


@@ -87,7 +88,7 @@ int main(void)


caca_refresh_display(dp); caca_refresh_display(dp);


caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, -1);
caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);


caca_free_display(dp); caca_free_display(dp);
cucul_free_canvas(cv); cucul_free_canvas(cv);


Loading…
Cancel
Save