Bienvenue sur le site de la LibLapin.
Jetez un coup d'oeil en bas de la page pour choisir votre niveau de documentation en fonction de votre niveau avec la LibLapin.
Pour l'instant, c'est réglé sur 'Manuel complet'. Si c'est votre première fois avec la LibLapin, il vaudrait mieux choisir 'Débutant'.
De même, n'oubliez pas de préciser une version de la bibliothèque.

LibLapin's logo

LibLapin

Events





The events module header is lapin/events.h.

Note that every function pointer typedef have a function typedef equivalent!
For example:

typedef enum e_bunny_response
{
     EXIT_ON_ERROR,      EXIT_ON_CROSS,      EXIT_ON_SUCCESS,      SWITCH_CONTEXT,      GO_ON
} t‌_‌b‌u‌n‌n‌y‌_‌r‌e‌s‌p‌o‌n‌s‌e;

Description

     This enumeration is used as return value by every event callbacks, b‌u‌n‌n‌y‌_‌l‌o‌o‌p and b‌u‌n‌n‌y‌_‌l‌o‌o‌p‌_‌m‌w and mix informations and request. Except GO_ON, every values of this enumeration if returned by an event callback will make b‌u‌n‌n‌y‌_‌l‌o‌o‌p or b‌u‌n‌n‌y‌_‌l‌o‌o‌p‌_‌m‌w exiting and returning the concerned value.

Symbols



INDEX

typedef enum e_bunny_response
{
     GO_DOWN,      GO_UP,      LOST_FOCUS = GO_DOWN,      GOT_FOCUS = GO_UP,      CONNECTED = GO_DOWN,      DISCONNECTED = GO_UP,      ENTERING = GO_DOWN,      LEAVING = GO_UP,
} t‌_‌b‌u‌n‌n‌y‌_‌r‌e‌s‌p‌o‌n‌s‌e;

Description

     Describe if a button is going up or down, the windows focus is lost or got, a joystick is connected or disconnected... or we are entering for the first time in the b‌u‌n‌n‌y‌_‌l‌o‌o‌p or b‌u‌n‌n‌y‌_‌l‌o‌o‌p‌_‌m‌w loop, or leaving it.


INDEX

typedef enum e_bunny_keysym
{
     BKS_UNKNOWN = -1,
     BKS_A,
     BKS_B,
     BKS_C,
     BKS_D,
     BKS_E,
     BKS_F,
     BKS_G,
     BKS_H,
     BKS_I,
     BKS_J,
     BKS_K,
     BKS_L,
     BKS_M,
     BKS_N,
     BKS_O,
     BKS_P,
     BKS_Q,
     BKS_R,
     BKS_S,
     BKS_T,
     BKS_U,
     BKS_V,
     BKS_W,
     BKS_X,
     BKS_Y,
     BKS_Z,
     BKS_0,
     BKS_1,
     BKS_2,
     BKS_3,
     BKS_4,
     BKS_5,
     BKS_6,
     BKS_7,
     BKS_8,
     BKS_9,
     BKS_ESCAPE,
     BKS_LCONTROL,
     BKS_LSHIFT,
     BKS_LALT,
     BKS_LSYSTEM,
     BKS_RCONTROL,
     BKS_RSHIFT,
     BKS_RALT,
     BKS_RSYSTEM,
     BKS_MENU,
     BKS_LBRACKET,
     BKS_RBRACKET,
     BKS_SEMICOLON,
     BKS_COMMA,
     BKS_PERIOD,
     BKS_QUOTE,
     BKS_SLASH,
     BKS_BACKSLASH,
     BKS_TILDE,
     BKS_EQUAL,
     BKS_DASH,
     BKS_SPACE,
     BKS_RETURN,
     BKS_BACKSPACE,
     BKS_TAB,
     BKS_PAGEUP,
     BKS_PAGEDOWN,
     BKS_END,
     BKS_HOME,
     BKS_INSERT,
     BKS_DELETE,
     BKS_ADD,
     BKS_SUBTRACT,
     BKS_MULTIPLY,
     BKS_DIVIDE,
     BKS_LEFT,
     BKS_RIGHT,
     BKS_UP,
     BKS_DOWN,
     BKS_NUMPAD0,
     BKS_NUMPAD1,
     BKS_NUMPAD2,
     BKS_NUMPAD3,
     BKS_NUMPAD4,
     BKS_NUMPAD5,
     BKS_NUMPAD6,
     BKS_NUMPAD7,
     BKS_NUMPAD8,
     BKS_NUMPAD9,
     BKS_F1,
     BKS_F2,
     BKS_F3,
     BKS_F4,
     BKS_F5,
     BKS_F6,
     BKS_F7,
     BKS_F8,
     BKS_F9,
     BKS_F10,
     BKS_F11,
     BKS_F12,
     BKS_F13,
     BKS_F14,
     BKS_F15,
     BKS_PAUSE,
     BKS_LAST_KEY

} t‌_‌b‌u‌n‌n‌y‌_‌k‌e‌y‌s‌y‌m;

