82 lines
1.7 KiB
C
82 lines
1.7 KiB
C
#ifndef EVENT_USER
|
|
#define EVENT_USER
|
|
|
|
#define DUMMY 0x80
|
|
|
|
/*
|
|
* Structure containing informations about events.
|
|
*/
|
|
typedef struct {
|
|
/*
|
|
* XD0T 00ZZ
|
|
*
|
|
* Where:
|
|
* * X = press (1) or release (0)
|
|
* * D = dummy, ignore this event (1)
|
|
* * 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 {
|
|
M_NONE = 0,
|
|
M_LEFT = 0x01,
|
|
M_RIGHT = 0x02,
|
|
M_MIDDLE = 0x03
|
|
} 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);
|
|
|
|
/*
|
|
* Make a dummy event.
|
|
*/
|
|
void dummy_event(event *event);
|
|
|
|
/*
|
|
* Check if an event is dummy or not.
|
|
*/
|
|
int is_dummy(event *event);
|
|
|
|
/*
|
|
* 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
|