aboutsummaryrefslogtreecommitdiffstats
path: root/test-list.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-07-23 14:39:44 +0200
committerMattias Andrée <maandree@kth.se>2022-07-23 14:40:11 +0200
commitd49393b339c47733c2eda207b8ba03d61db0a5a3 (patch)
treebc609622c3cabe1dc6b59970cb8a9a8364a561a7 /test-list.c
downloadlibgamepad-d49393b339c47733c2eda207b8ba03d61db0a5a3.tar.gz
libgamepad-d49393b339c47733c2eda207b8ba03d61db0a5a3.tar.bz2
libgamepad-d49393b339c47733c2eda207b8ba03d61db0a5a3.tar.xz
First commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'test-list.c')
-rw-r--r--test-list.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/test-list.c b/test-list.c
new file mode 100644
index 0000000..f604dd9
--- /dev/null
+++ b/test-list.c
@@ -0,0 +1,42 @@
+/* See LICENSE file for copyright and license details. */
+#include "libgamepad.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int
+main(void)
+{
+ char **devices;
+ size_t ndevices, i, j;
+ struct libgamepad_superdevice device;
+
+ if (libgamepad_list_superdevices(&devices, &ndevices)) {
+ perror("libgamepad_list_superdevices");
+ return 1;
+ }
+
+ for (i = 0; i < ndevices; i++) {
+ if (libgamepad_open_superdevice(&device, devices[i])) {
+ perror("libgamepad_open_superdevice");
+ free(devices[i]);
+ continue;
+ }
+ free(devices[i]);
+
+ printf("%s\n", device.syspath);
+ for (j = 0; j < device.ndevices; j++)
+ printf("\t%s (%x)\n", device.devices[j]->path, device.devices[j]->type);
+ for (j = 0; j < device.nleds; j++)
+ printf("\t%s (LED)\n", device.leds[j]);
+ for (j = 0; j < device.npower_supplies; j++)
+ printf("\t%s (PSU)\n", device.power_supplies[j]);
+
+ libgamepad_close_superdevice(&device);
+ }
+
+ free(devices);
+
+ return 0;
+}