blob: e6ea523c4f92e03e68834ddbe7c1637da13ac831 [file] [log] [blame]
Prabir Pradhanbaa5c822019-08-30 15:27:05 -07001/*
2 * Copyright (C) 2019 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 _UI_INPUTREADER_INPUT_READER_CONTEXT_H
18#define _UI_INPUTREADER_INPUT_READER_CONTEXT_H
19
20#include <input/InputDevice.h>
21
22#include <vector>
23
24namespace android {
25
26class EventHubInterface;
27class InputDevice;
28class InputListenerInterface;
29class InputMapper;
30class InputReaderPolicyInterface;
Prabir Pradhanc7ef27e2020-02-03 19:19:15 -080031class PointerControllerInterface;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070032struct StylusState;
33
34/* Internal interface used by individual input devices to access global input device state
35 * and parameters maintained by the input reader.
36 */
37class InputReaderContext {
38public:
39 InputReaderContext() {}
40 virtual ~InputReaderContext() {}
41
42 virtual void updateGlobalMetaState() = 0;
43 virtual int32_t getGlobalMetaState() = 0;
44
45 virtual void disableVirtualKeysUntil(nsecs_t time) = 0;
Nathaniel R. Lewis26ec2222020-01-10 16:30:54 -080046 virtual bool shouldDropVirtualKey(nsecs_t now, int32_t keyCode, int32_t scanCode) = 0;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070047
48 virtual void fadePointer() = 0;
Michael Wright17db18e2020-06-26 20:51:44 +010049 virtual std::shared_ptr<PointerControllerInterface> getPointerController(int32_t deviceId) = 0;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070050
51 virtual void requestTimeoutAtTime(nsecs_t when) = 0;
52 virtual int32_t bumpGeneration() = 0;
53
54 virtual void getExternalStylusDevices(std::vector<InputDeviceInfo>& outDevices) = 0;
55 virtual void dispatchExternalStylusState(const StylusState& outState) = 0;
56
57 virtual InputReaderPolicyInterface* getPolicy() = 0;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070058 virtual EventHubInterface* getEventHub() = 0;
59
arthurhungc903df12020-08-11 15:08:42 +080060 virtual void updateLedMetaState(int32_t metaState) = 0;
61 virtual int32_t getLedMetaState() = 0;
Siarhei Vishniakoucec3f6a2020-11-10 15:42:39 -060062
63 // Send events to InputListener interface
64
65 virtual void notifyConfigurationChanged(nsecs_t when) = 0;
66 virtual void notifyKey(nsecs_t eventTime, int32_t deviceId, uint32_t source, int32_t displayId,
67 uint32_t policyFlags, int32_t action, int32_t flags, int32_t keyCode,
68 int32_t scanCode, int32_t metaState, nsecs_t downTime) = 0;
69 virtual void notifyMotion(nsecs_t eventTime, int32_t deviceId, uint32_t source,
70 int32_t displayId, uint32_t policyFlags, int32_t action,
71 int32_t actionButton, int32_t flags, int32_t metaState,
72 int32_t buttonState, MotionClassification classification,
73 int32_t edgeFlags, uint32_t pointerCount,
74 const PointerProperties* pointerProperties,
75 const PointerCoords* pointerCoords, float xPrecision,
76 float yPrecision, float xCursorPosition, float yCursorPosition,
77 nsecs_t downTime,
78 const std::vector<TouchVideoFrame>& videoFrames) = 0;
79 virtual void notifySwitch(nsecs_t eventTime, uint32_t switchValues, uint32_t switchMask) = 0;
80 virtual void notifySensor(nsecs_t when, int32_t deviceId, InputDeviceSensorType sensorType,
81 InputDeviceSensorAccuracy accuracy, bool accuracyChanged,
82 nsecs_t timestamp, std::vector<float> values) = 0;
Chris Yefb552902021-02-03 17:18:37 -080083 virtual void notifyVibratorState(nsecs_t when, int32_t deviceId, bool isOn) = 0;
Siarhei Vishniakoucec3f6a2020-11-10 15:42:39 -060084 virtual void notifyDeviceReset(nsecs_t when, int32_t deviceId) = 0;
85 virtual void notifyPointerCaptureChanged(nsecs_t when, bool hasCapture) = 0;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070086};
87
88} // namespace android
89
90#endif // _UI_INPUTREADER_INPUT_READER_CONTEXT_H