[PATCH evtest v3] Add one-shot query functionality

Paul Fox pgf at foxharp.boston.ma.us
Fri Aug 26 08:32:08 PDT 2011


peter wrote:
 > On Wed, Jul 20, 2011 at 06:25:03PM +0100, Daniel Drake wrote:
 > > 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>
 > 
 > thanks! merged with one change: strcasecmp → strcmp. I'm not sure why we'd
 > need to accept both "EV_KEY" and "ev_key". I think it'd cause confusion for
 > little benefit but you can convince me otherwise before I push it on my
 > Monday :)

hi -- two small fixes to this, since i was just using the new evtest
features in powerd yesterday.

one is just a comment fixup, resulting from the above strcasecmp/strcmp
change.

the other makes the documentation match the code with respect to
exit return codes.  i confess that aesthetically i'd prefer to
change the code to match the docs -- so if anyone else agrees, i'm
all for it, and would be happy to create a different patch.  the
issue is whether the command should "succeed" when a switch or key is
closed, or when it's not closed.  since one is usually testing for
closure, i'd prefer that that be the success case.  but clearly either
way works, so leaving as-is is fine too.

paul

commit ed912b016e6e2bfea692a592058aeaee53b62234 (master)
Author: Paul Fox <pgf at laptop.org>
Date:   Fri Aug 26 11:16:34 2011 -0400

    change documentation of query-mode exit values  to match code
    
    in query mode, the zero/non-zero exit code matches the zero/non-zero
    state of the key bit.  so the command "succeeds" in the shell sense
    when the key or switch is _not_ pressed or closed.

diff --git a/evtest.txt b/evtest.txt
index 5ae7092..b614482 100644
--- a/evtest.txt
+++ b/evtest.txt
@@ -29,8 +29,8 @@ of the state of a specific key *value* of an event *type*.
 being queried.
 
 If the state bit is set (key pressed, switch on, ...), evtest exits with
-code 0. If the state bit is unset (key depressed, switch off, ...), evtest
-exits with code 10. No other output is generated.
+code 10. If the state bit is unset (key depressed, switch off, ...), evtest
+exits with code 0. No other output is generated.
 
 evtest needs to be able to read from the device; in most cases this means it
 must be run as root.

commit 760a0c03923bcb2a0e0579eee36a28928c0916a9 (master~1)
Author: Paul Fox <pgf at laptop.org>
Date:   Fri Aug 26 11:15:33 2011 -0400

    modify comments to match code (query lookups are case sensitive)

diff --git a/evtest.c b/evtest.c
index 022229e..ea03979 100644
--- a/evtest.c
+++ b/evtest.c
@@ -89,8 +89,7 @@ static const struct query_mode {
 };
 
 /**
- * Look up an entry in the query_modes table by its textual name. The search
- * is case-insensitive.
+ * Look up an entry in the query_modes table by its textual name.
  *
  * @param mode The name of the entry to be found.
  *


=---------------------
 paul fox, pgf at foxharp.boston.ma.us (arlington, ma, where it's 74.1 degrees)


More information about the xorg-devel mailing list