diff options
author | 2022-08-16 19:08:21 +0000 | |
---|---|---|
committer | 2022-08-16 19:08:21 +0000 | |
commit | 44732cde9e19a005def5e110140963a5c2e2f5ae (patch) | |
tree | 9a4deff758bed03ccc5ff838dc55f467c303d762 /libs/input/InputDevice.cpp | |
parent | 896cdca96956b6f14e262380b34a0b04e1214b50 (diff) | |
parent | 91192c8103e78895c57d9da1fc04c8695898580f (diff) |
Merge "DO NOT MERGE - Merge Android 13"
Diffstat (limited to 'libs/input/InputDevice.cpp')
-rw-r--r-- | libs/input/InputDevice.cpp | 17 |
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 ⦥ } } @@ -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()); |