linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Advice requested on reporting 'tap' events from accelerometers.
@ 2009-03-10  0:15 Neil Brown
  0 siblings, 0 replies; only message in thread
From: Neil Brown @ 2009-03-10  0:15 UTC (permalink / raw)
  To: linux-input


Hi experts in the 'input' subsystem...

I have been playing with the Neo Freerunner from Openmoko, and
particularly with the accelerometers lately.

The device has two accelerometers (in slightly different orientations)
which can, among other things, detect taps and double-taps.
A 'tap' involves the acceleration in a particular access crossing a
given threshold and going back below that threshold within a given
time.
A 'double tap' includes 2 such events within a set window.

I would like to program the accelerometers to detect those events and
report them through the input subsystem.

The obvious choice for event type is EV_KEY as it is much like a key
press.  What is less obvious, and what I seek advice on, is what event
codes to use.

Each accelerometer has 2 axes (x,y,z) and can detect taps and double
taps on each axis.  So that is a total of 6 different event codes
needed.
I don't think the device distinguished between taps from one direction
and taps from the opposite direction - if it did we would need 12!!

Looking through the values defined in input.h,
  BTN_X BTN_Y BTN_Z
seem like they could reasonably be used for single taps.
Nothing stands out for double taps, though it did cross my mind to use 
 BTX_A BTN_B BTN_C :-)

I guess I could just report two consecutive BTN_X up/down events...

So my questions are:

1/ Is it best to use EV_KEY for these tap events?

2/ Is it reasonable to use BTN_{X,Y,Z} for taps on the 3 axes?

3/ If there anything better for double-tap than just repeating the
   event?

4/ If I could e.g. differentiate taps from one direction against taps
   from the opposite direction and so needed 6 tap events, what would I
   use?

5/ Turning the device over, and hence reversing the acceleration in
   one axis, is a bit like turning a switch.  It has occurred to me
   that it could be useful to generate EV_SW events on this sort of
   action.   Might this be a reasonable thing to do?  If so what
   event codes might be appropriate?  Is it possible to increase
   SW_MAX  and add some directional switches (SW_X SW_Y SW_Z) ??


Thanks for your time.

NeilBrown


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-03-10  0:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-10  0:15 Advice requested on reporting 'tap' events from accelerometers Neil Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).