This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 029e3ccf2b47c2d3c884aa6e2be2c7fa6231433c (commit) via 360814b9ac458b2196bcc89413833af529c572d6 (commit) via dc07fdf90743e45d6ac86cb2a07d51c915419918 (commit) via 6c75f45c99e2f0a27974d9106d7b2620bbab78b5 (commit) from 6f9e031b813ac8d42b3faf6011b202d961894677 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/029e3ccf2b47c2d3c884aa6e2be2c7fa62314...
commit 029e3ccf2b47c2d3c884aa6e2be2c7fa6231433c Author: Cyril Hrubis metan@ucw.cz Date: Sun Feb 10 20:35:31 2013 +0100
backends: Fix virtual backend event propagation.
TODO: Resize Ack propagation
diff --git a/libs/backends/GP_BackendVirtual.c b/libs/backends/GP_BackendVirtual.c index 89598f7..41e947a 100644 --- a/libs/backends/GP_BackendVirtual.c +++ b/libs/backends/GP_BackendVirtual.c @@ -84,6 +84,11 @@ static void virt_poll(GP_Backend *self) struct virt_priv *virt = GP_BACKEND_PRIV(self);
virt->backend->Poll(virt->backend); + + struct GP_Event ev; + + while (GP_BackendGetEvent(virt->backend, &ev)) + GP_EventQueuePut(&self->event_queue, &ev); }
static void virt_wait(GP_Backend *self) @@ -91,6 +96,11 @@ static void virt_wait(GP_Backend *self) struct virt_priv *virt = GP_BACKEND_PRIV(self);
virt->backend->Wait(virt->backend); + + struct GP_Event ev; + + while (GP_BackendGetEvent(virt->backend, &ev)) + GP_EventQueuePut(&self->event_queue, &ev); }
static void virt_exit(GP_Backend *self) @@ -141,6 +151,9 @@ GP_Backend *GP_BackendVirtualInit(GP_Backend *backend, self->Wait = backend->Wait ? virt_wait : NULL; self->SetAttributes = backend->SetAttributes ? virt_set_attrs : NULL;
+ GP_EventQueueInit(&self->event_queue, backend->context->w, + backend->context->h, 0); + return self;
err0:
http://repo.or.cz/w/gfxprim.git/commit/360814b9ac458b2196bcc89413833af529c57...
commit 360814b9ac458b2196bcc89413833af529c572d6 Author: Cyril Hrubis metan@ucw.cz Date: Sun Feb 10 20:28:24 2013 +0100
build: Update input exported symbols.
diff --git a/build/syms/Input_symbols.txt b/build/syms/Input_symbols.txt index b823325..c52e2e3 100644 --- a/build/syms/Input_symbols.txt +++ b/build/syms/Input_symbols.txt @@ -1,15 +1,5 @@ GP_EventKeyName -GP_EventPushAbs -GP_EventSetScreenSize -GP_EventPushKey -GP_EventGet -GP_EventPushRel -GP_EventPush GP_EventDump -GP_EventPushResize -GP_EventPushRelTo -GP_EventSetScreenCursor -GP_EventsQueued
GP_InputDriverLinuxRead GP_InputDriverSDLEventPut @@ -20,10 +10,17 @@ GP_InputDriverLinuxClose GP_InputDriverKBDEventPut
GP_EventQueueSetCursorPosition -GP_EventQueueGetEvent -GP_EventQueueEventsQueued GP_EventQueueSetScreenSize +GP_EventQueueGet +GP_EventQueueEventsQueued GP_EventQueueInit GP_EventQueueFree GP_EventQueueAlloc + GP_EventQueuePutEvent +GP_EventQueuePushRelTo +GP_EventQueuePushRel +GP_EventQueuePushKey +GP_EventQueuePushAbs +GP_EventQueuePush +GP_EventQueuePushResize
http://repo.or.cz/w/gfxprim.git/commit/dc07fdf90743e45d6ac86cb2a07d51c915419...
commit dc07fdf90743e45d6ac86cb2a07d51c915419918 Author: Cyril Hrubis metan@ucw.cz Date: Sun Feb 10 20:23:02 2013 +0100
doc: backends,input: Update docs.
diff --git a/doc/Makefile b/doc/Makefile index db44fbc..87ead82 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -2,7 +2,8 @@ SOURCES=general.txt context.txt loaders.txt filters.txt basic_types.txt drawing_api.txt backends.txt gamma.txt grabbers.txt environment_variables.txt debug.txt core.txt api.txt input.txt gen.txt pixels.txt coordinate_system.txt coding_style.txt - get_put_pixel.txt blits.txt progress_callback.txt text_api.txt + get_put_pixel.txt blits.txt progress_callback.txt text_api.txt + event_queue.txt
EXAMPLE_SOURCES=$(wildcard example_*.txt)
diff --git a/doc/backends.txt b/doc/backends.txt index 678f8c7..8cfb010 100644 --- a/doc/backends.txt +++ b/doc/backends.txt @@ -339,7 +339,7 @@ size change. unsigned int GP_BackendEventsQueued(GP_Backend *self); -------------------------------------------------------------------------------
-Returns number of events queued in backend event queue. +Returns number of events queued in the backend event queue.
[source,c] ------------------------------------------------------------------------------- @@ -347,13 +347,14 @@ Returns number of events queued in backend event queue. /* or */ #include <GP.h>
-int GP_BackendEventGet(GP_Backend *self, GP_Event *ev); +int GP_BackendGetEvent(GP_Backend *self, GP_Event *ev); -------------------------------------------------------------------------------
In case there are any events queued, the top event is removed from the queue, copied into the event structure that is passed as argument and non-zero is returned.
-If there are no events queued the call returns immediately returning zero. +If there are no events queued the call returns immediately with zero return +value.
TIP: For more information see link:input.html[input events] documentation. diff --git a/doc/event_queue.txt b/doc/event_queue.txt new file mode 100644 index 0000000..7f786bc --- /dev/null +++ b/doc/event_queue.txt @@ -0,0 +1,134 @@ +Event Queue +----------- + +Event queue is a queue to store link:input.html[input events]. + +NOTE: This API is semi internal, normally the queue is used indirectly by the + backend code. + +Event Queue API +~~~~~~~~~~~~~~~ + +[source,c] +------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <input/GP_EventQueue.h> + +#define GP_EVENT_QUEUE_DECLARE(name, scr_w, scr_h) ...; + +/* + * Initializes event queue passed as a pointer. The events array must be + * queue_size long. + * + * If queue_size is set to zero, default value is expected. + */ +void GP_EventQueueInit(struct GP_EventQueue *self, + unsigned int screen_w, unsigned int screen_h, + unsigned int queue_size); + +/* + * Allocates and initializes event queue. + * + * If queue_size is set to zero, default value is used. + */ +struct GP_EventQueue *GP_EventQueueAlloc(unsigned int screen_w, + unsigned int screen_h, + unsigned int queue_size); +------------------------------------------------------------------------------- + +These functions are used to create an event queue. + +The 'GP_EVENT_QUEUE_DECLARE' is a macro that takes name and screen size and +declares and initializes an event queue structure. + +The initialization functions takes pointer to a memory large enough to hold an +event queue structure and array of queue_size events. + +The last function allocates and initializes an event queue. If allocation has +failed 'NULL' is returned. + +[source,c] +------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <input/GP_EventQueue.h> + +unsigned int GP_EventsQueueEventsQueued(void); +------------------------------------------------------------------------------- + +This function returns number of queued events. + +[source,c] +------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <input/GP_EventQueue.h> + +int GP_EventQueueGet(struct GP_Event *ev); +------------------------------------------------------------------------------- + +In case there are any events queued, the top event is removed from the +queue, copied into the event structure that is passed as argument and +non-zero is returned. + +If there are no events queued the call returns immediately with zero. + +[source,c] +------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <input/GP_EventQueue.h> + +/* + * Inject event that moves cursor by rx and ry. + * + * If timeval is NULL, current time is used. + */ +void GP_EventQueuePushRel(struct GP_EventQueue *self, + int32_t rx, int32_t ry, struct timeval *time); + +/* + * Produces relative event that moves cursor to the point x, y. + * + * If timeval is NULL, current time is used. + */ +void GP_EventQueuePushRelTo(struct GP_EventQueue *self, + uint32_t x, uint32_t y, struct timeval *time); + +/* + * Inject absolute event. + * + * If timeval is NULL, current time is used. + */ +void GP_EventQueuePushAbs(struct GP_EventQueue *self, + uint32_t x, uint32_t y, uint32_t pressure, + uint32_t x_max, uint32_t y_max, uint32_t pressure_max, + struct timeval *time); + +/* + * Inject event that changes key state (i.e. press, release, repeat). + * + * If timeval is NULL, current time is used. + */ +void GP_EventQueuePushKey(struct GP_EventQueue *self, + uint32_t key, uint8_t code, struct timeval *time); + +/* + * Inject window resize event + */ +void GP_EventQueuePushResize(struct GP_EventQueue *self, + uint32_t w, uint32_t h, struct timeval *time); + +/* + * Inject common event. + */ +void GP_EventQueuePush(struct GP_EventQueue *self, + uint16_t type, uint32_t code, int32_t value, + struct timeval *time); + +------------------------------------------------------------------------------- + +Following functions are used for puting events into the event queue. If +pointer to the timeval structure is 'NULL' the event 'time' will be filled +with exact time the event was added to the queue. diff --git a/doc/input.txt b/doc/input.txt index 6bfdbb9..a98428e 100644 --- a/doc/input.txt +++ b/doc/input.txt @@ -1,14 +1,15 @@ Input Events ------------ +Input events are somehow tied to the link:backends.html[backends] where they +are stored in the link:event_queue.html[event queue].
-Input events are somehow tied to the link:backends.html[backends]. Possibly in -contrast with other libraries there is not always 1:1 correspondence between -input driver and backend graphics driver. That means that you can, for -example, use linux input events together with X Window without any problems. -You can even write application that doesn't draw any graphics at all and still -use some of the input drivers. There are, of course, cases where input driver -is created only together with graphics driver, this is the case for example -for X Window backends or SDL backends. +Possibly in contrast with other libraries there is not always 1:1 +correspondence between input driver and backend graphics driver. That means +that you can, for example, use linux input events together with X Window +without any problems. You can even write application that doesn't draw any +graphics at all and still use some of the input drivers. There are, of course, +cases where input driver is created only together with graphics driver, this +is the case for example for X Window backends or SDL backends.
The basic structure is roughly modeled after Linux kernel input API. The main difference is that events that belongs together are delivered together (the @@ -181,29 +182,6 @@ Event API /* or */ #include <input/GP_Event.h>
-unsigned int GP_EventsQueued(void); -------------------------------------------------------------------------------- - -The 'GP_EventsQueued' returns number of queued events. - -[source,c] -------------------------------------------------------------------------------- -#include <GP.h> -/* or */ -#include <input/GP_Event.h> - -int GP_EventGet(struct GP_Event *ev); -------------------------------------------------------------------------------- - -The 'GP_EventGet' returns nonzero if event was copied to the structure pointed -by ev pointer. - -[source,c] -------------------------------------------------------------------------------- -#include <GP.h> -/* or */ -#include <input/GP_Event.h> - void GP_EventDump(struct GP_Event *ev); -------------------------------------------------------------------------------
@@ -215,53 +193,12 @@ The 'GP_EventDump' dumps event in human-readable format into the 'stdout'. /* or */ #include <input/GP_Event.h>
-void GP_EventSetScreenSize(uint32_t w, uint32_t h); - -void GP_EventSetScreenCursor(uint32_t x, uint32_t y); +const char *GP_EventKeyName(enum GP_EventKeyValue key); -------------------------------------------------------------------------------
-Sets screen size and pointer position, which is needed for calculating the -'cursor_x' and 'cursor_y' coordinates. - -[source,c] -------------------------------------------------------------------------------- -#include <GP.h> -/* or */ -#include <input/GP_Event.h> - -/* - * Pushes relative event. - */ -void GP_EventPushRel(int32_t rx, int32_t ry, struct timeval *time); - - -/* - * Produces relative event that moves to the point x, y - */ -void GP_EventPushRelTo(uint32_t x, uint32_t y, struct timeval *time); - -/* - * Inject absolute event. - */ -void GP_EventPushAbs(uint32_t x, uint32_t y, uint32_t pressure, - uint32_t x_max, uint32_t y_max, uint32_t pressure_max, - struct timeval *time); - -/* - * Inject event that changes key state. - */ -void GP_EventPushKey(uint32_t key, uint8_t code, struct timeval *time); - -/* - * Inject common event. - */ -void GP_EventPush(uint16_t type, uint32_t code, int32_t value, - struct timeval *time); -------------------------------------------------------------------------------- +Returns human-readable key name.
-Following functions are used for adding events into the event queue. If -pointer to the timeval structure is 'NULL' the event 'time' will be filled -with exact time the event was added to the queue. +The returned string must not be modified.
[source,c] -------------------------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/6c75f45c99e2f0a27974d9106d7b2620bbab7...
commit 6c75f45c99e2f0a27974d9106d7b2620bbab78b5 Author: Cyril Hrubis metan@ucw.cz Date: Sun Feb 10 20:20:36 2013 +0100
backends,input: Finish the per backend queue.
Everything seems to work, more testing is needed.
diff --git a/demos/bogoman/bogoman.c b/demos/bogoman/bogoman.c index 82189d8..ea1a4a2 100644 --- a/demos/bogoman/bogoman.c +++ b/demos/bogoman/bogoman.c @@ -64,7 +64,7 @@ static void event_loop(struct bogoman_map *map) while (GP_BackendEventsQueued(backend)) { GP_Event ev; - GP_BackendEventGet(backend, &ev); + GP_BackendGetEvent(backend, &ev);
switch (ev.type) { case GP_EV_KEY: diff --git a/demos/c_simple/backend_example.c b/demos/c_simple/backend_example.c index debba09..c711f41 100644 --- a/demos/c_simple/backend_example.c +++ b/demos/c_simple/backend_example.c @@ -58,8 +58,6 @@ int main(int argc, char *argv[])
context = backend->context;
- GP_EventSetScreenSize(context->w, context->h); - black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context); white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, context);
@@ -77,7 +75,7 @@ int main(int argc, char *argv[]) /* Read and parse events */ GP_Event ev;
- while (GP_BackendEventGet(backend, &ev)) { + while (GP_BackendGetEvent(backend, &ev)) {
GP_EventDump(&ev); @@ -92,10 +90,15 @@ int main(int argc, char *argv[]) } break; case GP_EV_SYS: + switch (ev.code) { + case GP_EV_SYS_RESIZE: + GP_BackendResizeAck(backend); + break; case GP_EV_SYS_QUIT: GP_BackendExit(backend); return 0; break; + } break; } } diff --git a/demos/c_simple/blittest.c b/demos/c_simple/blittest.c index 1ade1d9..57a11fa 100644 --- a/demos/c_simple/blittest.c +++ b/demos/c_simple/blittest.c @@ -94,7 +94,7 @@ void event_loop(void) { GP_Event ev;
- while (GP_BackendEventGet(win, &ev)) { + while (GP_BackendGetEvent(win, &ev)) { GP_EventDump(&ev); switch (ev.type) { diff --git a/demos/c_simple/fileview.c b/demos/c_simple/fileview.c index 6f36565..f1f3169 100644 --- a/demos/c_simple/fileview.c +++ b/demos/c_simple/fileview.c @@ -113,7 +113,7 @@ void event_loop(void) { GP_Event ev;
- while (GP_BackendEventGet(backend, &ev)) { + while (GP_BackendGetEvent(backend, &ev)) { switch (ev.type) { case GP_EV_KEY: if (ev.code != GP_EV_KEY_DOWN) diff --git a/demos/c_simple/fonttest.c b/demos/c_simple/fonttest.c index bf8a169..4c41423 100644 --- a/demos/c_simple/fonttest.c +++ b/demos/c_simple/fonttest.c @@ -175,7 +175,7 @@ void event_loop(void) { GP_Event ev;
- while (GP_BackendEventGet(win, &ev)) { + while (GP_BackendGetEvent(win, &ev)) { switch (ev.type) { case GP_EV_KEY: if (ev.code != GP_EV_KEY_DOWN) diff --git a/demos/c_simple/input_example.c b/demos/c_simple/input_example.c index 8eda0f5..820b530 100644 --- a/demos/c_simple/input_example.c +++ b/demos/c_simple/input_example.c @@ -59,7 +59,7 @@ static void event_loop(void) while (GP_BackendEventsQueued(backend)) { GP_Event ev;
- GP_BackendEventGet(backend, &ev); + GP_BackendGetEvent(backend, &ev); GP_EventDump(&ev);
switch (ev.type) { @@ -104,6 +104,17 @@ static void event_loop(void) break; } break; + case GP_EV_SYS: + switch (ev.code) { + case GP_EV_SYS_RESIZE: + GP_BackendResizeAck(backend); + break; + case GP_EV_SYS_QUIT: + GP_BackendExit(backend); + exit(0); + break; + } + break; } } } @@ -147,8 +158,6 @@ int main(int argc, char *argv[]) GP_Fill(win, black); GP_BackendFlip(backend);
- GP_EventSetScreenSize(win->w, win->h); - for (;;) { GP_BackendWait(backend); event_loop(); diff --git a/demos/c_simple/koch.c b/demos/c_simple/koch.c index 581a978..e546707 100644 --- a/demos/c_simple/koch.c +++ b/demos/c_simple/koch.c @@ -153,7 +153,7 @@ int main(void) GP_BackendPoll(backend); - while (GP_BackendEventGet(backend, &ev)) { + while (GP_BackendGetEvent(backend, &ev)) { GP_EventDump(&ev); switch (ev.type) { diff --git a/demos/c_simple/linetest.c b/demos/c_simple/linetest.c index f72d618..e0be94d 100644 --- a/demos/c_simple/linetest.c +++ b/demos/c_simple/linetest.c @@ -78,7 +78,7 @@ void event_loop(void) { GP_Event ev;
- while (GP_BackendEventGet(win, &ev)) { + while (GP_BackendGetEvent(win, &ev)) { switch (ev.type) { case GP_EV_KEY: if (ev.code != GP_EV_KEY_DOWN) diff --git a/demos/c_simple/randomshapetest.c b/demos/c_simple/randomshapetest.c index 1373ed9..bf53204 100644 --- a/demos/c_simple/randomshapetest.c +++ b/demos/c_simple/randomshapetest.c @@ -214,7 +214,7 @@ void event_loop(void) { GP_Event ev;
- while (GP_BackendEventGet(win, &ev)) { + while (GP_BackendGetEvent(win, &ev)) { switch (ev.type) { case GP_EV_KEY: if (ev.code != GP_EV_KEY_DOWN) diff --git a/demos/c_simple/shapetest.c b/demos/c_simple/shapetest.c index 02c2bab..0edfce1 100644 --- a/demos/c_simple/shapetest.c +++ b/demos/c_simple/shapetest.c @@ -337,7 +337,7 @@ void event_loop(void)
GP_Event ev;
- while (GP_BackendEventGet(backend, &ev)) { + while (GP_BackendGetEvent(backend, &ev)) { GP_EventDump(&ev); shift_pressed = GP_EventGetKey(&ev, GP_KEY_LEFT_SHIFT) || diff --git a/demos/c_simple/showimage.c b/demos/c_simple/showimage.c index f91bbec..8903515 100644 --- a/demos/c_simple/showimage.c +++ b/demos/c_simple/showimage.c @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) GP_Event ev;
- while (GP_BackendEventGet(backend, &ev)) { + while (GP_BackendGetEvent(backend, &ev)) { if (ev.type == GP_EV_KEY && ev.val.val == GP_KEY_Q) { GP_BackendExit(backend); return 0; diff --git a/demos/c_simple/sin_AA.c b/demos/c_simple/sin_AA.c index cd44879..80c9086 100644 --- a/demos/c_simple/sin_AA.c +++ b/demos/c_simple/sin_AA.c @@ -105,7 +105,7 @@ int main(void) GP_Event ev;
- while (GP_BackendEventGet(backend, &ev)) { + while (GP_BackendGetEvent(backend, &ev)) { if (ev.type == GP_EV_KEY && ev.code == GP_EV_KEY_DOWN) { switch (ev.val.val) { case GP_KEY_ESC: diff --git a/demos/c_simple/textaligntest.c b/demos/c_simple/textaligntest.c index 5d6d53b..5ae84ab 100644 --- a/demos/c_simple/textaligntest.c +++ b/demos/c_simple/textaligntest.c @@ -73,7 +73,7 @@ static void event_loop(void) { GP_Event ev;
- while (GP_BackendEventGet(win, &ev)) { + while (GP_BackendGetEvent(win, &ev)) { switch (ev.type) { case GP_EV_KEY: if (ev.code != GP_EV_KEY_DOWN) diff --git a/demos/c_simple/v4l2_show.c b/demos/c_simple/v4l2_show.c index 4bb5543..a65202c 100644 --- a/demos/c_simple/v4l2_show.c +++ b/demos/c_simple/v4l2_show.c @@ -129,7 +129,7 @@ int main(int argc, char *argv[]) /* Read and parse events */ GP_Event ev;
- while (GP_BackendEventGet(backend, &ev)) { + while (GP_BackendGetEvent(backend, &ev)) { switch (ev.type) { case GP_EV_KEY: diff --git a/demos/c_simple/virtual_backend_example.c b/demos/c_simple/virtual_backend_example.c index 0468a14..d1ce089 100644 --- a/demos/c_simple/virtual_backend_example.c +++ b/demos/c_simple/virtual_backend_example.c @@ -92,8 +92,6 @@ int main(int argc, char *argv[])
context = backend->context;
- GP_EventSetScreenSize(context->w, context->h); - /* Now draw some testing patters */ black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context); white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, context); @@ -148,7 +146,7 @@ int main(int argc, char *argv[]) /* Read and parse events */ GP_Event ev;
- while (GP_BackendEventGet(backend, &ev)) { + while (GP_BackendGetEvent(backend, &ev)) {
GP_EventDump(&ev); diff --git a/demos/particle/particle_demo.c b/demos/particle/particle_demo.c index e977cc6..9b708c5 100644 --- a/demos/particle/particle_demo.c +++ b/demos/particle/particle_demo.c @@ -104,7 +104,7 @@ int main(int argc, char *argv[]) /* Read and parse events */ GP_Event ev;
- while (GP_BackendEventGet(backend, &ev)) { + while (GP_BackendGetEvent(backend, &ev)) {
GP_EventDump(&ev); diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c index 23462b7..e7befb2 100644 --- a/demos/spiv/spiv.c +++ b/demos/spiv/spiv.c @@ -850,8 +850,6 @@ int main(int argc, char *argv[])
context = backend->context;
- GP_EventSetScreenSize(context->w, context->h); - black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context); white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, context);
@@ -871,7 +869,7 @@ int main(int argc, char *argv[]) /* Read and parse events */ GP_Event ev;
- while (GP_BackendEventGet(backend, &ev)) { + while (GP_BackendGetEvent(backend, &ev)) { shift_flag = GP_EventGetKey(&ev, GP_KEY_LEFT_SHIFT) || GP_EventGetKey(&ev, GP_KEY_RIGHT_SHIFT); @@ -1064,7 +1062,6 @@ int main(int argc, char *argv[]) GP_BackendResizeAck(backend); GP_Fill(backend->context, 0); params.show_progress_once = 1; - GP_EventSetScreenSize(ev.val.sys.w, ev.val.sys.h); show_image(¶ms, NULL); break; case GP_EV_SYS_QUIT: diff --git a/include/backends/GP_Backend.h b/include/backends/GP_Backend.h index 900b8d4..f4db9e4 100644 --- a/include/backends/GP_Backend.h +++ b/include/backends/GP_Backend.h @@ -44,6 +44,8 @@
#include "core/GP_Context.h"
+#include "input/GP_EventQueue.h" + struct GP_Backend;
typedef struct GP_Backend { @@ -129,6 +131,11 @@ typedef struct GP_Backend { */ void (*Wait)(struct GP_Backend *self);
+ /* + * Queue to store input events. + */ + struct GP_EventQueue event_queue; + /* Backed private data */ char priv[]; } GP_Backend; @@ -231,18 +238,14 @@ int GP_BackendResizeAck(GP_Backend *self); /* * Event Queue functions. */ -#include <input/GP_Event.h> - static inline unsigned int GP_BackendEventsQueued(GP_Backend *self) { - (void) self; - return GP_EventsQueued(); + return GP_EventQueueEventsQueued(&self->event_queue); }
-static inline int GP_BackendEventGet(GP_Backend *self, GP_Event *ev) +static inline int GP_BackendGetEvent(GP_Backend *self, GP_Event *ev) { - (void) self; - return GP_EventGet(ev); + return GP_EventQueueGet(&self->event_queue, ev); }
#endif /* BACKENDS_GP_BACKEND_H */ diff --git a/include/input/GP_Event.h b/include/input/GP_Event.h index 2c99bb2..3159ad0 100644 --- a/include/input/GP_Event.h +++ b/include/input/GP_Event.h @@ -293,23 +293,6 @@ typedef struct GP_Event { } GP_Event;
/* - * Sets global screen size. - */ -void GP_EventSetScreenSize(uint32_t w, uint32_t h); - -/* - * Sets global cursor position, doesn't generate an event. - * - * Use for initial cursor placement. - */ -void GP_EventSetScreenCursor(uint32_t x, uint32_t y); - -/* - * Returns number of queued events. - */ -unsigned int GP_EventsQueued(void); - -/* * Dump event into stdout. */ void GP_EventDump(struct GP_Event *ev); @@ -320,44 +303,6 @@ void GP_EventDump(struct GP_Event *ev); const char *GP_EventKeyName(enum GP_EventKeyValue key);
/* - * Fills event and returns true. Retuns false if queue is empty. - */ -int GP_EventGet(struct GP_Event *ev); - -/* - * Inject event that moves cursor by rx and ry. - */ -void GP_EventPushRel(int32_t rx, int32_t ry, struct timeval *time); - -/* - * Produces relative event that moves to the point x, y - */ -void GP_EventPushRelTo(uint32_t x, uint32_t y, struct timeval *time); - -/* - * Inject absolute event. - */ -void GP_EventPushAbs(uint32_t x, uint32_t y, uint32_t pressure, - uint32_t x_max, uint32_t y_max, uint32_t pressure_max, - struct timeval *time); - -/* - * Inject event that changes key state. - */ -void GP_EventPushKey(uint32_t key, uint8_t code, struct timeval *time); - -/* - * Inject window resize event - */ -void GP_EventPushResize(uint32_t w, uint32_t h, struct timeval *time); - -/* - * Inject common event. - */ -void GP_EventPush(uint16_t type, uint32_t code, int32_t value, - struct timeval *time); - -/* * Helpers for setting/getting key bits. */ static inline void GP_EventSetKey(struct GP_Event *ev, diff --git a/include/input/GP_EventQueue.h b/include/input/GP_EventQueue.h index df5067b..030742a 100644 --- a/include/input/GP_EventQueue.h +++ b/include/input/GP_EventQueue.h @@ -92,12 +92,75 @@ void GP_EventQueueSetScreenSize(struct GP_EventQueue *self, void GP_EventQueueSetCursorPosition(struct GP_EventQueue *self, unsigned int x, unsigned int y);
- +/* + * Returns number of events queued in the queue. + */ unsigned int GP_EventQueueEventsQueued(struct GP_EventQueue *self);
-unsigned int GP_EventQueueGetEvent(struct GP_EventQueue *self, - struct GP_Event *ev); +/* + * In case there are any events queued, the top event is removed from the + * queue, copied into the event structure that is passed as argument and + * non-zero is returned. + * + * If there are no events queued the call returns immediately with zero. + */ +int GP_EventQueueGet(struct GP_EventQueue *self, struct GP_Event *ev); + +/* + * Puts the event in the queue. + * + * This is bare call that just copies the event into the queue. Use the calls + * bellow instead. + */ +void GP_EventQueuePut(struct GP_EventQueue *self, struct GP_Event *ev); + +struct timeval; + +/* + * Inject event that moves cursor by rx and ry. + * + * If timeval is NULL, current time is used. + */ +void GP_EventQueuePushRel(struct GP_EventQueue *self, + int32_t rx, int32_t ry, struct timeval *time); + +/* + * Produces relative event that moves cursor to the point x, y. + * + * If timeval is NULL, current time is used. + */ +void GP_EventQueuePushRelTo(struct GP_EventQueue *self, + uint32_t x, uint32_t y, struct timeval *time); + +/* + * Inject absolute event. + * + * If timeval is NULL, current time is used. + */ +void GP_EventQueuePushAbs(struct GP_EventQueue *self, + uint32_t x, uint32_t y, uint32_t pressure, + uint32_t x_max, uint32_t y_max, uint32_t pressure_max, + struct timeval *time); + +/* + * Inject event that changes key state (i.e. press, release, repeat). + * + * If timeval is NULL, current time is used. + */ +void GP_EventQueuePushKey(struct GP_EventQueue *self, + uint32_t key, uint8_t code, struct timeval *time); + +/* + * Inject window resize event + */ +void GP_EventQueuePushResize(struct GP_EventQueue *self, + uint32_t w, uint32_t h, struct timeval *time);
-void GP_EventQueuePutEvent(struct GP_EventQueue *self, struct GP_Event *ev); +/* + * Inject common event. + */ +void GP_EventQueuePush(struct GP_EventQueue *self, + uint16_t type, uint32_t code, int32_t value, + struct timeval *time);
#endif /* INPUT_GP_EVENT_QUEUE_H */ diff --git a/include/input/GP_InputDriverKBD.h b/include/input/GP_InputDriverKBD.h index 4212bd7..b924882 100644 --- a/include/input/GP_InputDriverKBD.h +++ b/include/input/GP_InputDriverKBD.h @@ -16,21 +16,25 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
/*
+ Legacy KBD input driver.
*/
-#ifndef GP_INPUT_DRIVER_KBD_H -#define GP_INPUT_DRIVER_KBD_H +#ifndef INPUT_GP_INPUT_DRIVER_KBD_H +#define INPUT_GP_INPUT_DRIVER_KBD_H + +struct GP_EventQueue;
/* * Converts KBD event to GFXprim event and puts it into the queue. */ -void GP_InputDriverKBDEventPut(unsigned char ev); +void GP_InputDriverKBDEventPut(struct GP_EventQueue *event_queue, + unsigned char ev);
-#endif /* GP_INPUT_DRIVER_KBD_H */ +#endif /* INPUT_GP_INPUT_DRIVER_KBD_H */ diff --git a/include/input/GP_InputDriverLinux.h b/include/input/GP_InputDriverLinux.h index 56aef23..bb1b352 100644 --- a/include/input/GP_InputDriverLinux.h +++ b/include/input/GP_InputDriverLinux.h @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -26,8 +26,8 @@
*/
-#ifndef GP_INPUT_DRIVER_LINUX_H -#define GP_INPUT_DRIVER_LINUX_H +#ifndef INPUT_GP_INPUT_DRIVER_LINUX_H +#define INPUT_GP_INPUT_DRIVER_LINUX_H
#include <stdint.h>
@@ -72,6 +72,7 @@ void GP_InputDriverLinuxClose(struct GP_InputDriverLinux *self); * * Returns 0 on succes -1 on error and errno is set. */ -int GP_InputDriverLinuxRead(struct GP_InputDriverLinux *self); +int GP_InputDriverLinuxRead(struct GP_InputDriverLinux *self, + struct GP_EventQueue *event_queue);
-#endif /* GP_INPUT_DRIVER_LINUX_H */ +#endif /* INPUT_GP_INPUT_DRIVER_LINUX_H */ diff --git a/include/input/GP_InputDriverSDL.h b/include/input/GP_InputDriverSDL.h index 01269a9..2bdc489 100644 --- a/include/input/GP_InputDriverSDL.h +++ b/include/input/GP_InputDriverSDL.h @@ -16,24 +16,28 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
/*
+ SDL input driver. Translates SDL events to GFXprim events.
*/
-#ifndef GP_INPUT_DRIVER_SDL_H -#define GP_INPUT_DRIVER_SDL_H +#ifndef INPUT_GP_INPUT_DRIVER_SDL_H +#define INPUT_GP_INPUT_DRIVER_SDL_H
#include <stdint.h> #include <SDL/SDL.h>
+struct GP_EventQueue; + /* * Converts SDL event to GFXprim evevt and puts it into the queue. */ -void GP_InputDriverSDLEventPut(SDL_Event *ev); +void GP_InputDriverSDLEventPut(struct GP_EventQueue *event_queue, + SDL_Event *ev);
-#endif /* GP_INPUT_DRIVER_SDL_H */ +#endif /* INPUT_GP_INPUT_DRIVER_SDL_H */ diff --git a/include/input/GP_InputDriverX11.h b/include/input/GP_InputDriverX11.h index 4c6df2c..95c3b08 100644 --- a/include/input/GP_InputDriverX11.h +++ b/include/input/GP_InputDriverX11.h @@ -20,17 +20,14 @@ * * *****************************************************************************/
-/* - - - */ - #ifndef GP_INPUT_DRIVER_X11_H #define GP_INPUT_DRIVER_X11_H
#include <stdint.h> #include <X11/Xlib.h>
+struct GP_EventQueue; + /* * Loads X11 KeyCode translation table. */ @@ -39,6 +36,7 @@ void GP_InputDriverX11Init(Display *dpy); /* * Converts X11 event to GFXprim event and puts it into the queue. */ -void GP_InputDriverX11EventPut(XEvent *ev, int w, int h); +void GP_InputDriverX11EventPut(struct GP_EventQueue *event_queue, + XEvent *ev, int w, int h);
#endif /* GP_INPUT_DRIVER_X11_H */ diff --git a/libs/backends/GP_LinuxFB.c b/libs/backends/GP_LinuxFB.c index e819ae5..43197d6 100644 --- a/libs/backends/GP_LinuxFB.c +++ b/libs/backends/GP_LinuxFB.c @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -37,7 +37,7 @@
#include "core/GP_Debug.h" #include "input/GP_InputDriverKBD.h" -#include "GP_LinuxFB.h" +#include "backends/GP_LinuxFB.h"
struct fb_priv { GP_Context context; @@ -186,7 +186,7 @@ static void fb_poll(GP_Backend *self) res = read(fb->con_fd, buf, sizeof(buf));
for (i = 0; i < res; i++) - GP_InputDriverKBDEventPut(buf[i]); + GP_InputDriverKBDEventPut(&self->event_queue, buf[i]); }
static void fb_wait(GP_Backend *self) diff --git a/libs/backends/GP_SDL.c b/libs/backends/GP_SDL.c index 951511f..c54bc19 100644 --- a/libs/backends/GP_SDL.c +++ b/libs/backends/GP_SDL.c @@ -80,7 +80,7 @@ static void sdl_poll(struct GP_Backend *self __attribute__((unused))) SDL_mutexP(mutex); while (SDL_PollEvent(&ev)) - GP_InputDriverSDLEventPut(&ev); + GP_InputDriverSDLEventPut(&self->event_queue, &ev); SDL_mutexV(mutex); } @@ -92,10 +92,10 @@ static void sdl_wait(struct GP_Backend *self __attribute__((unused))) SDL_mutexP(mutex);
SDL_WaitEvent(&ev); - GP_InputDriverSDLEventPut(&ev); + GP_InputDriverSDLEventPut(&self->event_queue, &ev);
while (SDL_PollEvent(&ev)) - GP_InputDriverSDLEventPut(&ev); + GP_InputDriverSDLEventPut(&self->event_queue, &ev);
SDL_mutexV(mutex); } @@ -138,7 +138,7 @@ int GP_ContextFromSurface(GP_Context *c, const SDL_Surface *surf) return context_from_surface(c, surf); }
-static int sdl_set_attributes(struct GP_Backend *self __attribute__((unused)), +static int sdl_set_attributes(struct GP_Backend *self, uint32_t w, uint32_t h, const char *caption) { @@ -152,7 +152,7 @@ static int sdl_set_attributes(struct GP_Backend *self __attribute__((unused)), context_from_surface(&context, sdl_surface); /* Send event that resize was finished */ - GP_EventPushResize(w, h, NULL); + GP_EventQueuePushResize(&self->event_queue, w, h, NULL); }
SDL_mutexV(mutex); @@ -160,6 +160,14 @@ static int sdl_set_attributes(struct GP_Backend *self __attribute__((unused)), return 0; }
+static int sdl_resize_ack(struct GP_Backend *self) +{ + GP_EventQueueSetScreenSize(&self->event_queue, + self->context->w, self->context->h); + + return 0; +} + static void sdl_exit(struct GP_Backend *self __attribute__((unused)));
static struct GP_Backend backend = { @@ -168,7 +176,7 @@ static struct GP_Backend backend = { .Flip = sdl_flip, .UpdateRect = sdl_update_rect, .SetAttributes = sdl_set_attributes, - .ResizeAck = NULL, + .ResizeAck = sdl_resize_ack, .Exit = sdl_exit, .fd = -1, .Poll = sdl_poll, @@ -225,6 +233,8 @@ GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint8_t bpp, uint8_t flags,
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); + + GP_EventQueueInit(&backend.event_queue, w, h, 0);
backend.context = &context; diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c index f7a3fa4..c5b17d8 100644 --- a/libs/backends/GP_X11.c +++ b/libs/backends/GP_X11.c @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -183,7 +183,8 @@ static void x11_ev(GP_Backend *self, XEvent *ev) x11->resized_flag = 1; default: //TODO: More accurate window w and h? - GP_InputDriverX11EventPut(ev, x11->context.w, x11->context.h); + GP_InputDriverX11EventPut(&self->event_queue, ev, + x11->context.w, x11->context.h); break; } } @@ -270,6 +271,11 @@ static int x11_resize_ack(struct GP_Backend *self) x11->resized_flag = 0;
+ if (!ret) { + GP_EventQueueSetScreenSize(&self->event_queue, + x11->new_w, x11->new_h); + } + GP_DEBUG(3, "Done");
XUnlockDisplay(x11->dpy); @@ -805,7 +811,7 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
if (backend == NULL) return NULL; - + x11 = GP_BACKEND_PRIV(backend);
x11->dpy = XOpenDisplay(display); @@ -832,6 +838,9 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y, GP_DEBUG(1, "Failed to create window"); goto err1; } + + /* Init the event queue, once we know the window size */ + GP_EventQueueInit(&backend->event_queue, w, h, 0); if (flags & GP_X11_FULLSCREEN) request_fullscreen(backend, 1); diff --git a/libs/input/GP_Event.c b/libs/input/GP_Event.c index 0d638e9..7bfb9f8 100644 --- a/libs/input/GP_Event.c +++ b/libs/input/GP_Event.c @@ -29,9 +29,7 @@
#include <input/GP_EventQueue.h>
-#include "GP_Event.h" - -static GP_EVENT_QUEUE_DECLARE(event_queue, 0, 0); +#include <input/GP_Event.h>
static char *key_names[] = { "Reserved", "Escape", "1", "2", "3", @@ -62,31 +60,9 @@ static char *key_names[] = { "LeftMeta", "RightMeta", "Compose", };
-static uint16_t key_names_size = sizeof(key_names)/sizeof(void*); - -void GP_EventSetScreenSize(uint32_t w, uint32_t h) -{ - GP_EventQueueSetScreenSize(&event_queue, w, h); -} - -void GP_EventSetScreenCursor(uint32_t x, uint32_t y) -{ - GP_EventQueueSetCursorPosition(&event_queue, x, y); -} - -unsigned int GP_EventsQueued(void) -{ - return GP_EventQueueEventsQueued(&event_queue); -} - -int GP_EventGet(struct GP_Event *ev) -{ - return GP_EventQueueGetEvent(&event_queue, ev); -} - const char *GP_EventKeyName(enum GP_EventKeyValue key) { - if (key < key_names_size) + if (key < GP_ARRAY_SIZE(key_names)) return key_names[key];
switch (key) { @@ -107,7 +83,6 @@ const char *GP_EventKeyName(enum GP_EventKeyValue key) default: return "Unknown"; }; - }
static void dump_rel(struct GP_Event *ev) @@ -177,195 +152,3 @@ void GP_EventDump(struct GP_Event *ev) printf("Unknown %un", ev->type); } } - -static void event_put(struct GP_Event *ev) -{ - GP_EventQueuePutEvent(&event_queue, ev); -} - -static void set_time(struct timeval *time) -{ - if (time == NULL) - gettimeofday(&event_queue.cur_state.time, NULL); - else - event_queue.cur_state.time = *time; -} - -static uint32_t clip_rel(uint32_t val, uint32_t max, int32_t rel) -{ - if (rel < 0) { - if (val < GP_ABS(rel)) - return 0; - else - return val + rel; - } - - if (val + rel >= max) - return max - 1; - - return val + rel; -} - -void GP_EventPushRelTo(uint32_t x, uint32_t y, struct timeval *time) -{ - if (x > event_queue.screen_w || y > event_queue.screen_h) { - GP_WARN("x > screen_w or y > screen_h, forgot to set screen size?"); - return; - } - - int32_t rx = x - event_queue.cur_state.cursor_x; - int32_t ry = y - event_queue.cur_state.cursor_y; - - GP_EventPushRel(rx, ry, time); -} - -void GP_EventPushRel(int32_t rx, int32_t ry, struct timeval *time) -{ - /* event header */ - event_queue.cur_state.type = GP_EV_REL; - event_queue.cur_state.code = GP_EV_REL_POS; - - event_queue.cur_state.val.rel.rx = rx; - event_queue.cur_state.val.rel.ry = ry; - - set_time(time); - - /* move the global cursor */ - event_queue.cur_state.cursor_x = clip_rel(event_queue.cur_state.cursor_x, event_queue.screen_w, rx); - event_queue.cur_state.cursor_y = clip_rel(event_queue.cur_state.cursor_y, event_queue.screen_h, ry); - - /* put it into queue */ - event_put(&event_queue.cur_state); -} - -void GP_EventPushAbs(uint32_t x, uint32_t y, uint32_t pressure, - uint32_t x_max, uint32_t y_max, uint32_t pressure_max, - struct timeval *time) -{ - /* event header */ - event_queue.cur_state.type = GP_EV_ABS; - event_queue.cur_state.code = GP_EV_ABS_POS; - event_queue.cur_state.val.abs.x = x; - event_queue.cur_state.val.abs.y = y; - event_queue.cur_state.val.abs.pressure = pressure; - event_queue.cur_state.val.abs.x_max = x_max; - event_queue.cur_state.val.abs.y_max = y_max; - event_queue.cur_state.val.abs.pressure_max = pressure_max; - - set_time(time); - - /* - * Set global cursor, the packet could be partial, eg. update only x or - * only y. In such case x_max or y_max is zero. - */ - if (x_max != 0) - event_queue.cur_state.cursor_x = x * (event_queue.screen_w - 1) / x_max; - - if (y_max != 0) - event_queue.cur_state.cursor_y = y * (event_queue.screen_h - 1) / y_max; - - /* put it into queue */ - event_put(&event_queue.cur_state); -} - -void GP_EventPushResize(uint32_t w, uint32_t h, struct timeval *time) -{ - /* event header */ - event_queue.cur_state.type = GP_EV_SYS; - event_queue.cur_state.code = GP_EV_SYS_RESIZE; - - event_queue.cur_state.val.sys.w = w; - event_queue.cur_state.val.sys.h = h; - - set_time(time); - - /* put it into queue */ - event_put(&event_queue.cur_state); -} - -static char keys_to_ascii[] = { - 0x00, 0x1b, '1', '2', '3', '4', '5', '6', '7', '8', - '9', '0', '-', '=', 0x08, 't', 'q', 'w', 'e', 'r', - 't', 'y', 'u', 'i', 'o', 'p', '[', ']', 'n', 0x00, - 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', - ''', '`', 0x00, '', 'z', 'x', 'c', 'v', 'b', 'n', - 'm', ',', '.', '/', 0x00, '*', 0x00, ' ', 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, '7', '8', '9', '-', '4', '5', '6', '+', '1', - '2', '3', '0', '.' -}; - -static char keys_to_ascii_s[] = { - 0x00, 0x1b, '!', '@', '#', '$', '%', '^', '&', '*', - '(', ')', '_', '+', 0x08, 't', 'Q', 'W', 'E', 'R', - 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', 'n', 0x00, - 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', - '"', '~', 0x00, '|', 'Z', 'X', 'C', 'V', 'B', 'N', - 'M', '<', '>', '?', 0x00, '*', 0x00, ' ', 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, '7', '8', '9', '-', '4', '5', '6', '+', '1', - '2', '3', '0', '.' -}; - -/* - * Fills key ascii value accordingly to keys pressed. - */ -static void key_to_ascii(GP_Event *ev) -{ - ev->val.key.ascii = 0; - - if (GP_EventGetKey(ev, GP_KEY_LEFT_SHIFT) || - GP_EventGetKey(ev, GP_KEY_RIGHT_SHIFT)) { - if (ev->val.key.key < sizeof(keys_to_ascii_s)) - ev->val.key.ascii = keys_to_ascii_s[ev->val.key.key]; - } else { - if (ev->val.key.key < sizeof(keys_to_ascii)) - ev->val.key.ascii = keys_to_ascii[ev->val.key.key]; - } -} - -void GP_EventPushKey(uint32_t key, uint8_t code, struct timeval *time) -{ - switch (code) { - case GP_EV_KEY_UP: - GP_EventResetKey(&event_queue.cur_state, key); - break; - case GP_EV_KEY_DOWN: - GP_EventSetKey(&event_queue.cur_state, key); - break; - case GP_EV_KEY_REPEAT: - break; - default: - GP_WARN("Invalid key event code %u", code); - return; - } - - /* event header */ - event_queue.cur_state.type = GP_EV_KEY; - event_queue.cur_state.code = code; - event_queue.cur_state.val.key.key = key; - key_to_ascii(&event_queue.cur_state); - - set_time(time); - - /* put it into queue */ - event_put(&event_queue.cur_state); -} - -void GP_EventPush(uint16_t type, uint32_t code, int32_t value, - struct timeval *time) -{ - switch (type) { - case GP_EV_KEY: - GP_EventPushKey(code, value, time); - break; - default: - event_queue.cur_state.type = type; - event_queue.cur_state.code = code; - event_queue.cur_state.val.val = value; - - set_time(time); - - event_put(&event_queue.cur_state); - } -} diff --git a/libs/input/GP_EventQueue.c b/libs/input/GP_EventQueue.c index 7c962f1..5cf38c8 100644 --- a/libs/input/GP_EventQueue.c +++ b/libs/input/GP_EventQueue.c @@ -20,6 +20,7 @@ * * *****************************************************************************/
+#include "core/GP_Common.h" #include "core/GP_Debug.h"
#include "input/GP_EventQueue.h" @@ -36,7 +37,7 @@ void GP_EventQueueInit(struct GP_EventQueue *self,
self->queue_first = 0; self->queue_last = 0; - self->queue_size = queue_size; + self->queue_size = queue_size ? queue_size : GP_EVENT_QUEUE_SIZE; }
struct GP_EventQueue *GP_EventQueueAlloc(unsigned int screen_w, @@ -103,8 +104,7 @@ unsigned int GP_EventQueueEventsQueued(struct GP_EventQueue *self) return self->queue_size - (self->queue_last - self->queue_first); }
-unsigned int GP_EventQueueGetEvent(struct GP_EventQueue *self, - struct GP_Event *ev) +int GP_EventQueueGet(struct GP_EventQueue *self, struct GP_Event *ev) { if (self->queue_first == self->queue_last) return 0; @@ -116,7 +116,7 @@ unsigned int GP_EventQueueGetEvent(struct GP_EventQueue *self, return 1; }
-void GP_EventQueuePutEvent(struct GP_EventQueue *self, struct GP_Event *ev) +static void event_put(struct GP_EventQueue *self, struct GP_Event *ev) { unsigned int next = (self->queue_last + 1) % self->queue_size;
@@ -128,3 +128,204 @@ void GP_EventQueuePutEvent(struct GP_EventQueue *self, struct GP_Event *ev) self->events[self->queue_last] = *ev; self->queue_last = next; } + +void GP_EventQueuePut(struct GP_EventQueue *self, struct GP_Event *ev) +{ + event_put(self, ev); +} + +static void set_time(struct GP_EventQueue *self, struct timeval *time) +{ + if (time == NULL) + gettimeofday(&self->cur_state.time, NULL); + else + self->cur_state.time = *time; +} + +static uint32_t clip_rel(uint32_t val, uint32_t max, int32_t rel) +{ + if (rel < 0) { + if (val < GP_ABS(rel)) + return 0; + else + return val + rel; + } + + if (val + rel >= max) + return max - 1; + + return val + rel; +} + +void GP_EventQueuePushRel(struct GP_EventQueue *self, + int32_t rx, int32_t ry, struct timeval *time) +{ + /* event header */ + self->cur_state.type = GP_EV_REL; + self->cur_state.code = GP_EV_REL_POS; + + self->cur_state.val.rel.rx = rx; + self->cur_state.val.rel.ry = ry; + + set_time(self, time); + + /* move the global cursor */ + self->cur_state.cursor_x = clip_rel(self->cur_state.cursor_x, self->screen_w, rx); + self->cur_state.cursor_y = clip_rel(self->cur_state.cursor_y, self->screen_h, ry); + + /* put it into queue */ + event_put(self, &self->cur_state); +} + +void GP_EventQueuePushRelTo(struct GP_EventQueue *self, + uint32_t x, uint32_t y, struct timeval *time) +{ + if (x > self->screen_w || y > self->screen_h) { + GP_WARN("x > screen_w or y > screen_h"); + return; + } + + int32_t rx = x - self->cur_state.cursor_x; + int32_t ry = y - self->cur_state.cursor_y; + + GP_EventQueuePushRel(self, rx, ry, time); +} + +void GP_EventQueuePushAbs(struct GP_EventQueue *self, + uint32_t x, uint32_t y, uint32_t pressure, + uint32_t x_max, uint32_t y_max, uint32_t pressure_max, + struct timeval *time) +{ + /* event header */ + self->cur_state.type = GP_EV_ABS; + self->cur_state.code = GP_EV_ABS_POS; + self->cur_state.val.abs.x = x; + self->cur_state.val.abs.y = y; + self->cur_state.val.abs.pressure = pressure; + self->cur_state.val.abs.x_max = x_max; + self->cur_state.val.abs.y_max = y_max; + self->cur_state.val.abs.pressure_max = pressure_max; + + set_time(self, time); + + /* + * Set global cursor, the packet could be partial, eg. update only x or + * only y. In such case x_max or y_max is zero. + */ + if (x_max != 0) + self->cur_state.cursor_x = x * (self->screen_w - 1) / x_max; + + if (y_max != 0) + self->cur_state.cursor_y = y * (self->screen_h - 1) / y_max; + + /* put it into queue */ + event_put(self, &self->cur_state); +} + +static char keys_to_ascii[] = { + 0x00, 0x1b, '1', '2', '3', '4', '5', '6', '7', '8', + '9', '0', '-', '=', 0x08, 't', 'q', 'w', 'e', 'r', + 't', 'y', 'u', 'i', 'o', 'p', '[', ']', 'n', 0x00, + 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', + ''', '`', 0x00, '', 'z', 'x', 'c', 'v', 'b', 'n', + 'm', ',', '.', '/', 0x00, '*', 0x00, ' ', 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, '7', '8', '9', '-', '4', '5', '6', '+', '1', + '2', '3', '0', '.' +}; + +static char keys_to_ascii_shift[] = { + 0x00, 0x1b, '!', '@', '#', '$', '%', '^', '&', '*', + '(', ')', '_', '+', 0x08, 't', 'Q', 'W', 'E', 'R', + 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', 'n', 0x00, + 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', + '"', '~', 0x00, '|', 'Z', 'X', 'C', 'V', 'B', 'N', + 'M', '<', '>', '?', 0x00, '*', 0x00, ' ', 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, '7', '8', '9', '-', '4', '5', '6', '+', '1', + '2', '3', '0', '.' +}; + +/* + * Fills key ascii value accordingly to keys pressed. + */ +static void key_to_ascii(struct GP_Event *ev) +{ + unsigned int key = ev->val.key.key; + + ev->val.key.ascii = 0; + + if (GP_EventGetKey(ev, GP_KEY_LEFT_SHIFT) || + GP_EventGetKey(ev, GP_KEY_RIGHT_SHIFT)) { + if (ev->val.key.key < sizeof(keys_to_ascii_shift)) + ev->val.key.ascii = keys_to_ascii_shift[key]; + } else { + if (ev->val.key.key < sizeof(keys_to_ascii)) + ev->val.key.ascii = keys_to_ascii[key]; + } +} + +void GP_EventQueuePushKey(struct GP_EventQueue *self, + uint32_t key, uint8_t code, struct timeval *time) +{ + switch (code) { + case GP_EV_KEY_UP: + GP_EventResetKey(&self->cur_state, key); + break; + case GP_EV_KEY_DOWN: + GP_EventSetKey(&self->cur_state, key); + break; + case GP_EV_KEY_REPEAT: + break; + default: + GP_WARN("Invalid key event code %u", code); + return; + } + + /* event header */ + self->cur_state.type = GP_EV_KEY; + self->cur_state.code = code; + self->cur_state.val.key.key = key; + + key_to_ascii(&self->cur_state); + + set_time(self, time); + + /* put it into queue */ + event_put(self, &self->cur_state); +} + +void GP_EventQueuePushResize(struct GP_EventQueue *self, + uint32_t w, uint32_t h, struct timeval *time) +{ + /* event header */ + self->cur_state.type = GP_EV_SYS; + self->cur_state.code = GP_EV_SYS_RESIZE; + + self->cur_state.val.sys.w = w; + self->cur_state.val.sys.h = h; + + set_time(self, time); + + /* put it into queue */ + event_put(self, &self->cur_state); +} + +void GP_EventQueuePush(struct GP_EventQueue *self, + uint16_t type, uint32_t code, int32_t value, + struct timeval *time) +{ + switch (type) { + case GP_EV_KEY: + GP_EventQueuePushKey(self, code, value, time); + break; + default: + self->cur_state.type = type; + self->cur_state.code = code; + self->cur_state.val.val = value; + + set_time(self, time); + + event_put(self, &self->cur_state); + } +} diff --git a/libs/input/GP_InputDriverKBD.c b/libs/input/GP_InputDriverKBD.c index 9530fca..ae575c3 100644 --- a/libs/input/GP_InputDriverKBD.c +++ b/libs/input/GP_InputDriverKBD.c @@ -16,13 +16,15 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
+#include "core/GP_Common.h" #include "core/GP_Debug.h" -#include "GP_Event.h" -#include "GP_InputDriverKBD.h" + +#include "input/GP_EventQueue.h" +#include "input/GP_InputDriverKBD.h"
/* KBD raw mode keycodes */ static uint16_t keycode_table[] = { @@ -56,21 +58,20 @@ static uint16_t keycode_table[] = { GP_KEY_PAGE_DOWN, GP_KEY_INSERT, };
-static const uint16_t keycode_table_size = sizeof(keycode_table)/2; - -void GP_InputDriverKBDEventPut(unsigned char ev) +void GP_InputDriverKBDEventPut(struct GP_EventQueue *event_queue, + unsigned char ev) { + unsigned int keycode = ev & 0x7f; int press = !(ev & 0x80); - int keycode = ev & 0x7f; int key;
- printf("Press %i keycode %in", press, keycode); + GP_DEBUG(2, "Press %i keycode %in", press, keycode);
- if (keycode > 0 && keycode <= keycode_table_size) { + if (keycode > 0 && keycode <= GP_ARRAY_SIZE(keycode_table)) { key = keycode_table[keycode - 1]; if (key != 0) { - GP_EventPushKey(key, press, NULL); + GP_EventQueuePushKey(event_queue, key, press, NULL); return; } } diff --git a/libs/input/GP_InputDriverLinux.c b/libs/input/GP_InputDriverLinux.c index ca774ed..09415c5 100644 --- a/libs/input/GP_InputDriverLinux.c +++ b/libs/input/GP_InputDriverLinux.c @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -29,8 +29,8 @@
#include "core/GP_Debug.h"
-#include "GP_Event.h" -#include "GP_InputDriverLinux.h" +#include "input/GP_EventQueue.h" +#include "input/GP_InputDriverLinux.h"
static int get_version(int fd) { @@ -197,7 +197,9 @@ static void input_abs(struct GP_InputDriverLinux *self, struct input_event *ev) } }
-static void input_key(struct GP_InputDriverLinux *self, struct input_event *ev) +static void input_key(struct GP_InputDriverLinux *self, + struct GP_EventQueue *event_queue, + struct input_event *ev) { GP_DEBUG(4, "Key event");
@@ -212,14 +214,16 @@ static void input_key(struct GP_InputDriverLinux *self, struct input_event *ev) return; }
- GP_EventPushKey(ev->code, ev->value, NULL); + GP_EventQueuePushKey(event_queue, ev->code, ev->value, NULL); }
-static void do_sync(struct GP_InputDriverLinux *self) +static void do_sync(struct GP_InputDriverLinux *self, + struct GP_EventQueue *event_queue) { if (self->rel_flag) { self->rel_flag = 0; - GP_EventPushRel(self->rel_x, self->rel_y, NULL); + GP_EventQueuePushRel(event_queue, self->rel_x, + self->rel_y, NULL); self->rel_x = 0; self->rel_y = 0; } @@ -255,32 +259,35 @@ static void do_sync(struct GP_InputDriverLinux *self) self->abs_flag_y = 0; }
- GP_EventPushAbs(x, y, self->abs_press, x_max, y_max, - self->abs_press_max, NULL); + GP_EventQueuePushAbs(event_queue, x, y, self->abs_press, + x_max, y_max, self->abs_press_max, NULL); self->abs_press = 0;
if (self->abs_pen_flag) { - GP_EventPushKey(BTN_TOUCH, 1, NULL); + GP_EventQueuePushKey(event_queue, BTN_TOUCH, 1, NULL); self->abs_pen_flag = 0; } } }
-static void input_syn(struct GP_InputDriverLinux *self, struct input_event *ev) +static void input_syn(struct GP_InputDriverLinux *self, + struct GP_EventQueue *event_queue, + struct input_event *ev) { GP_DEBUG(4, "Sync event"); switch (ev->code) { case 0: - do_sync(self); + do_sync(self, event_queue); break; default: GP_DEBUG(3, "Unhandled code %i", ev->code); } }
-int GP_InputDriverLinuxRead(struct GP_InputDriverLinux *self) +int GP_InputDriverLinuxRead(struct GP_InputDriverLinux *self, + struct GP_EventQueue *event_queue) { struct input_event ev; int ret; @@ -301,10 +308,10 @@ int GP_InputDriverLinuxRead(struct GP_InputDriverLinux *self) input_abs(self, &ev); break; case EV_KEY: - input_key(self, &ev); + input_key(self, event_queue, &ev); break; case EV_SYN: - input_syn(self, &ev); + input_syn(self, event_queue, &ev); break; default: GP_DEBUG(3, "Unhandled type %i", ev.type); diff --git a/libs/input/GP_InputDriverSDL.c b/libs/input/GP_InputDriverSDL.c index 18da085..aa3176b 100644 --- a/libs/input/GP_InputDriverSDL.c +++ b/libs/input/GP_InputDriverSDL.c @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -24,10 +24,11 @@
#ifdef HAVE_LIBSDL
-#include <core/GP_Debug.h> +#include "core/GP_Common.h" +#include "core/GP_Debug.h"
-#include "GP_Event.h" -#include "GP_InputDriverSDL.h" +#include "input/GP_EventQueue.h" +#include "input/GP_InputDriverSDL.h"
/* SDL ascii mapped keys */ static uint16_t keysym_table1[] = { @@ -65,8 +66,6 @@ static uint16_t keysym_table1[] = { 0, 0, GP_KEY_DELETE, };
-static const uint16_t keysym_table1_size = sizeof(keysym_table1)/2; - /* keypad and function keys starting at 256 */ static uint16_t keysym_table2[] = { GP_KEY_KP_0, GP_KEY_KP_1, GP_KEY_KP_2, GP_KEY_KP_3, @@ -87,16 +86,16 @@ static uint16_t keysym_table2[] = { GP_KEY_SYSRQ, 0, 0, GP_KEY_COMPOSE, };
-static const uint16_t keysym_table2_size = sizeof(keysym_table2)/2; - -void GP_InputDriverSDLEventPut(SDL_Event *ev) +void GP_InputDriverSDLEventPut(struct GP_EventQueue *event_queue, + SDL_Event *ev) { uint16_t keysym; uint32_t key = 0;
switch (ev->type) { case SDL_MOUSEMOTION: - GP_EventPushRel(ev->motion.xrel, ev->motion.yrel, NULL); + GP_EventQueuePushRel(event_queue, ev->motion.xrel, + ev->motion.yrel, NULL); break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: @@ -113,11 +112,13 @@ void GP_InputDriverSDLEventPut(SDL_Event *ev) /* Mouse wheel */ case 4: if (ev->type == SDL_MOUSEBUTTONDOWN) - GP_EventPush(GP_EV_REL, GP_EV_REL_WHEEL, 1, NULL); + GP_EventQueuePush(event_queue, GP_EV_REL, + GP_EV_REL_WHEEL, 1, NULL); return; case 5: if (ev->type == SDL_MOUSEBUTTONDOWN) - GP_EventPush(GP_EV_REL, GP_EV_REL_WHEEL, -1, NULL); + GP_EventQueuePush(event_queue, GP_EV_REL, + GP_EV_REL_WHEEL, -1, NULL); return; default: GP_WARN("Unmapped SDL Mouse button %02x", @@ -125,16 +126,17 @@ void GP_InputDriverSDLEventPut(SDL_Event *ev) return; }
- GP_EventPush(GP_EV_KEY, key, ev->button.state, NULL); + GP_EventQueuePush(event_queue, GP_EV_KEY, + key, ev->button.state, NULL); break; case SDL_KEYDOWN: case SDL_KEYUP: keysym = ev->key.keysym.sym;
- if (keysym > 0 && keysym <= keysym_table1_size) + if (keysym > 0 && keysym <= GP_ARRAY_SIZE(keysym_table1)) key = keysym_table1[keysym - 1];
- if (keysym > 255 && keysym <= 255 + keysym_table2_size) + if (keysym > 255 && keysym <= 255 + GP_ARRAY_SIZE(keysym_table2)) key = keysym_table2[keysym - 256];
if (key == 0) { @@ -142,13 +144,15 @@ void GP_InputDriverSDLEventPut(SDL_Event *ev) return; } - GP_EventPushKey(key, ev->key.state, NULL); + GP_EventQueuePushKey(event_queue, key, ev->key.state, NULL); break; case SDL_VIDEORESIZE: - GP_EventPushResize(ev->resize.w, ev->resize.h, NULL); + GP_EventQueuePushResize(event_queue, ev->resize.w, + ev->resize.h, NULL); break; case SDL_QUIT: - GP_EventPush(GP_EV_SYS, GP_EV_SYS_QUIT, 0, NULL); + GP_EventQueuePush(event_queue, GP_EV_SYS, + GP_EV_SYS_QUIT, 0, NULL); break; } } diff --git a/libs/input/GP_InputDriverX11.c b/libs/input/GP_InputDriverX11.c index 7e5f1ef..a2bb7ef 100644 --- a/libs/input/GP_InputDriverX11.c +++ b/libs/input/GP_InputDriverX11.c @@ -24,7 +24,7 @@
#include "core/GP_Debug.h" #include "core/GP_Common.h" -#include "GP_Event.h" +#include "input/GP_EventQueue.h"
#ifdef HAVE_LIBX11
@@ -208,7 +208,8 @@ void GP_InputDriverX11Init(Display *dpy) init_table(dpy); }
-void GP_InputDriverX11EventPut(XEvent *ev, int w, int h) +void GP_InputDriverX11EventPut(struct GP_EventQueue *event_queue, + XEvent *ev, int w, int h) { int key = 0, press = 0;
@@ -229,11 +230,13 @@ void GP_InputDriverX11EventPut(XEvent *ev, int w, int h) /* Mouse wheel */ case 4: if (press) - GP_EventPush(GP_EV_REL, GP_EV_REL_WHEEL, 1, NULL); + GP_EventQueuePush(event_queue, GP_EV_REL, + GP_EV_REL_WHEEL, 1, NULL); return; case 5: if (press) - GP_EventPush(GP_EV_REL, GP_EV_REL_WHEEL, -1, NULL); + GP_EventQueuePush(event_queue, GP_EV_REL, + GP_EV_REL_WHEEL, -1, NULL); return; } @@ -243,11 +246,11 @@ void GP_InputDriverX11EventPut(XEvent *ev, int w, int h) return; }
- GP_EventPush(GP_EV_KEY, key, press, NULL); + GP_EventQueuePush(event_queue, GP_EV_KEY, key, press, NULL); break; case ConfigureNotify: - GP_EventPushResize(ev->xconfigure.width, - ev->xconfigure.height, NULL); + GP_EventQueuePushResize(event_queue, ev->xconfigure.width, + ev->xconfigure.height, NULL); break; break; case MotionNotify: @@ -256,7 +259,8 @@ void GP_InputDriverX11EventPut(XEvent *ev, int w, int h) ev->xmotion.x > w || ev->xmotion.y > h) return; - GP_EventPushRelTo(ev->xmotion.x, ev->xmotion.y, NULL); + GP_EventQueuePushRelTo(event_queue, + ev->xmotion.x, ev->xmotion.y, NULL); break; case KeyPress: press = 1; @@ -266,13 +270,14 @@ void GP_InputDriverX11EventPut(XEvent *ev, int w, int h) if (key == 0) return;
- GP_EventPushKey(key, press, NULL); + GP_EventQueuePushKey(event_queue, key, press, NULL); break; /* events from WM */ case ClientMessage: //TODO: We know we get WM_DELETE_WINDOW because it's the only // event we requested to get but we must check anyway - GP_EventPush(GP_EV_SYS, GP_EV_SYS_QUIT, 0, NULL); + GP_EventQueuePush(event_queue, GP_EV_SYS, + GP_EV_SYS_QUIT, 0, NULL); #if 0 switch (ev->xclient.message_type) { default: diff --git a/tests/drivers/linux_input.c b/tests/drivers/linux_input.c index 86b75a6..4bff9d2 100644 --- a/tests/drivers/linux_input.c +++ b/tests/drivers/linux_input.c @@ -16,20 +16,24 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
/*
+ Bare Linux Input event example. + */
#include <GP.h> + #include <input/GP_InputDriverLinux.h>
int main(int argc, char *argv[]) { struct GP_InputDriverLinux *drv; + GP_EVENT_QUEUE_DECLARE(event_queue, 640, 480);
GP_SetDebugLevel(2);
@@ -45,14 +49,12 @@ int main(int argc, char *argv[]) return 1; }
- GP_EventSetScreenSize(640, 480); - for (;;) { - while (GP_InputDriverLinuxRead(drv) >= 1); + while (GP_InputDriverLinuxRead(drv, &event_queue) >= 1); GP_Event ev;
- while (GP_EventGet(&ev)) + while (GP_EventQueueGet(&event_queue, &ev)) GP_EventDump(&ev);
usleep(1000);
-----------------------------------------------------------------------
Summary of changes: build/syms/Input_symbols.txt | 21 ++-- demos/bogoman/bogoman.c | 2 +- demos/c_simple/backend_example.c | 9 +- demos/c_simple/blittest.c | 2 +- demos/c_simple/fileview.c | 2 +- demos/c_simple/fonttest.c | 2 +- demos/c_simple/input_example.c | 15 ++- demos/c_simple/koch.c | 2 +- demos/c_simple/linetest.c | 2 +- demos/c_simple/randomshapetest.c | 2 +- demos/c_simple/shapetest.c | 2 +- demos/c_simple/showimage.c | 2 +- demos/c_simple/sin_AA.c | 2 +- demos/c_simple/textaligntest.c | 2 +- demos/c_simple/v4l2_show.c | 2 +- demos/c_simple/virtual_backend_example.c | 4 +- demos/particle/particle_demo.c | 2 +- demos/spiv/spiv.c | 5 +- doc/Makefile | 3 +- doc/backends.txt | 7 +- doc/event_queue.txt | 134 ++++++++++++++++++ doc/input.txt | 87 ++---------- include/backends/GP_Backend.h | 17 ++- include/input/GP_Event.h | 55 -------- include/input/GP_EventQueue.h | 71 +++++++++- include/input/GP_InputDriverKBD.h | 14 ++- include/input/GP_InputDriverLinux.h | 11 +- include/input/GP_InputDriverSDL.h | 14 ++- include/input/GP_InputDriverX11.h | 10 +- libs/backends/GP_BackendVirtual.c | 13 ++ libs/backends/GP_LinuxFB.c | 6 +- libs/backends/GP_SDL.c | 22 ++- libs/backends/GP_X11.c | 15 ++- libs/input/GP_Event.c | 221 +----------------------------- libs/input/GP_EventQueue.c | 209 +++++++++++++++++++++++++++- libs/input/GP_InputDriverKBD.c | 21 ++-- libs/input/GP_InputDriverLinux.c | 37 +++-- libs/input/GP_InputDriverSDL.c | 40 +++--- libs/input/GP_InputDriverX11.c | 25 ++-- tests/drivers/linux_input.c | 12 +- 40 files changed, 627 insertions(+), 497 deletions(-) create mode 100644 doc/event_queue.txt
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.