This thread contains a patchset. You're looking at the original emails,
but you may wish to use the patch review UI.
Review patch
5
2
[PATCH clickclack v2 0/4] Make vibrator event device node customizable
Changes since v1:
- drop 'CC ?= $(CROSS_COMPILE)gcc' from Makefile as it's pointless with
CC=cc (typically symlink to gcc) being a working default, and with the
ability to define a custom CC with the same patch anyway
This was hardcoded for PinePhone with its /vibrator node in device-tree
while on other devices the device vibrator event node could be anything
else really.
While at it fix a few other issues I noticed like add cross-compilation
support, exit when "-h" arg is used and fix a compile warning under
CC=clang.
Jami Kettunen (4):
Support cross-compilation
Make usage() take program executable name as arg and print it
Exit when -h usage() arg is issued
Make vibrator event device node customizable
Makefile | 2 +-
README.md | 2 ++
clickclack.c | 18 ++++++++++++++----
3 files changed, 17 insertions(+), 5 deletions(-)
--
2.36.1
[PATCH clickclack v2 2/4] Make usage() take program executable name as arg and print it
With CC=clang the following compile warning was generated:
clickclack.c:85:17: warning: too many arguments in call to 'usage'
usage(argv[0]);
~~~~~ ^
---
clickclack.c | 4 ++ --
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clickclack.c b/clickclack.c
index 7672f89..37acecb 100644
--- a/clickclack.c
+++ b/clickclack.c
@@ -35,8 +35,8 @@ extern int errno;
void playsound();
void vibrate();
- void usage() {
- fprintf(stderr, "Usage: clickclack [options]\n");
+ void usage(char* program) {
+ fprintf(stderr, "Usage: %s [options]\n", program);
fprintf(stderr, "Options:\n");
fprintf(stderr, " -V enable vibration\n");
fprintf(stderr, " -s [int] vibration strength\n");
--
2.36.1
[PATCH clickclack v2 1/4] Support cross-compilation
---
Makefile | 2 + -
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index b593b7f..ff07cbf 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ CFLAGS ?= -O2
all: $(PROGRAMS)
clickclack: clickclack.c
- gcc $(CFLAGS) -o clickclack clickclack.c -l SDL2
+ $(CC) $(CFLAGS) -o clickclack clickclack.c -l SDL2
clean:
rm -f clickclack
--
2.36.1
[PATCH clickclack v2 3/4] Exit when -h usage() arg is issued
When this is issued you're looking for the list of arguments and
wouldn't expect to continue execution further.
---
clickclack.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/clickclack.c b/clickclack.c
index 37acecb..63cfba0 100644
--- a/clickclack.c
+++ b/clickclack.c
@@ -74,6 +74,7 @@ int main(int argc, char* argv[])
echo = 1;
} else if (!strcmp(argv[i], "-h")) {
usage(argv[0]);
+ exit(0);
} else if (!strcmp(argv[i], "-D")) {
debug = 1;
} else if (!strcmp(argv[i], "-a")) {
--
2.36.1
[PATCH clickclack v2 4/4] Make vibrator event device node customizable
---
README.md | 2 ++
clickclack.c | 13 +++++++++++ --
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index c333dc4..a6b5815 100644
--- a/README.md
+++ b/README.md
@@ -29,6 +29,8 @@ Clickclack Options:
* ``-D`` - Debug mode
* ``-e`` - Echo input to output (allows further chaining of tools)
* ``-o`` - Vibrate/play sound only on the first character of the line. To be used in combination with the wvkbd -O option.
+ * ``-E`` - Vibrator device event file to use, defaults to `/dev/input/by-path/platform-vibrator-event` or value of
+ `SXMO_VIBRATE_DEV` environment variable if it's defined.
Virtual keyboards [svkbd](https://tools.suckless.org/x/svkbd/) and [wvkbd](https://github.com/jjsullivan5196/wvkbd) have an extra output mode where all keypresses are printed to standard output. This allows us
to use clickclack with it as follows:
diff --git a/clickclack.c b/clickclack.c
index 63cfba0..9e64f6c 100644
--- a/clickclack.c
+++ b/clickclack.c
@@ -15,6 +15,7 @@
#include <SDL2/SDL_audio.h>
+ char *vibra_event_dev = "/dev/input/by-path/platform-vibrator-event";
static int vibration = 0;
static int strength = 4000;
static int duration = 95; //in milliseconds
@@ -39,6 +40,7 @@ void usage(char* program) {
fprintf(stderr, "Usage: %s [options]\n", program);
fprintf(stderr, "Options:\n");
fprintf(stderr, " -V enable vibration\n");
+ fprintf(stderr, " -E [file] path to vibrator device event file\n");
fprintf(stderr, " -s [int] vibration strength\n");
fprintf(stderr, " -d [int] vibration duration in ms\n");
fprintf(stderr, " -f [file] audio file to play\n");
@@ -55,11 +57,18 @@ uint8_t *wavbuffer;
int main(int argc, char* argv[])
{
+ /* set vibrator device event file from env */
+ char *tmp;
+ if ((tmp = getenv("SXMO_VIBRATE_DEV")))
+ vibra_event_dev = strdup(tmp);
+
/* parse command line arguments */
int fd, i, ret;
for (i = 1; argv[i]; i++) {
if (!strcmp(argv[i], "-f")) {
audiofile = strdup(argv[++i]);
+ } else if (!strcmp(argv[i], "-E")) {
+ vibra_event_dev = strdup(argv[++i]);
} else if (!strcmp(argv[i], "-V")) {
vibration = 1;
} else if (!strcmp(argv[i], "-s")) {
@@ -184,9 +193,9 @@ void vibrate() {
struct pollfd pfds[1];
int effects;
- fd = open("/dev/input/by-path/platform-vibrator-event", O_RDWR | O_CLOEXEC);
+ fd = open(vibra_event_dev, O_RDWR | O_CLOEXEC);
if (fd < 0) {
- fprintf(stderr, "Error reading opening event device /dev/input/by-path/platform-vibrator-event\n");
+ fprintf(stderr, "Error reading opening event device %s\n", vibra_event_dev);
return;
}
--
2.36.1
Thanks! I have applied all four patches now. I'll also prepare a new
release because we probably want the customisable device node released
asap for other devices.
--
Maarten van Gompel (proycon)
https://proycon.anaproy.nl