README: mention SDL2 backend
[rofl0r-concol.git] / console_events.h
blobefe49d7d9a8713846f6c55675baa1e589dada5aa
1 #ifndef EVENTS_H
2 #define EVENTS_H
4 #include "point.h"
5 #include "rect.h"
7 typedef enum {
8 EV_MOUSE = 0,
9 EV_KEY_DOWN = 1,
10 EV_TIMER = 2,
11 EV_RESIZE = 3,
12 EV_COUNT = 4, // the number of total event types
13 } event_type;
15 typedef enum {
16 MB_NONE = -1,
17 MB_LEFT = 0,
18 MB_RIGHT = 1,
19 MB_MIDDLE = 2,
20 MB_COUNT = 3
21 } mouse_button;
23 typedef enum {
24 ME_BUTTON_DOWN = 0,
25 ME_BUTTON_UP,
26 ME_WHEEL_DOWN,
27 ME_WHEEL_UP,
28 ME_MOVE,
29 } mouse_event_type;
31 typedef struct {
32 point coords;
33 mouse_event_type mouse_ev;
34 mouse_button button;
35 } mouse_event;
37 typedef struct {
38 unsigned long counter;
39 int active:1; // the timer event is sent to all "subscribed" windows.
40 //this is to make them aware if the window is active or not.
41 } timer_event;
43 typedef struct {
44 rect newcoords;
45 } resize_event;
47 typedef enum {
48 MOD_SHIFT = 1 << 0,
49 MOD_ALT = 1 << 1,
50 MOD_CTRL = 1 << 2,
51 MOD_ALTGR = 1 << 3,
52 MOD_FLAG = 1 << 4,
53 } key_modifier;
55 typedef struct {
56 int ch;
57 key_modifier modifiers;
58 } key_event;
60 // this struct requires std=gnu89 or gnu99 to work. i am to lazy to make the union non-anonymous.
61 typedef struct {
62 event_type etype;
63 union {
64 mouse_event mouse_ev;
65 timer_event timer_ev;
66 key_event key_ev;
67 resize_event resize_ev;
69 } event;
72 #endif