widget/gonk/libui/InputListener.h

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     1 /*
     2  * Copyright (C) 2011 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  */
    17 #ifndef _UI_INPUT_LISTENER_H
    18 #define _UI_INPUT_LISTENER_H
    20 #include "Input.h"
    21 #include <utils/RefBase.h>
    22 #include <utils/Vector.h>
    24 namespace android {
    26 class InputListenerInterface;
    29 /* Superclass of all input event argument objects */
    30 struct NotifyArgs {
    31     virtual ~NotifyArgs() { }
    33     virtual void notify(const sp<InputListenerInterface>& listener) const = 0;
    34 };
    37 /* Describes a configuration change event. */
    38 struct NotifyConfigurationChangedArgs : public NotifyArgs {
    39     nsecs_t eventTime;
    41     inline NotifyConfigurationChangedArgs() { }
    43     NotifyConfigurationChangedArgs(nsecs_t eventTime);
    45     NotifyConfigurationChangedArgs(const NotifyConfigurationChangedArgs& other);
    47     virtual ~NotifyConfigurationChangedArgs() { }
    49     virtual void notify(const sp<InputListenerInterface>& listener) const;
    50 };
    53 /* Describes a key event. */
    54 struct NotifyKeyArgs : public NotifyArgs {
    55     nsecs_t eventTime;
    56     int32_t deviceId;
    57     uint32_t source;
    58     uint32_t policyFlags;
    59     int32_t action;
    60     int32_t flags;
    61     int32_t keyCode;
    62     int32_t scanCode;
    63     int32_t metaState;
    64     nsecs_t downTime;
    66     inline NotifyKeyArgs() { }
    68     NotifyKeyArgs(nsecs_t eventTime, int32_t deviceId, uint32_t source, uint32_t policyFlags,
    69             int32_t action, int32_t flags, int32_t keyCode, int32_t scanCode,
    70             int32_t metaState, nsecs_t downTime);
    72     NotifyKeyArgs(const NotifyKeyArgs& other);
    74     virtual ~NotifyKeyArgs() { }
    76     virtual void notify(const sp<InputListenerInterface>& listener) const;
    77 };
    80 /* Describes a motion event. */
    81 struct NotifyMotionArgs : public NotifyArgs {
    82     nsecs_t eventTime;
    83     int32_t deviceId;
    84     uint32_t source;
    85     uint32_t policyFlags;
    86     int32_t action;
    87     int32_t flags;
    88     int32_t metaState;
    89     int32_t buttonState;
    90     int32_t edgeFlags;
    91     int32_t displayId;
    92     uint32_t pointerCount;
    93     PointerProperties pointerProperties[MAX_POINTERS];
    94     PointerCoords pointerCoords[MAX_POINTERS];
    95     float xPrecision;
    96     float yPrecision;
    97     nsecs_t downTime;
    99     inline NotifyMotionArgs() { }
   101     NotifyMotionArgs(nsecs_t eventTime, int32_t deviceId, uint32_t source, uint32_t policyFlags,
   102             int32_t action, int32_t flags, int32_t metaState, int32_t buttonState,
   103             int32_t edgeFlags, int32_t displayId, uint32_t pointerCount,
   104             const PointerProperties* pointerProperties, const PointerCoords* pointerCoords,
   105             float xPrecision, float yPrecision, nsecs_t downTime);
   107     NotifyMotionArgs(const NotifyMotionArgs& other);
   109     virtual ~NotifyMotionArgs() { }
   111     virtual void notify(const sp<InputListenerInterface>& listener) const;
   112 };
   115 /* Describes a switch event. */
   116 struct NotifySwitchArgs : public NotifyArgs {
   117     nsecs_t eventTime;
   118     uint32_t policyFlags;
   119     uint32_t switchValues;
   120     uint32_t switchMask;
   122     inline NotifySwitchArgs() { }
   124     NotifySwitchArgs(nsecs_t eventTime, uint32_t policyFlags,
   125             uint32_t switchValues, uint32_t switchMask);
   127     NotifySwitchArgs(const NotifySwitchArgs& other);
   129     virtual ~NotifySwitchArgs() { }
   131     virtual void notify(const sp<InputListenerInterface>& listener) const;
   132 };
   135 /* Describes a device reset event, such as when a device is added,
   136  * reconfigured, or removed. */
   137 struct NotifyDeviceResetArgs : public NotifyArgs {
   138     nsecs_t eventTime;
   139     int32_t deviceId;
   141     inline NotifyDeviceResetArgs() { }
   143     NotifyDeviceResetArgs(nsecs_t eventTime, int32_t deviceId);
   145     NotifyDeviceResetArgs(const NotifyDeviceResetArgs& other);
   147     virtual ~NotifyDeviceResetArgs() { }
   149     virtual void notify(const sp<InputListenerInterface>& listener) const;
   150 };
   153 /*
   154  * The interface used by the InputReader to notify the InputListener about input events.
   155  */
   156 class InputListenerInterface : public virtual RefBase {
   157 protected:
   158     InputListenerInterface() { }
   159     virtual ~InputListenerInterface() { }
   161 public:
   162     virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) = 0;
   163     virtual void notifyKey(const NotifyKeyArgs* args) = 0;
   164     virtual void notifyMotion(const NotifyMotionArgs* args) = 0;
   165     virtual void notifySwitch(const NotifySwitchArgs* args) = 0;
   166     virtual void notifyDeviceReset(const NotifyDeviceResetArgs* args) = 0;
   167 };
   170 /*
   171  * An implementation of the listener interface that queues up and defers dispatch
   172  * of decoded events until flushed.
   173  */
   174 class QueuedInputListener : public InputListenerInterface {
   175 protected:
   176     virtual ~QueuedInputListener();
   178 public:
   179     QueuedInputListener(const sp<InputListenerInterface>& innerListener);
   181     virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args);
   182     virtual void notifyKey(const NotifyKeyArgs* args);
   183     virtual void notifyMotion(const NotifyMotionArgs* args);
   184     virtual void notifySwitch(const NotifySwitchArgs* args);
   185     virtual void notifyDeviceReset(const NotifyDeviceResetArgs* args);
   187     void flush();
   189 private:
   190     sp<InputListenerInterface> mInnerListener;
   191     Vector<NotifyArgs*> mArgsQueue;
   192 };
   194 } // namespace android
   196 #endif // _UI_INPUT_LISTENER_H

mercurial