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