summaryrefslogtreecommitdiff
path: root/libs/input/InputDevice.cpp
diff options
context:
space:
mode:
author Xin Li <delphij@google.com> 2022-06-29 21:21:49 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-06-29 21:21:49 +0000
commit618c76e5c04f99f2e295fcd2ffcb896476a68f38 (patch)
treedb84b827307260c3e1e05d5d30a08c08d427e158 /libs/input/InputDevice.cpp
parent31afdea9a497881604f2395b7a870d4ee21497c6 (diff)
parent552bdbb3f7e423c4047ed209917a12f8cadf86e9 (diff)
Merge "Merge tm-dev-plus-aosp-without-vendor@8763363" into stage-aosp-master
Diffstat (limited to 'libs/input/InputDevice.cpp')
-rw-r--r--libs/input/InputDevice.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/libs/input/InputDevice.cpp b/libs/input/InputDevice.cpp
index 18cd474058..a9089690b0 100644
--- a/libs/input/InputDevice.cpp
+++ b/libs/input/InputDevice.cpp
@@ -21,7 +21,7 @@
#include <ctype.h>
#include <android-base/stringprintf.h>
-#include <ftl/NamedEnum.h>
+#include <ftl/enum.h>
#include <input/InputDevice.h>
#include <input/InputEventLabels.h>
@@ -214,10 +214,8 @@ void InputDeviceInfo::initialize(int32_t id, int32_t generation, int32_t control
const InputDeviceInfo::MotionRange* InputDeviceInfo::getMotionRange(
int32_t axis, uint32_t source) const {
- size_t numRanges = mMotionRanges.size();
- for (size_t i = 0; i < numRanges; i++) {
- const MotionRange& range = mMotionRanges[i];
- if (range.axis == axis && range.source == source) {
+ for (const MotionRange& range : mMotionRanges) {
+ if (range.axis == axis && isFromSource(range.source, source)) {
return &range;
}
}
@@ -241,7 +239,7 @@ void InputDeviceInfo::addMotionRange(const MotionRange& range) {
void InputDeviceInfo::addSensorInfo(const InputDeviceSensorInfo& info) {
if (mSensors.find(info.type) != mSensors.end()) {
ALOGW("Sensor type %s already exists, will be replaced by new sensor added.",
- NamedEnum::string(info.type).c_str());
+ ftl::enum_string(info.type).c_str());
}
mSensors.insert_or_assign(info.type, info);
}
@@ -260,6 +258,13 @@ void InputDeviceInfo::addLightInfo(const InputDeviceLightInfo& info) {
mLights.insert_or_assign(info.id, info);
}
+void InputDeviceInfo::setKeyboardType(int32_t keyboardType) {
+ static_assert(AINPUT_KEYBOARD_TYPE_NONE < AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC);
+ static_assert(AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC < AINPUT_KEYBOARD_TYPE_ALPHABETIC);
+ // There can be multiple subdevices with different keyboard types, set it to the highest type
+ mKeyboardType = std::max(mKeyboardType, keyboardType);
+}
+
std::vector<InputDeviceSensorInfo> InputDeviceInfo::getSensors() {
std::vector<InputDeviceSensorInfo> infos;
infos.reserve(mSensors.size());