14#ifndef INPUT_GP_EV_QUEUE_H
15#define INPUT_GP_EV_QUEUE_H
21#define GP_EVENT_QUEUE_SIZE 32
36 unsigned int queue_first;
37 unsigned int queue_last;
38 unsigned int queue_size;
92 unsigned int screen_w,
unsigned int screen_h,
114 unsigned int w,
unsigned int h);
157 unsigned int x,
unsigned int y);
175 unsigned int next = (self->queue_last + 1) % self->queue_size;
177 return next == self->queue_first;
239 int32_t rx, int32_t ry, uint64_t time);
250 uint32_t x, uint32_t y, uint64_t time);
267 uint32_t x, uint32_t y, uint32_t pressure,
268 uint32_t x_max, uint32_t y_max, uint32_t pressure_max,
285 uint32_t key, uint8_t code,
312 uint32_t new_w, uint32_t new_h, uint64_t time);
326 uint16_t type, uint32_t code, int32_t value,
337 int32_t val, uint64_t time)
An input event feedback, e.g. keyboard leds.
void gp_ev_feedback_unregister(gp_ev_feedback **root, gp_ev_feedback *self)
Removes a feedback from a feedback queue.
void gp_ev_feedback_set_all(gp_ev_feedback *root, gp_ev_feedback_op *op)
Passes an opeartion to all registered feedbacks.
void gp_ev_feedback_register(gp_ev_feedback **root, gp_ev_feedback *self)
Adds a feedback to a feedback queue.
void gp_ev_queue_put_back(gp_ev_queue *self, gp_event *ev)
Pushes back an event to the event queue.
void gp_ev_queue_push_resize(gp_ev_queue *self, uint32_t new_w, uint32_t new_h, uint64_t time)
Pushes a window resize event to the queue.
void gp_ev_queue_set_cursor_pos(gp_ev_queue *self, unsigned int x, unsigned int y)
Sets a cursor postion.
void gp_ev_queue_push_rel(gp_ev_queue *self, int32_t rx, int32_t ry, uint64_t time)
Pushes a relative event that moves cursor by rx and ry.
gp_event * gp_ev_queue_peek(gp_ev_queue *self)
Peeks at a top event from the queue.
static int gp_ev_queue_full(gp_ev_queue *self)
Returns true if queue is full.
gp_ev_queue_flags
An event queue init flags.
@ GP_EVENT_QUEUE_LOAD_KEYMAP
Load keymap during initialization.
void gp_ev_queue_put(gp_ev_queue *self, gp_event *ev)
Pushes an event to the event queue.
#define GP_EVENT_QUEUE_SIZE
Maximal number of events the queue can hold.
gp_event * gp_ev_queue_get(gp_ev_queue *self)
Remoes and returns pointer to a top event from the queue.
void gp_ev_queue_push_key(gp_ev_queue *self, uint32_t key, uint8_t code, uint64_t time)
Pushes a key event into the event queue.
void gp_ev_queue_push_abs(gp_ev_queue *self, uint32_t x, uint32_t y, uint32_t pressure, uint32_t x_max, uint32_t y_max, uint32_t pressure_max, uint64_t time)
Pushes an absolute event into the queue.
void gp_ev_queue_push_rel_to(gp_ev_queue *self, uint32_t x, uint32_t y, uint64_t time)
Pushes a relative event that moves cursor to the point x, y.
void gp_ev_queue_push_utf(gp_ev_queue *self, uint32_t utf_ch, uint64_t time)
Pushes an unicode character typed on keyboard into the queue.
unsigned int gp_ev_queue_events(gp_ev_queue *self)
Returns number of events queued in the queue.
void gp_ev_queue_push(gp_ev_queue *self, uint16_t type, uint32_t code, int32_t value, uint64_t time)
Push a generic event into the queue.
void gp_ev_queue_flush(gp_ev_queue *self)
Removes all events from the queue.
static void gp_ev_queue_feedback_unregister(gp_ev_queue *self, gp_ev_feedback *feedback)
Unregisters an input device feedback callback.
void gp_ev_queue_set_screen_size(gp_ev_queue *self, unsigned int w, unsigned int h)
Sets screen (window) size.
static void gp_ev_queue_push_wheel(gp_ev_queue *self, int32_t val, uint64_t time)
Pushes a mouse wheel movement into the queue.
static void gp_ev_queue_feedback_register(gp_ev_queue *self, gp_ev_feedback *feedback)
Registers an input device feedback callback.
void gp_ev_queue_init(gp_ev_queue *self, unsigned int screen_w, unsigned int screen_h, unsigned int queue_size, enum gp_ev_queue_flags flags)
Initializes event queue.
static void gp_ev_queue_feedback_set_all(gp_ev_queue *self, gp_ev_feedback_op *op)
Calls a all feedback handlers with a specified value.
@ GP_EV_REL_WHEEL
A mouse wheel.
@ GP_EV_REL
A relative event, e.g. mouse cursor movement.
uint32_t cursor_y
A cursor y position valid for the last event in the queue.
gp_event events[32]
A circular buffer for input events.
uint32_t cursor_x
A cursor x position valid for the last event in the queue.
gp_keymap * keymap
A keymap.
gp_ev_feedback * feedbacks_list
A list of callbacks to turn on/off leds, e.g. caps lock, and other feedback.
gp_events_state state
An accumulated state.
unsigned int screen_h
A display/window/screen height.
unsigned int screen_w
A display/window/screen width.