summaryrefslogtreecommitdiff
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
parent6cc35c96996ca3f1432b92daf9b9d544c7631df8 (diff)
ALL BUT FF
-rw-r--r--.DS_Storebin6148 -> 6148 bytes
-rw-r--r--README.md16
-rw-r--r--ff.c41
-rw-r--r--main.c5
4 files changed, 62 insertions, 0 deletions
diff --git a/.DS_Store b/.DS_Store
index 15d9152..9658f48 100644
--- a/.DS_Store
+++ b/.DS_Store
Binary files differ
diff --git a/README.md b/README.md
index e69de29..2d6251a 100644
--- a/README.md
+++ b/README.md
@@ -0,0 +1,16 @@
+#Devout
+
+A Linux specific program to aid students learning how to code by giving them variadic input that fluctuates and is imperfect.
+
+##USAGE
+```
+./devout
+./devout 12
+./devout 2 5 25
+```
+
+The first line will print the available devices and events the user can have printed to the terminal.
+The second line prints /dev/input/event12 to standard out.
+THe third line prints /dev/input/event2, /dev/input/event5, and /dev/input/event25 to standard out.
+
+The output is always 5 colomns where the first column is an integer representing the event number passed in by the user. The second is the time since the beginning of the program. The third Number is the type associated with the event. The fourth number is the code associated with the event. In the fifth and final column is the current value.
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;
+}
diff --git a/main.c b/main.c
index b90cc5b..65221d7 100644
--- a/main.c
+++ b/main.c
@@ -10,6 +10,11 @@ int main(int argc, char** argv)
setvbuf(stdout, NULL, _IONBF, BUFSIZ);
if (argc < 2) {
show_device_options();
+ printf("\n\nAbove is a list of all the devices currently connected to your computer.\n"
+ "Find the event(s) above you want to use and determine the event number associated with it/them.\n"
+ "Then use the same command with every event number you want to use seperated by a space.\n"
+ "EXAMPLE: ./devout 17 14\n"
+ "The above example will print output for events /dev/input/event17 and /dev/input/event14\n\n\n");
} else if (argc == 2) {
//open and print a single event
unsigned long long event_num;