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_bunny_response;
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_bunny_response;
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
bunny_loop or
bunny_loop_mw 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_bunny_keysym;
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_bunny_type instead.
INDEX
Description
  This function allow you to define a callback function that
will be called when a key event occurs.
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.
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.
INDEX
typedef enum e_bunny_mouse_button
{
 
BMB_LEFT,
 
BMB_RIGHT,
 
BMB_MIDDLE,
 
BMB_EXTRABUTTON0,
 
BMB_EXTRABUTTON1,
 
LAST_BUNNY_MOUSEBUTTON
}
t_bunny_mouse_button;
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.
INDEX
Description
  This function allow you to define a callback function that
will be called when a mouse button is clicked.
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.
INDEX
Description
  This function allow you to define a callback function that
will be called when a mouse move events occurs.
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.
INDEX
Description
  The type of function called when a mouse wheel event happen.
INDEX
Description
  This function allow you to define a callback function that
will be called when the mouse wheel is rolled.
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_bunny_joystick;
Description
  This structure describe a joystick.
INDEX
Description
  The type of function called when a joystick is connected or disconnected.
INDEX
Description
  This function allow you to define a callback function that
will be called when a joystick connection or disconnection event occurs.
INDEX
Description
  This function returns informations about the joystick with the associated
sent id.
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_bunny_axis;
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.
INDEX
Description
  This function allow you to define a callback function that
will be called when a joystick axis is moved.
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
-
t_bunny_axis axis:
  The axis to restrict.
-
float offset:
  The minimum shift. Must be a value between 0 and 100.
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.
INDEX
Description
  This function allow you to define a callback function that
will be called when a joystick button is pressed or released.
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.
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.
INDEX
Description
  This function allow you to define a callback function that
will be called when a window lost the focus.
INDEX
k
Description
  The type of function called when a window is resized.
INDEX
Description
  This function allow you to define a callback function that
will be called when a window is resized.
INDEX
Description
  The type of function called when a window is closed. This function pointer is
usefuly only if you use
bunny_loop_mw as main loop.
INDEX
Description
  This function allow you to define a callback function that
will be called when a window is closed. Only works with
bunny_loop_mw.
INDEX
Description
  This function returns the window that is currently handling events.
This function is useful when using
bunny_loop_mw.
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.
INDEX
Description
  The type of function called at a specific frequency to do central processing.
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
bunny_loop_mw.
Parameters
-
t_bunny_window *window:
  The window that will have its events managed by bunny loop.
-
uint8_t frequency:
  The frequency in Hertz of the event loop and the average frequency
of calls to the function set with bunny_set_loop_main_function.
-
void *data:
  A data that will be given to every event handlers, loop and
display function. It should be your program main data.
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
-
t_bunny_window **window:
  Windows that will have their events managed by bunny loop. The array
is nbr_win window long.
-
size_t nbr_win:
  The length of the window array in cases.
-
uint8_t frequency:
  The frequency in Hertz of the event loop and the average frequency
of calls to the function set with bunny_set_loop_main_function.
-
void *data:
  A data that will be given to every event handlers, loop and
display function. It should be your program main data.
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
Return value
Returns the frequency of the current bunny loop.
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
-
int fd:
  The file descriptor that received the message.
-
const void *buffer:
  The received data.
-
size_t size:
  The size in bytes of the received data.
-
void *data:
  The data sent as the last parameter of bunny_loop or bunny_loop_mw.
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.
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.
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.
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_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_bunny_anonymous_context;
Description
  This structure is a full callback context compatible with the
t_bunny_context
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,
Bunny::SetContext is available in the Context module.
INDEX
Description
  Get all callbacks from bunny loop in a single call and store them inside
context.
INDEX