diff --git a/src/event.h b/src/event.h new file mode 100644 index 0000000..0c99946 --- /dev/null +++ b/src/event.h @@ -0,0 +1,67 @@ +#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 diff --git a/src/read_events.h b/src/read_events.h new file mode 100644 index 0000000..ea21748 --- /dev/null +++ b/src/read_events.h @@ -0,0 +1,9 @@ +#ifndef READ_EVENTS +#define READ_EVENTS +#include "event.h" + +void write_event(event *new_event, FILE *file); + +/* Just listen the input and write them in the parameter file. */ +int listen(FILE *file); +#endif diff --git a/src/read_file.h b/src/read_file.h new file mode 100644 index 0000000..7a4d243 --- /dev/null +++ b/src/read_file.h @@ -0,0 +1,4 @@ +#ifndef READ_FILE +#define READ_FILE +void readfile(FILE *file); +#endif