Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (C) 2011 The Android Open Source Project |
michael@0 | 3 | * |
michael@0 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
michael@0 | 5 | * you may not use this file except in compliance with the License. |
michael@0 | 6 | * You may obtain a copy of the License at |
michael@0 | 7 | * |
michael@0 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 9 | * |
michael@0 | 10 | * Unless required by applicable law or agreed to in writing, software |
michael@0 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
michael@0 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
michael@0 | 13 | * See the License for the specific language governing permissions and |
michael@0 | 14 | * limitations under the License. |
michael@0 | 15 | */ |
michael@0 | 16 | |
michael@0 | 17 | #ifndef _UI_INPUT_LISTENER_H |
michael@0 | 18 | #define _UI_INPUT_LISTENER_H |
michael@0 | 19 | |
michael@0 | 20 | #include "Input.h" |
michael@0 | 21 | #include <utils/RefBase.h> |
michael@0 | 22 | #include <utils/Vector.h> |
michael@0 | 23 | |
michael@0 | 24 | namespace android { |
michael@0 | 25 | |
michael@0 | 26 | class InputListenerInterface; |
michael@0 | 27 | |
michael@0 | 28 | |
michael@0 | 29 | /* Superclass of all input event argument objects */ |
michael@0 | 30 | struct NotifyArgs { |
michael@0 | 31 | virtual ~NotifyArgs() { } |
michael@0 | 32 | |
michael@0 | 33 | virtual void notify(const sp<InputListenerInterface>& listener) const = 0; |
michael@0 | 34 | }; |
michael@0 | 35 | |
michael@0 | 36 | |
michael@0 | 37 | /* Describes a configuration change event. */ |
michael@0 | 38 | struct NotifyConfigurationChangedArgs : public NotifyArgs { |
michael@0 | 39 | nsecs_t eventTime; |
michael@0 | 40 | |
michael@0 | 41 | inline NotifyConfigurationChangedArgs() { } |
michael@0 | 42 | |
michael@0 | 43 | NotifyConfigurationChangedArgs(nsecs_t eventTime); |
michael@0 | 44 | |
michael@0 | 45 | NotifyConfigurationChangedArgs(const NotifyConfigurationChangedArgs& other); |
michael@0 | 46 | |
michael@0 | 47 | virtual ~NotifyConfigurationChangedArgs() { } |
michael@0 | 48 | |
michael@0 | 49 | virtual void notify(const sp<InputListenerInterface>& listener) const; |
michael@0 | 50 | }; |
michael@0 | 51 | |
michael@0 | 52 | |
michael@0 | 53 | /* Describes a key event. */ |
michael@0 | 54 | struct NotifyKeyArgs : public NotifyArgs { |
michael@0 | 55 | nsecs_t eventTime; |
michael@0 | 56 | int32_t deviceId; |
michael@0 | 57 | uint32_t source; |
michael@0 | 58 | uint32_t policyFlags; |
michael@0 | 59 | int32_t action; |
michael@0 | 60 | int32_t flags; |
michael@0 | 61 | int32_t keyCode; |
michael@0 | 62 | int32_t scanCode; |
michael@0 | 63 | int32_t metaState; |
michael@0 | 64 | nsecs_t downTime; |
michael@0 | 65 | |
michael@0 | 66 | inline NotifyKeyArgs() { } |
michael@0 | 67 | |
michael@0 | 68 | NotifyKeyArgs(nsecs_t eventTime, int32_t deviceId, uint32_t source, uint32_t policyFlags, |
michael@0 | 69 | int32_t action, int32_t flags, int32_t keyCode, int32_t scanCode, |
michael@0 | 70 | int32_t metaState, nsecs_t downTime); |
michael@0 | 71 | |
michael@0 | 72 | NotifyKeyArgs(const NotifyKeyArgs& other); |
michael@0 | 73 | |
michael@0 | 74 | virtual ~NotifyKeyArgs() { } |
michael@0 | 75 | |
michael@0 | 76 | virtual void notify(const sp<InputListenerInterface>& listener) const; |
michael@0 | 77 | }; |
michael@0 | 78 | |
michael@0 | 79 | |
michael@0 | 80 | /* Describes a motion event. */ |
michael@0 | 81 | struct NotifyMotionArgs : public NotifyArgs { |
michael@0 | 82 | nsecs_t eventTime; |
michael@0 | 83 | int32_t deviceId; |
michael@0 | 84 | uint32_t source; |
michael@0 | 85 | uint32_t policyFlags; |
michael@0 | 86 | int32_t action; |
michael@0 | 87 | int32_t flags; |
michael@0 | 88 | int32_t metaState; |
michael@0 | 89 | int32_t buttonState; |
michael@0 | 90 | int32_t edgeFlags; |
michael@0 | 91 | int32_t displayId; |
michael@0 | 92 | uint32_t pointerCount; |
michael@0 | 93 | PointerProperties pointerProperties[MAX_POINTERS]; |
michael@0 | 94 | PointerCoords pointerCoords[MAX_POINTERS]; |
michael@0 | 95 | float xPrecision; |
michael@0 | 96 | float yPrecision; |
michael@0 | 97 | nsecs_t downTime; |
michael@0 | 98 | |
michael@0 | 99 | inline NotifyMotionArgs() { } |
michael@0 | 100 | |
michael@0 | 101 | NotifyMotionArgs(nsecs_t eventTime, int32_t deviceId, uint32_t source, uint32_t policyFlags, |
michael@0 | 102 | int32_t action, int32_t flags, int32_t metaState, int32_t buttonState, |
michael@0 | 103 | int32_t edgeFlags, int32_t displayId, uint32_t pointerCount, |
michael@0 | 104 | const PointerProperties* pointerProperties, const PointerCoords* pointerCoords, |
michael@0 | 105 | float xPrecision, float yPrecision, nsecs_t downTime); |
michael@0 | 106 | |
michael@0 | 107 | NotifyMotionArgs(const NotifyMotionArgs& other); |
michael@0 | 108 | |
michael@0 | 109 | virtual ~NotifyMotionArgs() { } |
michael@0 | 110 | |
michael@0 | 111 | virtual void notify(const sp<InputListenerInterface>& listener) const; |
michael@0 | 112 | }; |
michael@0 | 113 | |
michael@0 | 114 | |
michael@0 | 115 | /* Describes a switch event. */ |
michael@0 | 116 | struct NotifySwitchArgs : public NotifyArgs { |
michael@0 | 117 | nsecs_t eventTime; |
michael@0 | 118 | uint32_t policyFlags; |
michael@0 | 119 | uint32_t switchValues; |
michael@0 | 120 | uint32_t switchMask; |
michael@0 | 121 | |
michael@0 | 122 | inline NotifySwitchArgs() { } |
michael@0 | 123 | |
michael@0 | 124 | NotifySwitchArgs(nsecs_t eventTime, uint32_t policyFlags, |
michael@0 | 125 | uint32_t switchValues, uint32_t switchMask); |
michael@0 | 126 | |
michael@0 | 127 | NotifySwitchArgs(const NotifySwitchArgs& other); |
michael@0 | 128 | |
michael@0 | 129 | virtual ~NotifySwitchArgs() { } |
michael@0 | 130 | |
michael@0 | 131 | virtual void notify(const sp<InputListenerInterface>& listener) const; |
michael@0 | 132 | }; |
michael@0 | 133 | |
michael@0 | 134 | |
michael@0 | 135 | /* Describes a device reset event, such as when a device is added, |
michael@0 | 136 | * reconfigured, or removed. */ |
michael@0 | 137 | struct NotifyDeviceResetArgs : public NotifyArgs { |
michael@0 | 138 | nsecs_t eventTime; |
michael@0 | 139 | int32_t deviceId; |
michael@0 | 140 | |
michael@0 | 141 | inline NotifyDeviceResetArgs() { } |
michael@0 | 142 | |
michael@0 | 143 | NotifyDeviceResetArgs(nsecs_t eventTime, int32_t deviceId); |
michael@0 | 144 | |
michael@0 | 145 | NotifyDeviceResetArgs(const NotifyDeviceResetArgs& other); |
michael@0 | 146 | |
michael@0 | 147 | virtual ~NotifyDeviceResetArgs() { } |
michael@0 | 148 | |
michael@0 | 149 | virtual void notify(const sp<InputListenerInterface>& listener) const; |
michael@0 | 150 | }; |
michael@0 | 151 | |
michael@0 | 152 | |
michael@0 | 153 | /* |
michael@0 | 154 | * The interface used by the InputReader to notify the InputListener about input events. |
michael@0 | 155 | */ |
michael@0 | 156 | class InputListenerInterface : public virtual RefBase { |
michael@0 | 157 | protected: |
michael@0 | 158 | InputListenerInterface() { } |
michael@0 | 159 | virtual ~InputListenerInterface() { } |
michael@0 | 160 | |
michael@0 | 161 | public: |
michael@0 | 162 | virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) = 0; |
michael@0 | 163 | virtual void notifyKey(const NotifyKeyArgs* args) = 0; |
michael@0 | 164 | virtual void notifyMotion(const NotifyMotionArgs* args) = 0; |
michael@0 | 165 | virtual void notifySwitch(const NotifySwitchArgs* args) = 0; |
michael@0 | 166 | virtual void notifyDeviceReset(const NotifyDeviceResetArgs* args) = 0; |
michael@0 | 167 | }; |
michael@0 | 168 | |
michael@0 | 169 | |
michael@0 | 170 | /* |
michael@0 | 171 | * An implementation of the listener interface that queues up and defers dispatch |
michael@0 | 172 | * of decoded events until flushed. |
michael@0 | 173 | */ |
michael@0 | 174 | class QueuedInputListener : public InputListenerInterface { |
michael@0 | 175 | protected: |
michael@0 | 176 | virtual ~QueuedInputListener(); |
michael@0 | 177 | |
michael@0 | 178 | public: |
michael@0 | 179 | QueuedInputListener(const sp<InputListenerInterface>& innerListener); |
michael@0 | 180 | |
michael@0 | 181 | virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args); |
michael@0 | 182 | virtual void notifyKey(const NotifyKeyArgs* args); |
michael@0 | 183 | virtual void notifyMotion(const NotifyMotionArgs* args); |
michael@0 | 184 | virtual void notifySwitch(const NotifySwitchArgs* args); |
michael@0 | 185 | virtual void notifyDeviceReset(const NotifyDeviceResetArgs* args); |
michael@0 | 186 | |
michael@0 | 187 | void flush(); |
michael@0 | 188 | |
michael@0 | 189 | private: |
michael@0 | 190 | sp<InputListenerInterface> mInnerListener; |
michael@0 | 191 | Vector<NotifyArgs*> mArgsQueue; |
michael@0 | 192 | }; |
michael@0 | 193 | |
michael@0 | 194 | } // namespace android |
michael@0 | 195 | |
michael@0 | 196 | #endif // _UI_INPUT_LISTENER_H |