aboutsummaryrefslogtreecommitdiffstats
path: root/libgamepad_close_device.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 /libgamepad_close_device.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 'libgamepad_close_device.c')
-rw-r--r--libgamepad_close_device.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/libgamepad_close_device.c b/libgamepad_close_device.c
new file mode 100644
index 0000000..edb8361
--- /dev/null
+++ b/libgamepad_close_device.c
@@ -0,0 +1,22 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+
+void
+libgamepad_close_device(struct libgamepad_device *device)
+{
+ if (device) {
+ if (device->close_fd)
+ close(device->fd);
+ if (device->dev)
+ libevdev_free(device->dev);
+ free(device->buttons);
+ free(device->absolute_axes);
+ free(device->relative_axes);
+ device->close_fd = 0;
+ device->dev = NULL;
+ device->buttons = NULL;
+ device->absolute_axes = NULL;
+ device->relative_axes = NULL;
+ }
+}