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