99 Commits

Author SHA1 Message Date
Jeff Brown
af9e8d3818 Notify applications when input devices change.
This change allows the InputManager to keep track of what input
devices are registered with the system and when they change.
It needs to do this so that it can properly clear its cache of
input device properties (especially the key map!) when changes
occur.

Added new API so that applications can register listeners for
input device changes.

Fixed a minor bug in EventHub where it didn't handle EPOLLHUP
properly so it would spam the log about unsupposed epoll events
until inotify noticed that the device was gone and removed it.

Change-Id: I937d8c601f7185d4299038bce6a2934fe4fdd2b3
2012-04-12 18:54:54 -07:00
Jeff Brown
49ccac530b Refactor key code mapping.
Added handling for EV_MSC / MSC_SCAN which typically reports
the HID usage associated with a key.  This will enable key maps
to map keys with HID usages that Linux does not natively recognize.

Removed keyCode and flags fields from EventHub RawEvent since
they don't necessarily make sense in isolation now that we
pay attention to HID usage codes too.

Removed the fallback code for mapping keys and axes.  In practice,
an input device should be self-sufficient.  We should not ever
need to look at the built-in keyboard's key map.  In fact, there
usually isn't a built-in keyboard anyhow.  This code was originally
working around a problem where we weren't loading the key map
for touch screens with virtual keys, which has long since been fixed.

Change-Id: I0a319bdec44be9514f795526347397e94d53a127
2012-04-11 20:28:09 -07:00
Jeff Brown
9f25b7fdf2 Request key maps from input manager service.
Instead of each application loading the KeyCharacterMap from
the file system, get them from the input manager service as
part of the InputDevice object.

Refactored InputManager to be a proper singleton instead of
having a bunch of static methods.

InputManager now maintains a cache of all InputDevice objects
that it has loaded.  Currently we never invalidate the cache
which can cause InputDevice to return stale motion ranges if
the device is reconfigured.  This will be fixed in a future change.

Added a fake InputDevice with ID -1 to represent the virtual keyboard.

Change-Id: If7a695839ad0972317a5aab89e9d1e42ace28eb7
2012-04-10 18:23:58 -07:00
Jeff Brown
e38fdfae91 Add a unique input device descriptor.
The purpose of the input device descriptor is to make it possible
to associate persistent settings for each input device, such as the
keyboard layout.

The descriptor is a hash of the information we have about the
device, such as its vendor id, product id, unique id, name,
or location.

Bug: 6110399
Change-Id: Idb80f946819b3f0dbf4e661bb0a753dbc2b60981
2012-04-06 14:57:19 -07:00
Mathias Agopian
b93a03f841 frameworks/base refactoring.
First step. Move libui includes to their new home: androidfw.

Change-Id: Ic042b52fdba72f30edc3cc6339bf30b4c1b99662
2012-02-17 15:36:10 -08:00
Jeff Brown
112b5f52c5 Improve watchdog monitor for InputReader and InputDispatcher.
Try harder to test for liveness.  There are situations where
the lock might not be held but the input system is stuck in
a callback into the window manager policy that has hung.

Bug: 5094994
Change-Id: Iff88655512a5dc8bbb4615be65f4115e975c020b
2012-01-27 17:33:42 -08:00
Steve Block
ec193dec4d Rename LOG_ASSERT to ALOG_ASSERT DO NOT MERGE
See https://android-git.corp.google.com/g/157519

