Gfxprim
Threads by month
- ----- 2026 -----
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- 929 discussions
[repo.or.cz] gfxprim.git branch master updated: 86bcd463620e8f23223be4ba6aa7c119431a17ff
by metan 15 Feb '13
by metan 15 Feb '13
15 Feb '13
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 86bcd463620e8f23223be4ba6aa7c119431a17ff (commit)
via 025e4e5bfe38679138c784e52b1132cf9ddad9e1 (commit)
via 670966c1d27848e937e3e72806ebb83d8a4c264c (commit)
via 4004e53d7506d44299808e28fb578b0bdfbce3d4 (commit)
via f6010aa98ae98c4e01c5f9a0c0c4ae15a44a32d0 (commit)
from 24510ed5795faacbc9dc7f362d7921c2cc2d2730 (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/86bcd463620e8f23223be4ba6aa7c119431a…
commit 86bcd463620e8f23223be4ba6aa7c119431a17ff
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Feb 15 20:46:18 2013 +0100
tests: Fix wrong path in runtests.py script.
diff --git a/tests/runtests.py b/tests/runtests.py
index 9f3704e..d6619a5 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -26,7 +26,7 @@ results_dir='results'
#
# Relative path to the directory with GP libraries to run tests against
#
-build_dir='../../build'
+build_dir='../build'
#
# By default the glibc __libc_message() writes to /dev/tty before calling
http://repo.or.cz/w/gfxprim.git/commit/025e4e5bfe38679138c784e52b1132cf9dda…
commit 025e4e5bfe38679138c784e52b1132cf9ddad9e1
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Feb 15 20:46:00 2013 +0100
text: Add GP_FontTiny (proportional variant).
diff --git a/build/syms/Text_symbols.txt b/build/syms/Text_symbols.txt
index fe608d3..4aa0fe3 100644
--- a/build/syms/Text_symbols.txt
+++ b/build/syms/Text_symbols.txt
@@ -18,6 +18,7 @@ GP_Print
GP_DefaultStyle
+GP_FontTiny
GP_FontTinyMono
GP_DefaultProportionalFont
GP_DefaultConsoleFont
diff --git a/demos/c_simple/fileview.c b/demos/c_simple/fileview.c
index 175e4c2..aa6ff0b 100644
--- a/demos/c_simple/fileview.c
+++ b/demos/c_simple/fileview.c
@@ -69,6 +69,9 @@ void redraw_screen(void)
style.font = GP_FontTinyMono;
break;
case 3:
+ style.font = GP_FontTiny;
+ break;
+ case 4:
style.font = font;
break;
}
@@ -128,9 +131,9 @@ void event_loop(void)
switch (ev.val.key.key) {
case GP_KEY_SPACE:
if (font)
- font_flag = (font_flag + 1) % 4;
+ font_flag = (font_flag + 1) % 5;
else
- font_flag = (font_flag + 1) % 3;
+ font_flag = (font_flag + 1) % 4;
redraw_screen();
GP_BackendFlip(backend);
diff --git a/demos/c_simple/fonttest.c b/demos/c_simple/fonttest.c
index 1cd3349..e374ec9 100644
--- a/demos/c_simple/fonttest.c
+++ b/demos/c_simple/fonttest.c
@@ -113,9 +113,12 @@ void redraw_screen(void)
style.font = &GP_DefaultConsoleFont;
break;
case 2:
- style.font = GP_FontTinyMono;
+ style.font = GP_FontTiny;
break;
case 3:
+ style.font = GP_FontTinyMono;
+ break;
+ case 4:
style.font = font;
break;
}
@@ -170,7 +173,7 @@ void redraw_screen(void)
style.pixel_xspace = 1;
style.pixel_yspace = 1;
- if (font_flag == 2) {
+ if (font_flag == 2 || font_flag == 3) {
style.pixel_xmul = 2;
style.pixel_ymul = 5;
@@ -196,9 +199,9 @@ void event_loop(void)
switch (ev.val.key.key) {
case GP_KEY_SPACE:
if (font)
- font_flag = (font_flag + 1) % 4;
+ font_flag = (font_flag + 1) % 5;
else
- font_flag = (font_flag + 1) % 3;
+ font_flag = (font_flag + 1) % 4;
redraw_screen();
GP_BackendFlip(win);
diff --git a/include/text/GP_Fonts.h b/include/text/GP_Fonts.h
index 40ac8c6..d05dfc3 100644
--- a/include/text/GP_Fonts.h
+++ b/include/text/GP_Fonts.h
@@ -34,4 +34,9 @@
*/
extern const GP_FontFace *GP_FontTinyMono;
+/*
+ * Similar as FontTinyMono but proportional
+ */
+extern const GP_FontFace *GP_FontTiny;
+
#endif /* TEXT_GP_FONTS_H */
diff --git a/libs/text/GP_FontTinyMono.c b/libs/text/GP_FontTiny.c
similarity index 57%
copy from libs/text/GP_FontTinyMono.c
copy to libs/text/GP_FontTiny.c
index 5ff283e..a210997 100644
--- a/libs/text/GP_FontTinyMono.c
+++ b/libs/text/GP_FontTiny.c
@@ -22,210 +22,210 @@
#include "GP_Font.h"
-static int8_t tiny_mono_glyphs[] = {
- /* ' ' */ 5, 5, 0, 5, 6,
+static int8_t tiny_glyphs[] = {
+ /* ' ' */ 4, 5, 0, 5, 4,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- /* '!' */ 5, 5, 0, 5, 6,
- 0x20, 0x20, 0x20, 0x00, 0x20, 0x00, 0x00,
- /* '"' */ 5, 5, 0, 5, 6,
+ /* '!' */ 1, 5, 1, 5, 3,
+ 0x80, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00,
+ /* '"' */ 4, 5, 0, 5, 6,
0x50, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00,
/* '#' */ 5, 5, 0, 5, 6,
0x50, 0xf8, 0x50, 0xf8, 0x50, 0x00, 0x00,
- /* '$' */ 5, 5, 0, 5, 6,
- 0x20, 0x70, 0x02, 0x70, 0x20, 0x00, 0x00,
+ /* '$' */ 3, 5, 0, 5, 4,
+ 0x40, 0xe0, 0x40, 0xe0, 0x40, 0x00, 0x00,
/* '%' */ 5, 5, 0, 5, 6,
0xd0, 0x90, 0x20, 0x48, 0x58, 0x00, 0x00,
- /* '&' */ 5, 5, 0, 5, 6,
+ /* '&' */ 4, 5, 0, 5, 5,
0x60, 0x90, 0x40, 0xa0, 0xd0, 0x00, 0x00,
- /* ''' */ 5, 5, 0, 5, 6,
- 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
- /* '(' */ 5, 5, 0, 5, 6,
- 0x20, 0x40, 0x40, 0x40, 0x20, 0x00, 0x00,
- /* ')' */ 5, 5, 0, 5, 6,
- 0x20, 0x10, 0x10, 0x10, 0x20, 0x00, 0x00,
- /* '*' */ 5, 5, 0, 5, 6,
- 0x00, 0x50, 0x20, 0x50, 0x00, 0x00, 0x00,
- /* '+' */ 5, 5, 0, 5, 6,
- 0x00, 0x20, 0x70, 0x20, 0x00, 0x00, 0x00,
- /* ',' */ 5, 6, 0, 5, 6,
- 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x00,
- /* '-' */ 5, 5, 0, 5, 6,
- 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00,
- /* '.' */ 5, 5, 0, 5, 6,
- 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
- /* '/' */ 5, 5, 0, 5, 6,
- 0x10, 0x10, 0x20, 0x40, 0x40, 0x00, 0x00,
- /* '0' */ 5, 5, 0, 5, 6,
+ /* ''' */ 1, 5, 0, 5, 2,
+ 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* '(' */ 2, 5, 0, 5, 3,
+ 0x40, 0x80, 0x80, 0x80, 0x40, 0x00, 0x00,
+ /* ')' */ 2, 5, 0, 5, 3,
+ 0x80, 0x40, 0x40, 0x40, 0x80, 0x00, 0x00,
+ /* '*' */ 3, 5, 0, 5, 4,
+ 0x00, 0xa0, 0x40, 0xa0, 0x00, 0x00, 0x00,
+ /* '+' */ 3, 5, 0, 5, 4,
+ 0x00, 0x40, 0xe0, 0x40, 0x00, 0x00, 0x00,
+ /* ',' */ 1, 6, 0, 5, 2,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00,
+ /* '-' */ 3, 5, 0, 5, 4,
+ 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00,
+ /* '.' */ 1, 5, 0, 5, 2,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ /* '/' */ 3, 5, 0, 5, 4,
+ 0x20, 0x20, 0x40, 0x80, 0x80, 0x00, 0x00,
+ /* '0' */ 4, 5, 0, 5, 5,
0x60, 0xb0, 0x90, 0xd0, 0x60, 0x00, 0x00,
- /* '1' */ 5, 5, 0, 5, 6,
- 0x60, 0x20, 0x20, 0x20, 0x70, 0x00, 0x00,
- /* '2' */ 5, 5, 0, 5, 6,
+ /* '1' */ 3, 5, 0, 5, 4,
+ 0xc0, 0x40, 0x40, 0x40, 0xe0, 0x00, 0x00,
+ /* '2' */ 4, 5, 0, 5, 5,
0xe0, 0x10, 0x60, 0x80, 0xf0, 0x00, 0x00,
- /* '3' */ 5, 5, 0, 5, 6,
+ /* '3' */ 4, 5, 0, 5, 5,
0xe0, 0x10, 0x60, 0x10, 0xe0, 0x00, 0x00,
- /* '4' */ 5, 5, 0, 5, 6,
+ /* '4' */ 4, 5, 0, 5, 5,
0x20, 0x60, 0xa0, 0xf0, 0x20, 0x00, 0x00,
- /* '5' */ 5, 5, 0, 5, 6,
+ /* '5' */ 4, 5, 0, 5, 5,
0xf0, 0x80, 0xe0, 0x10, 0xe0, 0x00, 0x00,
- /* '6' */ 5, 5, 0, 5, 6,
+ /* '6' */ 4, 5, 0, 5, 5,
0x60, 0x80, 0xe0, 0x90, 0x60, 0x00, 0x00,
- /* '7' */ 5, 5, 0, 5, 6,
+ /* '7' */ 4, 5, 0, 5, 5,
0xf0, 0x10, 0x20, 0x40, 0x40, 0x00, 0x00,
- /* '8' */ 5, 5, 0, 5, 6,
+ /* '8' */ 4, 5, 0, 5, 5,
0x60, 0x90, 0x60, 0x90, 0x60, 0x00, 0x00,
- /* '9' */ 5, 5, 0, 5, 6,
+ /* '9' */ 4, 5, 0, 5, 5,
0x60, 0x90, 0x70, 0x10, 0x60, 0x00, 0x00,
- /* ':' */ 5, 5, 0, 5, 6,
- 0x00, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00,
- /* ';' */ 5, 5, 0, 5, 6,
- 0x00, 0x20, 0x00, 0x20, 0x20, 0x00, 0x00,
- /* '<' */ 5, 5, 0, 5, 6,
- 0x10, 0x20, 0x40, 0x20, 0x10, 0x00, 0x00,
- /* '=' */ 5, 5, 0, 5, 6,
- 0x00, 0x70, 0x00, 0x70, 0x00, 0x00, 0x00,
- /* '>' */ 5, 5, 0, 5, 6,
- 0x40, 0x20, 0x10, 0x20, 0x40, 0x00, 0x00,
- /* '?' */ 5, 5, 0, 5, 6,
- 0x60, 0x10, 0x20, 0x00, 0x20, 0x00, 0x00,
+ /* ':' */ 1, 5, 0, 5, 2,
+ 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00,
+ /* ';' */ 1, 5, 0, 5, 2,
+ 0x00, 0x80, 0x00, 0x80, 0x80, 0x00, 0x00,
+ /* '<' */ 3, 5, 0, 5, 4,
+ 0x20, 0x40, 0x80, 0x40, 0x20, 0x00, 0x00,
+ /* '=' */ 3, 5, 0, 5, 4,
+ 0x00, 0xe0, 0x00, 0xe0, 0x00, 0x00, 0x00,
+ /* '>' */ 3, 5, 0, 5, 4,
+ 0x80, 0x40, 0x20, 0x40, 0x80, 0x00, 0x00,
+ /* '?' */ 3, 5, 0, 5, 4,
+ 0xc0, 0x20, 0x40, 0x00, 0x40, 0x00, 0x00,
/* '@' */ 5, 5, 0, 5, 6,
0x70, 0x88, 0xb0, 0x80, 0x70, 0x00, 0x00,
- /* 'A' */ 5, 5, 0, 5, 6,
+ /* 'A' */ 4, 5, 0, 5, 5,
0x60, 0x90, 0xf0, 0x90, 0x90, 0x00, 0x00,
- /* 'B' */ 5, 5, 0, 5, 6,
+ /* 'B' */ 4, 5, 0, 5, 5,
0xe0, 0x90, 0xe0, 0x90, 0xe0, 0x00, 0x00,
- /* 'C' */ 5, 5, 0, 5, 6,
+ /* 'C' */ 4, 5, 0, 5, 5,
0x70, 0x80, 0x80, 0x80, 0x70, 0x00, 0x00,
- /* 'D' */ 5, 5, 0, 5, 6,
+ /* 'D' */ 4, 5, 0, 5, 5,
0xe0, 0x90, 0x90, 0x90, 0xe0, 0x00, 0x00,
- /* 'E' */ 5, 5, 0, 5, 6,
+ /* 'E' */ 4, 5, 0, 5, 5,
0xf0, 0x80, 0xe0, 0x80, 0xf0, 0x00, 0x00,
- /* 'F' */ 5, 5, 0, 5, 6,
+ /* 'F' */ 4, 5, 0, 5, 5,
0xf0, 0x80, 0xe0, 0x80, 0x80, 0x00, 0x00,
/* 'G' */ 5, 5, 0, 5, 6,
0x70, 0x80, 0x98, 0x88, 0x70, 0x00, 0x00,
- /* 'H' */ 5, 5, 0, 5, 6,
+ /* 'H' */ 4, 5, 0, 5, 5,
0x90, 0x90, 0xf0, 0x90, 0x90, 0x00, 0x00,
- /* 'I' */ 5, 5, 0, 5, 6,
- 0x70, 0x20, 0x20, 0x20, 0x70, 0x00, 0x00,
- /* 'J' */ 5, 5, 0, 5, 6,
+ /* 'I' */ 3, 5, 0, 5, 4,
+ 0xe0, 0x40, 0x40, 0x40, 0xe0, 0x00, 0x00,
+ /* 'J' */ 4, 5, 0, 5, 5,
0xf0, 0x10, 0x10, 0x90, 0x60, 0x00, 0x00,
- /* 'K' */ 5, 5, 0, 5, 6,
+ /* 'K' */ 4, 5, 0, 5, 5,
0x90, 0xa0, 0xc0, 0xa0, 0x90, 0x00, 0x00,
- /* 'L' */ 5, 5, 0, 5, 6,
+ /* 'L' */ 4, 5, 0, 5, 5,
0x80, 0x80, 0x80, 0x80, 0xf0, 0x00, 0x00,
/* 'M' */ 5, 5, 0, 5, 6,
0x88, 0xd8, 0xa8, 0x88, 0x88, 0x00, 0x00,
- /* 'N' */ 5, 5, 0, 5, 6,
+ /* 'N' */ 4, 5, 0, 5, 5,
0x90, 0xd0, 0xb0, 0x90, 0x90, 0x00, 0x00,
- /* 'O' */ 5, 5, 0, 5, 6,
+ /* 'O' */ 4, 5, 0, 5, 5,
0x60, 0x90, 0x90, 0x90, 0x60, 0x00, 0x00,
- /* 'P' */ 5, 5, 0, 5, 6,
+ /* 'P' */ 4, 5, 0, 5, 5,
0xe0, 0x90, 0xe0, 0x80, 0x80, 0x00, 0x00,
- /* 'Q' */ 5, 5, 0, 5, 6,
+ /* 'Q' */ 4, 5, 0, 5, 5,
0x60, 0x90, 0x90, 0xa0, 0x50, 0x00, 0x00,
- /* 'R' */ 5, 5, 0, 5, 6,
+ /* 'R' */ 4, 5, 0, 5, 5,
0xe0, 0x90, 0xe0, 0x90, 0x90, 0x00, 0x00,
- /* 'S' */ 5, 5, 0, 5, 6,
+ /* 'S' */ 4, 5, 0, 5, 5,
0x70, 0x80, 0x60, 0x10, 0xe0, 0x00, 0x00,
/* 'T' */ 5, 5, 0, 5, 6,
0xf8, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00,
- /* 'U' */ 5, 5, 0, 5, 6,
+ /* 'U' */ 4, 5, 0, 5, 5,
0x90, 0x90, 0x90, 0x90, 0x60, 0x00, 0x00,
/* 'V' */ 5, 5, 0, 5, 6,
0x88, 0x88, 0x50, 0x50, 0x20, 0x00, 0x00,
/* 'W' */ 5, 5, 0, 5, 6,
0x88, 0x88, 0x88, 0xa8, 0x50, 0x00, 0x00,
- /* 'X' */ 5, 5, 0, 5, 6,
+ /* 'X' */ 4, 5, 0, 5, 5,
0x90, 0x90, 0x60, 0x90, 0x90, 0x00, 0x00,
- /* 'Y' */ 5, 5, 0, 5, 6,
+ /* 'Y' */ 4, 5, 0, 5, 5,
0x90, 0x90, 0x70, 0x10, 0x60, 0x00, 0x00,
- /* 'Z' */ 5, 5, 0, 5, 6,
- 0xf0, 0x10, 0x20, 0xc0, 0xf0, 0x00, 0x00,
- /* '[' */ 5, 5, 0, 5, 6,
- 0x60, 0x40, 0x40, 0x40, 0x60, 0x00, 0x00,
- /* '' */ 5, 5, 0, 5, 6,
- 0x40, 0x40, 0x20, 0x10, 0x10, 0x00, 0x00,
- /* ']' */ 5, 5, 0, 5, 6,
- 0x30, 0x10, 0x10, 0x10, 0x30, 0x00, 0x00,
- /* '^' */ 5, 5, 0, 5, 6,
- 0x20, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00,
- /* '_' */ 5, 5, 0, 5, 6,
+ /* 'Z' */ 4, 5, 0, 5, 5,
+ 0xf0, 0x10, 0x60, 0x80, 0xf0, 0x00, 0x00,
+ /* '[' */ 2, 5, 0, 5, 3,
+ 0xc0, 0x80, 0x80, 0x80, 0xc0, 0x00, 0x00,
+ /* '' */ 3, 5, 0, 5, 4,
+ 0x80, 0x80, 0x40, 0x20, 0x20, 0x00, 0x00,
+ /* ']' */ 2, 5, 0, 5, 3,
+ 0xc0, 0x40, 0x40, 0x40, 0xc0, 0x00, 0x00,
+ /* '^' */ 3, 5, 0, 5, 4,
+ 0x40, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* '_' */ 4, 5, 0, 5, 5,
0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00,
- /* '`' */ 5, 5, 0, 5, 6,
- 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
- /* 'a' */ 5, 5, 0, 5, 6,
+ /* '`' */ 2, 5, 0, 5, 3,
+ 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* 'a' */ 4, 5, 0, 5, 5,
0x00, 0x60, 0x90, 0x90, 0x70, 0x00, 0x00,
- /* 'b' */ 5, 5, 0, 5, 6,
+ /* 'b' */ 4, 5, 0, 5, 5,
0x80, 0xe0, 0x90, 0x90, 0xe0, 0x00, 0x00,
- /* 'c' */ 5, 5, 0, 5, 6,
+ /* 'c' */ 4, 5, 0, 5, 5,
0x00, 0x70, 0x80, 0x80, 0x70, 0x00, 0x00,
- /* 'd' */ 5, 5, 0, 5, 6,
+ /* 'd' */ 4, 5, 0, 5, 5,
0x10, 0x70, 0x90, 0x90, 0x70, 0x00, 0x00,
- /* 'e' */ 5, 5, 0, 5, 6,
+ /* 'e' */ 4, 5, 0, 5, 5,
0x00, 0x60, 0xf0, 0x80, 0x70, 0x00, 0x00,
- /* 'f' */ 5, 7, 0, 5, 6,
+ /* 'f' */ 4, 7, 0, 5, 5,
0x00, 0x70, 0x80, 0xc0, 0x80, 0x80, 0x80,
- /* 'g' */ 5, 7, 0, 5, 6,
+ /* 'g' */ 4, 7, 0, 5, 5,
0x00, 0x60, 0x90, 0x90, 0x70, 0x10, 0x60,
- /* 'h' */ 5, 5, 0, 5, 6,
+ /* 'h' */ 4, 5, 0, 5, 5,
0x80, 0xe0, 0x90, 0x90, 0x90, 0x00, 0x00,
- /* 'i' */ 5, 5, 0, 5, 6,
- 0x20, 0x00, 0x20, 0x20, 0x70, 0x00, 0x00,
- /* 'j' */ 5, 5, 0, 5, 6,
+ /* 'i' */ 3, 5, 0, 5, 4,
+ 0x40, 0x00, 0x40, 0x40, 0xe0, 0x00, 0x00,
+ /* 'j' */ 4, 5, 0, 5, 5,
0x00, 0x10, 0x10, 0x90, 0x60, 0x00, 0x00,
- /* 'k' */ 5, 5, 0, 5, 6,
+ /* 'k' */ 4, 5, 0, 5, 5,
0x80, 0xb0, 0xc0, 0xa0, 0x90, 0x00, 0x00,
- /* 'l' */ 5, 5, 0, 5, 6,
- 0x40, 0x40, 0x40, 0x40, 0x30, 0x00, 0x00,
+ /* 'l' */ 2, 5, 0, 5, 3,
+ 0x80, 0x80, 0x80, 0x80, 0x40, 0x00, 0x00,
/* 'm' */ 5, 5, 0, 5, 6,
0x00, 0xd0, 0xa8, 0xa8, 0xa8, 0x00, 0x00,
- /* 'n' */ 5, 5, 0, 5, 6,
+ /* 'n' */ 4, 5, 0, 5, 5,
0x00, 0xe0, 0x90, 0x90, 0x90, 0x00, 0x00,
- /* 'o' */ 5, 5, 0, 5, 6,
+ /* 'o' */ 4, 5, 0, 5, 5,
0x00, 0x60, 0x90, 0x90, 0x60, 0x00, 0x00,
- /* 'p' */ 5, 7, 0, 5, 6,
+ /* 'p' */ 4, 7, 0, 5, 5,
0x00, 0xe0, 0x90, 0x90, 0xe0, 0x80, 0x80,
- /* 'q' */ 5, 7, 0, 5, 6,
+ /* 'q' */ 4, 7, 0, 5, 5,
0x00, 0x70, 0x90, 0x90, 0x70, 0x10, 0x10,
- /* 'r' */ 5, 5, 0, 5, 6,
+ /* 'r' */ 4, 5, 0, 5, 5,
0x00, 0x70, 0x80, 0x80, 0x80, 0x00, 0x00,
- /* 's' */ 5, 5, 0, 5, 6,
+ /* 's' */ 4, 5, 0, 5, 5,
0x00, 0x70, 0xc0, 0x30, 0xe0, 0x00, 0x00,
- /* 't' */ 5, 5, 0, 5, 6,
+ /* 't' */ 4, 5, 0, 5, 5,
0x40, 0xf0, 0x40, 0x40, 0x30, 0x00, 0x00,
- /* 'u' */ 5, 5, 0, 5, 6,
+ /* 'u' */ 4, 5, 0, 5, 5,
0x00, 0x90, 0x90, 0x90, 0x70, 0x00, 0x00,
- /* 'v' */ 5, 5, 0, 5, 6,
+ /* 'v' */ 4, 5, 0, 5, 5,
0x00, 0x90, 0x90, 0x90, 0x60, 0x00, 0x00,
/* 'w' */ 5, 5, 0, 5, 6,
0x00, 0x88, 0xa8, 0xa8, 0x50, 0x00, 0x00,
- /* 'x' */ 5, 5, 0, 5, 6,
+ /* 'x' */ 4, 5, 0, 5, 5,
0x00, 0x90, 0x60, 0x60, 0x90, 0x00, 0x00,
- /* 'y' */ 5, 7, 0, 5, 6,
+ /* 'y' */ 4, 7, 0, 5, 5,
0x00, 0x90, 0x90, 0x90, 0x70, 0x10, 0x60,
- /* 'z' */ 5, 5, 0, 5, 6,
+ /* 'z' */ 4, 5, 0, 5, 5,
0x00, 0xf0, 0x20, 0x40, 0xf0, 0x00, 0x00,
- /* '{' */ 5, 5, 0, 5, 6,
- 0x30, 0x40, 0x20, 0x40, 0x30, 0x00, 0x00,
- /* '|' */ 5, 5, 0, 5, 6,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00,
- /* '}' */ 5, 5, 0, 5, 6,
- 0x60, 0x10, 0x20, 0x10, 0x60, 0x00, 0x00,
- /* '~' */ 5, 5, 0, 5, 6,
+ /* '{' */ 3, 5, 0, 5, 4,
+ 0x60, 0x80, 0x40, 0x80, 0x60, 0x00, 0x00,
+ /* '|' */ 1, 5, 0, 5, 2,
+ 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00,
+ /* '}' */ 3, 5, 0, 5, 4,
+ 0xc0, 0x20, 0x40, 0x20, 0xc0, 0x00, 0x00,
+ /* '~' */ 4, 5, 0, 5, 5,
0x00, 0x50, 0xa0, 0x00, 0x00, 0x00, 0x00,
};
-static struct GP_FontFace tiny_mono = {
+static struct GP_FontFace tiny = {
.family_name = "Tiny",
- .style_name = "Mono",
+ .style_name = "",
.charset = GP_CHARSET_7BIT,
.ascend = 5,
.descend = 3,
.max_glyph_width = 5,
.max_glyph_advance = 6,
.glyph_bitmap_format = GP_FONT_BITMAP_1BPP,
- .glyphs = tiny_mono_glyphs,
+ .glyphs = tiny_glyphs,
.glyph_offsets = {12},
};
-struct GP_FontFace *GP_FontTinyMono = &tiny_mono;
+struct GP_FontFace *GP_FontTiny = &tiny;
diff --git a/libs/text/GP_FontTinyMono.c b/libs/text/GP_FontTinyMono.c
index 5ff283e..2859472 100644
--- a/libs/text/GP_FontTinyMono.c
+++ b/libs/text/GP_FontTinyMono.c
@@ -32,7 +32,7 @@ static int8_t tiny_mono_glyphs[] = {
/* '#' */ 5, 5, 0, 5, 6,
0x50, 0xf8, 0x50, 0xf8, 0x50, 0x00, 0x00,
/* '$' */ 5, 5, 0, 5, 6,
- 0x20, 0x70, 0x02, 0x70, 0x20, 0x00, 0x00,
+ 0x20, 0x70, 0x20, 0x70, 0x20, 0x00, 0x00,
/* '%' */ 5, 5, 0, 5, 6,
0xd0, 0x90, 0x20, 0x48, 0x58, 0x00, 0x00,
/* '&' */ 5, 5, 0, 5, 6,
@@ -140,7 +140,7 @@ static int8_t tiny_mono_glyphs[] = {
/* 'Y' */ 5, 5, 0, 5, 6,
0x90, 0x90, 0x70, 0x10, 0x60, 0x00, 0x00,
/* 'Z' */ 5, 5, 0, 5, 6,
- 0xf0, 0x10, 0x20, 0xc0, 0xf0, 0x00, 0x00,
+ 0xf0, 0x10, 0x60, 0x80, 0xf0, 0x00, 0x00,
/* '[' */ 5, 5, 0, 5, 6,
0x60, 0x40, 0x40, 0x40, 0x60, 0x00, 0x00,
/* '' */ 5, 5, 0, 5, 6,
http://repo.or.cz/w/gfxprim.git/commit/670966c1d27848e937e3e72806ebb83d8a4c…
commit 670966c1d27848e937e3e72806ebb83d8a4c264c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Feb 15 20:39:29 2013 +0100
build: Add forgotten symbol to Input symbols.
diff --git a/build/syms/Input_symbols.txt b/build/syms/Input_symbols.txt
index c52e2e3..0368dc2 100644
--- a/build/syms/Input_symbols.txt
+++ b/build/syms/Input_symbols.txt
@@ -17,6 +17,7 @@ GP_EventQueueInit
GP_EventQueueFree
GP_EventQueueAlloc
+GP_EventQueuePut
GP_EventQueuePutEvent
GP_EventQueuePushRelTo
GP_EventQueuePushRel
http://repo.or.cz/w/gfxprim.git/commit/4004e53d7506d44299808e28fb578b0bdfbc…
commit 4004e53d7506d44299808e28fb578b0bdfbce3d4
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Feb 15 20:38:18 2013 +0100
build: Fix check_symbols.sh script.
Fix regular expression passed to grep.
diff --git a/build/check_symbols.sh b/build/check_symbols.sh
index 31231cb..a229912 100755
--- a/build/check_symbols.sh
+++ b/build/check_symbols.sh
@@ -37,7 +37,7 @@ function check_symbols
shift
for i in `cat $symfile`; do
- if ! grep $i $@ 2>&1 > /dev/null; then
+ if ! grep "^$i$" $@ 2>&1 > /dev/null; then
find_symbol "$i"
fi
done
http://repo.or.cz/w/gfxprim.git/commit/f6010aa98ae98c4e01c5f9a0c0c4ae15a44a…
commit f6010aa98ae98c4e01c5f9a0c0c4ae15a44a32d0
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Feb 15 19:47:36 2013 +0100
build: Update text exported syms.
diff --git a/build/syms/Text_symbols.txt b/build/syms/Text_symbols.txt
index 8dc7ca1..fe608d3 100644
--- a/build/syms/Text_symbols.txt
+++ b/build/syms/Text_symbols.txt
@@ -1,19 +1,23 @@
GP_FontFaceLoad
+GP_FontFaceFree
+
GP_Text_Raw
-GP_GetGlyphCount
GP_TextAscent
GP_TextMaxStrWidth
GP_DefaultTextStyle
-GP_DefaultProportionalFont
-GP_DefaultConsoleFont
+GP_GetGlyphCount
GP_GetGlyphBitmap
GP_TextClear
GP_TextMaxWidth
GP_TextHeight
GP_TextWidth
GP_TextDescent
-GP_Text
GP_TextClearStr
+GP_Text
GP_Print
-GP_FontFaceFree
+
GP_DefaultStyle
+
+GP_FontTinyMono
+GP_DefaultProportionalFont
+GP_DefaultConsoleFont
-----------------------------------------------------------------------
Summary of changes:
build/check_symbols.sh | 2 +-
build/syms/Input_symbols.txt | 1 +
build/syms/Text_symbols.txt | 15 +-
demos/c_simple/fileview.c | 7 +-
demos/c_simple/fonttest.c | 11 +-
include/text/GP_Fonts.h | 5 +
libs/text/{GP_FontTinyMono.c => GP_FontTiny.c} | 240 ++++++++++++------------
libs/text/GP_FontTinyMono.c | 4 +-
tests/runtests.py | 2 +-
9 files changed, 152 insertions(+), 135 deletions(-)
copy libs/text/{GP_FontTinyMono.c => GP_FontTiny.c} (57%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 24510ed5795faacbc9dc7f362d7921c2cc2d2730
by metan 15 Feb '13
by metan 15 Feb '13
15 Feb '13
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 24510ed5795faacbc9dc7f362d7921c2cc2d2730 (commit)
from a111300cad036b48205c7be7dd5430e6fb853bf0 (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/24510ed5795faacbc9dc7f362d7921c2cc2d…
commit 24510ed5795faacbc9dc7f362d7921c2cc2d2730
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Feb 15 14:14:05 2013 +0100
text: Two small fixes for TinyMono Font.
diff --git a/libs/text/GP_FontTinyMono.c b/libs/text/GP_FontTinyMono.c
index cd02341..5ff283e 100644
--- a/libs/text/GP_FontTinyMono.c
+++ b/libs/text/GP_FontTinyMono.c
@@ -32,7 +32,7 @@ static int8_t tiny_mono_glyphs[] = {
/* '#' */ 5, 5, 0, 5, 6,
0x50, 0xf8, 0x50, 0xf8, 0x50, 0x00, 0x00,
/* '$' */ 5, 5, 0, 5, 6,
- 0x10, 0x7c, 0x92, 0x90, 0x7c, 0x00, 0x00,
+ 0x20, 0x70, 0x02, 0x70, 0x20, 0x00, 0x00,
/* '%' */ 5, 5, 0, 5, 6,
0xd0, 0x90, 0x20, 0x48, 0x58, 0x00, 0x00,
/* '&' */ 5, 5, 0, 5, 6,
@@ -176,7 +176,7 @@ static int8_t tiny_mono_glyphs[] = {
/* 'k' */ 5, 5, 0, 5, 6,
0x80, 0xb0, 0xc0, 0xa0, 0x90, 0x00, 0x00,
/* 'l' */ 5, 5, 0, 5, 6,
- 0x40, 0x40, 0x40, 0x40, 0x38, 0x00, 0x00,
+ 0x40, 0x40, 0x40, 0x40, 0x30, 0x00, 0x00,
/* 'm' */ 5, 5, 0, 5, 6,
0x00, 0xd0, 0xa8, 0xa8, 0xa8, 0x00, 0x00,
/* 'n' */ 5, 5, 0, 5, 6,
-----------------------------------------------------------------------
Summary of changes:
libs/text/GP_FontTinyMono.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: a111300cad036b48205c7be7dd5430e6fb853bf0
by metan 13 Feb '13
by metan 13 Feb '13
13 Feb '13
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 a111300cad036b48205c7be7dd5430e6fb853bf0 (commit)
from 7a68442b6e9b1172544f0e709ce50a2be6e376f7 (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/a111300cad036b48205c7be7dd5430e6fb85…
commit a111300cad036b48205c7be7dd5430e6fb853bf0
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Feb 13 01:01:09 2013 +0100
text: Add Tiny Mono font.
diff --git a/demos/c_simple/fileview.c b/demos/c_simple/fileview.c
index f1f3169..175e4c2 100644
--- a/demos/c_simple/fileview.c
+++ b/demos/c_simple/fileview.c
@@ -27,7 +27,7 @@
#include <stdlib.h>
#include <string.h>
-#include "GP.h"
+#include <GP.h>
static GP_Context *win;
static GP_Backend *backend;
@@ -38,6 +38,9 @@ static GP_Pixel white_pixel, gray_pixel, dark_gray_pixel, black_pixel,
static int font_flag = 0;
static int tracking = 0;
+static int mul = 1;
+static int space = 0;
+
static GP_FontFace *font;
struct FileLine {
@@ -63,14 +66,17 @@ void redraw_screen(void)
style.font = &GP_DefaultProportionalFont;
break;
case 2:
+ style.font = GP_FontTinyMono;
+ break;
+ case 3:
style.font = font;
break;
}
- style.pixel_xmul = 1;
- style.pixel_ymul = 1;
- style.pixel_xspace = 0;
- style.pixel_yspace = 0;
+ style.pixel_xmul = mul;
+ style.pixel_ymul = mul;
+ style.pixel_xspace = space;
+ style.pixel_yspace = space;
style.char_xspace = tracking;
/* Text alignment (we are always drawing to the right
@@ -122,9 +128,9 @@ void event_loop(void)
switch (ev.val.key.key) {
case GP_KEY_SPACE:
if (font)
- font_flag = (font_flag + 1) % 3;
+ font_flag = (font_flag + 1) % 4;
else
- font_flag = (font_flag + 1) % 2;
+ font_flag = (font_flag + 1) % 3;
redraw_screen();
GP_BackendFlip(backend);
@@ -145,6 +151,27 @@ void event_loop(void)
case GP_KEY_DOWN:
warp_down(1);
break;
+ case GP_KEY_DOT:
+ space++;
+ redraw_screen();
+ GP_BackendFlip(backend);
+ break;
+ case GP_KEY_COMMA:
+ space--;
+ redraw_screen();
+ GP_BackendFlip(backend);
+ break;
+ case GP_KEY_RIGHT_BRACE:
+ mul++;
+ redraw_screen();
+ GP_BackendFlip(backend);
+ break;
+ case GP_KEY_LEFT_BRACE:
+ if (mul > 0)
+ mul--;
+ redraw_screen();
+ GP_BackendFlip(backend);
+ break;
case GP_KEY_PAGE_UP:
warp_up(30);
break;
diff --git a/demos/c_simple/fonttest.c b/demos/c_simple/fonttest.c
index 4c41423..1cd3349 100644
--- a/demos/c_simple/fonttest.c
+++ b/demos/c_simple/fonttest.c
@@ -113,6 +113,9 @@ void redraw_screen(void)
style.font = &GP_DefaultConsoleFont;
break;
case 2:
+ style.font = GP_FontTinyMono;
+ break;
+ case 3:
style.font = font;
break;
}
@@ -163,9 +166,18 @@ void redraw_screen(void)
style.pixel_xmul = 4;
style.pixel_ymul = 2;
+
style.pixel_xspace = 1;
style.pixel_yspace = 1;
-
+
+ if (font_flag == 2) {
+ style.pixel_xmul = 2;
+ style.pixel_ymul = 5;
+
+ style.pixel_xspace = 2;
+ style.pixel_yspace = 2;
+ }
+
GP_Text(win->context, &style, 64, SPACING*i + 88, align,
dark_gray_pixel, black_pixel, test_string);
}
@@ -184,9 +196,9 @@ void event_loop(void)
switch (ev.val.key.key) {
case GP_KEY_SPACE:
if (font)
- font_flag = (font_flag + 1) % 3;
+ font_flag = (font_flag + 1) % 4;
else
- font_flag = (font_flag + 1) % 2;
+ font_flag = (font_flag + 1) % 3;
redraw_screen();
GP_BackendFlip(win);
diff --git a/include/text/GP_Fonts.h b/include/text/GP_Fonts.h
new file mode 100644
index 0000000..40ac8c6
--- /dev/null
+++ b/include/text/GP_Fonts.h
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#ifndef TEXT_GP_FONTS_H
+#define TEXT_GP_FONTS_H
+
+#include "GP_Font.h"
+
+/*
+ * Monospace 7x6 font
+ *
+ * Ascend: 5
+ * Descent: 2
+ * Width: 5 + 1
+ */
+extern const GP_FontFace *GP_FontTinyMono;
+
+#endif /* TEXT_GP_FONTS_H */
diff --git a/include/text/GP_Text.h b/include/text/GP_Text.h
index 3111e73..6ee567f 100644
--- a/include/text/GP_Text.h
+++ b/include/text/GP_Text.h
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -28,9 +28,10 @@
#include "core/GP_Context.h"
-#include "GP_TextStyle.h"
-#include "GP_TextMetric.h"
-#include "GP_DefaultFont.h"
+#include "text/GP_TextStyle.h"
+#include "text/GP_TextMetric.h"
+#include "text/GP_DefaultFont.h"
+#include "text/GP_Fonts.h"
/* How the rendered text should be aligned.
* For GP_Text(), the alignment is relative to the specified point:
diff --git a/libs/text/GP_FontTinyMono.c b/libs/text/GP_FontTinyMono.c
new file mode 100644
index 0000000..cd02341
--- /dev/null
+++ b/libs/text/GP_FontTinyMono.c
@@ -0,0 +1,231 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include "GP_Font.h"
+
+static int8_t tiny_mono_glyphs[] = {
+ /* ' ' */ 5, 5, 0, 5, 6,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* '!' */ 5, 5, 0, 5, 6,
+ 0x20, 0x20, 0x20, 0x00, 0x20, 0x00, 0x00,
+ /* '"' */ 5, 5, 0, 5, 6,
+ 0x50, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* '#' */ 5, 5, 0, 5, 6,
+ 0x50, 0xf8, 0x50, 0xf8, 0x50, 0x00, 0x00,
+ /* '$' */ 5, 5, 0, 5, 6,
+ 0x10, 0x7c, 0x92, 0x90, 0x7c, 0x00, 0x00,
+ /* '%' */ 5, 5, 0, 5, 6,
+ 0xd0, 0x90, 0x20, 0x48, 0x58, 0x00, 0x00,
+ /* '&' */ 5, 5, 0, 5, 6,
+ 0x60, 0x90, 0x40, 0xa0, 0xd0, 0x00, 0x00,
+ /* ''' */ 5, 5, 0, 5, 6,
+ 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* '(' */ 5, 5, 0, 5, 6,
+ 0x20, 0x40, 0x40, 0x40, 0x20, 0x00, 0x00,
+ /* ')' */ 5, 5, 0, 5, 6,
+ 0x20, 0x10, 0x10, 0x10, 0x20, 0x00, 0x00,
+ /* '*' */ 5, 5, 0, 5, 6,
+ 0x00, 0x50, 0x20, 0x50, 0x00, 0x00, 0x00,
+ /* '+' */ 5, 5, 0, 5, 6,
+ 0x00, 0x20, 0x70, 0x20, 0x00, 0x00, 0x00,
+ /* ',' */ 5, 6, 0, 5, 6,
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x00,
+ /* '-' */ 5, 5, 0, 5, 6,
+ 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00,
+ /* '.' */ 5, 5, 0, 5, 6,
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
+ /* '/' */ 5, 5, 0, 5, 6,
+ 0x10, 0x10, 0x20, 0x40, 0x40, 0x00, 0x00,
+ /* '0' */ 5, 5, 0, 5, 6,
+ 0x60, 0xb0, 0x90, 0xd0, 0x60, 0x00, 0x00,
+ /* '1' */ 5, 5, 0, 5, 6,
+ 0x60, 0x20, 0x20, 0x20, 0x70, 0x00, 0x00,
+ /* '2' */ 5, 5, 0, 5, 6,
+ 0xe0, 0x10, 0x60, 0x80, 0xf0, 0x00, 0x00,
+ /* '3' */ 5, 5, 0, 5, 6,
+ 0xe0, 0x10, 0x60, 0x10, 0xe0, 0x00, 0x00,
+ /* '4' */ 5, 5, 0, 5, 6,
+ 0x20, 0x60, 0xa0, 0xf0, 0x20, 0x00, 0x00,
+ /* '5' */ 5, 5, 0, 5, 6,
+ 0xf0, 0x80, 0xe0, 0x10, 0xe0, 0x00, 0x00,
+ /* '6' */ 5, 5, 0, 5, 6,
+ 0x60, 0x80, 0xe0, 0x90, 0x60, 0x00, 0x00,
+ /* '7' */ 5, 5, 0, 5, 6,
+ 0xf0, 0x10, 0x20, 0x40, 0x40, 0x00, 0x00,
+ /* '8' */ 5, 5, 0, 5, 6,
+ 0x60, 0x90, 0x60, 0x90, 0x60, 0x00, 0x00,
+ /* '9' */ 5, 5, 0, 5, 6,
+ 0x60, 0x90, 0x70, 0x10, 0x60, 0x00, 0x00,
+ /* ':' */ 5, 5, 0, 5, 6,
+ 0x00, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00,
+ /* ';' */ 5, 5, 0, 5, 6,
+ 0x00, 0x20, 0x00, 0x20, 0x20, 0x00, 0x00,
+ /* '<' */ 5, 5, 0, 5, 6,
+ 0x10, 0x20, 0x40, 0x20, 0x10, 0x00, 0x00,
+ /* '=' */ 5, 5, 0, 5, 6,
+ 0x00, 0x70, 0x00, 0x70, 0x00, 0x00, 0x00,
+ /* '>' */ 5, 5, 0, 5, 6,
+ 0x40, 0x20, 0x10, 0x20, 0x40, 0x00, 0x00,
+ /* '?' */ 5, 5, 0, 5, 6,
+ 0x60, 0x10, 0x20, 0x00, 0x20, 0x00, 0x00,
+ /* '@' */ 5, 5, 0, 5, 6,
+ 0x70, 0x88, 0xb0, 0x80, 0x70, 0x00, 0x00,
+ /* 'A' */ 5, 5, 0, 5, 6,
+ 0x60, 0x90, 0xf0, 0x90, 0x90, 0x00, 0x00,
+ /* 'B' */ 5, 5, 0, 5, 6,
+ 0xe0, 0x90, 0xe0, 0x90, 0xe0, 0x00, 0x00,
+ /* 'C' */ 5, 5, 0, 5, 6,
+ 0x70, 0x80, 0x80, 0x80, 0x70, 0x00, 0x00,
+ /* 'D' */ 5, 5, 0, 5, 6,
+ 0xe0, 0x90, 0x90, 0x90, 0xe0, 0x00, 0x00,
+ /* 'E' */ 5, 5, 0, 5, 6,
+ 0xf0, 0x80, 0xe0, 0x80, 0xf0, 0x00, 0x00,
+ /* 'F' */ 5, 5, 0, 5, 6,
+ 0xf0, 0x80, 0xe0, 0x80, 0x80, 0x00, 0x00,
+ /* 'G' */ 5, 5, 0, 5, 6,
+ 0x70, 0x80, 0x98, 0x88, 0x70, 0x00, 0x00,
+ /* 'H' */ 5, 5, 0, 5, 6,
+ 0x90, 0x90, 0xf0, 0x90, 0x90, 0x00, 0x00,
+ /* 'I' */ 5, 5, 0, 5, 6,
+ 0x70, 0x20, 0x20, 0x20, 0x70, 0x00, 0x00,
+ /* 'J' */ 5, 5, 0, 5, 6,
+ 0xf0, 0x10, 0x10, 0x90, 0x60, 0x00, 0x00,
+ /* 'K' */ 5, 5, 0, 5, 6,
+ 0x90, 0xa0, 0xc0, 0xa0, 0x90, 0x00, 0x00,
+ /* 'L' */ 5, 5, 0, 5, 6,
+ 0x80, 0x80, 0x80, 0x80, 0xf0, 0x00, 0x00,
+ /* 'M' */ 5, 5, 0, 5, 6,
+ 0x88, 0xd8, 0xa8, 0x88, 0x88, 0x00, 0x00,
+ /* 'N' */ 5, 5, 0, 5, 6,
+ 0x90, 0xd0, 0xb0, 0x90, 0x90, 0x00, 0x00,
+ /* 'O' */ 5, 5, 0, 5, 6,
+ 0x60, 0x90, 0x90, 0x90, 0x60, 0x00, 0x00,
+ /* 'P' */ 5, 5, 0, 5, 6,
+ 0xe0, 0x90, 0xe0, 0x80, 0x80, 0x00, 0x00,
+ /* 'Q' */ 5, 5, 0, 5, 6,
+ 0x60, 0x90, 0x90, 0xa0, 0x50, 0x00, 0x00,
+ /* 'R' */ 5, 5, 0, 5, 6,
+ 0xe0, 0x90, 0xe0, 0x90, 0x90, 0x00, 0x00,
+ /* 'S' */ 5, 5, 0, 5, 6,
+ 0x70, 0x80, 0x60, 0x10, 0xe0, 0x00, 0x00,
+ /* 'T' */ 5, 5, 0, 5, 6,
+ 0xf8, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00,
+ /* 'U' */ 5, 5, 0, 5, 6,
+ 0x90, 0x90, 0x90, 0x90, 0x60, 0x00, 0x00,
+ /* 'V' */ 5, 5, 0, 5, 6,
+ 0x88, 0x88, 0x50, 0x50, 0x20, 0x00, 0x00,
+ /* 'W' */ 5, 5, 0, 5, 6,
+ 0x88, 0x88, 0x88, 0xa8, 0x50, 0x00, 0x00,
+ /* 'X' */ 5, 5, 0, 5, 6,
+ 0x90, 0x90, 0x60, 0x90, 0x90, 0x00, 0x00,
+ /* 'Y' */ 5, 5, 0, 5, 6,
+ 0x90, 0x90, 0x70, 0x10, 0x60, 0x00, 0x00,
+ /* 'Z' */ 5, 5, 0, 5, 6,
+ 0xf0, 0x10, 0x20, 0xc0, 0xf0, 0x00, 0x00,
+ /* '[' */ 5, 5, 0, 5, 6,
+ 0x60, 0x40, 0x40, 0x40, 0x60, 0x00, 0x00,
+ /* '' */ 5, 5, 0, 5, 6,
+ 0x40, 0x40, 0x20, 0x10, 0x10, 0x00, 0x00,
+ /* ']' */ 5, 5, 0, 5, 6,
+ 0x30, 0x10, 0x10, 0x10, 0x30, 0x00, 0x00,
+ /* '^' */ 5, 5, 0, 5, 6,
+ 0x20, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* '_' */ 5, 5, 0, 5, 6,
+ 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00,
+ /* '`' */ 5, 5, 0, 5, 6,
+ 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* 'a' */ 5, 5, 0, 5, 6,
+ 0x00, 0x60, 0x90, 0x90, 0x70, 0x00, 0x00,
+ /* 'b' */ 5, 5, 0, 5, 6,
+ 0x80, 0xe0, 0x90, 0x90, 0xe0, 0x00, 0x00,
+ /* 'c' */ 5, 5, 0, 5, 6,
+ 0x00, 0x70, 0x80, 0x80, 0x70, 0x00, 0x00,
+ /* 'd' */ 5, 5, 0, 5, 6,
+ 0x10, 0x70, 0x90, 0x90, 0x70, 0x00, 0x00,
+ /* 'e' */ 5, 5, 0, 5, 6,
+ 0x00, 0x60, 0xf0, 0x80, 0x70, 0x00, 0x00,
+ /* 'f' */ 5, 7, 0, 5, 6,
+ 0x00, 0x70, 0x80, 0xc0, 0x80, 0x80, 0x80,
+ /* 'g' */ 5, 7, 0, 5, 6,
+ 0x00, 0x60, 0x90, 0x90, 0x70, 0x10, 0x60,
+ /* 'h' */ 5, 5, 0, 5, 6,
+ 0x80, 0xe0, 0x90, 0x90, 0x90, 0x00, 0x00,
+ /* 'i' */ 5, 5, 0, 5, 6,
+ 0x20, 0x00, 0x20, 0x20, 0x70, 0x00, 0x00,
+ /* 'j' */ 5, 5, 0, 5, 6,
+ 0x00, 0x10, 0x10, 0x90, 0x60, 0x00, 0x00,
+ /* 'k' */ 5, 5, 0, 5, 6,
+ 0x80, 0xb0, 0xc0, 0xa0, 0x90, 0x00, 0x00,
+ /* 'l' */ 5, 5, 0, 5, 6,
+ 0x40, 0x40, 0x40, 0x40, 0x38, 0x00, 0x00,
+ /* 'm' */ 5, 5, 0, 5, 6,
+ 0x00, 0xd0, 0xa8, 0xa8, 0xa8, 0x00, 0x00,
+ /* 'n' */ 5, 5, 0, 5, 6,
+ 0x00, 0xe0, 0x90, 0x90, 0x90, 0x00, 0x00,
+ /* 'o' */ 5, 5, 0, 5, 6,
+ 0x00, 0x60, 0x90, 0x90, 0x60, 0x00, 0x00,
+ /* 'p' */ 5, 7, 0, 5, 6,
+ 0x00, 0xe0, 0x90, 0x90, 0xe0, 0x80, 0x80,
+ /* 'q' */ 5, 7, 0, 5, 6,
+ 0x00, 0x70, 0x90, 0x90, 0x70, 0x10, 0x10,
+ /* 'r' */ 5, 5, 0, 5, 6,
+ 0x00, 0x70, 0x80, 0x80, 0x80, 0x00, 0x00,
+ /* 's' */ 5, 5, 0, 5, 6,
+ 0x00, 0x70, 0xc0, 0x30, 0xe0, 0x00, 0x00,
+ /* 't' */ 5, 5, 0, 5, 6,
+ 0x40, 0xf0, 0x40, 0x40, 0x30, 0x00, 0x00,
+ /* 'u' */ 5, 5, 0, 5, 6,
+ 0x00, 0x90, 0x90, 0x90, 0x70, 0x00, 0x00,
+ /* 'v' */ 5, 5, 0, 5, 6,
+ 0x00, 0x90, 0x90, 0x90, 0x60, 0x00, 0x00,
+ /* 'w' */ 5, 5, 0, 5, 6,
+ 0x00, 0x88, 0xa8, 0xa8, 0x50, 0x00, 0x00,
+ /* 'x' */ 5, 5, 0, 5, 6,
+ 0x00, 0x90, 0x60, 0x60, 0x90, 0x00, 0x00,
+ /* 'y' */ 5, 7, 0, 5, 6,
+ 0x00, 0x90, 0x90, 0x90, 0x70, 0x10, 0x60,
+ /* 'z' */ 5, 5, 0, 5, 6,
+ 0x00, 0xf0, 0x20, 0x40, 0xf0, 0x00, 0x00,
+ /* '{' */ 5, 5, 0, 5, 6,
+ 0x30, 0x40, 0x20, 0x40, 0x30, 0x00, 0x00,
+ /* '|' */ 5, 5, 0, 5, 6,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00,
+ /* '}' */ 5, 5, 0, 5, 6,
+ 0x60, 0x10, 0x20, 0x10, 0x60, 0x00, 0x00,
+ /* '~' */ 5, 5, 0, 5, 6,
+ 0x00, 0x50, 0xa0, 0x00, 0x00, 0x00, 0x00,
+};
+
+static struct GP_FontFace tiny_mono = {
+ .family_name = "Tiny",
+ .style_name = "Mono",
+ .charset = GP_CHARSET_7BIT,
+ .ascend = 5,
+ .descend = 3,
+ .max_glyph_width = 5,
+ .max_glyph_advance = 6,
+ .glyph_bitmap_format = GP_FONT_BITMAP_1BPP,
+ .glyphs = tiny_mono_glyphs,
+ .glyph_offsets = {12},
+};
+
+struct GP_FontFace *GP_FontTinyMono = &tiny_mono;
-----------------------------------------------------------------------
Summary of changes:
demos/c_simple/fileview.c | 41 +++-
demos/c_simple/fonttest.c | 18 ++-
.../bogoman_loader.h => include/text/GP_Fonts.h | 17 +-
include/text/GP_Text.h | 9 +-
libs/text/GP_FontTinyMono.c | 231 ++++++++++++++++++++
5 files changed, 297 insertions(+), 19 deletions(-)
copy demos/bogoman/bogoman_loader.h => include/text/GP_Fonts.h (88%)
create mode 100644 libs/text/GP_FontTinyMono.c
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 7a68442b6e9b1172544f0e709ce50a2be6e376f7
by metan 11 Feb '13
by metan 11 Feb '13
11 Feb '13
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 7a68442b6e9b1172544f0e709ce50a2be6e376f7 (commit)
from 7c4bb66768b4757c3944e0d99e6ba5fb3060fcee (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/7a68442b6e9b1172544f0e709ce50a2be6e3…
commit 7a68442b6e9b1172544f0e709ce50a2be6e376f7
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Feb 11 00:56:25 2013 +0100
text: Fix y_mul in text rendering.
diff --git a/libs/text/GP_Text.gen.c.t b/libs/text/GP_Text.gen.c.t
index 12a8e7e..8df9c36 100644
--- a/libs/text/GP_Text.gen.c.t
+++ b/libs/text/GP_Text.gen.c.t
@@ -52,7 +52,7 @@ static void text_draw_1BPP_{{ pt.name }}(GP_Context *context, GP_TextStyle *styl
for (k = 0; k < style->pixel_ymul; k++)
GP_HLine(context, x_start, x_start + style->pixel_xmul - 1,
- y - (glyph->bearing_y - style->font->ascend) * y_mul, fg);
+ y - (glyph->bearing_y - style->font->ascend) * y_mul + k, fg);
}
y += style->pixel_ymul + style->pixel_yspace;
-----------------------------------------------------------------------
Summary of changes:
libs/text/GP_Text.gen.c.t | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 7c4bb66768b4757c3944e0d99e6ba5fb3060fcee
by gavento 10 Feb '13
by gavento 10 Feb '13
10 Feb '13
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 7c4bb66768b4757c3944e0d99e6ba5fb3060fcee (commit)
via 2de090f680f9cba9f40a1516a231db982880e928 (commit)
via 8fffa8a364bdde37f5401f6c3b7250520721b76f (commit)
from 029e3ccf2b47c2d3c884aa6e2be2c7fa6231433c (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/7c4bb66768b4757c3944e0d99e6ba5fb3060…
commit 7c4bb66768b4757c3944e0d99e6ba5fb3060fcee
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Mon Jan 28 19:48:54 2013 +0100
pylib: test: tests for Polygon and FillPolygon
diff --git a/tests/pylib/test_gfx.py b/tests/pylib/test_gfx.py
index 784dce1..9b854cb 100644
--- a/tests/pylib/test_gfx.py
+++ b/tests/pylib/test_gfx.py
@@ -4,18 +4,18 @@ from unittest import SkipTest
from testutils import *
from gfxprim.core import Context
-from gfxprim import gfx
+from gfxprim import gfx, core
def test_gfx_submodule_loads():
"gfx is present in a Context"
- c = Context(1, 1, 1)
+ c = Context(1, 1, core.C.PIXEL_RGB888)
assert c.gfx
def test_gfx_submodule_has_C():
"gfx contains C"
- c = Context(1, 1, 1)
+ c = Context(1, 1, core.C.PIXEL_RGB888)
assert c.gfx.C
assert gfx.C
@@ -53,7 +53,7 @@ gfx_params = {
def test_all_methods_are_known():
"All methods of gfx submodule have known param types in this test"
- c = Context(1, 1, 1)
+ c = Context(1, 1, core.C.PIXEL_RGB888)
for name in dir(c.gfx):
if name[0] != '_' and name not in ['C', 'ctx']:
assert name in gfx_params
@@ -85,12 +85,33 @@ def gen_dummy_args(params):
return tuple(args)
@for_each_case(gfx_params)
-def test_method_callable(n, params):
- "Call with dummy parameters"
- c = Context(10, 10, 1)
+def test_method_call(n, params):
+ "Calling with dummy parameters:"
+ c = ContextRand(10, 10, core.C.PIXEL_RGB888)
if isinstance(params, str):
c.gfx.__getattribute__(n)(*gen_dummy_args(params))
else:
assert isinstance(params, tuple) and isinstance(params[-1], dict)
c.gfx.__getattribute__(n)(*params[:-1], **params[-1])
+def test_Polygon():
+ "Polygon() works"
+ c0 = ContextRand(13, 12, core.C.PIXEL_RGB888, seed=42)
+ c1 = ContextRand(13, 12, core.C.PIXEL_RGB888, seed=42)
+ c2 = ContextRand(13, 12, core.C.PIXEL_RGB888, seed=42)
+ assert c1 == c0
+ c1.gfx.Polygon([1,2,0,4,7,9,5,4,3,2], 43)
+ c2.gfx.Polygon([(1,2),(0,4),(7,9),(5,4),(3,2)], 43)
+ assert c1 == c2
+ assert c1 != c0
+
+def test_FillPolygon():
+ "FillPolygon() works"
+ c0 = ContextRand(13, 9, core.C.PIXEL_RGB888, seed=41)
+ c1 = ContextRand(13, 9, core.C.PIXEL_RGB888, seed=41)
+ c2 = ContextRand(13, 9, core.C.PIXEL_RGB888, seed=41)
+ assert c1 == c0
+ c1.gfx.FillPolygon([1,2,0,4,7,9,5,4,3,2], 0)
+ c2.gfx.FillPolygon([(1,2),(0,4),(7,9),(5,4),(3,2)], 0)
+ assert c1 == c2
+ assert c1 != c0
http://repo.or.cz/w/gfxprim.git/commit/2de090f680f9cba9f40a1516a231db982880…
commit 2de090f680f9cba9f40a1516a231db982880e928
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Mon Jan 28 19:46:22 2013 +0100
pywrap: gfx: implement [Fill]Polygon interface
diff --git a/pylib/gfxprim/gfx/__init__.py b/pylib/gfxprim/gfx/__init__.py
index 62ce4f0..f7fe741 100644
--- a/pylib/gfxprim/gfx/__init__.py
+++ b/pylib/gfxprim/gfx/__init__.py
@@ -42,12 +42,45 @@ def _init(module):
for name in [
'ArcSegment', 'Circle', 'Ellipse', 'Fill', 'FillCircle', 'FillEllipse',
- 'FillPolygon', 'FillRect', 'FillRect_AA', 'FillRing', 'FillSymbol',
+ 'FillRect', 'FillRect_AA', 'FillRing', 'FillSymbol',
'FillTetragon', 'FillTriangle', 'HLine', 'HLineAA', 'Line', 'LineAA',
- 'Polygon', 'PutPixelAA', 'Rect', 'Ring', 'Symbol', 'Tetragon',
+ 'PutPixelAA', 'Rect', 'Ring', 'Symbol', 'Tetragon',
'Triangle', 'VLine', 'VLineAA']:
extend_submodule(GfxSubmodule, name, c_gfx.__getattribute__('GP_' + name))
+ def flatten_coords(points):
+ "Helper for Polygon and FillPolygon coordinates"
+ l = []
+ for p in points:
+ if hasattr(p, '__iter__'):
+ l.extend(p)
+ else:
+ l.append(p)
+ for i in l:
+ assert isinstance(i, int)
+ return tuple(l)
+
+ @extend(GfxSubmodule)
+ def Polygon(self, points, pixel):
+ """
+ Polygon(context, coordinates, pixel)
+
+ Draw a polygon with color `pixel`.
+ `coordinates` is either an iterable of `int` coordinates `(x0, y0, x1, y1, ...)`
+ or an iterable of tuples `[(x0, y0), (x1, y1), ...]`.
+ """
+ c_gfx.GP_Polygon_wrap(self.ctx, flatten_coords(points), pixel)
+
+ @extend(GfxSubmodule)
+ def FillPolygon(self, points, pixel):
+ """
+ FillPolygon(context, coordinates, pixel)
+
+ Draw a filled polygon with color `pixel`.
+ `coordinates` is either an iterable of `int` coordinates `(x0, y0, x1, y1, ...)`
+ or an iterable of tuples `[(x0, y0), (x1, y1), ...]`.
+ """
+ c_gfx.GP_FillPolygon_wrap(self.ctx, flatten_coords(points), pixel)
_init(locals())
del _init
diff --git a/pylib/gfxprim/gfx/gfx.i b/pylib/gfxprim/gfx/gfx.i
index 881d2ca..9d3b0c4 100644
--- a/pylib/gfxprim/gfx/gfx.i
+++ b/pylib/gfxprim/gfx/gfx.i
@@ -30,3 +30,38 @@
%include "GP_LineAA.h"
%include "GP_RectAA.h"
+%inline %{
+static GP_Coord *GP_Polygon_unpack_coordinates(PyObject *coords)
+{
+ unsigned int i, vertex_count;
+ GP_Coord *cs;
+
+ GP_ASSERT(PyTuple_Check(coords));
+ vertex_count = PyTuple_Size(coords);
+ GP_ASSERT(vertex_count % 2 == 0);
+ cs = malloc(sizeof(GP_Coord[vertex_count]));
+ GP_ASSERT(cs != NULL);
+ for (i = 0; i < vertex_count; i++) {
+ PyObject *e = PyTuple_GetItem(coords, i); // Borrowed or ?
+ GP_ASSERT(PyInt_Check(e));
+ cs[i] = PyInt_AsLong(e);
+ }
+ return cs;
+}
+
+void GP_Polygon_wrap(GP_Context *context, PyObject *coords, GP_Pixel pixel)
+{
+ GP_Coord *cs = GP_Polygon_unpack_coordinates(coords);
+ GP_Polygon(context, PyTuple_Size(coords) / 2, cs, pixel);
+ free(cs);
+}
+
+void GP_FillPolygon_wrap(GP_Context *context, PyObject *coords, GP_Pixel pixel)
+{
+ GP_Coord *cs = GP_Polygon_unpack_coordinates(coords);
+ GP_FillPolygon(context, PyTuple_Size(coords) / 2, cs, pixel);
+ free(cs);
+}
+%}
+
+
http://repo.or.cz/w/gfxprim.git/commit/8fffa8a364bdde37f5401f6c3b7250520721…
commit 8fffa8a364bdde37f5401f6c3b7250520721b76f
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Mon Jan 28 15:58:56 2013 +0100
pylib: test: Fix Py3 syntax, improve filter gens.
diff --git a/tests/pylib/test_gfx.py b/tests/pylib/test_gfx.py
index e502e22..784dce1 100644
--- a/tests/pylib/test_gfx.py
+++ b/tests/pylib/test_gfx.py
@@ -28,7 +28,7 @@ gfx_params = {
'Fill': 'P',
'FillCircle': 'IIIP',
'FillEllipse': 'IIIIP',
- 'FillPolygon': None,
+ 'FillPolygon': ([(0,0),(1,1),(1,0)], 0, {}),
'FillRect': 'IIIIP',
'FillRect_AA': 'FFFFP',
'FillRing': 'IIIIP',
@@ -39,7 +39,7 @@ gfx_params = {
'HLineAA': 'FFFP',
'Line': 'IIIIP',
'LineAA': 'FFFFP',
- 'Polygon': None,
+ 'Polygon': ([(0,0),(1,1),(1,0)], 0, {}),
'PutPixelAA': 'FFP',
'Rect': 'IIIIP',
'Ring': 'IIIIP',
@@ -84,9 +84,13 @@ def gen_dummy_args(params):
assert False
return tuple(args)
-@for_each_case(gfx_params, _filter=(lambda(n, params): params is not None))
+@for_each_case(gfx_params)
def test_method_callable(n, params):
"Call with dummy parameters"
c = Context(10, 10, 1)
- c.gfx.__getattribute__(n)(*gen_dummy_args(params))
+ if isinstance(params, str):
+ c.gfx.__getattribute__(n)(*gen_dummy_args(params))
+ else:
+ assert isinstance(params, tuple) and isinstance(params[-1], dict)
+ c.gfx.__getattribute__(n)(*params[:-1], **params[-1])
diff --git a/tests/pylib/testutils.py b/tests/pylib/testutils.py
index 6c7ee5f..8c1badc 100644
--- a/tests/pylib/testutils.py
+++ b/tests/pylib/testutils.py
@@ -12,23 +12,21 @@ def alltypes(_filter=None):
"""
Creates one test for each PixelType (except INVALID).
The pixeltype is given to the test function and the name
- is appended to its name and docstring.
+ is appended to its name and is mentioned in the new docstring.
"""
- flt = lambda n, t: _filter(t)
- return for_each_case(dict([(t.name, t) for t in core.PixelTypes[1:]]),
- givename=False, _filter=(flt if _filter else None))
+ if _filter is None:
+ _filter = lambda x: True
+ cases = dict([(t.name, t) for t in core.PixelTypes[1:] if _filter(t)])
+ return for_each_case(cases, givename=False)
-def for_each_case(cases, givename=True, _filter=None):
+def for_each_case(cases, givename=True):
"""
Creates one test for each of `cases`.
Cases is either list of strings or or string dict (with any values).
The test is then given (name) for list or (name, value) for dict,
or just (value) if givename=False.
-
- Optional _filter is called with (name) or (name, value) for dict to
- determine which values to use (ret. True -> include).
"""
def decorate(f):
for n in cases:
-----------------------------------------------------------------------
Summary of changes:
pylib/gfxprim/gfx/__init__.py | 37 ++++++++++++++++++++++++++++++-
pylib/gfxprim/gfx/gfx.i | 35 ++++++++++++++++++++++++++++++
tests/pylib/test_gfx.py | 47 +++++++++++++++++++++++++++++++---------
tests/pylib/testutils.py | 14 +++++-------
4 files changed, 112 insertions(+), 21 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 029e3ccf2b47c2d3c884aa6e2be2c7fa6231433c
by metan 10 Feb '13
by metan 10 Feb '13
10 Feb '13
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/029e3ccf2b47c2d3c884aa6e2be2c7fa6231…
commit 029e3ccf2b47c2d3c884aa6e2be2c7fa6231433c
Author: Cyril Hrubis <metan(a)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/360814b9ac458b2196bcc89413833af529c5…
commit 360814b9ac458b2196bcc89413833af529c572d6
Author: Cyril Hrubis <metan(a)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/dc07fdf90743e45d6ac86cb2a07d51c91541…
commit dc07fdf90743e45d6ac86cb2a07d51c915419918
Author: Cyril Hrubis <metan(a)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/6c75f45c99e2f0a27974d9106d7b2620bbab…
commit 6c75f45c99e2f0a27974d9106d7b2620bbab78b5
Author: Cyril Hrubis <metan(a)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(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)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(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)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(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)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(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)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(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)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(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)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(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)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(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)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(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)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(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 6f9e031b813ac8d42b3faf6011b202d961894677
by metan 10 Feb '13
by metan 10 Feb '13
10 Feb '13
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 6f9e031b813ac8d42b3faf6011b202d961894677 (commit)
from 1a2dd1860b0fa145f2dec2e19af2d4931ac923db (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/6f9e031b813ac8d42b3faf6011b202d96189…
commit 6f9e031b813ac8d42b3faf6011b202d961894677
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Feb 10 14:36:37 2013 +0100
backends: Another step towards per backend event queue.
Now the backend has GP_BackendEventsQueued()
and GP_BackendEventGet() functions and examples
are chaged to use it.
Also the docs are updated.
diff --git a/demos/bogoman/bogoman.c b/demos/bogoman/bogoman.c
index f6f969b..82189d8 100644
--- a/demos/bogoman/bogoman.c
+++ b/demos/bogoman/bogoman.c
@@ -61,10 +61,10 @@ static struct GP_Backend *backend;
static void event_loop(struct bogoman_map *map)
{
- while (GP_EventsQueued()) {
+ while (GP_BackendEventsQueued(backend)) {
GP_Event ev;
- GP_EventGet(&ev);
+ GP_BackendEventGet(backend, &ev);
switch (ev.type) {
case GP_EV_KEY:
@@ -142,7 +142,7 @@ int main(int argc, char *argv[])
bogoman_render(&render, BOGOMAN_RENDER_DIRTY);
GP_BackendFlip(backend);
- usleep(100000);
+ usleep(50000);
}
return 0;
diff --git a/demos/c_simple/backend_example.c b/demos/c_simple/backend_example.c
index 3d565ef..debba09 100644
--- a/demos/c_simple/backend_example.c
+++ b/demos/c_simple/backend_example.c
@@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
/* Read and parse events */
GP_Event ev;
- while (GP_EventGet(&ev)) {
+ while (GP_BackendEventGet(backend, &ev)) {
GP_EventDump(&ev);
diff --git a/demos/c_simple/blittest.c b/demos/c_simple/blittest.c
index 5a80233..1ade1d9 100644
--- a/demos/c_simple/blittest.c
+++ b/demos/c_simple/blittest.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -94,7 +94,7 @@ void event_loop(void)
{
GP_Event ev;
- while (GP_EventGet(&ev)) {
+ while (GP_BackendEventGet(win, &ev)) {
GP_EventDump(&ev);
switch (ev.type) {
@@ -171,6 +171,9 @@ int main(void)
black = GP_ColorToContextPixel(GP_COL_BLACK, win->context);
white = GP_ColorToContextPixel(GP_COL_WHITE, win->context);
+ GP_Fill(win->context, black);
+ GP_BackendFlip(win);
+
for (;;) {
GP_BackendPoll(win);
event_loop();
diff --git a/demos/c_simple/fileview.c b/demos/c_simple/fileview.c
index 66c2925..6f36565 100644
--- a/demos/c_simple/fileview.c
+++ b/demos/c_simple/fileview.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -113,7 +113,7 @@ void event_loop(void)
{
GP_Event ev;
- while (GP_EventGet(&ev)) {
+ while (GP_BackendEventGet(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 b9a5898..bf8a169 100644
--- a/demos/c_simple/fonttest.c
+++ b/demos/c_simple/fonttest.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -175,7 +175,7 @@ void event_loop(void)
{
GP_Event ev;
- while (GP_EventGet(&ev)) {
+ while (GP_BackendEventGet(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 cb4877b..8eda0f5 100644
--- a/demos/c_simple/input_example.c
+++ b/demos/c_simple/input_example.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -56,10 +56,10 @@ static void event_loop(void)
for (;;) {
GP_BackendWait(backend);
- while (GP_EventsQueued()) {
+ while (GP_BackendEventsQueued(backend)) {
GP_Event ev;
- GP_EventGet(&ev);
+ GP_BackendEventGet(backend, &ev);
GP_EventDump(&ev);
switch (ev.type) {
diff --git a/demos/c_simple/koch.c b/demos/c_simple/koch.c
index 6668cb0..581a978 100644
--- a/demos/c_simple/koch.c
+++ b/demos/c_simple/koch.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -153,7 +153,7 @@ int main(void)
GP_BackendPoll(backend);
- while (GP_EventGet(&ev)) {
+ while (GP_BackendEventGet(backend, &ev)) {
GP_EventDump(&ev);
switch (ev.type) {
diff --git a/demos/c_simple/linetest.c b/demos/c_simple/linetest.c
index 9e7078b..f72d618 100644
--- a/demos/c_simple/linetest.c
+++ b/demos/c_simple/linetest.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -78,7 +78,7 @@ void event_loop(void)
{
GP_Event ev;
- while (GP_EventGet(&ev)) {
+ while (GP_BackendEventGet(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 19fcae4..1373ed9 100644
--- a/demos/c_simple/randomshapetest.c
+++ b/demos/c_simple/randomshapetest.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -214,7 +214,7 @@ void event_loop(void)
{
GP_Event ev;
- while (GP_EventGet(&ev)) {
+ while (GP_BackendEventGet(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 a807f5b..02c2bab 100644
--- a/demos/c_simple/shapetest.c
+++ b/demos/c_simple/shapetest.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -337,7 +337,7 @@ void event_loop(void)
GP_Event ev;
- while (GP_EventGet(&ev)) {
+ while (GP_BackendEventGet(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 9b1741b..f91bbec 100644
--- a/demos/c_simple/showimage.c
+++ b/demos/c_simple/showimage.c
@@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
GP_Event ev;
- while (GP_EventGet(&ev)) {
+ while (GP_BackendEventGet(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 94b3563..cd44879 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_EventGet(&ev)) {
+ while (GP_BackendEventGet(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 0f1b4a3..5d6d53b 100644
--- a/demos/c_simple/textaligntest.c
+++ b/demos/c_simple/textaligntest.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -73,7 +73,7 @@ static void event_loop(void)
{
GP_Event ev;
- while (GP_EventGet(&ev)) {
+ while (GP_BackendEventGet(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 c7f5cbb..4bb5543 100644
--- a/demos/c_simple/v4l2_show.c
+++ b/demos/c_simple/v4l2_show.c
@@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -129,7 +129,7 @@ int main(int argc, char *argv[])
/* Read and parse events */
GP_Event ev;
- while (GP_EventGet(&ev)) {
+ while (GP_BackendEventGet(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 448c72c..0468a14 100644
--- a/demos/c_simple/virtual_backend_example.c
+++ b/demos/c_simple/virtual_backend_example.c
@@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -148,7 +148,7 @@ int main(int argc, char *argv[])
/* Read and parse events */
GP_Event ev;
- while (GP_EventGet(&ev)) {
+ while (GP_BackendEventGet(backend, &ev)) {
GP_EventDump(&ev);
diff --git a/demos/particle/particle_demo.c b/demos/particle/particle_demo.c
index 4143ffe..e977cc6 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_EventGet(&ev)) {
+ while (GP_BackendEventGet(backend, &ev)) {
GP_EventDump(&ev);
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index f681b1a..23462b7 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -871,7 +871,7 @@ int main(int argc, char *argv[])
/* Read and parse events */
GP_Event ev;
- while (GP_EventGet(&ev)) {
+ while (GP_BackendEventGet(backend, &ev)) {
shift_flag = GP_EventGetKey(&ev, GP_KEY_LEFT_SHIFT) ||
GP_EventGetKey(&ev, GP_KEY_RIGHT_SHIFT);
diff --git a/doc/backends.txt b/doc/backends.txt
index 501baca..678f8c7 100644
--- a/doc/backends.txt
+++ b/doc/backends.txt
@@ -330,4 +330,30 @@ multithreaded application where one threads waits for events and others draws
into the buffer so you can stop the drawing threads before the backend context
size change.
+[source,c]
+-------------------------------------------------------------------------------
+#include <backends/GP_Backend.h>
+/* or */
+#include <GP.h>
+
+unsigned int GP_BackendEventsQueued(GP_Backend *self);
+-------------------------------------------------------------------------------
+
+Returns number of events queued in backend event queue.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <backends/GP_Backend.h>
+/* or */
+#include <GP.h>
+
+int GP_BackendEventGet(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.
+
TIP: For more information see link:input.html[input events] documentation.
diff --git a/include/backends/GP_Backend.h b/include/backends/GP_Backend.h
index 01bf3c1..900b8d4 100644
--- a/include/backends/GP_Backend.h
+++ b/include/backends/GP_Backend.h
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -228,4 +228,21 @@ int GP_BackendResize(GP_Backend *backend, uint32_t w, uint32_t h);
*/
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();
+}
+
+static inline int GP_BackendEventGet(GP_Backend *self, GP_Event *ev)
+{
+ (void) self;
+ return GP_EventGet(ev);
+}
+
#endif /* BACKENDS_GP_BACKEND_H */
diff --git a/include/input/GP_Event.h b/include/input/GP_Event.h
index c985cad..2c99bb2 100644
--- a/include/input/GP_Event.h
+++ b/include/input/GP_Event.h
@@ -31,8 +31,8 @@
*/
-#ifndef GP_EVENT_H
-#define GP_EVENT_H
+#ifndef INPUT_GP_EVENT_H
+#define INPUT_GP_EVENT_H
#include <stdint.h>
#include <sys/time.h>
@@ -387,4 +387,4 @@ static inline void GP_EventResetKey(struct GP_Event *ev,
ev->keys_pressed[(key)/8] &= ~(1<<((key)%8));
}
-#endif /* GP_EVENT_H */
+#endif /* INPUT_GP_EVENT_H */
-----------------------------------------------------------------------
Summary of changes:
demos/bogoman/bogoman.c | 6 +++---
demos/c_simple/backend_example.c | 4 ++--
demos/c_simple/blittest.c | 7 +++++--
demos/c_simple/fileview.c | 4 ++--
demos/c_simple/fonttest.c | 4 ++--
demos/c_simple/input_example.c | 6 +++---
demos/c_simple/koch.c | 4 ++--
demos/c_simple/linetest.c | 4 ++--
demos/c_simple/randomshapetest.c | 4 ++--
demos/c_simple/shapetest.c | 4 ++--
demos/c_simple/showimage.c | 4 ++--
demos/c_simple/sin_AA.c | 2 +-
demos/c_simple/textaligntest.c | 4 ++--
demos/c_simple/v4l2_show.c | 4 ++--
demos/c_simple/virtual_backend_example.c | 4 ++--
demos/particle/particle_demo.c | 2 +-
demos/spiv/spiv.c | 2 +-
doc/backends.txt | 26 ++++++++++++++++++++++++++
include/backends/GP_Backend.h | 19 ++++++++++++++++++-
include/input/GP_Event.h | 6 +++---
20 files changed, 83 insertions(+), 37 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 1a2dd1860b0fa145f2dec2e19af2d4931ac923db
by metan 09 Feb '13
by metan 09 Feb '13
09 Feb '13
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 1a2dd1860b0fa145f2dec2e19af2d4931ac923db (commit)
from 65f775044b3b4852f5819f18e975675ffba2b5f7 (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/1a2dd1860b0fa145f2dec2e19af2d4931ac9…
commit 1a2dd1860b0fa145f2dec2e19af2d4931ac923db
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Feb 9 21:51:32 2013 +0100
backends: X11: Fix build without MIT SHM.
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c
index 2dd17a0..f7a3fa4 100644
--- a/libs/backends/GP_X11.c
+++ b/libs/backends/GP_X11.c
@@ -58,8 +58,9 @@ struct x11_priv {
#ifdef HAVE_X_SHM
XShmSegmentInfo shminfo;
- GP_Context context;
#endif /* HAVE_X_SHM */
+
+ GP_Context context;
int resized_flag:1;
int shm_flag:1;
@@ -431,6 +432,7 @@ static int resize_shm_ximage(GP_Backend GP_UNUSED(*self),
int GP_UNUSED(w), int GP_UNUSED(h))
{
GP_WARN("Stub called");
+ return 1;
}
#endif /* HAVE_X_SHM */
-----------------------------------------------------------------------
Summary of changes:
libs/backends/GP_X11.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 65f775044b3b4852f5819f18e975675ffba2b5f7
by metan 09 Feb '13
by metan 09 Feb '13
09 Feb '13
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 65f775044b3b4852f5819f18e975675ffba2b5f7 (commit)
from 992b25b48eb696727ef6d19113a164ed7b286570 (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/65f775044b3b4852f5819f18e975675ffba2…
commit 65f775044b3b4852f5819f18e975675ffba2b5f7
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Feb 9 20:27:24 2013 +0100
build: Update list of exported syms.
diff --git a/build/check_symbols.sh b/build/check_symbols.sh
index f4ccd32..31231cb 100755
--- a/build/check_symbols.sh
+++ b/build/check_symbols.sh
@@ -51,7 +51,7 @@ function do_check
rm $SYMTMPFILE
}
-do_check libGP.so syms/Core_symbols.txt syms/Event_symbols.txt +do_check libGP.so syms/Core_symbols.txt syms/Input_symbols.txt syms/Filters_symbols.txt syms/GFX_symbols.txt syms/Loaders_symbols.txt syms/Text_symbols.txt
diff --git a/build/syms/Event_symbols.txt b/build/syms/Event_symbols.txt
deleted file mode 100644
index 6dc7e12..0000000
--- a/build/syms/Event_symbols.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-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
-GP_InputDriverLinuxOpen
-GP_InputDriverX11EventPut
-GP_InputDriverLinuxClose
-GP_InputDriverKBDEventPut
diff --git a/build/syms/Input_symbols.txt b/build/syms/Input_symbols.txt
new file mode 100644
index 0000000..b823325
--- /dev/null
+++ b/build/syms/Input_symbols.txt
@@ -0,0 +1,29 @@
+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
+GP_InputDriverLinuxOpen
+GP_InputDriverX11EventPut
+GP_InputDriverX11Init
+GP_InputDriverLinuxClose
+GP_InputDriverKBDEventPut
+
+GP_EventQueueSetCursorPosition
+GP_EventQueueGetEvent
+GP_EventQueueEventsQueued
+GP_EventQueueSetScreenSize
+GP_EventQueueInit
+GP_EventQueueFree
+GP_EventQueueAlloc
+GP_EventQueuePutEvent
-----------------------------------------------------------------------
Summary of changes:
build/check_symbols.sh | 2 +-
build/syms/Event_symbols.txt | 19 -------------------
build/syms/Input_symbols.txt | 29 +++++++++++++++++++++++++++++
3 files changed, 30 insertions(+), 20 deletions(-)
delete mode 100644 build/syms/Event_symbols.txt
create mode 100644 build/syms/Input_symbols.txt
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 992b25b48eb696727ef6d19113a164ed7b286570
by metan 09 Feb '13
by metan 09 Feb '13
09 Feb '13
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 992b25b48eb696727ef6d19113a164ed7b286570 (commit)
from c3fb40e752939f3ef6d3194f29613ed9c2f4d0dc (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/992b25b48eb696727ef6d19113a164ed7b28…
commit 992b25b48eb696727ef6d19113a164ed7b286570
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Feb 9 20:22:20 2013 +0100
input: X11: Fix typo (left ctrl vs. right ctrl)
diff --git a/libs/input/GP_InputDriverX11.c b/libs/input/GP_InputDriverX11.c
index 7874588..7e5f1ef 100644
--- a/libs/input/GP_InputDriverX11.c
+++ b/libs/input/GP_InputDriverX11.c
@@ -115,8 +115,8 @@ static const struct keytable sym_to_key[] = {
{XK_Shift_R, GP_KEY_RIGHT_SHIFT},
{XK_Alt_L, GP_KEY_LEFT_ALT},
{XK_Alt_R, GP_KEY_RIGHT_ALT},
- {XK_Control_L, GP_KEY_RIGHT_CTRL},
- {XK_Control_R, GP_KEY_LEFT_CTRL},
+ {XK_Control_L, GP_KEY_LEFT_CTRL},
+ {XK_Control_R, GP_KEY_RIGHT_CTRL},
{XK_Caps_Lock, GP_KEY_CAPS_LOCK},
{XK_Super_L, GP_KEY_LEFT_META},
{XK_Super_R, GP_KEY_RIGHT_META},
-----------------------------------------------------------------------
Summary of changes:
libs/input/GP_InputDriverX11.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0