keymap tool: improve help
Do not duplicate help strings, and add missing calling variant for interactivity.
This commit is contained in:
parent
acdf6ae7ac
commit
b02c9fa19b
|
@ -272,6 +272,19 @@ static void interactive(int fd)
|
||||||
ioctl(fd, EVIOCGRAB, 0);
|
ioctl(fd, EVIOCGRAB, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void help(int error)
|
||||||
|
{
|
||||||
|
const char* h = "Usage: keymap <event device> [<map file>]\n"
|
||||||
|
" keymap -i <event device>\n";
|
||||||
|
if (error) {
|
||||||
|
fputs(h, stderr);
|
||||||
|
exit(2);
|
||||||
|
} else {
|
||||||
|
fputs(h, stdout);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
static const struct option options[] = {
|
static const struct option options[] = {
|
||||||
|
@ -291,8 +304,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
switch (option) {
|
switch (option) {
|
||||||
case 'h':
|
case 'h':
|
||||||
printf("Usage: keymap <event device> [<map file>]\n\n");
|
help(0);
|
||||||
return 0;
|
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
opt_interactive = 1;
|
opt_interactive = 1;
|
||||||
|
@ -302,10 +314,8 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc < optind+1 || argc > optind+2) {
|
if (argc < optind+1 || argc > optind+2)
|
||||||
fprintf(stderr, "Usage: keymap <event device> [<map file>]\n\n");
|
help (1);
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((fd = evdev_open(argv[optind])) < 0)
|
if ((fd = evdev_open(argv[optind])) < 0)
|
||||||
return 3;
|
return 3;
|
||||||
|
|
Loading…
Reference in a new issue