Description

     This enumeration represents all keys that the bunny library can handle on a keyboard as key pressed or key released events.



INDEX


Description

     The type of function called when a keyboard event happen. If you need to handle text input, use t‌_‌b‌u‌n‌n‌y‌_‌t‌y‌p‌e instead.

Parameters



INDEX


Description

     This function allow you to define a callback function that will be called when a key event occurs.

Parameters



INDEX


Description

     This function returns the keyboard status. In the bunny library, keyboard status is updated only if a keyboard response function is set.

Return value

Returns an array of BKS_LAST_KEY size containing keys status.




INDEX


Description

     The type of function called when a character is typed.

Parameters



INDEX


Description

     This function allow you to define a callback function that will be called when a character is entered.
It handles special characters, take care of CTRL and SHIFT modifier.

Parameters



INDEX

typedef enum e_bunny_mouse_button
{
     BMB_LEFT,
     BMB_RIGHT,
     BMB_MIDDLE,
     BMB_EXTRABUTTON0,
     BMB_EXTRABUTTON1,
     LAST_BUNNY_MOUSEBUTTON

} t‌_‌b‌u‌n‌n‌y‌_‌m‌o‌u‌s‌e‌_‌b‌u‌t‌t‌o‌n;

Description

     This enumeration represents all buttons that the bunny library can handle on a mouse.



INDEX


Description

     The type of function called when a mouse button event happen.

Parameters



INDEX


Description

     This function allow you to define a callback function that will be called when a mouse button is clicked.

Parameters



INDEX


Description

     This function returns the mouse button status. In the bunny library, mouse button status is updated only if a mouse button response function is set.

Return value

Returns an array of LAST_BUNNY_MOUSEBUTTON size containing buttons status.




INDEX


Description

     The type of function called when a mouse move event happen.

Parameters



INDEX


Description

     This function allow you to define a callback function that will be called when a mouse move events occurs.

Parameters



INDEX


Description

     This function returns the cursor position, relatively to the top left corner of the window. In the bunny library, mouse position is updated only if a mouse move response function is set.

Return value

Returns a statically allocated t‌_‌b‌u‌n‌n‌y‌_‌p‌o‌s‌i‌t‌i‌o‌n with the cursor position inside.




INDEX


Description

     The type of function called when a mouse wheel event happen.

Parameters



INDEX


Description

     This function allow you to define a callback function that will be called when the mouse wheel is rolled.

Parameters



INDEX

typedef struct s_bunny_joystick
{
     bool connected;
     const char *name;
     unsigned int vendor;
     unsigned int product;
     unsigned int nb_button;
     unsigned char axis;

} t‌_‌b‌u‌n‌n‌y‌_‌j‌o‌y‌s‌t‌i‌c‌k;

Description

     This structure describe a joystick.



INDEX


Description

     The type of function called when a joystick is connected or disconnected.

Parameters



INDEX


Description

     This function allow you to define a callback function that will be called when a joystick connection or disconnection event occurs.

Parameters



INDEX


Description

     This function returns informations about the joystick with the associated sent id.

Return value

Returns a t‌_‌b‌u‌n‌n‌y‌_‌j‌o‌y‌s‌t‌i‌c‌k pointer or NULL if id was invalid.




INDEX

typedef enum e_bunny_axis
{
     BA_X = 1,
     BA_Y = 2,
     BA_Z = 4,
     BA_R = 8,
     BA_U = 16,
     BA_V = 32,
     BA_POVX = 64,
     BA_POVY = 128,
     LAST_BUNNY_AXIS = 8

} t‌_‌b‌u‌n‌n‌y‌_‌a‌x‌i‌s;

Description

     This enumeration represents all axis that the bunny library can handle on a joystick.



INDEX


Description

     The type of function called when a joystick axis moved.

Parameters



INDEX


Description

     This function allow you to define a callback function that will be called when a joystick axis is moved.

Parameters



INDEX


Description

     Set a minimum shift between a previous value and a new one to trigger the joystick axis event. It avoids useless repetition on analogic joystick that can be annoying on menus.

Parameters



INDEX


Description

     This function returns an array with two dimensions, the first one being the joystick id, the second one being the axis. In the bunny library, joystick axis status is updated only if a joystick axis response function is set.

Return value

Returns a two dimensional array. Values are in [-100; 100].




INDEX


Description

     The type of function called when a joystick button is pressed or released.

Parameters



INDEX


Description

     This function allow you to define a callback function that will be called when a joystick button is pressed or released.

Parameters



INDEX


Description

     This function returns an array with two dimensions, the first one being the joystick id, the second one being the buttons. In the bunny library, joystick button status is updated only if a joystick button response function is set.