Bug: 5449033
Change-Id: I8ceb2dba1b031a0fd68d15d146960d9ced62bbf3
2012-01-09 21:36:22 +00:00
Steve Block
8564c8da81 Rename (IF_)LOGW(_IF) to (IF_)ALOGW(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/157065

Bug: 5449033
Change-Id: I00a4b904f9449e6f93b7fd35eac28640d7929e69
2012-01-06 10:07:54 +00:00
Steve Block
6215d3ff4b Rename (IF_)LOGI(_IF) to (IF_)ALOGI(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/156801

Bug: 5449033
Change-Id: Ib08fe86d23db91ee153e9f91a99a35c42b9208ea
2012-01-04 20:05:49 +00:00
Steve Block
5baa3a62a9 Rename (IF_)LOGD(_IF) to (IF_)ALOGD(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/156016

Bug: 5449033
Change-Id: I4c4e33bb9df3e39e11cd985e193e6fbab4635298
2012-01-03 22:38:27 +00:00
Jeff Brown
221096fdd6 am 4c0e0dd2: am 3e7497b4: Merge "Eliminate hw.keyboards system properties." into ics-mr1
* commit '4c0e0dd29dcce33e7521b11d01d21d9431f3b264':
  Eliminate hw.keyboards system properties.
2011-11-15 19:43:35 -08:00
Jeff Brown
1e08fe90df Eliminate hw.keyboards system properties.
Stop using system properties to publish information about
the key character map path.  Instead, we can retrieve it
on demand by asking the window manager.

It was possible to exhaust the supply of system properties
when repeatedly adding and removing input devices.

Bug: 5532806
Change-Id: Idd361a24ad7db2edc185c8546db7fb05f9c28669
2011-11-15 18:00:10 -08:00
David Deephanphongs
fbca596721 Modify getState to prefer AKEY_STATE_DOWN and AKEY_STATE_UP over AKEY_STATE_UNKNOWN.
For the getState() routines that operate on multiple devices / mappers:
Return AKEY_STATE_DOWN (or AKEY_STATE_VIRTUAL) if any of the devices/mappers
have the key down.
Otherwise, return AKEY_STATE_UP if at least one device/mapper returns AKEY_STATE_UP.
Otherwise, return AKEY_STATE_UNKNOWN.

Change-Id: I1ef6251d73af916b51f408a41c5e4adf5bdc237a
2011-11-15 11:10:07 -08:00
Jeff Brown
9ee285afe7 Support composite touch / joystick devices better.
This change enables the joystick input mapper to handle any axes
that are not claimed by the touch input mapper, which makes
auxiliary controls such as wheels / knobs accessible.

Change-Id: I01ee7f342ac91acfcb4ccb6676fd52b3d5bf31a0
2011-08-31 12:56:34 -07:00
Jeff Brown
8d3feb6292 Merge "Add a "show touches" option for demos and presentations. Bug: 4569045" 2011-08-29 14:04:31 -07:00
Jeff Brown
deffe07c22 Prioritize INPUT_PROP_DIRECT first.
If the device tells us it's really direct, then it's direct.

Change-Id: I83875cf47e865ff6f0def149ad0c68db24d9dc4a
2011-08-26 18:38:46 -07:00
Jeff Brown
daf4a127ba Add a "show touches" option for demos and presentations.
Bug: 4569045

Change-Id: I8726ea292dd7def790a5e40d7d7e58968974f896
2011-08-26 17:14:14 -07:00
Jeff Brown
c28306ad4a Improve input device wake heuristics.
Bug: 5205674

Only wake the device on positive interactions from the user
such as button presses, movement, initial touch down events.
In particular, do not wake the device on up events since the
driver might synthesize them on power off, causing the device
to wake up again for no good reason.

Change-Id: I767f553ea36d110e6f3a10611b324487ba7d880d
2011-08-23 21:32:42 -07:00
Jeff Brown
ea6892e02e Support BTN_TOOL_*TAP as synonyms for BTN_TOOL_FINGER.
Bug: 5205301

Some drivers report one finger as BTN_TOOL_FINGER, two as
BTN_TOOL_DOUBLETAP, three as BTN_TOOL_TRIPLETAP and four
as BTN_TOOL_QUADTAP.  Since we care about the tool type,
we need to handle _DOUBLE/_TRIPLE/_QUAD tap in the same way
we handle _FINGER.

Change-Id: I8eb83d2a2bada9ac32d07619c7eea84e924316b8
2011-08-23 17:49:49 -07:00
Jeff Brown
a66cee134e Fix tap gesture on touch pads.
Change-Id: I92b23e5971d4b98b173aacd64fe03ce9f0755c88
2011-08-19 16:04:30 -07:00
Jeff Brown
65fd251c39 Input system bug fixes, particularly for stylus.
Bug: 5049148

Finished stylus support, including support for indirect stylus
and mouse tools.

Added TILT axis.  When stylus tilt X/Y is available, it is transformed
into an orientation and tilt inclination which is a more convenient
representation and a simpler extension to the exiting API.

Touch devices now only report touch data using a single input
source.  Previously touch devices in pointer mode would report
both absolute touch pad data and cooked pointer gestures.
Now we just pick one.  The touch device switches modes as needed
when the focused application enables/disables pointer gestures.
This change greatly simplifies the code and reduces the load
on the input dispatcher.

Fixed an incorrect assumption that the value of ABS_(MT_)DISTANCE
would be zero whenever the stylus was in direct contact.  It appears
that the correct way to determine whether the stylus is in direct
contact (rather than hovering) is by checking for a non-zero
reported pressure.

Added code to read the initial state of tool buttons and axis values
when the input devices are initialized or reset.  This fixes
problems where the input mapper state might have the wrong initial
state.

Moved responsibility for cancelling pending inputs (keys down,
touches, etc.) to the InputDispatcher by sending it a device reset
notification.  This frees the InputReader from having to synthesize
events during reset, which was cumbersome and somewhat brittle
to begin with.

Consolidated more of the common accumulator logic from
SingleTouchInputMapper and MultiTouchInputMapper into
TouchInputMapper.

Improved the PointerLocation output.

Change-Id: I595d3647f7fd7cb1e3eff8b3c76b85043b5fe2f0
2011-08-19 15:02:26 -07:00
Jeff Brown
8bcbbefa3b Exorcise notification panel ghosts.
Bug: 5105599

Don't clear slot data when slot is no longer in use.

The kernel will not resend absolute slot values if they are
unchanged, even if the slot was previously marked unused.

Because the protocol is stateful, this could cause problems if
evdev drops events (marked by SYN_DROPPED) since we cannot
query the initial values of the slots, but there's nothing
we can do.

Change-Id: Ie13e68097fb8ed2542c2f60338b499082cf9e77f
2011-08-11 15:54:54 -07:00
Jeff Brown
a1f89ceec0 Improve touch device configuration.
Bug: 5064702

This change improves compatibility with standard touch device
drivers.  All existing touch device IDC files will need to
be updated because the input system now assumes that the
touch device drivers implement the multitouch input
protocol correctly and use the appropriate axes.

Change-Id: I93aad0e011efea74fbc7fa3da31f7967aff8136c
2011-08-11 14:57:50 -07:00
Jeff Brown
89ef0720ee Add input system to Watchdog.
Bug: 5094994

Change-Id: I153866958efc64ac19bda8b997c1c9f6ad425ec4
2011-08-10 16:25:21 -07:00
Jeff Brown
d87c6d5fd5 Use BTN_TOUCH or BTN_TOOL_* to determine if touch active.
Bug: 5064702

Should not include stylus buttons in the condition.

Change-Id: If4d78a875b77da8bd59672d6fdbf5353004d0023
2011-08-10 14:55:59 -07:00
Jeff Brown
be1aa8250c Refactor input reader to add stylus support.
Bug: 5064702

Introduced the concept of an InputListener to further decouple
the InputReader from the InputDispatcher.  The InputListener
exposes just the minimum interface that the InputReader needs
to communicate with the outside world.  The InputReader
passes arguments to the InputListener by reference, which makes
it easy to queue them up.

Consolidated all of the InputReader locks into one simple global
Mutex.  The reason this wasn't done before was due to potential
re-entrance in outbound calls to the InputDispatcher.  To fix this,
the InputReader now queues up all of the events it wants to send
using a QueuedInputListener, then flushes them outside of the
critical section after all of the event processing is finished.
Removing all of the InputMapper locks greatly simplifies the
implementation.

Added tests for new stylus features such as buttons, tool types,
and hovering.

Added some helpers to BitSet32 to handle common code patterns
like finding the first marked bit and clearing it.

Fixed a bug in VelocityTracker where the wrong pointer trace
could get cleared when handling ACTION_POINTER_DOWN.  Oops.

Changed PointerCoords so it no longer stores useless zero
axis values.  Removed editAxisValue because it is not very
useful when all zero value axes are absent and therefore
cannot be edited in place.

Added dispatch of stylus hover events.

Added support for distance and tool types.

Change-Id: I4cf14d134fcb1db7d10be5f2af7b37deef8f8468
2011-07-31 15:38:09 -07:00
Jeff Brown
bc68a59c02 Report the external display size to the input reader.
The input reader needs this information so that it knows how to
interpolate touches on an external touch screen.

Changed Display so that it asks the WindowManager what the real
display size is (as opposed to the raw display size).  This means
it now takes into the forced display size set by
adb shell am display-size.

Replaced all calls to getRealWidth() / getRealHeight() /
getRealMetrics() in the WindowManager and replaced them with direct
usages of the mCurDisplayWidth / mCurDisplayHeight so that the WM
doesn't end up making a reentrant Binder call into itself.

Fixed the table status bar HeightReceiver so that it updates the
height on all configuration changes since it is possible that the
display size changed independently of an external HDMI display
being plugged / unplugged.

Improved the Display class documentation to make the distinctions
betweeen the various sizes clearer.

Change-Id: I3f75de559d3ebffed532ab46c4ae52c5e7f1da2b
2011-07-25 20:10:12 -07:00
Jeff Brown
49754db5a3 Handle stylus buttons and tool types.
Added TOOL_TYPE_ERASER.

Refactored the InputReader to share more code between the
various input mappers that handle button states and to
simplify the accumulator implementations by having each
one only handle a single type of input.

Removed the concept of direct/indirect tool types from the API.
If we add it back, it should be done in a manner that is orthogonal
to the tool type itself, perhaps as a flags field on the pointer.
The device source may well provide sufficient information anyhow.

Change-Id: I811c22d95e8304269b6ee4f6d11a6b04f3cfc1b2
2011-07-25 20:04:18 -07:00
Jeff Brown
44e504e089 Drop hack for drivers that emit zero ABS_MT_TOUCH_MAJOR.
Bug: 5064702

When using Linux MT Protocol A, drivers are supposed to omit
fingers that go up and to send an empty sync with no fingers
(can be just an SYN_MT_REPORT / SYN_REPORT) when no fingers
remain.

This makes Android more compliant with the protocol standard.

Change-Id: I5775feb14ab7db015824a32b1e2c015da239385d
2011-07-25 20:04:17 -07:00
Jeff Brown
612891e07b Add support for orientationAware touch pads.
Bug: 5038388

Change-Id: I9c571b1542299334d2d64c5b33e456ec20ebc0ae
2011-07-15 20:54:03 -07:00
Jeff Brown
6069139356 Remove more edge flag cruft.
Change-Id: I4f9f4f4cc7c771a918aee82a941a3e86ecfe48fe
2011-07-15 19:08:26 -07:00
Jeff Brown
a6111377e1 Remove edge slop support.
The edge slop feature was added a long time ago for a specific
device that had severe non-linear touch response issues near
the edges of its touch screen.  The feature is not useful on
modern hardware that is property calibrated.

Change-Id: I26716cbc7411c31883ddb4bb4ddd981027790d0f
2011-07-14 21:48:23 -07:00
Jeff Brown
a4d1bc5172 Drop obsolete touch screen hacks.
Change-Id: I47354c37ee2cc2b36340eb709bb5043b3ba78ed9
2011-07-01 19:23:40 -07:00
Jeff Brown
6894a2947e Workaround apps that make assumptions about pointer ids.
Modified the touch input mapper to assign pointer ids sequentially
starting from 0 instead of using the tracking id or slot index
supplied by the driver.  Applications should not depend on this
ordering but some do.  (sigh)

Bug: 4980884
Change-Id: I0dfeb3ac27c57a7102a13c960c760e2a02eb7669
2011-07-01 19:08:15 -07:00
Jeff Brown
2717eff2ac Query input device for initial slot index.
This fixes a problem where touches can get stuck because the
driver and the framework have different ideas of what the
initial slot index is.  The framework assumed it was slot 0
but it could in principle be any slot, such as slot 1.  When
that happened, the framework would start tracking the first
touch as slot 0, but it might never receive an "up" for that slot.

Change-Id: Idaffc4534b275d66b9d4360987b28dc2d0f63218
2011-07-01 02:59:26 -07:00
Jeff Brown
2e45fb6f95 Fix joystick and trackpad regression.
Change-Id: I33b6756f95a6b0725ffa210f341da3c98426491b
2011-06-29 21:19:05 -07:00
Jeff Brown
aba321aa6f Add some logging code to track down touch issues.
Change-Id: I9bd7af6b93f82a83c6863986d21e7a222d97e4ae
2011-06-28 20:34:40 -07:00
Jeff Brown
8134681b25 Improve input event consistency invariants.
Fixed some issues where inconsistent streams of events could
be generated by the dispatcher, particularly when switching from
hovering with one device to hovering with another.

Fixed a bug where the touch pad would fail to generate a new
HOVER_MOVE following a tap event.  As a result, the hover event
stream would not resume until the user touched the touch pad
again.

Change-Id: I444dce84641fb12e56a0af84c931520771d6c493
2011-06-28 20:10:40 -07:00
Jeff Brown
53ca3f13e7 Hover and stylus API cleanup.
Added missing setOnHoverListener method.
Removed BUTTON_STATE_ERASER.

Change-Id: I5d820d0a8e47fe5fd2d88e9fd9fc3fc6ce0dea0d
2011-06-27 21:35:59 -07:00
Jeff Brown
474dcb5c3d Add support for disabling pointer gestures.
Made it possible for individual windows to disable pointer gestures
while the window has focus using a private API.

Cleaned up the InputReader configuration code to enable in-place
reconfiguration of input devices without having to reopen them all.
This change makes changing the pointer speed somewhat nicer since the
pointer doesn't jump back to the origin after each change.

Change-Id: I9727419c2f4cb39e16acb4b15fd7fd84526b1239
2011-06-14 22:07:31 -07:00
Jeff Brown
93fa9b30b9 EventHub code cleanup.
Use epoll_wait() instead of poll().
Dropped all support for non-Linux platforms.
Added a wake-up protocol so that the InputReader can wake up
the event loop immediately as needed.

Change-Id: Ibf84337bcceb3c2df068c5c637de42a319786d66
2011-06-14 21:37:53 -07:00
Jeff Brown
b3a2d13307 Take advantage of updated linux/input.h kernel headers.
Change-Id: I72d2ef82de5c504d46b0cdb57aa43bbd0d769174
2011-06-13 18:05:15 -07:00
Jeff Brown
9429e6ebe4 am 92110af2: am 5f0b1721: am 25bd8abc: Merge "Fix swipe gesture cosine calculation. Bug: 4124987" into honeycomb-mr2
* commit '92110af24a9a93b73264560b57f55f45ec65dab5':
  Fix swipe gesture cosine calculation. Bug: 4124987
2011-06-09 11:56:21 -07:00
Jeff Brown
051e8f2bfa am 55cc25c1: am 797dc698: am b92dcf9c: Merge "Simplify spot tracking logic. Bug: 4124987" into honeycomb-mr2
* commit '55cc25c12c45e8ffb65d2275cc0b6941b68db9df':
  Simplify spot tracking logic. Bug: 4124987
2011-06-07 17:52:22 -07:00
Jeff Brown
774ed9d953 resolved conflicts for merge of 8b2c0014 to master
Change-Id: I33a5a2949dc6c2d09e8196ba8c7128caa7ac2361
2011-06-07 17:48:39 -07:00
Jeff Brown
6674d9bf0a Fix swipe gesture cosine calculation.
Bug: 4124987

Recent changes introduced a multiplication factor into the
distance calculation which ended up being absent from the
dot product calculation.

Change-Id: Ia367912b9ac09b6285d5a498a0c271563c9e9e39
2011-06-07 16:50:14 -07:00
Jeff Brown
cb5ffcf0e4 Simplify spot tracking logic.
Bug: 4124987

Since spots are now one-to-one with the touch gesture points,
we can eliminate a lot of redundant logic that assumed they weren't.

Change-Id: Ic60d8d0898c285317f480bc8fb17fb9797770e69
2011-06-06 20:06:19 -07:00
Jeff Brown
bb3fcba0ca Touch pad improvements.
Bug: 4124987

Only show one spot per touch point instead of one spot per
finger for multitouch gestures.

Tweaked the pointer acceleration curves.

Dissociated the hover/tap timeouts from the "tap" timeout
since they mean very different things.

Change-Id: I7c2cbd30feeb65ebc12f6c7e33a67dc9a9f59d4c
2011-06-06 19:23:05 -07:00
Jeff Brown
b12682270a Use pointer mode instead of spots for SEMI_MT touch pads.
The spot-based presentation relies on being able to accurately
locate and distinguish two or more fingers on the touch pad.
We can still do gesture recognition without distinct multitouch
but it doesn't make sense to show spots because we can't be sure
that the spots will appear in the right places.

Change-Id: Ia282d77000bf3b50d395273a1f0ac0bbe55b3c6f
2011-06-03 17:08:09 -07:00
Jeff Brown
7218d830e2 resolved conflicts for merge of ca2b552d to master
Change-Id: I2f3693a59042ac5aa2d7bcdc3a504c78dc99a18b
2011-06-03 15:50:27 -07:00