xref: /aosp_15_r20/frameworks/native/services/inputflinger/reader/mapper/InputMapper.cpp (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
1 /*
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 #include "../Macros.h"
18 
19 #include "InputMapper.h"
20 
21 #include <optional>
22 #include <sstream>
23 
24 #include <ftl/enum.h>
25 
26 #include "InputDevice.h"
27 #include "input/PrintTools.h"
28 
29 namespace android {
30 
InputMapper(InputDeviceContext & deviceContext,const InputReaderConfiguration & readerConfig)31 InputMapper::InputMapper(InputDeviceContext& deviceContext,
32                          const InputReaderConfiguration& readerConfig)
33       : mDeviceContext(deviceContext) {}
34 
~InputMapper()35 InputMapper::~InputMapper() {}
36 
populateDeviceInfo(InputDeviceInfo & info)37 void InputMapper::populateDeviceInfo(InputDeviceInfo& info) {
38     info.addSource(getSources());
39 }
40 
dump(std::string & dump)41 void InputMapper::dump(std::string& dump) {}
42 
reconfigure(nsecs_t when,const InputReaderConfiguration & config,ConfigurationChanges changes)43 std::list<NotifyArgs> InputMapper::reconfigure(nsecs_t when, const InputReaderConfiguration& config,
44                                                ConfigurationChanges changes) {
45     return {};
46 }
47 
reset(nsecs_t when)48 std::list<NotifyArgs> InputMapper::reset(nsecs_t when) {
49     return {};
50 }
51 
timeoutExpired(nsecs_t when)52 std::list<NotifyArgs> InputMapper::timeoutExpired(nsecs_t when) {
53     return {};
54 }
55 
getKeyCodeState(uint32_t sourceMask,int32_t keyCode)56 int32_t InputMapper::getKeyCodeState(uint32_t sourceMask, int32_t keyCode) {
57     return AKEY_STATE_UNKNOWN;
58 }
59 
getScanCodeState(uint32_t sourceMask,int32_t scanCode)60 int32_t InputMapper::getScanCodeState(uint32_t sourceMask, int32_t scanCode) {
61     return AKEY_STATE_UNKNOWN;
62 }
63 
getSwitchState(uint32_t sourceMask,int32_t switchCode)64 int32_t InputMapper::getSwitchState(uint32_t sourceMask, int32_t switchCode) {
65     return AKEY_STATE_UNKNOWN;
66 }
67 
getKeyCodeForKeyLocation(int32_t locationKeyCode) const68 int32_t InputMapper::getKeyCodeForKeyLocation(int32_t locationKeyCode) const {
69     return AKEYCODE_UNKNOWN;
70 }
71 
markSupportedKeyCodes(uint32_t sourceMask,const std::vector<int32_t> & keyCodes,uint8_t * outFlags)72 bool InputMapper::markSupportedKeyCodes(uint32_t sourceMask, const std::vector<int32_t>& keyCodes,
73                                         uint8_t* outFlags) {
74     return false;
75 }
76 
vibrate(const VibrationSequence & sequence,ssize_t repeat,int32_t token)77 std::list<NotifyArgs> InputMapper::vibrate(const VibrationSequence& sequence, ssize_t repeat,
78                                            int32_t token) {
79     return {};
80 }
81 
cancelVibrate(int32_t token)82 std::list<NotifyArgs> InputMapper::cancelVibrate(int32_t token) {
83     return {};
84 }
85 
isVibrating()86 bool InputMapper::isVibrating() {
87     return false;
88 }
89 
getVibratorIds()90 std::vector<int32_t> InputMapper::getVibratorIds() {
91     return {};
92 }
93 
cancelTouch(nsecs_t when,nsecs_t readTime)94 std::list<NotifyArgs> InputMapper::cancelTouch(nsecs_t when, nsecs_t readTime) {
95     return {};
96 }
97 
enableSensor(InputDeviceSensorType sensorType,std::chrono::microseconds samplingPeriod,std::chrono::microseconds maxBatchReportLatency)98 bool InputMapper::enableSensor(InputDeviceSensorType sensorType,
99                                std::chrono::microseconds samplingPeriod,
100                                std::chrono::microseconds maxBatchReportLatency) {
101     return true;
102 }
103 
disableSensor(InputDeviceSensorType sensorType)104 void InputMapper::disableSensor(InputDeviceSensorType sensorType) {}
105 
flushSensor(InputDeviceSensorType sensorType)106 void InputMapper::flushSensor(InputDeviceSensorType sensorType) {}
107 
getMetaState()108 int32_t InputMapper::getMetaState() {
109     return 0;
110 }
111 
updateExternalStylusState(const StylusState & state)112 std::list<NotifyArgs> InputMapper::updateExternalStylusState(const StylusState& state) {
113     return {};
114 }
115 
getAbsoluteAxisInfo(int32_t axis)116 std::optional<RawAbsoluteAxisInfo> InputMapper::getAbsoluteAxisInfo(int32_t axis) {
117     return getDeviceContext().getAbsoluteAxisInfo(axis);
118 }
119 
bumpGeneration()120 void InputMapper::bumpGeneration() {
121     getDeviceContext().bumpGeneration();
122 }
123 
dumpRawAbsoluteAxisInfo(std::string & dump,const std::optional<RawAbsoluteAxisInfo> & axis,const char * name)124 void InputMapper::dumpRawAbsoluteAxisInfo(std::string& dump,
125                                           const std::optional<RawAbsoluteAxisInfo>& axis,
126                                           const char* name) {
127     std::stringstream out;
128     out << INDENT4 << name << ": " << axis << "\n";
129     dump += out.str();
130 }
131 
dumpStylusState(std::string & dump,const StylusState & state)132 void InputMapper::dumpStylusState(std::string& dump, const StylusState& state) {
133     dump += StringPrintf(INDENT4 "When: %" PRId64 "\n", state.when);
134     dump += StringPrintf(INDENT4 "Pressure: %s\n", toString(state.pressure).c_str());
135     dump += StringPrintf(INDENT4 "Button State: 0x%08x\n", state.buttons);
136     dump += StringPrintf(INDENT4 "Tool Type: %s\n", ftl::enum_string(state.toolType).c_str());
137 }
138 
getTouchpadHardwareProperties()139 std::optional<HardwareProperties> InputMapper::getTouchpadHardwareProperties() {
140     return std::nullopt;
141 }
142 } // namespace android
143