Gfxprim
Threads by month
- ----- 2026 -----
- March
- February
- 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
February 2013
- 2 participants
- 14 discussions
[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
[repo.or.cz] gfxprim.git branch master updated: c3fb40e752939f3ef6d3194f29613ed9c2f4d0dc
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 c3fb40e752939f3ef6d3194f29613ed9c2f4d0dc (commit)
via 17c1de1de50338ab954d6b62e41ed55ff77c7484 (commit)
via ea2c59ddb80527d69107808dfe0d5a56a4609894 (commit)
from ff0dc088ad0e31060e426df42bb3913ffed3cab3 (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/c3fb40e752939f3ef6d3194f29613ed9c2f4…
commit c3fb40e752939f3ef6d3194f29613ed9c2f4d0dc
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Feb 9 19:34:07 2013 +0100
input: X11: Load some KeyCodes dynamically.
The X11 KeyCodes are not carved into the
stone. As a matter of fact some of the
keys are mapped differently on my iBook.
Now we load part of the translation table
dynamically based on X keysyms.
diff --git a/include/input/GP_InputDriverX11.h b/include/input/GP_InputDriverX11.h
index 87d4030..4c6df2c 100644
--- a/include/input/GP_InputDriverX11.h
+++ b/include/input/GP_InputDriverX11.h
@@ -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> *
* *
*****************************************************************************/
@@ -32,6 +32,11 @@
#include <X11/Xlib.h>
/*
+ * Loads X11 KeyCode translation table.
+ */
+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);
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c
index 9d5a3e1..2dd17a0 100644
--- a/libs/backends/GP_X11.c
+++ b/libs/backends/GP_X11.c
@@ -811,6 +811,9 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
if (x11->dpy == NULL)
goto err0;
+ /* Initialized key translation table */
+ GP_InputDriverX11Init(x11->dpy);
+
//XSynchronize(x11->dpy, True);
x11->scr = DefaultScreen(x11->dpy);
diff --git a/libs/input/GP_Event.c b/libs/input/GP_Event.c
index 7a5364a..0d638e9 100644
--- a/libs/input/GP_Event.c
+++ b/libs/input/GP_Event.c
@@ -98,6 +98,12 @@ const char *GP_EventKeyName(enum GP_EventKeyValue key)
return "MiddleButton";
case GP_BTN_PEN:
return "Pen";
+ case GP_KEY_NEXTSONG:
+ return "NextSong";
+ case GP_KEY_PREVIOUSSONG:
+ return "PreviousSong";
+ case GP_KEY_PLAYPAUSE:
+ return "PlayPause";
default:
return "Unknown";
};
diff --git a/libs/input/GP_InputDriverX11.c b/libs/input/GP_InputDriverX11.c
index 2b537fa..7874588 100644
--- a/libs/input/GP_InputDriverX11.c
+++ b/libs/input/GP_InputDriverX11.c
@@ -16,60 +16,201 @@
* 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 "../../config.h"
#include "core/GP_Debug.h"
+#include "core/GP_Common.h"
#include "GP_Event.h"
#ifdef HAVE_LIBX11
+#include <X11/keysym.h>
+#include <X11/XF86keysym.h>
+
#include "GP_InputDriverX11.h"
/* X11 keycodes */
static uint16_t keycode_table[] = {
- GP_KEY_ESC, GP_KEY_1, GP_KEY_2, GP_KEY_3,
+ 0, GP_KEY_1, GP_KEY_2, GP_KEY_3,
GP_KEY_4, GP_KEY_5, GP_KEY_6, GP_KEY_7,
GP_KEY_8, GP_KEY_9, GP_KEY_0, GP_KEY_MINUS,
- GP_KEY_EQUAL, GP_KEY_BACKSPACE, GP_KEY_TAB, GP_KEY_Q,
+ GP_KEY_EQUAL, 0, 0, GP_KEY_Q,
GP_KEY_W, GP_KEY_E, GP_KEY_R, GP_KEY_T,
GP_KEY_Y, GP_KEY_U, GP_KEY_I, GP_KEY_O,
GP_KEY_P, GP_KEY_LEFT_BRACE, GP_KEY_RIGHT_BRACE, GP_KEY_ENTER,
- GP_KEY_LEFT_CTRL, GP_KEY_A, GP_KEY_S, GP_KEY_D,
+ 0, GP_KEY_A, GP_KEY_S, GP_KEY_D,
GP_KEY_F, GP_KEY_G, GP_KEY_H, GP_KEY_J,
GP_KEY_K, GP_KEY_L, GP_KEY_SEMICOLON, GP_KEY_APOSTROPHE,
- GP_KEY_GRAVE, GP_KEY_LEFT_SHIFT, GP_KEY_BACKSLASH, GP_KEY_Z,
+ GP_KEY_GRAVE, 0, GP_KEY_BACKSLASH, GP_KEY_Z,
GP_KEY_X, GP_KEY_C, GP_KEY_V, GP_KEY_B,
GP_KEY_N, GP_KEY_M, GP_KEY_COMMA, GP_KEY_DOT,
- GP_KEY_SLASH, GP_KEY_RIGHT_SHIFT, GP_KEY_KP_ASTERISK, GP_KEY_LEFT_ALT,
- GP_KEY_SPACE, GP_KEY_CAPS_LOCK, GP_KEY_F1, GP_KEY_F2,
+ GP_KEY_SLASH, 0, 0, 0,
+ GP_KEY_SPACE, 0, GP_KEY_F1, GP_KEY_F2,
GP_KEY_F3, GP_KEY_F4, GP_KEY_F5, GP_KEY_F6,
GP_KEY_F7, GP_KEY_F8, GP_KEY_F9, GP_KEY_F10,
- GP_KEY_NUM_LOCK, GP_KEY_SCROLL_LOCK, GP_KEY_KP_7, GP_KEY_KP_8,
- GP_KEY_KP_9, GP_KEY_KP_MINUS, GP_KEY_KP_4, GP_KEY_KP_5,
- GP_KEY_KP_6, GP_KEY_KP_PLUS, GP_KEY_KP_1, GP_KEY_KP_2,
- GP_KEY_KP_3, GP_KEY_KP_0, GP_KEY_KP_DOT, 0,
+ GP_KEY_NUM_LOCK, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
0, 0, GP_KEY_F11, GP_KEY_F12,
0, 0, 0, 0,
- 0, 0, 0, GP_KEY_KP_ENTER,
- GP_KEY_RIGHT_CTRL, GP_KEY_KP_SLASH, GP_KEY_SYSRQ, GP_KEY_RIGHT_ALT,
- 0, GP_KEY_HOME, GP_KEY_UP, GP_KEY_PAGE_UP,
- GP_KEY_LEFT, GP_KEY_RIGHT, GP_KEY_END, GP_KEY_DOWN,
- GP_KEY_PAGE_DOWN, GP_KEY_INSERT, GP_KEY_DELETE, 0,
- GP_KEY_MUTE, GP_KEY_VOLUMEDOWN, GP_KEY_VOLUMEUP, 0,
- 0, 0, GP_KEY_PAUSE, 0,
0, 0, 0, 0,
- GP_KEY_LEFT_META, GP_KEY_RIGHT_META, GP_KEY_COMPOSE,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+};
+
+/* X11 KeySyms to load dynamically */
+struct keytable {
+ uint32_t x_keysym;
+ uint16_t key;
+};
+
+static const struct keytable sym_to_key[] = {
+ /* Cursor control */
+ {XK_Up, GP_KEY_UP},
+ {XK_Down, GP_KEY_DOWN},
+ {XK_Left, GP_KEY_LEFT},
+ {XK_Right, GP_KEY_RIGHT},
+ {XK_Home, GP_KEY_HOME},
+ {XK_Page_Up, GP_KEY_PAGE_UP},
+ {XK_Page_Down, GP_KEY_PAGE_DOWN},
+ {XK_End, GP_KEY_END},
+
+ /* TTY Keys */
+ {XK_BackSpace, GP_KEY_BACKSPACE},
+ {XK_Tab, GP_KEY_TAB},
+ {XK_Escape, GP_KEY_ESC},
+ {XK_Delete, GP_KEY_DELETE},
+ {XK_Insert, GP_KEY_INSERT},
+ {XK_Sys_Req, GP_KEY_SYSRQ},
+ {XK_Pause, GP_KEY_PAUSE},
+ {XK_Scroll_Lock, GP_KEY_SCROLL_LOCK},
+
+ /* Modifiers */
+ {XK_Shift_L, GP_KEY_LEFT_SHIFT},
+ {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_Caps_Lock, GP_KEY_CAPS_LOCK},
+ {XK_Super_L, GP_KEY_LEFT_META},
+ {XK_Super_R, GP_KEY_RIGHT_META},
+ {XK_Menu, GP_KEY_COMPOSE},
+
+ /* keypad */
+ {XK_KP_Enter, GP_KEY_KP_ENTER},
+ {XK_KP_0, GP_KEY_KP_0},
+ {XK_KP_1, GP_KEY_KP_1},
+ {XK_KP_2, GP_KEY_KP_2},
+ {XK_KP_3, GP_KEY_KP_3},
+ {XK_KP_4, GP_KEY_KP_4},
+ {XK_KP_5, GP_KEY_KP_5},
+ {XK_KP_6, GP_KEY_KP_6},
+ {XK_KP_7, GP_KEY_KP_7},
+ {XK_KP_8, GP_KEY_KP_8},
+ {XK_KP_9, GP_KEY_KP_9},
+ {XK_KP_Add, GP_KEY_KP_PLUS},
+ {XK_KP_Subtract, GP_KEY_KP_MINUS},
+ {XK_KP_Decimal, GP_KEY_KP_DOT},
+ {XK_KP_Divide, GP_KEY_KP_SLASH},
+ {XK_KP_Multiply, GP_KEY_KP_ASTERISK},
+
+ /* Multimedia */
+ {XF86XK_AudioLowerVolume, GP_KEY_VOLUMEDOWN},
+ {XF86XK_AudioRaiseVolume, GP_KEY_VOLUMEUP},
+ {XF86XK_AudioMute, GP_KEY_MUTE},
+ {XF86XK_AudioNext, GP_KEY_NEXTSONG},
+ {XF86XK_AudioPrev, GP_KEY_PREVIOUSSONG},
+ {XF86XK_AudioPlay, GP_KEY_PLAYPAUSE},
};
-static const uint16_t keycode_table_size = sizeof(keycode_table)/2;
+static void init_table(Display *dpy)
+{
+ GP_DEBUG(1, "Initializing X11 KeyCode table");
+
+ unsigned int i;
+
+ for (i = 0; i < GP_ARRAY_SIZE(sym_to_key); i++) {
+ unsigned int keycode;
+
+ keycode = XKeysymToKeycode(dpy, sym_to_key[i].x_keysym);
+
+ if (keycode == 0) {
+ GP_DEBUG(1, "KeySym '%s' (%u) not defined",
+ XKeysymToString(sym_to_key[i].x_keysym),
+ sym_to_key[i].x_keysym);
+ continue;
+ }
+
+ GP_DEBUG(3, "Mapping Key '%s' KeySym '%s' (%u) to KeyCode %u",
+ GP_EventKeyName(sym_to_key[i].key),
+ XKeysymToString(sym_to_key[i].x_keysym),
+ sym_to_key[i].x_keysym,
+ keycode);
+
+ if (keycode - 9 >= GP_ARRAY_SIZE(keycode_table)) {
+ GP_WARN("Key '%s' keycode %u out of table",
+ GP_EventKeyName(sym_to_key[i].key), keycode);
+ continue;
+ }
+
+ if (keycode_table[keycode - 9]) {
+ GP_WARN("Key '%s' keycode %u collides with key '%s'",
+ GP_EventKeyName(sym_to_key[i].key), keycode,
+ GP_EventKeyName(keycode_table[keycode - 9]));
+ continue;
+ }
+
+ keycode_table[keycode - 9] = sym_to_key[i].key;
+ }
+}
+
+static unsigned int get_key(unsigned int xkey)
+{
+ unsigned int key = 0;
+
+ if (xkey > 8 && xkey - 9 <= GP_ARRAY_SIZE(keycode_table))
+ key = keycode_table[xkey - 9];
+
+ if (key == 0)
+ GP_WARN("Unmapped X11 keycode 0x%02x %u", xkey, xkey);
+
+ return key;
+}
+
+void GP_InputDriverX11Init(Display *dpy)
+{
+ init_table(dpy);
+}
void GP_InputDriverX11EventPut(XEvent *ev, int w, int h)
{
- int key = 0, keycode, press = 0;
+ int key = 0, press = 0;
switch (ev->type) {
case ButtonPress:
@@ -95,7 +236,7 @@ void GP_InputDriverX11EventPut(XEvent *ev, int w, int h)
GP_EventPush(GP_EV_REL, GP_EV_REL_WHEEL, -1, NULL);
return;
}
-
+
if (key == 0) {
GP_WARN("Unmapped X11 button %02x",
ev->xbutton.button);
@@ -120,16 +261,11 @@ void GP_InputDriverX11EventPut(XEvent *ev, int w, int h)
case KeyPress:
press = 1;
case KeyRelease:
- keycode = ev->xkey.keycode;
-
- if (keycode > 8 && keycode - 9 <= keycode_table_size)
- key = keycode_table[keycode - 9];
+ key = get_key(ev->xkey.keycode);
- if (key == 0) {
- GP_WARN("Unmapped X11 keycode %02x", keycode);
+ if (key == 0)
return;
- }
-
+
GP_EventPushKey(key, press, NULL);
break;
/* events from WM */
http://repo.or.cz/w/gfxprim.git/commit/17c1de1de50338ab954d6b62e41ed55ff77c…
commit 17c1de1de50338ab954d6b62e41ed55ff77c7484
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Feb 9 19:29:19 2013 +0100
core: Add GP_ARRAY_SIZE() to GP_Common.c
diff --git a/include/core/GP_Common.h b/include/core/GP_Common.h
index 1352c76..8718054 100644
--- a/include/core/GP_Common.h
+++ b/include/core/GP_Common.h
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2012 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> *
* *
*****************************************************************************/
@@ -76,6 +76,8 @@
(_a > 0) ? 1 : ((_a < 0) ? -1 : 0); })
+#define GP_ARRAY_SIZE(array) (sizeof(array) / sizeof(*array))
+
#endif /* __cplusplus */
/*
diff --git a/libs/input/GP_InputDriverX11.c b/libs/input/GP_InputDriverX11.c
index 992cbfc..2b537fa 100644
--- a/libs/input/GP_InputDriverX11.c
+++ b/libs/input/GP_InputDriverX11.c
@@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
http://repo.or.cz/w/gfxprim.git/commit/ea2c59ddb80527d69107808dfe0d5a56a460…
commit ea2c59ddb80527d69107808dfe0d5a56a4609894
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Feb 2 14:12:34 2013 +0100
input: Create EventQeueue.
This commit mostly shuffles code from GP_Event
to GP_EventQueue in preparation for per window
input queue.
diff --git a/include/input/GP_Event.h b/include/input/GP_Event.h
index ef21afb..c985cad 100644
--- a/include/input/GP_Event.h
+++ b/include/input/GP_Event.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> *
* *
*****************************************************************************/
diff --git a/include/input/GP_EventQueue.h b/include/input/GP_EventQueue.h
new file mode 100644
index 0000000..df5067b
--- /dev/null
+++ b/include/input/GP_EventQueue.h
@@ -0,0 +1,103 @@
+/*****************************************************************************
+ * 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> *
+ * *
+ *****************************************************************************/
+
+/*
+
+ Event Queue.
+
+ This API is internally used by backends to store input events and is not
+ supposed to be used directly.
+
+ */
+
+#ifndef INPUT_GP_EVENT_QUEUE_H
+#define INPUT_GP_EVENT_QUEUE_H
+
+#include "input/GP_Event.h"
+
+typedef struct GP_EventQueue {
+ /* screen size */
+ unsigned int screen_w;
+ unsigned int screen_h;
+
+ /* event queue */
+ unsigned int queue_first;
+ unsigned int queue_last;
+ unsigned int queue_size;
+ struct GP_Event cur_state;
+ struct GP_Event events[GP_EVENT_QUEUE_SIZE];
+} GP_EventQueue;
+
+#define GP_EVENT_QUEUE_DECLARE(name, scr_w, scr_h) + struct GP_EventQueue name = { + .screen_w = scr_w, + .screen_h = scr_h, + + .queue_first = 0, + .queue_last = 0, + .queue_size = GP_EVENT_QUEUE_SIZE, + .cur_state = {.cursor_x = scr_w / 2, + .cursor_y = scr_h / 2} + }
+
+/*
+ * 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);
+
+void GP_EventQueueFree(struct GP_EventQueue *self);
+
+/*
+ * Sets screen (window) size.
+ */
+void GP_EventQueueSetScreenSize(struct GP_EventQueue *self,
+ unsigned int w, unsigned int h);
+
+/*
+ * Sets cursor postion.
+ */
+void GP_EventQueueSetCursorPosition(struct GP_EventQueue *self,
+ unsigned int x, unsigned int y);
+
+
+unsigned int GP_EventQueueEventsQueued(struct GP_EventQueue *self);
+
+unsigned int GP_EventQueueGetEvent(struct GP_EventQueue *self,
+ struct GP_Event *ev);
+
+void GP_EventQueuePutEvent(struct GP_EventQueue *self, struct GP_Event *ev);
+
+#endif /* INPUT_GP_EVENT_QUEUE_H */
diff --git a/libs/input/GP_Event.c b/libs/input/GP_Event.c
index 9066540..7a5364a 100644
--- a/libs/input/GP_Event.c
+++ b/libs/input/GP_Event.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> *
* *
*****************************************************************************/
@@ -27,17 +27,11 @@
#include <core/GP_Debug.h>
#include <core/GP_Common.h>
-#include "GP_Event.h"
-
-/* Screen size for clipping the cursor position */
-static uint32_t screen_w = 0, screen_h = 0;
+#include <input/GP_EventQueue.h>
-/* Event queue */
-static uint32_t queue_first = 0, queue_last = 0;
-static struct GP_Event event_queue[GP_EVENT_QUEUE_SIZE];
+#include "GP_Event.h"
-/* Global input state */
-static struct GP_Event cur_state = {.cursor_x = 0, .cursor_y = 0};
+static GP_EVENT_QUEUE_DECLARE(event_queue, 0, 0);
static char *key_names[] = {
"Reserved", "Escape", "1", "2", "3",
@@ -72,41 +66,22 @@ static uint16_t key_names_size = sizeof(key_names)/sizeof(void*);
void GP_EventSetScreenSize(uint32_t w, uint32_t h)
{
- screen_w = w;
- screen_h = h;
-
- /* clip cursor */
- if (cur_state.cursor_x >= w)
- cur_state.cursor_x = w - 1;
-
- if (cur_state.cursor_y >= h)
- cur_state.cursor_y = h - 1;
+ GP_EventQueueSetScreenSize(&event_queue, w, h);
}
void GP_EventSetScreenCursor(uint32_t x, uint32_t y)
{
- cur_state.cursor_x = x;
- cur_state.cursor_y = y;
+ GP_EventQueueSetCursorPosition(&event_queue, x, y);
}
unsigned int GP_EventsQueued(void)
{
- if (queue_first <= queue_last)
- return queue_last - queue_first;
-
- return GP_EVENT_QUEUE_SIZE - (queue_last - queue_first);
+ return GP_EventQueueEventsQueued(&event_queue);
}
int GP_EventGet(struct GP_Event *ev)
{
- if (queue_first == queue_last)
- return 0;
-
- *ev = event_queue[queue_first];
-
- queue_first = (queue_first + 1) % GP_EVENT_QUEUE_SIZE;
-
- return 1;
+ return GP_EventQueueGetEvent(&event_queue, ev);
}
const char *GP_EventKeyName(enum GP_EventKeyValue key)
@@ -199,23 +174,15 @@ void GP_EventDump(struct GP_Event *ev)
static void event_put(struct GP_Event *ev)
{
- uint32_t next = (queue_last + 1) % GP_EVENT_QUEUE_SIZE;
-
- if (next == queue_first) {
- GP_WARN("Event queue full, dropping event.");
- return;
- }
-
- event_queue[queue_last] = *ev;
- queue_last = next;
+ GP_EventQueuePutEvent(&event_queue, ev);
}
static void set_time(struct timeval *time)
{
if (time == NULL)
- gettimeofday(&cur_state.time, NULL);
+ gettimeofday(&event_queue.cur_state.time, NULL);
else
- cur_state.time = *time;
+ event_queue.cur_state.time = *time;
}
static uint32_t clip_rel(uint32_t val, uint32_t max, int32_t rel)
@@ -235,13 +202,13 @@ static uint32_t clip_rel(uint32_t val, uint32_t max, int32_t rel)
void GP_EventPushRelTo(uint32_t x, uint32_t y, struct timeval *time)
{
- if (x > screen_w || y > screen_h) {
+ 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 - cur_state.cursor_x;
- int32_t ry = y - cur_state.cursor_y;
+ 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);
}
@@ -249,20 +216,20 @@ void GP_EventPushRelTo(uint32_t x, uint32_t y, struct timeval *time)
void GP_EventPushRel(int32_t rx, int32_t ry, struct timeval *time)
{
/* event header */
- cur_state.type = GP_EV_REL;
- cur_state.code = GP_EV_REL_POS;
+ event_queue.cur_state.type = GP_EV_REL;
+ event_queue.cur_state.code = GP_EV_REL_POS;
- cur_state.val.rel.rx = rx;
- cur_state.val.rel.ry = ry;
+ event_queue.cur_state.val.rel.rx = rx;
+ event_queue.cur_state.val.rel.ry = ry;
set_time(time);
/* move the global cursor */
- cur_state.cursor_x = clip_rel(cur_state.cursor_x, screen_w, rx);
- cur_state.cursor_y = clip_rel(cur_state.cursor_y, screen_h, ry);
+ 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(&cur_state);
+ event_put(&event_queue.cur_state);
}
void GP_EventPushAbs(uint32_t x, uint32_t y, uint32_t pressure,
@@ -270,14 +237,14 @@ void GP_EventPushAbs(uint32_t x, uint32_t y, uint32_t pressure,
struct timeval *time)
{
/* event header */
- cur_state.type = GP_EV_ABS;
- cur_state.code = GP_EV_ABS_POS;
- cur_state.val.abs.x = x;
- cur_state.val.abs.y = y;
- cur_state.val.abs.pressure = pressure;
- cur_state.val.abs.x_max = x_max;
- cur_state.val.abs.y_max = y_max;
- cur_state.val.abs.pressure_max = pressure_max;
+ 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);
@@ -285,30 +252,29 @@ void GP_EventPushAbs(uint32_t x, uint32_t y, uint32_t pressure,
* 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)
- cur_state.cursor_x = x * (screen_w - 1) / x_max;
+ event_queue.cur_state.cursor_x = x * (event_queue.screen_w - 1) / x_max;
if (y_max != 0)
- cur_state.cursor_y = y * (screen_h - 1) / y_max;
+ event_queue.cur_state.cursor_y = y * (event_queue.screen_h - 1) / y_max;
/* put it into queue */
- event_put(&cur_state);
+ event_put(&event_queue.cur_state);
}
void GP_EventPushResize(uint32_t w, uint32_t h, struct timeval *time)
{
/* event header */
- cur_state.type = GP_EV_SYS;
- cur_state.code = GP_EV_SYS_RESIZE;
+ event_queue.cur_state.type = GP_EV_SYS;
+ event_queue.cur_state.code = GP_EV_SYS_RESIZE;
- cur_state.val.sys.w = w;
- cur_state.val.sys.h = h;
+ 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(&cur_state);
+ event_put(&event_queue.cur_state);
}
static char keys_to_ascii[] = {
@@ -356,10 +322,10 @@ void GP_EventPushKey(uint32_t key, uint8_t code, struct timeval *time)
{
switch (code) {
case GP_EV_KEY_UP:
- GP_EventResetKey(&cur_state, key);
+ GP_EventResetKey(&event_queue.cur_state, key);
break;
case GP_EV_KEY_DOWN:
- GP_EventSetKey(&cur_state, key);
+ GP_EventSetKey(&event_queue.cur_state, key);
break;
case GP_EV_KEY_REPEAT:
break;
@@ -369,15 +335,15 @@ void GP_EventPushKey(uint32_t key, uint8_t code, struct timeval *time)
}
/* event header */
- cur_state.type = GP_EV_KEY;
- cur_state.code = code;
- cur_state.val.key.key = key;
- key_to_ascii(&cur_state);
+ 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(&cur_state);
+ event_put(&event_queue.cur_state);
}
void GP_EventPush(uint16_t type, uint32_t code, int32_t value,
@@ -388,12 +354,12 @@ void GP_EventPush(uint16_t type, uint32_t code, int32_t value,
GP_EventPushKey(code, value, time);
break;
default:
- cur_state.type = type;
- cur_state.code = code;
- cur_state.val.val = value;
+ event_queue.cur_state.type = type;
+ event_queue.cur_state.code = code;
+ event_queue.cur_state.val.val = value;
set_time(time);
- event_put(&cur_state);
+ event_put(&event_queue.cur_state);
}
}
diff --git a/libs/input/GP_EventQueue.c b/libs/input/GP_EventQueue.c
new file mode 100644
index 0000000..7c962f1
--- /dev/null
+++ b/libs/input/GP_EventQueue.c
@@ -0,0 +1,130 @@
+/*****************************************************************************
+ * 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 "core/GP_Debug.h"
+
+#include "input/GP_EventQueue.h"
+
+void GP_EventQueueInit(struct GP_EventQueue *self,
+ unsigned int screen_w, unsigned int screen_h,
+ unsigned int queue_size)
+{
+ self->screen_w = screen_w;
+ self->screen_h = screen_h;
+
+ self->cur_state.cursor_x = screen_w / 2;
+ self->cur_state.cursor_y = screen_h / 2;
+
+ self->queue_first = 0;
+ self->queue_last = 0;
+ self->queue_size = queue_size;
+}
+
+struct GP_EventQueue *GP_EventQueueAlloc(unsigned int screen_w,
+ unsigned int screen_h,
+ unsigned int queue_size)
+{
+ size_t size;
+ struct GP_EventQueue *new;
+
+ size = sizeof(struct GP_EventQueue) +
+ (queue_size - GP_EVENT_QUEUE_SIZE) * sizeof(struct GP_Event);
+
+ new = malloc(size);
+
+ if (new == NULL) {
+ GP_WARN("Malloc failed :(");
+ return NULL;
+ }
+
+ GP_EventQueueInit(new, screen_w, screen_h, queue_size);
+
+ return new;
+}
+
+void GP_EventQueueFree(struct GP_EventQueue *self)
+{
+ free(self);
+}
+
+void GP_EventQueueSetScreenSize(struct GP_EventQueue *self,
+ unsigned int w, unsigned int h)
+{
+ GP_DEBUG(1, "Resizing input queue screen to %ux%u", w, h);
+
+ self->screen_w = w;
+ self->screen_h = h;
+
+ /* clip cursor */
+ if (self->cur_state.cursor_x >= w)
+ self->cur_state.cursor_x = w - 1;
+
+ if (self->cur_state.cursor_y >= h)
+ self->cur_state.cursor_y = h - 1;
+}
+
+void GP_EventQueueSetCursorPosition(struct GP_EventQueue *self,
+ unsigned int x, unsigned int y)
+{
+ if (x >= self->screen_w || y >= self->screen_h) {
+ GP_WARN("Attempt to set cursor %u,%u out of the screen %ux%u",
+ x, y, self->screen_w, self->screen_h);
+ return;
+ }
+
+ self->cur_state.cursor_x = x;
+ self->cur_state.cursor_y = y;
+}
+
+unsigned int GP_EventQueueEventsQueued(struct GP_EventQueue *self)
+{
+ if (self->queue_first <= self->queue_last)
+ return self->queue_last - self->queue_first;
+
+ return self->queue_size - (self->queue_last - self->queue_first);
+}
+
+unsigned int GP_EventQueueGetEvent(struct GP_EventQueue *self,
+ struct GP_Event *ev)
+{
+ if (self->queue_first == self->queue_last)
+ return 0;
+
+ *ev = self->events[self->queue_first];
+
+ self->queue_first = (self->queue_first + 1) % self->queue_size;
+
+ return 1;
+}
+
+void GP_EventQueuePutEvent(struct GP_EventQueue *self, struct GP_Event *ev)
+{
+ unsigned int next = (self->queue_last + 1) % self->queue_size;
+
+ if (next == self->queue_first) {
+ GP_WARN("Event queue full, dropping event.");
+ return;
+ }
+
+ self->events[self->queue_last] = *ev;
+ self->queue_last = next;
+}
diff --git a/libs/input/GP_InputDriverX11.c b/libs/input/GP_InputDriverX11.c
index 2b537fa..992cbfc 100644
--- a/libs/input/GP_InputDriverX11.c
+++ b/libs/input/GP_InputDriverX11.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> *
* *
*****************************************************************************/
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_Common.h | 4 +-
include/input/GP_Event.h | 2 +-
include/input/GP_EventQueue.h | 103 +++++++++++++++++++
include/input/GP_InputDriverX11.h | 7 +-
libs/backends/GP_X11.c | 3 +
libs/input/GP_Event.c | 136 ++++++++++---------------
libs/input/GP_EventQueue.c | 130 ++++++++++++++++++++++++
libs/input/GP_InputDriverX11.c | 196 +++++++++++++++++++++++++++++++------
8 files changed, 466 insertions(+), 115 deletions(-)
create mode 100644 include/input/GP_EventQueue.h
create mode 100644 libs/input/GP_EventQueue.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