blob: d7a9a2c3be067da9c24c0a9a9fa6d25818c9174c [file] [log] [blame]
Dianne Hackborn54a181b2010-06-30 18:35:14 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
Dianne Hackborn289b9b62010-07-09 11:44:11 -070017#ifndef _ANDROID_APP_NATIVEACTIVITY_H
18#define _ANDROID_APP_NATIVEACTIVITY_H
Dianne Hackborn54a181b2010-06-30 18:35:14 -070019
Dianne Hackbornd76b67c2010-07-13 17:48:30 -070020#include <ui/InputTransport.h>
21
Dianne Hackborn289b9b62010-07-09 11:44:11 -070022#include <android/native_activity.h>
Dianne Hackborn54a181b2010-06-30 18:35:14 -070023
24#include "jni.h"
25
26namespace android {
27
Dianne Hackborn289b9b62010-07-09 11:44:11 -070028extern void android_NativeActivity_setWindowFormat(
29 ANativeActivity* activity, int32_t format);
30
31extern void android_NativeActivity_setWindowFlags(
32 ANativeActivity* activity, int32_t values, int32_t mask);
33
Dianne Hackbornd76b67c2010-07-13 17:48:30 -070034extern void android_NativeActivity_showSoftInput(
35 ANativeActivity* activity, int32_t flags);
36
37extern void android_NativeActivity_hideSoftInput(
38 ANativeActivity* activity, int32_t flags);
Dianne Hackborn54a181b2010-06-30 18:35:14 -070039
40} // namespace android
41
Dianne Hackbornd76b67c2010-07-13 17:48:30 -070042
43/*
44 * NDK input queue API.
45 */
46struct AInputQueue {
47public:
48 /* Creates a consumer associated with an input channel. */
49 explicit AInputQueue(const android::sp<android::InputChannel>& channel, int workWrite);
50
51 /* Destroys the consumer and releases its input channel. */
52 ~AInputQueue();
53
54 void attachLooper(ALooper* looper, ALooper_callbackFunc* callback, void* data);
55
56 void detachLooper();
57
58 int32_t hasEvents();
59
60 int32_t getEvent(AInputEvent** outEvent);
61
62 void finishEvent(AInputEvent* event, bool handled);
63
64
65 // ----------------------------------------------------------
66
67 inline android::InputConsumer& getConsumer() { return mConsumer; }
68
69 void dispatchEvent(android::KeyEvent* event);
70
71 android::KeyEvent* consumeUnhandledEvent();
72
73 int mWorkWrite;
74
75private:
76 void doDefaultKey(android::KeyEvent* keyEvent);
77
78 android::InputConsumer mConsumer;
79 android::PreallocatedInputEventFactory mInputEventFactory;
80 android::sp<android::PollLoop> mPollLoop;
81
82 int mDispatchKeyRead;
83 int mDispatchKeyWrite;
84
85 // This is only touched by the event reader thread. It is the current
86 // key events that came out of the mDispatchingKeys list and are now
87 //Êdelivered to the app.
88 android::Vector<android::KeyEvent*> mDeliveringKeys;
89
90 android::Mutex mLock;
91 android::Vector<android::KeyEvent*> mPendingKeys;
92 android::Vector<android::KeyEvent*> mDispatchingKeys;
93};
94
Dianne Hackborn289b9b62010-07-09 11:44:11 -070095#endif // _ANDROID_APP_NATIVEACTIVITY_H