4 Event queue is a queue to store link:input.html[input events].
6 NOTE: This API is semi internal, normally the queue is used indirectly by the
13 -------------------------------------------------------------------------------
16 #include <input/GP_EventQueue.h>
18 #define GP_EVENT_QUEUE_DECLARE(name, scr_w, scr_h) ...;
21 * Initializes event queue passed as a pointer. The events array must be
24 * If queue_size is set to zero, default value is expected.
26 void GP_EventQueueInit(struct GP_EventQueue *self,
27 unsigned int screen_w, unsigned int screen_h,
28 unsigned int queue_size);
31 * Allocates and initializes event queue.
33 * If queue_size is set to zero, default value is used.
35 struct GP_EventQueue *GP_EventQueueAlloc(unsigned int screen_w,
36 unsigned int screen_h,
37 unsigned int queue_size);
38 -------------------------------------------------------------------------------
40 These functions are used to create an event queue.
42 The 'GP_EVENT_QUEUE_DECLARE' is a macro that takes name and screen size and
43 declares and initializes an event queue structure.
45 The initialization functions takes pointer to a memory large enough to hold an
46 event queue structure and array of queue_size events.
48 The last function allocates and initializes an event queue. If allocation has
49 failed 'NULL' is returned.
52 -------------------------------------------------------------------------------
55 #include <input/GP_EventQueue.h>
57 unsigned int GP_EventsQueueEventsQueued(GP_EventQueue *self);
58 -------------------------------------------------------------------------------
60 This function returns number of queued events.
63 -------------------------------------------------------------------------------
66 #include <input/GP_EventQueue.h>
68 int GP_EventQueueGet(GP_EventQueue *self, GP_Event *ev);
69 -------------------------------------------------------------------------------
71 In case there are any events queued, the top event is removed from the
72 queue, copied into the event structure that is passed as argument and
75 If there are no events queued the call returns immediately with zero.
78 -------------------------------------------------------------------------------
81 #include <input/GP_EventQueue.h>
83 int GP_EventQueuePeek(GP_EventQueue *self, GP_Event *ev);
84 -------------------------------------------------------------------------------
86 Same as +GP_EventQueueGet()+ but the top event is not removed from the queue.
89 -------------------------------------------------------------------------------
92 #include <input/GP_EventQueue.h>
94 void GP_EventQueuePutBack(GP_EventQueue *self, GP_Event *ev);
95 -------------------------------------------------------------------------------
97 Puts event to the top of the queue. Useful for putting back event that has
98 been removed from the queue.
101 -------------------------------------------------------------------------------
104 #include <input/GP_EventQueue.h>
107 * Inject event that moves cursor by rx and ry.
109 * If timeval is NULL, current time is used.
111 void GP_EventQueuePushRel(struct GP_EventQueue *self,
112 int32_t rx, int32_t ry, struct timeval *time);
115 * Produces relative event that moves cursor to the point x, y.
117 * If timeval is NULL, current time is used.
119 void GP_EventQueuePushRelTo(struct GP_EventQueue *self,
120 uint32_t x, uint32_t y, struct timeval *time);
123 * Inject absolute event.
125 * If timeval is NULL, current time is used.
127 void GP_EventQueuePushAbs(struct GP_EventQueue *self,
128 uint32_t x, uint32_t y, uint32_t pressure,
129 uint32_t x_max, uint32_t y_max, uint32_t pressure_max,
130 struct timeval *time);
133 * Inject event that changes key state (i.e. press, release, repeat).
135 * If timeval is NULL, current time is used.
137 void GP_EventQueuePushKey(struct GP_EventQueue *self,
138 uint32_t key, uint8_t code, struct timeval *time);
141 * Inject window resize event
143 void GP_EventQueuePushResize(struct GP_EventQueue *self,
144 uint32_t w, uint32_t h, struct timeval *time);
147 * Inject common event.
149 void GP_EventQueuePush(struct GP_EventQueue *self,
150 uint16_t type, uint32_t code, int32_t value,
151 struct timeval *time);
153 -------------------------------------------------------------------------------
155 Following functions are used for puting events into the event queue. If
156 pointer to the timeval structure is 'NULL' the event 'time' will be filled
157 with exact time the event was added to the queue.