[PATCH evtest 2/2] Add one-shot query functionality
Peter Hutterer
peter.hutterer at who-t.net
Sun Jul 17 17:20:19 PDT 2011
On Sun, Jul 17, 2011 at 02:59:36PM +0200, walter harms wrote:
> Am 17.07.2011 00:07, schrieb Daniel Drake:
> > Add functionality to query evdev state of a specific key, switch, button,
> > LED or sound event. This is useful in programs such as powerd
> > (http://wiki.laptop.org/go/Powerd) which need to query things like the
> > state of the laptop lid switch from shell code.
> >
> > Original capture-mode functionality is left unchanged and is still
> > activated by default. New usage modes are explained in the man page.
> >
> > Signed-off-by: Daniel Drake <dsd at laptop.org>
> > ---
> > evtest.c | 203 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
> > evtest.txt | 33 ++++++++--
> > 2 files changed, 226 insertions(+), 10 deletions(-)
> >
> > diff --git a/evtest.c b/evtest.c
> > index eb04a51..9a7ac7f 100644
> > --- a/evtest.c
> > +++ b/evtest.c
[...]
> > @@ -546,8 +619,18 @@ static char* scan_devices(void)
> > */
> > static void usage(void)
> > {
> > - printf("Usage: evtest /dev/input/eventX\n");
> > - printf("Where X = input device number\n");
> > + printf("USAGE:\n");
> > + printf(" Grab mode:\n");
> > + printf(" %s /dev/input/eventX\n", program_invocation_short_name);
> > + printf("\n");
> > + printf(" Query mode: (check exit code)\n");
> > + printf(" %s --query /dev/input/eventX <type> <value>\n",
> > + program_invocation_short_name);
> > +
> > + printf("\n");
> > + printf("<type> is one of: key, sw, led, snd\n");
> > + printf("<value> can either be a numerical value, or the textual name of the\n");
> > + printf("key/switch/LED/sound being queried (e.g. SW_DOCK).\n");
> > }
> >
>
>
> you could make it exit(EXIT_FAILURE) and never return.
fwiw, I suggested to Daniel in a previous patchset to just make it "int
usage()" and return EXIT_FAILURE. That way, callers can just call "return
usage()".
[...]
> > diff --git a/evtest.txt b/evtest.txt
> > index 685a4de..4cb1a18 100644
> > --- a/evtest.txt
> > +++ b/evtest.txt
[...]
> > @@ -32,6 +48,13 @@ when debugging a synaptics device from within X. VT switching to a TTY or
> > shutting down the X server terminates this grab and synaptics devices can be
> > debugged.
> >
> > +EXIT CODE
> > +---------
> > +evtest returns 1 on error.
> that will any decent unix program do ?
IMO it is still useful to spell it out given that the return code for query
may be non-zero and carry value.
Cheers,
Peter
More information about the xorg-devel
mailing list