Ignore:
Timestamp:
Nov 25, 2007, 12:11:54 PM (13 years ago)
Author:
Sam Hocevar
Message:
  • Made the caca_event_t structure opaque and created a whole bunch of functions to access its real data. This is a big API change that will break your software, sorry :(
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/caca.h

    r2043 r2049  
    5454struct caca_event
    5555{
    56     /** \brief User event type enumeration.
    57      *
    58      *  This enum serves two purposes:
    59      *  - Build listening masks for caca_get_event().
    60      *  - Define the type of a \e caca_event_t.
    61      */
    62     enum caca_event_type
    63     {
    64         CACA_EVENT_NONE =          0x0000, /**< No event. */
     56    unsigned char opaque_structure[32];
     57};
    6558
    66         CACA_EVENT_KEY_PRESS =     0x0001, /**< A key was pressed. */
    67         CACA_EVENT_KEY_RELEASE =   0x0002, /**< A key was released. */
    68         CACA_EVENT_MOUSE_PRESS =   0x0004, /**< A mouse button was pressed. */
    69         CACA_EVENT_MOUSE_RELEASE = 0x0008, /**< A mouse button was released. */
    70         CACA_EVENT_MOUSE_MOTION =  0x0010, /**< The mouse was moved. */
    71         CACA_EVENT_RESIZE =        0x0020, /**< The window was resized. */
    72         CACA_EVENT_QUIT =          0x0040, /**< The user requested to quit. */
     59/** \brief User event type enumeration.
     60 *
     61 *  This enum serves two purposes:
     62 *  - Build listening masks for caca_get_event().
     63 *  - Define the type of a \e caca_event_t.
     64 */
     65enum caca_event_type
     66{
     67    CACA_EVENT_NONE =          0x0000, /**< No event. */
    7368
    74         CACA_EVENT_ANY =           0xffff  /**< Bitmask for any event. */
    75     }
    76     /** \brief User event type member.
    77      *
    78      *  This field is always valid when caca_get_event() returns.
    79     */
    80     type;
     69    CACA_EVENT_KEY_PRESS =     0x0001, /**< A key was pressed. */
     70    CACA_EVENT_KEY_RELEASE =   0x0002, /**< A key was released. */
     71    CACA_EVENT_MOUSE_PRESS =   0x0004, /**< A mouse button was pressed. */
     72    CACA_EVENT_MOUSE_RELEASE = 0x0008, /**< A mouse button was released. */
     73    CACA_EVENT_MOUSE_MOTION =  0x0010, /**< The mouse was moved. */
     74    CACA_EVENT_RESIZE =        0x0020, /**< The window was resized. */
     75    CACA_EVENT_QUIT =          0x0040, /**< The user requested to quit. */
    8176
    82     /** \brief User event data member.
    83      *
    84      *  The validity of the \e data union depends on the value of the \e type
    85      *  field:
    86      *  - \c CACA_EVENT_NONE: no other field is valid.
    87      *  - \c CACA_EVENT_KEY_PRESS, \c CACA_EVENT_KEY_RELEASE: the
    88      *  \e data.key.ch field is valid and contains either the ASCII value for
    89      *  the key, or an \e enum \e caca_key value. If the value is a printable
    90      *  ASCII character, the \e data.key.utf32 and \e data.key.utf8 fields are
    91      *  also filled and contain respectively the UTF-32/UCS-4 and the UTF-8
    92      *  representations of the character. Otherwise, their content is
    93      *  undefined.
    94      *  - \c CACA_EVENT_MOUSE_PRESS, \c CACA_EVENT_MOUSE_RELEASE: the
    95      *  \e data.mouse.button field is valid and contains the index of the
    96      *  mouse button that was pressed.
    97      *  - \c CACA_EVENT_MOUSE_MOTION: the \e data.mouse.x and \e data.mouse.y
    98      *  fields are valid and contain the mouse coordinates in character
    99      *  cells.
    100      *  - \c CACA_EVENT_RESIZE: the \e data.resize.w and \e data.resize.h
    101      *  fields are valid and contain the new width and height values of
    102      *  the \e libcucul canvas attached to \e libcaca.
    103      *  - \c CACA_EVENT_QUIT: no other field is valid.
    104      *
    105      *  The result of accessing data members outside the above conditions is
    106      *  undefined.
    107      */
    108     union
    109     {
    110         struct { unsigned int x, y, button; } mouse;
    111         struct { unsigned int w, h; } resize;
    112         struct { unsigned int ch; unsigned long int utf32; char utf8[8]; } key;
    113     } data;
     77    CACA_EVENT_ANY =           0xffff  /**< Bitmask for any event. */
    11478};
    11579
     
    197161__extern unsigned int caca_get_display_height(caca_display_t const *);
    198162__extern int caca_set_display_title(caca_display_t *, char const *);
     163__extern int caca_set_mouse(caca_display_t *, int);
     164__extern int caca_set_cursor(caca_display_t *, int);
    199165/*  @} */
    200166
     
    209175__extern unsigned int caca_get_mouse_x(caca_display_t const *);
    210176__extern unsigned int caca_get_mouse_y(caca_display_t const *);
    211 __extern int caca_set_mouse(caca_display_t *, int);
    212 __extern int caca_set_cursor(caca_display_t *, int);
     177__extern enum caca_event_type caca_get_event_type(caca_event_t const *);
     178__extern unsigned int caca_get_event_key_ch(caca_event_t const *);
     179__extern unsigned long int caca_get_event_key_utf32(caca_event_t const *);
     180__extern int caca_get_event_key_utf8(caca_event_t const *, char *);
     181__extern unsigned int caca_get_event_mouse_button(caca_event_t const *);
     182__extern unsigned int caca_get_event_mouse_x(caca_event_t const *);
     183__extern unsigned int caca_get_event_mouse_y(caca_event_t const *);
     184__extern unsigned int caca_get_event_resize_width(caca_event_t const *);
     185__extern unsigned int caca_get_event_resize_height(caca_event_t const *);
    213186/*  @} */
    214187
Note: See TracChangeset for help on using the changeset viewer.