• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 #ifndef _LIBINPUT_INPUT_H
18 #define _LIBINPUT_INPUT_H
19 
20 /**
21  * Native input event structures.
22  */
23 
24 #include <android/input.h>
25 #include <utils/BitSet.h>
26 #include <utils/KeyedVector.h>
27 #include <utils/RefBase.h>
28 #include <utils/String8.h>
29 #include <utils/Timers.h>
30 #include <utils/Vector.h>
31 
32 /*
33  * Additional private constants not defined in ndk/ui/input.h.
34  */
35 enum {
36     /* Signifies that the key is being predispatched */
37     AKEY_EVENT_FLAG_PREDISPATCH = 0x20000000,
38 
39     /* Private control to determine when an app is tracking a key sequence. */
40     AKEY_EVENT_FLAG_START_TRACKING = 0x40000000,
41 
42     /* Key event is inconsistent with previously sent key events. */
43     AKEY_EVENT_FLAG_TAINTED = 0x80000000,
44 };
45 
46 enum {
47     /* Motion event is inconsistent with previously sent motion events. */
48     AMOTION_EVENT_FLAG_TAINTED = 0x80000000,
49 };
50 
51 enum {
52     /* Used when a motion event is not associated with any display.
53      * Typically used for non-pointer events. */
54     ADISPLAY_ID_NONE = -1,
55 
56     /* The default display id. */
57     ADISPLAY_ID_DEFAULT = 0,
58 };
59 
60 enum {
61     /*
62      * Indicates that an input device has switches.
63      * This input source flag is hidden from the API because switches are only used by the system
64      * and applications have no way to interact with them.
65      */
66     AINPUT_SOURCE_SWITCH = 0x80000000,
67 };
68 
69 enum {
70     /**
71      * Constants for LEDs. Hidden from the API since we don't actually expose a way to interact
72      * with LEDs to developers
73      *
74      * NOTE: If you add LEDs here, you must also add them to InputEventLabels.h
75      */
76 
77     ALED_NUM_LOCK = 0x00,
78     ALED_CAPS_LOCK = 0x01,
79     ALED_SCROLL_LOCK = 0x02,
80     ALED_COMPOSE = 0x03,
81     ALED_KANA = 0x04,
82     ALED_SLEEP = 0x05,
83     ALED_SUSPEND = 0x06,
84     ALED_MUTE = 0x07,
85     ALED_MISC = 0x08,
86     ALED_MAIL = 0x09,
87     ALED_CHARGING = 0x0a,
88     ALED_CONTROLLER_1 = 0x10,
89     ALED_CONTROLLER_2 = 0x11,
90     ALED_CONTROLLER_3 = 0x12,
91     ALED_CONTROLLER_4 = 0x13,
92 };
93 
94 /* Maximum number of controller LEDs we support */
95 #define MAX_CONTROLLER_LEDS 4
96 
97 /*
98  * SystemUiVisibility constants from View.
99  */
100 enum {
101     ASYSTEM_UI_VISIBILITY_STATUS_BAR_VISIBLE = 0,
102     ASYSTEM_UI_VISIBILITY_STATUS_BAR_HIDDEN = 0x00000001,
103 };
104 
105 /*
106  * Maximum number of pointers supported per motion event.
107  * Smallest number of pointers is 1.
108  * (We want at least 10 but some touch controllers obstensibly configured for 10 pointers
109  * will occasionally emit 11.  There is not much harm making this constant bigger.)
110  */
111 #define MAX_POINTERS 16
112 
113 /*
114  * Maximum number of samples supported per motion event.
115  */
116 #define MAX_SAMPLES UINT16_MAX
117 
118 /*
119  * Maximum pointer id value supported in a motion event.
120  * Smallest pointer id is 0.
121  * (This is limited by our use of BitSet32 to track pointer assignments.)
122  */
123 #define MAX_POINTER_ID 31
124 
125 /*
126  * Declare a concrete type for the NDK's input event forward declaration.
127  */
128 struct AInputEvent {
~AInputEventAInputEvent129     virtual ~AInputEvent() { }
130 };
131 
132 /*
133  * Declare a concrete type for the NDK's input device forward declaration.
134  */
135 struct AInputDevice {
~AInputDeviceAInputDevice136     virtual ~AInputDevice() { }
137 };
138 
139 
140 namespace android {
141 
142 #ifdef HAVE_ANDROID_OS
143 class Parcel;
144 #endif
145 
146 /*
147  * Flags that flow alongside events in the input dispatch system to help with certain
148  * policy decisions such as waking from device sleep.
149  *
150  * These flags are also defined in frameworks/base/core/java/android/view/WindowManagerPolicy.java.
151  */
152 enum {
153     /* These flags originate in RawEvents and are generally set in the key map.
154      * NOTE: If you want a flag to be able to set in a keylayout file, then you must add it to
155      * InputEventLabels.h as well. */
156 
157     POLICY_FLAG_WAKE = 0x00000001,
158     POLICY_FLAG_VIRTUAL = 0x00000002,
159     POLICY_FLAG_FUNCTION = 0x00000004,
160 
161     POLICY_FLAG_RAW_MASK = 0x0000ffff,
162 
163     /* These flags are set by the input dispatcher. */
164 
165     // Indicates that the input event was injected.
166     POLICY_FLAG_INJECTED = 0x01000000,
167 
168     // Indicates that the input event is from a trusted source such as a directly attached
169     // input device or an application with system-wide event injection permission.
170     POLICY_FLAG_TRUSTED = 0x02000000,
171 
172     // Indicates that the input event has passed through an input filter.
173     POLICY_FLAG_FILTERED = 0x04000000,
174 
175     // Disables automatic key repeating behavior.
176     POLICY_FLAG_DISABLE_KEY_REPEAT = 0x08000000,
177 
178     /* These flags are set by the input reader policy as it intercepts each event. */
179 
180     // Indicates that the device was in an interactive state when the
181     // event was intercepted.
182     POLICY_FLAG_INTERACTIVE = 0x20000000,
183 
184     // Indicates that the event should be dispatched to applications.
185     // The input event should still be sent to the InputDispatcher so that it can see all
186     // input events received include those that it will not deliver.
187     POLICY_FLAG_PASS_TO_USER = 0x40000000,
188 };
189 
190 /*
191  * Pointer coordinate data.
192  */
193 struct PointerCoords {
194     enum { MAX_AXES = 30 }; // 30 so that sizeof(PointerCoords) == 128
195 
196     // Bitfield of axes that are present in this structure.
197     uint64_t bits __attribute__((aligned(8)));
198 
199     // Values of axes that are stored in this structure packed in order by axis id
200     // for each axis that is present in the structure according to 'bits'.
201     float values[MAX_AXES];
202 
clearPointerCoords203     inline void clear() {
204         BitSet64::clear(bits);
205     }
206 
isEmptyPointerCoords207     bool isEmpty() const {
208         return BitSet64::isEmpty(bits);
209     }
210 
211     float getAxisValue(int32_t axis) const;
212     status_t setAxisValue(int32_t axis, float value);
213 
214     void scale(float scale);
215     void applyOffset(float xOffset, float yOffset);
216 
getXPointerCoords217     inline float getX() const {
218         return getAxisValue(AMOTION_EVENT_AXIS_X);
219     }
220 
getYPointerCoords221     inline float getY() const {
222         return getAxisValue(AMOTION_EVENT_AXIS_Y);
223     }
224 
225 #ifdef HAVE_ANDROID_OS
226     status_t readFromParcel(Parcel* parcel);
227     status_t writeToParcel(Parcel* parcel) const;
228 #endif
229 
230     bool operator==(const PointerCoords& other) const;
231     inline bool operator!=(const PointerCoords& other) const {
232         return !(*this == other);
233     }
234 
235     void copyFrom(const PointerCoords& other);
236 
237 private:
238     void tooManyAxes(int axis);
239 };
240 
241 /*
242  * Pointer property data.
243  */
244 struct PointerProperties {
245     // The id of the pointer.
246     int32_t id;
247 
248     // The pointer tool type.
249     int32_t toolType;
250 
clearPointerProperties251     inline void clear() {
252         id = -1;
253         toolType = 0;
254     }
255 
256     bool operator==(const PointerProperties& other) const;
257     inline bool operator!=(const PointerProperties& other) const {
258         return !(*this == other);
259     }
260 
261     void copyFrom(const PointerProperties& other);
262 };
263 
264 /*
265  * Input events.
266  */
267 class InputEvent : public AInputEvent {
268 public:
~InputEvent()269     virtual ~InputEvent() { }
270 
271     virtual int32_t getType() const = 0;
272 
getDeviceId()273     inline int32_t getDeviceId() const { return mDeviceId; }
274 
getSource()275     inline int32_t getSource() const { return mSource; }
276 
setSource(int32_t source)277     inline void setSource(int32_t source) { mSource = source; }
278 
279 protected:
280     void initialize(int32_t deviceId, int32_t source);
281     void initialize(const InputEvent& from);
282 
283     int32_t mDeviceId;
284     int32_t mSource;
285 };
286 
287 /*
288  * Key events.
289  */
290 class KeyEvent : public InputEvent {
291 public:
~KeyEvent()292     virtual ~KeyEvent() { }
293 
getType()294     virtual int32_t getType() const { return AINPUT_EVENT_TYPE_KEY; }
295 
getAction()296     inline int32_t getAction() const { return mAction; }
297 
getFlags()298     inline int32_t getFlags() const { return mFlags; }
299 
setFlags(int32_t flags)300     inline void setFlags(int32_t flags) { mFlags = flags; }
301 
getKeyCode()302     inline int32_t getKeyCode() const { return mKeyCode; }
303 
getScanCode()304     inline int32_t getScanCode() const { return mScanCode; }
305 
getMetaState()306     inline int32_t getMetaState() const { return mMetaState; }
307 
getRepeatCount()308     inline int32_t getRepeatCount() const { return mRepeatCount; }
309 
getDownTime()310     inline nsecs_t getDownTime() const { return mDownTime; }
311 
getEventTime()312     inline nsecs_t getEventTime() const { return mEventTime; }
313 
314     static const char* getLabel(int32_t keyCode);
315     static int32_t getKeyCodeFromLabel(const char* label);
316 
317     void initialize(
318             int32_t deviceId,
319             int32_t source,
320             int32_t action,
321             int32_t flags,
322             int32_t keyCode,
323             int32_t scanCode,
324             int32_t metaState,
325             int32_t repeatCount,
326             nsecs_t downTime,
327             nsecs_t eventTime);
328     void initialize(const KeyEvent& from);
329 
330 protected:
331     int32_t mAction;
332     int32_t mFlags;
333     int32_t mKeyCode;
334     int32_t mScanCode;
335     int32_t mMetaState;
336     int32_t mRepeatCount;
337     nsecs_t mDownTime;
338     nsecs_t mEventTime;
339 };
340 
341 /*
342  * Motion events.
343  */
344 class MotionEvent : public InputEvent {
345 public:
~MotionEvent()346     virtual ~MotionEvent() { }
347 
getType()348     virtual int32_t getType() const { return AINPUT_EVENT_TYPE_MOTION; }
349 
getAction()350     inline int32_t getAction() const { return mAction; }
351 
getActionMasked()352     inline int32_t getActionMasked() const { return mAction & AMOTION_EVENT_ACTION_MASK; }
353 
getActionIndex()354     inline int32_t getActionIndex() const {
355         return (mAction & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK)
356                 >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
357     }
358 
setAction(int32_t action)359     inline void setAction(int32_t action) { mAction = action; }
360 
getFlags()361     inline int32_t getFlags() const { return mFlags; }
362 
setFlags(int32_t flags)363     inline void setFlags(int32_t flags) { mFlags = flags; }
364 
getEdgeFlags()365     inline int32_t getEdgeFlags() const { return mEdgeFlags; }
366 
setEdgeFlags(int32_t edgeFlags)367     inline void setEdgeFlags(int32_t edgeFlags) { mEdgeFlags = edgeFlags; }
368 
getMetaState()369     inline int32_t getMetaState() const { return mMetaState; }
370 
setMetaState(int32_t metaState)371     inline void setMetaState(int32_t metaState) { mMetaState = metaState; }
372 
getButtonState()373     inline int32_t getButtonState() const { return mButtonState; }
374 
getXOffset()375     inline float getXOffset() const { return mXOffset; }
376 
getYOffset()377     inline float getYOffset() const { return mYOffset; }
378 
getXPrecision()379     inline float getXPrecision() const { return mXPrecision; }
380 
getYPrecision()381     inline float getYPrecision() const { return mYPrecision; }
382 
getDownTime()383     inline nsecs_t getDownTime() const { return mDownTime; }
384 
setDownTime(nsecs_t downTime)385     inline void setDownTime(nsecs_t downTime) { mDownTime = downTime; }
386 
getPointerCount()387     inline size_t getPointerCount() const { return mPointerProperties.size(); }
388 
getPointerProperties(size_t pointerIndex)389     inline const PointerProperties* getPointerProperties(size_t pointerIndex) const {
390         return &mPointerProperties[pointerIndex];
391     }
392 
getPointerId(size_t pointerIndex)393     inline int32_t getPointerId(size_t pointerIndex) const {
394         return mPointerProperties[pointerIndex].id;
395     }
396 
getToolType(size_t pointerIndex)397     inline int32_t getToolType(size_t pointerIndex) const {
398         return mPointerProperties[pointerIndex].toolType;
399     }
400 
getEventTime()401     inline nsecs_t getEventTime() const { return mSampleEventTimes[getHistorySize()]; }
402 
403     const PointerCoords* getRawPointerCoords(size_t pointerIndex) const;
404 
405     float getRawAxisValue(int32_t axis, size_t pointerIndex) const;
406 
getRawX(size_t pointerIndex)407     inline float getRawX(size_t pointerIndex) const {
408         return getRawAxisValue(AMOTION_EVENT_AXIS_X, pointerIndex);
409     }
410 
getRawY(size_t pointerIndex)411     inline float getRawY(size_t pointerIndex) const {
412         return getRawAxisValue(AMOTION_EVENT_AXIS_Y, pointerIndex);
413     }
414 
415     float getAxisValue(int32_t axis, size_t pointerIndex) const;
416 
getX(size_t pointerIndex)417     inline float getX(size_t pointerIndex) const {
418         return getAxisValue(AMOTION_EVENT_AXIS_X, pointerIndex);
419     }
420 
getY(size_t pointerIndex)421     inline float getY(size_t pointerIndex) const {
422         return getAxisValue(AMOTION_EVENT_AXIS_Y, pointerIndex);
423     }
424 
getPressure(size_t pointerIndex)425     inline float getPressure(size_t pointerIndex) const {
426         return getAxisValue(AMOTION_EVENT_AXIS_PRESSURE, pointerIndex);
427     }
428 
getSize(size_t pointerIndex)429     inline float getSize(size_t pointerIndex) const {
430         return getAxisValue(AMOTION_EVENT_AXIS_SIZE, pointerIndex);
431     }
432 
getTouchMajor(size_t pointerIndex)433     inline float getTouchMajor(size_t pointerIndex) const {
434         return getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, pointerIndex);
435     }
436 
getTouchMinor(size_t pointerIndex)437     inline float getTouchMinor(size_t pointerIndex) const {
438         return getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, pointerIndex);
439     }
440 
getToolMajor(size_t pointerIndex)441     inline float getToolMajor(size_t pointerIndex) const {
442         return getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, pointerIndex);
443     }
444 
getToolMinor(size_t pointerIndex)445     inline float getToolMinor(size_t pointerIndex) const {
446         return getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, pointerIndex);
447     }
448 
getOrientation(size_t pointerIndex)449     inline float getOrientation(size_t pointerIndex) const {
450         return getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, pointerIndex);
451     }
452 
getHistorySize()453     inline size_t getHistorySize() const { return mSampleEventTimes.size() - 1; }
454 
getHistoricalEventTime(size_t historicalIndex)455     inline nsecs_t getHistoricalEventTime(size_t historicalIndex) const {
456         return mSampleEventTimes[historicalIndex];
457     }
458 
459     const PointerCoords* getHistoricalRawPointerCoords(
460             size_t pointerIndex, size_t historicalIndex) const;
461 
462     float getHistoricalRawAxisValue(int32_t axis, size_t pointerIndex,
463             size_t historicalIndex) const;
464 
getHistoricalRawX(size_t pointerIndex,size_t historicalIndex)465     inline float getHistoricalRawX(size_t pointerIndex, size_t historicalIndex) const {
466         return getHistoricalRawAxisValue(
467                 AMOTION_EVENT_AXIS_X, pointerIndex, historicalIndex);
468     }
469 
getHistoricalRawY(size_t pointerIndex,size_t historicalIndex)470     inline float getHistoricalRawY(size_t pointerIndex, size_t historicalIndex) const {
471         return getHistoricalRawAxisValue(
472                 AMOTION_EVENT_AXIS_Y, pointerIndex, historicalIndex);
473     }
474 
475     float getHistoricalAxisValue(int32_t axis, size_t pointerIndex, size_t historicalIndex) const;
476 
getHistoricalX(size_t pointerIndex,size_t historicalIndex)477     inline float getHistoricalX(size_t pointerIndex, size_t historicalIndex) const {
478         return getHistoricalAxisValue(
479                 AMOTION_EVENT_AXIS_X, pointerIndex, historicalIndex);
480     }
481 
getHistoricalY(size_t pointerIndex,size_t historicalIndex)482     inline float getHistoricalY(size_t pointerIndex, size_t historicalIndex) const {
483         return getHistoricalAxisValue(
484                 AMOTION_EVENT_AXIS_Y, pointerIndex, historicalIndex);
485     }
486 
getHistoricalPressure(size_t pointerIndex,size_t historicalIndex)487     inline float getHistoricalPressure(size_t pointerIndex, size_t historicalIndex) const {
488         return getHistoricalAxisValue(
489                 AMOTION_EVENT_AXIS_PRESSURE, pointerIndex, historicalIndex);
490     }
491 
getHistoricalSize(size_t pointerIndex,size_t historicalIndex)492     inline float getHistoricalSize(size_t pointerIndex, size_t historicalIndex) const {
493         return getHistoricalAxisValue(
494                 AMOTION_EVENT_AXIS_SIZE, pointerIndex, historicalIndex);
495     }
496 
getHistoricalTouchMajor(size_t pointerIndex,size_t historicalIndex)497     inline float getHistoricalTouchMajor(size_t pointerIndex, size_t historicalIndex) const {
498         return getHistoricalAxisValue(
499                 AMOTION_EVENT_AXIS_TOUCH_MAJOR, pointerIndex, historicalIndex);
500     }
501 
getHistoricalTouchMinor(size_t pointerIndex,size_t historicalIndex)502     inline float getHistoricalTouchMinor(size_t pointerIndex, size_t historicalIndex) const {
503         return getHistoricalAxisValue(
504                 AMOTION_EVENT_AXIS_TOUCH_MINOR, pointerIndex, historicalIndex);
505     }
506 
getHistoricalToolMajor(size_t pointerIndex,size_t historicalIndex)507     inline float getHistoricalToolMajor(size_t pointerIndex, size_t historicalIndex) const {
508         return getHistoricalAxisValue(
509                 AMOTION_EVENT_AXIS_TOOL_MAJOR, pointerIndex, historicalIndex);
510     }
511 
getHistoricalToolMinor(size_t pointerIndex,size_t historicalIndex)512     inline float getHistoricalToolMinor(size_t pointerIndex, size_t historicalIndex) const {
513         return getHistoricalAxisValue(
514                 AMOTION_EVENT_AXIS_TOOL_MINOR, pointerIndex, historicalIndex);
515     }
516 
getHistoricalOrientation(size_t pointerIndex,size_t historicalIndex)517     inline float getHistoricalOrientation(size_t pointerIndex, size_t historicalIndex) const {
518         return getHistoricalAxisValue(
519                 AMOTION_EVENT_AXIS_ORIENTATION, pointerIndex, historicalIndex);
520     }
521 
522     ssize_t findPointerIndex(int32_t pointerId) const;
523 
524     void initialize(
525             int32_t deviceId,
526             int32_t source,
527             int32_t action,
528             int32_t flags,
529             int32_t edgeFlags,
530             int32_t metaState,
531             int32_t buttonState,
532             float xOffset,
533             float yOffset,
534             float xPrecision,
535             float yPrecision,
536             nsecs_t downTime,
537             nsecs_t eventTime,
538             size_t pointerCount,
539             const PointerProperties* pointerProperties,
540             const PointerCoords* pointerCoords);
541 
542     void copyFrom(const MotionEvent* other, bool keepHistory);
543 
544     void addSample(
545             nsecs_t eventTime,
546             const PointerCoords* pointerCoords);
547 
548     void offsetLocation(float xOffset, float yOffset);
549 
550     void scale(float scaleFactor);
551 
552     // Apply 3x3 perspective matrix transformation.
553     // Matrix is in row-major form and compatible with SkMatrix.
554     void transform(const float matrix[9]);
555 
556 #ifdef HAVE_ANDROID_OS
557     status_t readFromParcel(Parcel* parcel);
558     status_t writeToParcel(Parcel* parcel) const;
559 #endif
560 
561     static bool isTouchEvent(int32_t source, int32_t action);
isTouchEvent()562     inline bool isTouchEvent() const {
563         return isTouchEvent(mSource, mAction);
564     }
565 
566     // Low-level accessors.
getPointerProperties()567     inline const PointerProperties* getPointerProperties() const {
568         return mPointerProperties.array();
569     }
getSampleEventTimes()570     inline const nsecs_t* getSampleEventTimes() const { return mSampleEventTimes.array(); }
getSamplePointerCoords()571     inline const PointerCoords* getSamplePointerCoords() const {
572             return mSamplePointerCoords.array();
573     }
574 
575     static const char* getLabel(int32_t axis);
576     static int32_t getAxisFromLabel(const char* label);
577 
578 protected:
579     int32_t mAction;
580     int32_t mFlags;
581     int32_t mEdgeFlags;
582     int32_t mMetaState;
583     int32_t mButtonState;
584     float mXOffset;
585     float mYOffset;
586     float mXPrecision;
587     float mYPrecision;
588     nsecs_t mDownTime;
589     Vector<PointerProperties> mPointerProperties;
590     Vector<nsecs_t> mSampleEventTimes;
591     Vector<PointerCoords> mSamplePointerCoords;
592 };
593 
594 /*
595  * Input event factory.
596  */
597 class InputEventFactoryInterface {
598 protected:
~InputEventFactoryInterface()599     virtual ~InputEventFactoryInterface() { }
600 
601 public:
InputEventFactoryInterface()602     InputEventFactoryInterface() { }
603 
604     virtual KeyEvent* createKeyEvent() = 0;
605     virtual MotionEvent* createMotionEvent() = 0;
606 };
607 
608 /*
609  * A simple input event factory implementation that uses a single preallocated instance
610  * of each type of input event that are reused for each request.
611  */
612 class PreallocatedInputEventFactory : public InputEventFactoryInterface {
613 public:
PreallocatedInputEventFactory()614     PreallocatedInputEventFactory() { }
~PreallocatedInputEventFactory()615     virtual ~PreallocatedInputEventFactory() { }
616 
createKeyEvent()617     virtual KeyEvent* createKeyEvent() { return & mKeyEvent; }
createMotionEvent()618     virtual MotionEvent* createMotionEvent() { return & mMotionEvent; }
619 
620 private:
621     KeyEvent mKeyEvent;
622     MotionEvent mMotionEvent;
623 };
624 
625 /*
626  * An input event factory implementation that maintains a pool of input events.
627  */
628 class PooledInputEventFactory : public InputEventFactoryInterface {
629 public:
630     PooledInputEventFactory(size_t maxPoolSize = 20);
631     virtual ~PooledInputEventFactory();
632 
633     virtual KeyEvent* createKeyEvent();
634     virtual MotionEvent* createMotionEvent();
635 
636     void recycle(InputEvent* event);
637 
638 private:
639     const size_t mMaxPoolSize;
640 
641     Vector<KeyEvent*> mKeyEventPool;
642     Vector<MotionEvent*> mMotionEventPool;
643 };
644 
645 } // namespace android
646 
647 #endif // _LIBINPUT_INPUT_H
648