diff options
author | Dianne Hackborn <hackbod@google.com> | 2010-07-02 18:52:01 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2010-07-02 18:57:02 -0700 |
commit | 682674154e3fe88f6061245145f934f25f1a2eb8 (patch) | |
tree | a105ce9f0ae4d88732bfc8fb1a52d4474f17bc86 /native/android/input.cpp | |
parent | 8ecfb60a8e74dfcd51bbf3f236d5f414a4d5ac7d (diff) |
Add new native Looper API.
This allows us to avoid exposing the file descriptor of
the event queue; instead, you attach an event queue to
a looper. This will also should allow native apps to be
written without the need for a separate thread, by attaching
the event queue to the main thread's looper and scheduling
their own messages there.
Change-Id: I38489282635895ae2cbfacb88599c1b1cad9b239
Diffstat (limited to 'native/android/input.cpp')
-rw-r--r-- | native/android/input.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/native/android/input.cpp b/native/android/input.cpp index 84988403e301..015a1ced432b 100644 --- a/native/android/input.cpp +++ b/native/android/input.cpp @@ -20,6 +20,7 @@ #include <android/input.h> #include <ui/Input.h> #include <ui/InputTransport.h> +#include <utils/PollLoop.h> #include <poll.h> @@ -184,8 +185,16 @@ float AMotionEvent_getHistoricalSize(AInputEvent* motion_event, size_t pointer_i pointer_index, history_index); } -int AInputQueue_getFd(AInputQueue* queue) { - return queue->getConsumer().getChannel()->getReceivePipeFd(); +void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper, + ALooper_callbackFunc callback, void* data) { + queue->setPollLoop(static_cast<android::PollLoop*>(looper)); + ALooper_setCallback(looper, queue->getConsumer().getChannel()->getReceivePipeFd(), + POLLIN, callback, data); +} + +void AInputQueue_detachLooper(AInputQueue* queue) { + queue->getPollLoop()->removeCallback( + queue->getConsumer().getChannel()->getReceivePipeFd()); } int AInputQueue_hasEvents(AInputQueue* queue) { |