InputEvent.java revision c5ed5910c9ef066cec6a13bbb404ec57b1e92637
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
17package android.view;
18
19import android.os.Parcelable;
20
21/**
22 * Common base class for input events.
23 */
24public abstract class InputEvent implements Parcelable {
25    protected int mDeviceId;
26    protected int mSource;
27
28    /*package*/ InputEvent() {
29    }
30
31    /**
32     * Gets the id for the device that this event came from.  An id of
33     * zero indicates that the event didn't come from a physical device
34     * and maps to the default keymap.  The other numbers are arbitrary and
35     * you shouldn't depend on the values.
36     *
37     * @return The device id.
38     * @see InputDevice#getDevice
39     */
40    public final int getDeviceId() {
41        return mDeviceId;
42    }
43
44    /**
45     * Gets the source of the event.
46     *
47     * @return The event source or {@link InputDevice.SOURCE_UNKNOWN} if unknown.
48     * @see InputDevice#getSourceInfo
49     */
50    public final int getSource() {
51        return mSource;
52    }
53
54    /**
55     * Modifies the source of the event.
56     * @param source The source.
57     *
58     * @hide
59     */
60    public final void setSource(int source) {
61        mSource = source;
62    }
63}
64