aboutsummaryrefslogtreecommitdiffstats
path: root/test-input.c
diff options
context:
space:
mode:
Diffstat (limited to 'test-input.c')
-rw-r--r--test-input.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/test-input.c b/test-input.c
index d74e684..9e2dc37 100644
--- a/test-input.c
+++ b/test-input.c
@@ -3,6 +3,7 @@
#include <assert.h>
#include <signal.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -31,7 +32,7 @@ int
main(int argc, char *argv[])
{
struct libgamepad_input_event event;
- int r;
+ ssize_t r;
if (argc != 2) {
fprintf(stderr, "Please provide the path to the subdevice as the only command line argument\n");
@@ -54,7 +55,7 @@ main(int argc, char *argv[])
}
for (;;) {
- r = libgamepad_next_event(&gamepad, &event);
+ r = libgamepad_next_event(&gamepad, &event, 1);
if (r <= 0) {
if (!r || errno == EINTR)
continue;
@@ -62,16 +63,17 @@ main(int argc, char *argv[])
return 1;
}
printf("[%lli.%06li] ", (long long int)event.time.tv_sec, event.time.tv_usec);
- if (event.sync_event)
- printf("[sync] ");
- if (event.type == LIBGAMEPAD_BUTTON) {
- printf("%s ", libgamepad_get_button_name(NULL, event.code));
- } else if (event.type == LIBGAMEPAD_ABSOLUTE_AXIS) {
- printf("%s ", libgamepad_get_absolute_axis_name(NULL, event.code));
- } else {
- assert(event.type == LIBGAMEPAD_RELATIVE_AXIS);
- printf("%s ", libgamepad_get_relative_axis_name(NULL, event.code));
- }
- printf("%lli\n", (long long int)event.value);
+ if (event.type == LIBGAMEPAD_BUTTON)
+ printf("%s %ji\n", libgamepad_get_button_name(NULL, event.code), (intmax_t)event.value);
+ else if (event.type == LIBGAMEPAD_ABSOLUTE_AXIS)
+ printf("%s %ji\n", libgamepad_get_absolute_axis_name(NULL, event.code), (intmax_t)event.value);
+ else if (event.type == LIBGAMEPAD_RELATIVE_AXIS)
+ printf("%s %ji\n", libgamepad_get_relative_axis_name(NULL, event.code), (intmax_t)event.value);
+ else if (event.type == LIBGAMEPAD_EVENT_DROP)
+ printf("event drop\n");
+ else if (event.type == LIBGAMEPAD_EVENT_END)
+ printf("event conclusion\n");
+ else
+ printf("unknown event\n");
}
}