blob: 627df7fb5b96cc535429463e6cd2813425074fc8 [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
Prabir Pradhan9244aea2020-02-05 20:31:40 -080017#include "../Macros.h"
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070018
19#include "InputMapper.h"
20
Prabir Pradhan132f21c2024-07-25 16:48:30 +000021#include <optional>
Harry Cuttsea73eaa2023-01-16 17:55:46 +000022#include <sstream>
23
Harry Cuttsc57cd3c2024-04-24 13:52:55 +000024#include <ftl/enum.h>
25
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070026#include "InputDevice.h"
Prabir Pradhan3f7545f2022-10-19 16:56:39 +000027#include "input/PrintTools.h"
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070028
29namespace android {
30
Arpit Singh8e6fb252023-04-06 11:49:17 +000031InputMapper::InputMapper(InputDeviceContext& deviceContext,
32 const InputReaderConfiguration& readerConfig)
33 : mDeviceContext(deviceContext) {}
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070034
35InputMapper::~InputMapper() {}
36
Harry Cuttsd02ea102023-03-17 18:21:30 +000037void InputMapper::populateDeviceInfo(InputDeviceInfo& info) {
38 info.addSource(getSources());
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070039}
40
41void InputMapper::dump(std::string& dump) {}
42
Arpit Singhed6c3de2023-04-05 19:24:37 +000043std::list<NotifyArgs> InputMapper::reconfigure(nsecs_t when, const InputReaderConfiguration& config,
Prabir Pradhan4bf6d452023-04-18 21:26:56 +000044 ConfigurationChanges changes) {
Siarhei Vishniakou2935db72022-09-22 13:35:22 -070045 return {};
46}
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070047
Siarhei Vishniakou2935db72022-09-22 13:35:22 -070048std::list<NotifyArgs> InputMapper::reset(nsecs_t when) {
49 return {};
50}
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070051
Siarhei Vishniakou2935db72022-09-22 13:35:22 -070052std::list<NotifyArgs> InputMapper::timeoutExpired(nsecs_t when) {
53 return {};
54}
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070055
56int32_t InputMapper::getKeyCodeState(uint32_t sourceMask, int32_t keyCode) {
57 return AKEY_STATE_UNKNOWN;
58}
59
60int32_t InputMapper::getScanCodeState(uint32_t sourceMask, int32_t scanCode) {
61 return AKEY_STATE_UNKNOWN;
62}
63
64int32_t InputMapper::getSwitchState(uint32_t sourceMask, int32_t switchCode) {
65 return AKEY_STATE_UNKNOWN;
66}
67
Philip Junker4af3b3d2021-12-14 10:36:55 +010068int32_t InputMapper::getKeyCodeForKeyLocation(int32_t locationKeyCode) const {
69 return AKEYCODE_UNKNOWN;
70}
71
Siarhei Vishniakou74007942022-06-13 13:57:47 -070072bool InputMapper::markSupportedKeyCodes(uint32_t sourceMask, const std::vector<int32_t>& keyCodes,
73 uint8_t* outFlags) {
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070074 return false;
75}
76
Siarhei Vishniakou2935db72022-09-22 13:35:22 -070077std::list<NotifyArgs> InputMapper::vibrate(const VibrationSequence& sequence, ssize_t repeat,
78 int32_t token) {
79 return {};
80}
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070081
Siarhei Vishniakou2935db72022-09-22 13:35:22 -070082std::list<NotifyArgs> InputMapper::cancelVibrate(int32_t token) {
83 return {};
84}
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070085
Chris Ye87143712020-11-10 05:05:58 +000086bool InputMapper::isVibrating() {
87 return false;
88}
89
90std::vector<int32_t> InputMapper::getVibratorIds() {
91 return {};
92}
93
Siarhei Vishniakou2935db72022-09-22 13:35:22 -070094std::list<NotifyArgs> InputMapper::cancelTouch(nsecs_t when, nsecs_t readTime) {
95 return {};
96}
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070097
Chris Yef59a2f42020-10-16 12:55:26 -070098bool InputMapper::enableSensor(InputDeviceSensorType sensorType,
99 std::chrono::microseconds samplingPeriod,
100 std::chrono::microseconds maxBatchReportLatency) {
101 return true;
102}
103
104void InputMapper::disableSensor(InputDeviceSensorType sensorType) {}
105
106void InputMapper::flushSensor(InputDeviceSensorType sensorType) {}
107
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700108int32_t InputMapper::getMetaState() {
109 return 0;
110}
111
Arthur Hungcb40a002021-08-03 14:31:01 +0000112bool InputMapper::updateMetaState(int32_t keyCode) {
113 return false;
114}
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700115
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700116std::list<NotifyArgs> InputMapper::updateExternalStylusState(const StylusState& state) {
117 return {};
118}
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700119
Prabir Pradhan132f21c2024-07-25 16:48:30 +0000120std::optional<RawAbsoluteAxisInfo> InputMapper::getAbsoluteAxisInfo(int32_t axis) {
121 return getDeviceContext().getAbsoluteAxisInfo(axis);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700122}
123
124void InputMapper::bumpGeneration() {
Nathaniel R. Lewis26ec2222020-01-10 16:30:54 -0800125 getDeviceContext().bumpGeneration();
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700126}
127
Prabir Pradhan132f21c2024-07-25 16:48:30 +0000128void InputMapper::dumpRawAbsoluteAxisInfo(std::string& dump,
129 const std::optional<RawAbsoluteAxisInfo>& axis,
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700130 const char* name) {
Harry Cuttsea73eaa2023-01-16 17:55:46 +0000131 std::stringstream out;
132 out << INDENT4 << name << ": " << axis << "\n";
133 dump += out.str();
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700134}
135
136void InputMapper::dumpStylusState(std::string& dump, const StylusState& state) {
137 dump += StringPrintf(INDENT4 "When: %" PRId64 "\n", state.when);
Prabir Pradhan3f7545f2022-10-19 16:56:39 +0000138 dump += StringPrintf(INDENT4 "Pressure: %s\n", toString(state.pressure).c_str());
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700139 dump += StringPrintf(INDENT4 "Button State: 0x%08x\n", state.buttons);
Harry Cuttsc57cd3c2024-04-24 13:52:55 +0000140 dump += StringPrintf(INDENT4 "Tool Type: %s\n", ftl::enum_string(state.toolType).c_str());
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700141}
142
Omar Abdelmonem5e70e962024-08-06 09:38:42 +0000143std::optional<HardwareProperties> InputMapper::getTouchpadHardwareProperties() {
144 return std::nullopt;
145}
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700146} // namespace android