aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--marsond.820
-rw-r--r--marsond.c20
-rw-r--r--marsond.rst14
3 files changed, 41 insertions, 13 deletions
diff --git a/marsond.8 b/marsond.8
index 02b4da5..943571d 100644
--- a/marsond.8
+++ b/marsond.8
@@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
-.TH "MARSOND" 8 "2025-05-11" "0.3.0" "Urchlay's Stuff"
+.TH "MARSOND" 8 "2025-05-12" "0.3.0" "Urchlay's Stuff"
.SH NAME
marsond \- Fix Enter key timing on Marson/USBLink/MT606-1 PS/2-USB adaptors
.SH SYNOPSIS
@@ -59,7 +59,7 @@ Options can be "bundled": \fB\-vf\fP is the same as \fB\-v\fP \fB\-f\fP\&.
.TP
.BI \-d \ delay\-ms
Amount of time in milliseconds to delay the Enter key release events.
-Default: 30.
+Minimum 1, default 30 (unless changed at compile time; see \fB\-\-help\fP).
.UNINDENT
.\" delay time for Enter key release.
.
@@ -75,7 +75,18 @@ daemon. In this mode, \fBmarsond\fP can be killed with \fI^C\fP\&.
.TP
.BI \-k \ keyboard\-device
Input device for the keyboard adaptor. Default:
+.INDENT 7.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
/dev/input/by\-id/usb\-Marson_Marson_Keyboard_and_Mouse_Link_Ver:ps2120L\-event\-kbd
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.sp
+\&...unless changed at compile time; see \fB\-\-help\fP\&.
.UNINDENT
.\" keyboard device (usually under /dev/input/by-id/).
.
@@ -85,7 +96,7 @@ Input device for the keyboard adaptor. Default:
Amount of time in milliseconds to pause at startup, before opening the
keyboard and uinput devices. May be useful on slow systems, if
\fBmarsond\fP won\(aqt consistently start from udev, but works fine
-if started manually. Default: 0.
+if started manually. Minimum 0, default 0.
.UNINDENT
.\" pause before opening keyboard/uinput devs (default 0).
.
@@ -102,7 +113,8 @@ background as a daemon. If you want to debug the event loop, combine
.INDENT 0.0
.TP
.B \-h\fP,\fB \-\-help
-Shows built\-in usage message and exits.
+Shows built\-in usage message and exits. This includes the
+compiled\-in defaults for the \fB\-d\fP and \fB\-k\fP options.
.UNINDENT
.\" this help text.
.
diff --git a/marsond.c b/marsond.c
index 309d62c..8070d78 100644
--- a/marsond.c
+++ b/marsond.c
@@ -93,6 +93,17 @@ void version(void) {
puts(VERSION);
}
+int parse_num(const char *num, char opt, int min) {
+ char *end;
+ int result;
+
+ result = (int)strtol(num, &end, 10);
+ if(*end || (result < min)) {
+ die("%c option expects an integer >= %d, not '%s'", opt, min, num);
+ }
+ return result;
+}
+
void parse_args(int argc, char **argv) {
int opt;
@@ -110,11 +121,11 @@ void parse_args(int argc, char **argv) {
while( (opt = getopt(argc, argv, ":d:hfk:p:vV")) != -1) {
switch(opt) {
- case 'd': delay_ms = atoi(optarg); break;
+ case 'd': delay_ms = parse_num(optarg, 'd', 1); break;
case 'f': foreground++; break;
case 'h': print_help(); exit(0); break;
case 'k': keyboard_dev = optarg; break;
- case 'p': pause_ms = atoi(optarg); break;
+ case 'p': pause_ms = parse_num(optarg, 'p', 0); break;
case 'v': debugging++; break;
case 'V': version(); exit(0); break;
case ':': die("option -%c requires an argument (try --help)", optopt); break;
@@ -122,8 +133,9 @@ void parse_args(int argc, char **argv) {
}
}
- if(delay_ms < 1) die("invalid -d argument");
- if(pause_ms < 0) die("invalid -p argument");
+ if(optind < argc) {
+ die("unknown argument: %s", argv[optind]);
+ }
}
/* cleanup() gets called by die() and sighandler() */
diff --git a/marsond.rst b/marsond.rst
index 2e705f6..c21554f 100644
--- a/marsond.rst
+++ b/marsond.rst
@@ -45,7 +45,7 @@ Options can be "bundled": **-vf** is the same as **-v** **-f**.
-d delay-ms
Amount of time in milliseconds to delay the Enter key release events.
- Default: 30.
+ Minimum 1, default 30 (unless changed at compile time; see **--help**).
.. delay time for Enter key release.
@@ -56,8 +56,11 @@ Options can be "bundled": **-vf** is the same as **-v** **-f**.
.. run in foreground, not as a daemon.
-k keyboard-device
- Input device for the keyboard adaptor. Default:
- /dev/input/by-id/usb-Marson_Marson_Keyboard_and_Mouse_Link_Ver:ps2120L-event-kbd
+ Input device for the keyboard adaptor. Default::
+
+ /dev/input/by-id/usb-Marson_Marson_Keyboard_and_Mouse_Link_Ver:ps2120L-event-kbd
+
+ \.\.\.unless changed at compile time; see **--help**.
.. keyboard device (usually under /dev/input/by-id/).
@@ -65,7 +68,7 @@ Options can be "bundled": **-vf** is the same as **-v** **-f**.
Amount of time in milliseconds to pause at startup, before opening the
keyboard and uinput devices. May be useful on slow systems, if
**marsond** won't consistently start from udev, but works fine
- if started manually. Default: 0.
+ if started manually. Minimum 0, default 0.
.. pause before opening keyboard/uinput devs (default 0).
@@ -78,7 +81,8 @@ Options can be "bundled": **-vf** is the same as **-v** **-f**.
.. verbose debugging.
-h, --help
- Shows built-in usage message and exits.
+ Shows built-in usage message and exits. This includes the
+ compiled-in defaults for the **-d** and **-k** options.
.. this help text.