aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-07-20 11:19:02 +0200
committerDavid Robillard <d@drobilla.net>2019-07-24 01:02:52 +0200
commit3526bf913402b4061fd19b2f77b9f1dd1a60b2a5 (patch)
tree84dba6491f1832c9a29e0bae43daa926f43244cd /test
parent1deb98f57f7b597be941fd944a91f2daa1a1f10a (diff)
downloadpugl-3526bf913402b4061fd19b2f77b9f1dd1a60b2a5.tar.gz
pugl-3526bf913402b4061fd19b2f77b9f1dd1a60b2a5.tar.bz2
pugl-3526bf913402b4061fd19b2f77b9f1dd1a60b2a5.zip
Unify key and character fields and separate text events
Only one field is necessary to store any kind of key, including special keys, since PuglKey occupies a reserved Unicode region. This is generally much simpler to deal with since there is only one value to dispatch on. Text events are separated from key events (like Windows but unlike MacOS or X11) because it is not possible to derive text events from key press events when they occur on Windows. Since merging the two has been the source of some confusion, this approach has some advantages anyway, even though it introduces the need to handle another event type. In the process, text input has been almost completely rewritten. I have tested this with a compose key on X11 and dead keys on Windows and MacOS and everything seems to work correctly, though there may (as always) still be issues with more exotic input methods.
Diffstat (limited to 'test')
-rw-r--r--test/pugl_cairo_test.c4
-rw-r--r--test/pugl_test.c4
-rw-r--r--test/test_utils.h17
3 files changed, 10 insertions, 15 deletions
diff --git a/test/pugl_cairo_test.c b/test/pugl_cairo_test.c
index 524e8b0..47907db 100644
--- a/test/pugl_cairo_test.c
+++ b/test/pugl_cairo_test.c
@@ -129,9 +129,7 @@ onEvent(PuglView* view, const PuglEvent* event)
{
switch (event->type) {
case PUGL_KEY_PRESS:
- if (event->key.character == 'q' ||
- event->key.character == 'Q' ||
- event->key.character == PUGL_CHAR_ESCAPE) {
+ if (event->key.key == 'q' || event->key.key == PUGL_KEY_ESCAPE) {
quit = 1;
}
break;
diff --git a/test/pugl_test.c b/test/pugl_test.c
index fdf78c1..a609027 100644
--- a/test/pugl_test.c
+++ b/test/pugl_test.c
@@ -103,9 +103,7 @@ onEvent(PuglView* view, const PuglEvent* event)
quit = 1;
break;
case PUGL_KEY_PRESS:
- if (event->key.character == 'q' ||
- event->key.character == 'Q' ||
- event->key.character == PUGL_CHAR_ESCAPE) {
+ if (event->key.key == 'q' || event->key.key == PUGL_KEY_ESCAPE) {
quit = 1;
}
break;
diff --git a/test/test_utils.h b/test/test_utils.h
index 285cc83..fb04f4b 100644
--- a/test/test_utils.h
+++ b/test/test_utils.h
@@ -101,16 +101,15 @@ printEvent(const PuglEvent* event, const char* prefix)
{
switch (event->type) {
case PUGL_KEY_PRESS:
- return fprintf(stderr, "%sKey %u (char U+%04X special U+%04X) press (%s)%s\n",
- prefix,
- event->key.keycode, event->key.character, event->key.special,
- event->key.string, event->key.filter ? " (filtered)" : "");
-
+ return fprintf(stderr, "%sKey press code %3u key U+%04X\n",
+ prefix, event->key.keycode, event->key.key);
case PUGL_KEY_RELEASE:
- return fprintf(stderr, "%sKey %u (char U+%04X special U+%04X) release (%s)%s\n",
- prefix,
- event->key.keycode, event->key.character, event->key.special,
- event->key.string, event->key.filter ? " (filtered)" : "");
+ return fprintf(stderr, "%sKey release code %3u key U+%04X\n",
+ prefix, event->key.keycode, event->key.key);
+ case PUGL_TEXT:
+ return fprintf(stderr, "%sText entry code %3u char U+%04X (%s)\n",
+ prefix, event->text.keycode,
+ event->text.character, event->text.string);
case PUGL_BUTTON_PRESS:
case PUGL_BUTTON_RELEASE:
return (fprintf(stderr, "%sMouse %d %s at %f,%f ",