2 * Copyright (C) 2013 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef _ANDROID_VIEW_INPUTQUEUE_H
18 #define _ANDROID_VIEW_INPUTQUEUE_H
20 #include <input/Input.h>
21 #include <utils/Looper.h>
22 #include <utils/TypeHelpers.h>
23 #include <utils/Vector.h>
28 * Declare a concrete type for the NDK's AInputQueue forward declaration
35 class InputQueue : public AInputQueue, public MessageHandler {
37 virtual ~InputQueue();
39 void attachLooper(Looper* looper, int ident, ALooper_callbackFunc callback, void* data);
45 status_t getEvent(InputEvent** outEvent);
47 bool preDispatchEvent(InputEvent* event);
49 void finishEvent(InputEvent* event, bool handled);
51 KeyEvent* createKeyEvent();
53 MotionEvent* createMotionEvent();
55 void recycleInputEvent(InputEvent* event);
57 void enqueueEvent(InputEvent* event);
59 static InputQueue* createQueue(jobject inputQueueObj, const sp<Looper>& looper);
62 virtual void handleMessage(const Message& message);
65 InputQueue(jobject inputQueueObj, const sp<Looper>& looper,
66 int readDispatchFd, int writeDispatchFd);
68 void detachLooperLocked();
70 jobject mInputQueueWeakGlobal;
73 Vector<Looper*> mAppLoopers;
74 sp<Looper> mDispatchLooper;
75 sp<WeakMessageHandler> mHandler;
76 PooledInputEventFactory mPooledInputEventFactory;
77 // Guards the pending and finished event vectors
79 Vector<InputEvent*> mPendingEvents;
80 Vector<key_value_pair_t<InputEvent*, bool> > mFinishedEvents;
83 } // namespace android