summaryrefslogtreecommitdiff
path: root/ff.c
diff options
context:
space:
mode:
authorClay Smith <claysmith158@gmail.com>2023-02-21 03:59:41 -0600
committerClay Smith <claysmith158@gmail.com>2023-02-21 03:59:41 -0600
commit99c9a32520fa75eb09ad40672e5341f683a64281 (patch)
treea5846079d3e20b91b36c12169ce0b78c77a5bb06 /ff.c
parent6cc35c96996ca3f1432b92daf9b9d544c7631df8 (diff)
ALL BUT FF
Diffstat (limited to 'ff.c')
-rw-r--r--ff.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/ff.c b/ff.c
new file mode 100644
index 0000000..bcffc5d
--- /dev/null
+++ b/ff.c
@@ -0,0 +1,41 @@
+#define _GNU_SOURCE /* for asprintf */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <linux/input.h>
+
+#define BITS_PER_LONG (sizeof(long) * 8)
+#define BITS_TO_LONGS(x) \
+ (((x) + 8 * sizeof (unsigned long) - 1) / (8 * sizeof (unsigned long)))
+
+
+int main(int argc, char** argv)
+{
+
+ int fd = open("/dev/input/event14", O_RDWR);
+
+
+ char name[4096];
+ int return_value = ioctl(fd, EVIOCGNAME(sizeof(name)), name);
+ printf("%s\n", name);
+ printf("%d\n", return_value);
+
+
+ unsigned long features[BITS_TO_LONGS(FF_CNT)];
+ return_value = ioctl(fd, EVIOCGBIT(EV_FF, sizeof(features)), features);
+ printf("return of ioctl is: %d\n", return_value);
+ printf("features[] holds: ");
+ for (int i = 0; i < BITS_TO_LONGS(FF_CNT); ++i) {
+ printf("%d ", features[i]);
+ }
+ puts("");
+
+ int num;
+ return_value = ioctl(fd, EVIOCGEFFECTS, &num);
+
+ printf("return_value: %d, num: %d\n", return_value, num);
+
+ return 0;
+}