aboutsummaryrefslogtreecommitdiffstats
path: root/pugl_test.c
diff options
context:
space:
mode:
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);