Return value

Returns a two dimensional array.




INDEX


Description

     The type of function called when a window got the focus.

Parameters



INDEX


Description

     This function allow you to define a callback function that will be called when a window got the focus.

Parameters

  • t_bunny_got_focus function:
         The function to call.


INDEX


Description

     The type of function called when a window lost the focus.

Parameters



INDEX


Description

     This function allow you to define a callback function that will be called when a window lost the focus.

Parameters



INDEX

k

Description

     The type of function called when a window is resized.

Parameters



INDEX


Description

     This function allow you to define a callback function that will be called when a window is resized.

Parameters



INDEX


Description

     The type of function called when a window is closed. This function pointer is usefuly only if you use b‌u‌n‌n‌y‌_‌l‌o‌o‌p‌_‌m‌w as main loop.

Parameters



INDEX


Description

     This function allow you to define a callback function that will be called when a window is closed. Only works with b‌u‌n‌n‌y‌_‌l‌o‌o‌p‌_‌m‌w.

Parameters



INDEX


Description

     This function returns the window that is currently handling events. This function is useful when using b‌u‌n‌n‌y‌_‌l‌o‌o‌p‌_‌m‌w.

Return value

Returns the window that have its event currently being handled.




INDEX


Description

     The type of function called at the end of the main loop, when displaying is required, if there is enough time left after all events and main computing.

Parameters



INDEX


Description

     This function allow you to define a callback function that will be called at the end of the b‌u‌n‌n‌y‌_‌l‌o‌o‌p or b‌u‌n‌n‌y‌_‌l‌o‌o‌p‌_‌m‌w cycle if there is enough time remaining (a security ensure that it is called sometimes, even if the loop is always late). In the best case, it is called as much as the function sent to b‌u‌n‌n‌y‌_‌s‌e‌t‌_‌l‌o‌o‌p‌_‌m‌a‌i‌n‌_‌f‌u‌n‌c‌t‌i‌o‌n.

Parameters



INDEX


Description

     The type of function called at a specific frequency to do central processing.

Parameters



INDEX

k

Description

     This function allow you to define a callback function that will be called at the frequency given to b‌u‌n‌n‌y‌_‌l‌o‌o‌p or b‌u‌n‌n‌y‌_‌l‌o‌o‌p‌_‌m‌w. If the loop is late, calls will be caught back later. Several call to the function to catch up will not provoke several calls to the function set with b‌u‌n‌n‌y‌_‌s‌e‌t‌_‌d‌i‌s‌p‌l‌a‌y‌_‌f‌u‌n‌c‌t‌i‌o‌n but a single one.

Parameters



INDEX


Description

     This function is a giant loop that handles events and real-time pacing. It only manage a single window. For multiple window, see b‌u‌n‌n‌y‌_‌l‌o‌o‌p‌_‌m‌w.

Parameters


Return value

This function returns the first value returned by an event or display or loop function that is not GO_ON from t_bunny_event.




INDEX


Description

     This function is a giant loop that handles events and real-time pacing. It manages nbr_win windows.

Parameters


Return value

This function returns the first value returned by an event or display or loop function that is not GO_ON from t_bunny_event.




INDEX


Description

     This function returns the frequency under perfect conditions of the b‌u‌n‌n‌y‌_‌l‌o‌o‌p or of the b‌u‌n‌n‌y‌_‌l‌o‌o‌p‌_‌m‌w in Hertz.

Return value

Returns the frequency of the current bunny loop.



INDEX


Description

     This function set a network client inside the bunny loop to handle its events. To remove it, use b‌u‌n‌n‌y‌_‌r‌e‌m‌o‌v‌e‌_‌n‌e‌t‌w‌o‌r‌k‌_‌f‌r‌o‌m‌_‌s‌c‌h‌e‌d‌u‌l‌e‌r.

Parameters



INDEX


Description

     This function set a network server inside the bunny loop to handle its events. To remove it, use b‌u‌n‌n‌y‌_‌r‌e‌m‌o‌v‌e‌_‌n‌e‌t‌w‌o‌r‌k‌_‌f‌r‌o‌m‌_‌s‌c‌h‌e‌d‌u‌l‌e‌r.

Parameters



INDEX


Description

     Remove network server or client from the bunny loop.



INDEX


Description

     The type of function called when a network message is received.

Parameters



INDEX


Description

     This function allow you to define a callback function that will be called when a network message is received.



INDEX


Description

     The type of function called when a connection is opened or closed.

Parameters



INDEX


Description

     This function allow you to define a callback function that will be called when a network connection is established or closed.



INDEX

k

Description

     This function allow you to define a callback function that will be called when entering in the bunny loop.

Parameters



INDEX

k

