![]() |
GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
Event Queue. More...
Go to the source code of this file.
Data Structures | |
| struct | gp_ev_queue |
| An event queue. More... | |
Macros | |
| #define | GP_EVENT_QUEUE_SIZE 32 |
| Maximal number of events the queue can hold. | |
Enumerations | |
| enum | gp_ev_queue_flags { GP_EVENT_QUEUE_LOAD_KEYMAP = 0x01 } |
| An event queue init flags. More... | |
Functions | |
| void | gp_ev_queue_init (gp_ev_queue *self, unsigned int screen_w, unsigned int screen_h, unsigned int queue_size, void(*cursor_move)(void *cursor_priv, uint32_t x, uint32_t y), void *cursor_priv, enum gp_ev_queue_flags flags) |
| Initializes event queue. | |
| void | gp_ev_queue_flush (gp_ev_queue *self) |
| Removes all events from the queue. | |
| 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_feedback_register (gp_ev_queue *self, gp_ev_feedback *feedback) |
| Registers an input device feedback callback. | |
| static void | gp_ev_queue_feedback_unregister (gp_ev_queue *self, gp_ev_feedback *feedback) |
| Unregisters an input device feedback callback. | |
| 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. | |
| void | gp_ev_queue_set_cursor_pos (gp_ev_queue *self, unsigned int x, unsigned int y) |
| Sets a cursor postion. | |
| unsigned int | gp_ev_queue_events (gp_ev_queue *self) |
| Returns number of events queued in the queue. | |
| static int | gp_ev_queue_full (gp_ev_queue *self) |
| Returns true if queue is full. | |
| gp_event * | gp_ev_queue_get (gp_ev_queue *self) |
| Remoes and returns pointer to a top event from the queue. | |
| gp_event * | gp_ev_queue_peek (gp_ev_queue *self) |
| Peeks at a top event from the queue. | |
| void | gp_ev_queue_put (gp_ev_queue *self, gp_event *ev) |
| Pushes an event to the event 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_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. | |
| 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_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_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_utf (gp_ev_queue *self, uint32_t utf_ch, uint64_t time) |
| Pushes an unicode character typed on keyboard into the 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_push (gp_ev_queue *self, uint16_t type, uint32_t code, int32_t value, uint64_t time) |
| Push a generic event into the queue. | |
| 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. | |
Event Queue.
This API is internally used by backends to store input events and is not supposed to be used directly.
Definition in file gp_ev_queue.h.
| enum gp_ev_queue_flags |
An event queue init flags.
Definition at line 70 of file gp_ev_queue.h.
| unsigned int gp_ev_queue_events | ( | gp_ev_queue * | self | ) |
Returns number of events queued in the queue.
| self | An event queue. |
Referenced by gp_backend_ev_queued().
|
inlinestatic |
Registers an input device feedback callback.
| self | An event queue. |
| feedback | An input device feedback callback. |
Definition at line 130 of file gp_ev_queue.h.
References gp_ev_queue::feedbacks_list, and gp_ev_feedback_register().
|
inlinestatic |
Calls a all feedback handlers with a specified value.
| self | An event queue. |
| op | An operation to be done, e.g. turn on caps lock led. |
Definition at line 152 of file gp_ev_queue.h.
References gp_ev_queue::feedbacks_list, and gp_ev_feedback_set_all().
|
inlinestatic |
Unregisters an input device feedback callback.
| self | An event queue. |
| feedback | An input device feedback callback. |
Definition at line 141 of file gp_ev_queue.h.
References gp_ev_queue::feedbacks_list, and gp_ev_feedback_unregister().
| void gp_ev_queue_flush | ( | gp_ev_queue * | self | ) |
Removes all events from the queue.
| self | An event queue. |
Referenced by gp_backend_ev_flush().
|
inlinestatic |
Returns true if queue is full.
| self | An event queue. |
Definition at line 181 of file gp_ev_queue.h.
| gp_event * gp_ev_queue_get | ( | gp_ev_queue * | self | ) |
Remoes and returns pointer to a top event from the queue.
In case there are any events queued a pointer to a top event in the queue is returned. The pointer is valid until next call to gp_ev_queue_get().
The pointer is also invalidated by a call to gp_ev_queue_put_back().
If there are no events queued the call returns NULL.
| self | An event queue. |
| void gp_ev_queue_init | ( | gp_ev_queue * | self, |
| unsigned int | screen_w, | ||
| unsigned int | screen_h, | ||
| unsigned int | queue_size, | ||
| void(* | cursor_move )(void *cursor_priv, uint32_t x, uint32_t y), | ||
| void * | cursor_priv, | ||
| enum gp_ev_queue_flags | flags ) |
Initializes event queue.
The queue has to be allocatedpassed as a pointer. The events array must be queue_size long.
If queue_size is set to zero, default value is expected.
| self | A pointer to newly allocated event queue structure. |
| screen_w | A width of the display/window. |
| screen_h | A height of the display/window. |
| queue_size | A size of the circular buffer for the queue, pass 0 for default. |
| cursor_move | A cursor move callback. |
| cursor_priv | A private pointer used by the backend to pass context. |
| flags | A bitwise combination of enum gp_ev_queue_flags. |
| gp_event * gp_ev_queue_peek | ( | gp_ev_queue * | self | ) |
Peeks at a top event from the queue.
Same as gp_ev_queue_get() but the event is not removed from the queue. The pointer is valid until a call to gp_ev_queue_get().
If there are no events queued the calll returns NULL.
| self | An event queue. |
Referenced by gp_backend_ev_peek().
| 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.
| self | An input queue. |
| type | An event type enum gp_ev_type. |
| code | Based on type one of the enum gp_ev_key_code, enum gp_ev_rel_code, enum gp_ev_abs_code, enum gp_ev_sys_code. |
| value | An event value, e.g. which key was pressed. |
| time | A timestamp, if NULL current time is used. |
Referenced by gp_backend_clipboard_ready(), and gp_ev_queue_push_wheel().
| 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.
The values are scaled between 0 and max value.
| self | An input queue. |
| x | An absolute x coordinate. |
| y | An absolute y coordinate. |
| pressure | A pen pressure. |
| x_max | An absolute x coordinate maximum. |
| y_max | An absolute y coordinate maximum. |
| pressure_max | A maximal pen pressure. |
| time | A timestamp, if NULL current time is used. |
| 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.
Pushes a GP_EV_KEY event to the event queue.
If backend uses a keymap key events are processed by the keymap state machine and GP_EV_UTF events are generated accordingly.
| self | An input queue. |
| key | Physical key pressed on keyboard. |
| code | Action enum gp_ev_key_code press/release/repeat. |
| time | A timestamp, if NULL current time is used. |
| 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.
| self | An input queue. |
| rx | A relative change in x coordinate. |
| ry | A relative change in y coordinate. |
| time | A timestamp, if NULL current time is used. |
| 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.
| self | An input queue. |
| x | A x coordinate to move the cursor to. |
| y | A y coordinate to move the cursor to. |
| time | A timestamp, if NULL current time is used. |
| 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.
Backends start the resize operation by pushing the GP_EV_SYS_RESIZE event to the input queue. When the application processes the event it has to acknowledge the resize by calling gp_backend_resize_ack(), which resizes the pixel buffers and also calls gp_ev_queue_set_screen_size().
| self | An input queue. |
| new_w | A new display/window/screen width. |
| new_h | A new display/window/screen height. |
| time | A timestamp, if NULL current time is used. |
| 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.
| self | An input queue. |
| utf_ch | An unicode character. |
| time | A timestamp, if NULL current time is used. |
|
inlinestatic |
Pushes a mouse wheel movement into the queue.
| self | An input queue. |
| val | A relative change of the mouse wheel position. |
| time | A timestamp, if NULL current time is used. |
Definition at line 344 of file gp_ev_queue.h.
References gp_ev_queue_push(), GP_EV_REL, and GP_EV_REL_WHEEL.
| void gp_ev_queue_put | ( | gp_ev_queue * | self, |
| gp_event * | ev ) |
Pushes an event to the event queue.
This is bare call that just copies the event into the queue. Use the calls below instead.
| self | An input queue. |
| ev | A pointer to an event. |
| void gp_ev_queue_put_back | ( | gp_ev_queue * | self, |
| gp_event * | ev ) |
Pushes back an event to the event queue.
Puts event to the top of the queue, i.e. this event is going to be returned by a next call to gp_ev_queue_get().
| self | An input queue. |
| ev | A pointer to an event. |
Referenced by gp_backend_ev_put_back().
| void gp_ev_queue_set_cursor_pos | ( | gp_ev_queue * | self, |
| unsigned int | x, | ||
| unsigned int | y ) |
Sets a cursor postion.
| self | An event queue. |
| x | A new cursor x position. |
| y | A new cursor y position. |
| void gp_ev_queue_set_screen_size | ( | gp_ev_queue * | self, |
| unsigned int | w, | ||
| unsigned int | h ) |
Sets screen (window) size.
This is needs to be called when backend is resized in order to update cursor position and limits.
| self | An event queue. |
| w | New display/window/screen width. |
| h | New display/window/screen height. |