summaryrefslogtreecommitdiff
path: root/pugl_test.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-02-14 21:32:37 -0500
committerDavid Robillard <d@drobilla.net>2015-02-14 21:40:49 -0500
commit70f365258d73ac8cc37025777e13fdf9e016922c (patch)
tree07b08b9bb6fd740c604943634f445a45bdbb653d /pugl_test.c
parent10606d469c6d3ccc245d293b8637a5be3e95bdb1 (diff)
UTF-8 keyboard input support on X11.
Diffstat (limited to 'pugl_test.c')
-rw-r--r--pugl_test.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/pugl_test.c b/pugl_test.c
index 9b942f4..248a49a 100644
--- a/pugl_test.c
+++ b/pugl_test.c
@@ -99,12 +99,16 @@ printModifiers(PuglView* view)
}
static void
-onKeyboard(PuglView* view, bool press, uint32_t key)
+onEvent(PuglView* view, const PuglEvent* event)
{
- fprintf(stderr, "Key %c %s ", (char)key, press ? "down" : "up");
- printModifiers(view);
- if (key == 'q' || key == 'Q' || key == PUGL_CHAR_ESCAPE ||
- key == PUGL_CHAR_DELETE || key == PUGL_CHAR_BACKSPACE) {
+ const uint32_t ucode = event->key.character;
+ if (event->type == PUGL_KEY_PRESS) {
+ fprintf(stderr, "Key %u (char %u) down (%s)%s\n",
+ event->key.keycode, event->key.character, event->key.utf8,
+ event->key.filter ? " (filtered)" : "");
+ }
+ if (ucode == 'q' || ucode == 'Q' || ucode == PUGL_CHAR_ESCAPE ||
+ ucode == PUGL_CHAR_DELETE || ucode == PUGL_CHAR_BACKSPACE) {
quit = 1;
}
}
@@ -172,9 +176,9 @@ main(int argc, char** argv)
puglInitWindowSize(view, 512, 512);
puglInitWindowMinSize(view, 256, 256);
puglInitResizable(view, resizable);
-
+
puglIgnoreKeyRepeat(view, ignoreKeyRepeat);
- puglSetKeyboardFunc(view, onKeyboard);
+ puglSetEventFunc(view, onEvent);
puglSetMotionFunc(view, onMotion);
puglSetMouseFunc(view, onMouse);
puglSetScrollFunc(view, onScroll);