Description

     The type of function called when b‌u‌n‌n‌y‌_‌l‌o‌o‌p or b‌u‌n‌n‌y‌_‌l‌o‌o‌p‌_‌m‌w is exited.



INDEX


Description

     This function allow you to define a callback function that will be called when leaving the bunny loop.



INDEX


Description

     The type of function called when an asynchronous computation requested is terminated.

Parameters



INDEX


Description

     This function allow you to define a callback function that will be called when an asynchronous computation request is terminated.



INDEX

typedef struct s_bunny_context
{
     t‌_‌b‌u‌n‌n‌y‌_‌k‌e‌y key;
     t‌_‌b‌u‌n‌n‌y‌_‌t‌y‌p‌e type;
     t‌_‌b‌u‌n‌n‌y‌_‌c‌l‌i‌c‌k click;
     t‌_‌b‌u‌n‌n‌y‌_‌m‌o‌v‌e move;
     t‌_‌b‌u‌n‌n‌y‌_‌w‌h‌e‌e‌l wheel;
     t‌_‌b‌u‌n‌n‌y‌_‌j‌o‌y‌_‌c‌o‌n‌n‌e‌c‌t connect;
     t‌_‌b‌u‌n‌n‌y‌_‌j‌o‌y‌_‌b‌u‌t‌t‌o‌n button;
     t‌_‌b‌u‌n‌n‌y‌_‌j‌o‌y‌_‌a‌x‌i‌s axis;
     t‌_‌b‌u‌n‌n‌y‌_‌g‌e‌t‌_‌f‌o‌c‌u‌s get_focus;
     t‌_‌b‌u‌n‌n‌y‌_‌l‌o‌s‌t‌_‌f‌o‌c‌u‌s lost_focus;
     t‌_‌b‌u‌n‌n‌y‌_‌r‌e‌s‌i‌z‌e resize;
     t‌_‌b‌u‌n‌n‌y‌_‌l‌o‌o‌p loop;
     t‌_‌b‌u‌n‌n‌y‌_‌d‌i‌s‌p‌l‌a‌y display;
     t‌_‌b‌u‌n‌n‌y‌_‌c‌l‌o‌s‌e close;
     t‌_‌b‌u‌n‌n‌y‌_‌n‌e‌t‌w‌o‌r‌k *netcom;
     t‌_‌b‌u‌n‌n‌y‌_‌m‌e‌s‌s‌a‌g‌e‌_‌r‌e‌s‌p‌o‌n‌s‌e netmessage;
     t‌_‌b‌u‌n‌n‌y‌_‌c‌o‌n‌n‌e‌c‌t‌_‌r‌e‌s‌p‌o‌n‌s‌e netconnect;
     t‌_‌b‌u‌n‌n‌y‌_‌l‌o‌o‌p entering_context;
     t‌_‌b‌u‌n‌n‌y‌_‌l‌e‌a‌v‌i‌n‌g‌_‌c‌o‌n‌t‌e‌x‌t leaving_context;

} t‌_‌b‌u‌n‌n‌y‌_‌c‌o‌n‌t‌e‌x‌t;

Description

     This structure is a full callback context. It allow to set every callbacks in a single call to b‌u‌n‌n‌y‌_‌s‌e‌t‌_‌c‌o‌n‌t‌e‌x‌t. NULL can be use to deactivate callbacks.

     To enable network events, the netcom field must be set to your t‌_‌b‌u‌n‌n‌y‌_‌s‌e‌r‌v‌e‌r or t‌_‌b‌u‌n‌n‌y‌_‌c‌l‌i‌e‌n‌t.



INDEX

typedef struct s_bunny_anonymous_context
{
     void key;
     void type;
     void click;
     void move;
     void wheel;
     void connect;
     void button;
     void axis;
     void get_focus;
     void lost_focus;
     void resize;
     void loop;
     void display;
     void close;
     void *netcom;
     void netmessage;
     void netconnect;
     void entering_context;
     void leaving_context;

} t‌_‌b‌u‌n‌n‌y‌_‌a‌n‌o‌n‌y‌m‌o‌u‌s‌_‌c‌o‌n‌t‌e‌x‌t;

Description

     This structure is a full callback context compatible with the t‌_‌b‌u‌n‌n‌y‌_‌c‌o‌n‌t‌e‌x‌t structure and present for commodity: the power of void pointers allow you, depending of how you compile, not cast slitghly different function pointers to make them go inside the structure. Slitghly different means, in most case, with a type specified instead of a regular void pointer as data parameter.



INDEX


Description

     Set all callbacks of bunny loop in a single call with function pointers from context.

A C++ version, B‌u‌n‌n‌y‌:‌:‌S‌e‌t‌C‌o‌n‌t‌e‌x‌t is available in the Context module.

Parameters



INDEX


Description

     Get all callbacks from bunny loop in a single call and store them inside context.

Parameters



INDEX