#ifndef EVENT_USER #define EVENT_USER /* * Structure containing informations about events. */ typedef struct { /* * X00T 00ZZ * * Where: * * X = press (1) or release (0) * * T = keyboard (1) or mouse (0) * * ZZ (only for mouse events) = button * * left (01) * * right (10) * * middle (11) */ unsigned char infos; /* Key pressed (not use if mouse event) */ unsigned char key; /* X coordinate of click (not use if keyboard event) */ signed short x; /* Y coordinate of click (not use if keyboard event) */ signed short y; } event; typedef enum { LEFT = 0x01, RIGHT = 0x10, MIDDLE = 0x11 } mouse_button; /* * Create a new event, the caller must free it after use. */ event * new_event(); /* * Put all fields at 0. */ void reset(event *event); /* * Init a basic event and set if the key/button is pressed or not. */ void init_event(event *event, char is_pressed); /* * Init a mouse event and set if the button is pressed or not. * The caller must indicate coordonates. */ void mouse_event(event *event, mouse_button button); /* * Init a mouse event and set if the button is pressed or not. * It sets also the coordinates. */ void mouse_event_coord(event *event, mouse_button button, signed short x, signed short y); /* * Init a keyboard event and set if the key is pressed or not. */ void kb_event(event *event, char key, char is_pressed); #endif