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 "InputDevice.h"
22 
23 namespace android {
24 
InputMapper(InputDevice * device)25 InputMapper::InputMapper(InputDevice* device) : mDevice(device), mContext(device->getContext()) {}
26 
~InputMapper()27 InputMapper::~InputMapper() {}
28 
populateDeviceInfo(InputDeviceInfo * info)29 void InputMapper::populateDeviceInfo(InputDeviceInfo* info) {
30     info->addSource(getSources());
31 }
32 
dump(std::string & dump)33 void InputMapper::dump(std::string& dump) {}
34 
configure(nsecs_t when,const InputReaderConfiguration * config,uint32_t changes)35 void InputMapper::configure(nsecs_t when, const InputReaderConfiguration* config,
36                             uint32_t changes) {}
37 
reset(nsecs_t when)38 void InputMapper::reset(nsecs_t when) {}
39 
timeoutExpired(nsecs_t when)40 void InputMapper::timeoutExpired(nsecs_t when) {}
41 
getKeyCodeState(uint32_t sourceMask,int32_t keyCode)42 int32_t InputMapper::getKeyCodeState(uint32_t sourceMask, int32_t keyCode) {
43     return AKEY_STATE_UNKNOWN;
44 }
45 
getScanCodeState(uint32_t sourceMask,int32_t scanCode)46 int32_t InputMapper::getScanCodeState(uint32_t sourceMask, int32_t scanCode) {
47     return AKEY_STATE_UNKNOWN;
48 }
49 
getSwitchState(uint32_t sourceMask,int32_t switchCode)50 int32_t InputMapper::getSwitchState(uint32_t sourceMask, int32_t switchCode) {
51     return AKEY_STATE_UNKNOWN;
52 }
53 
markSupportedKeyCodes(uint32_t sourceMask,size_t numCodes,const int32_t * keyCodes,uint8_t * outFlags)54 bool InputMapper::markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes,
55                                         const int32_t* keyCodes, uint8_t* outFlags) {
56     return false;
57 }
58 
vibrate(const nsecs_t * pattern,size_t patternSize,ssize_t repeat,int32_t token)59 void InputMapper::vibrate(const nsecs_t* pattern, size_t patternSize, ssize_t repeat,
60                           int32_t token) {}
61 
cancelVibrate(int32_t token)62 void InputMapper::cancelVibrate(int32_t token) {}
63 
cancelTouch(nsecs_t when)64 void InputMapper::cancelTouch(nsecs_t when) {}
65 
getMetaState()66 int32_t InputMapper::getMetaState() {
67     return 0;
68 }
69 
updateMetaState(int32_t keyCode)70 void InputMapper::updateMetaState(int32_t keyCode) {}
71 
updateExternalStylusState(const StylusState & state)72 void InputMapper::updateExternalStylusState(const StylusState& state) {}
73 
fadePointer()74 void InputMapper::fadePointer() {}
75 
getAbsoluteAxisInfo(int32_t axis,RawAbsoluteAxisInfo * axisInfo)76 status_t InputMapper::getAbsoluteAxisInfo(int32_t axis, RawAbsoluteAxisInfo* axisInfo) {
77     return getEventHub()->getAbsoluteAxisInfo(getDeviceId(), axis, axisInfo);
78 }
79 
bumpGeneration()80 void InputMapper::bumpGeneration() {
81     mDevice->bumpGeneration();
82 }
83 
dumpRawAbsoluteAxisInfo(std::string & dump,const RawAbsoluteAxisInfo & axis,const char * name)84 void InputMapper::dumpRawAbsoluteAxisInfo(std::string& dump, const RawAbsoluteAxisInfo& axis,
85                                           const char* name) {
86     if (axis.valid) {
87         dump += StringPrintf(INDENT4 "%s: min=%d, max=%d, flat=%d, fuzz=%d, resolution=%d\n", name,
88                              axis.minValue, axis.maxValue, axis.flat, axis.fuzz, axis.resolution);
89     } else {
90         dump += StringPrintf(INDENT4 "%s: unknown range\n", name);
91     }
92 }
93 
dumpStylusState(std::string & dump,const StylusState & state)94 void InputMapper::dumpStylusState(std::string& dump, const StylusState& state) {
95     dump += StringPrintf(INDENT4 "When: %" PRId64 "\n", state.when);
96     dump += StringPrintf(INDENT4 "Pressure: %f\n", state.pressure);
97     dump += StringPrintf(INDENT4 "Button State: 0x%08x\n", state.buttons);
98     dump += StringPrintf(INDENT4 "Tool Type: %" PRId32 "\n", state.toolType);
99 }
100 
101 } // namespace android
102