summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chris Ye <lzye@google.com> 2020-07-04 18:22:41 -0700
committer Chris Ye <lzye@google.com> 2020-07-04 18:24:49 -0700
commit1d927aa2377c9e1fa57f9e2e409dc9a33d1bcc7a (patch)
tree5b031bdd96c6dcc79d9f9468c46348cc7491d9f9
parent12d24c504621cc5ff117b41726d734475eb8836c (diff)
Convert InputDeviceConfigurationFileType to enum class.
Convert InputDeviceConfigurationFileType to enum class and the reference to it accordingly. Test: atest inputflinger_tests Change-Id: I9a7c0371aa3c519ca69cc4e019079f9645d4ff09
-rw-r--r--include/input/InputDevice.h8
-rw-r--r--libs/input/InputDevice.cpp4
-rw-r--r--libs/input/Keyboard.cpp7
-rw-r--r--services/inputflinger/host/InputDriver.cpp6
-rw-r--r--services/inputflinger/reader/EventHub.cpp6
5 files changed, 17 insertions, 14 deletions
diff --git a/include/input/InputDevice.h b/include/input/InputDevice.h
index 20a17e3347..c7685b7c13 100644
--- a/include/input/InputDevice.h
+++ b/include/input/InputDevice.h
@@ -144,10 +144,10 @@ private:
};
/* Types of input device configuration files. */
-enum InputDeviceConfigurationFileType {
- INPUT_DEVICE_CONFIGURATION_FILE_TYPE_CONFIGURATION = 0, /* .idc file */
- INPUT_DEVICE_CONFIGURATION_FILE_TYPE_KEY_LAYOUT = 1, /* .kl file */
- INPUT_DEVICE_CONFIGURATION_FILE_TYPE_KEY_CHARACTER_MAP = 2, /* .kcm file */
+enum class InputDeviceConfigurationFileType : int32_t {
+ CONFIGURATION = 0, /* .idc file */
+ KEY_LAYOUT = 1, /* .kl file */
+ KEY_CHARACTER_MAP = 2, /* .kcm file */
};
/*
diff --git a/libs/input/InputDevice.cpp b/libs/input/InputDevice.cpp
index 4db9e06d8d..dbd6293a64 100644
--- a/libs/input/InputDevice.cpp
+++ b/libs/input/InputDevice.cpp
@@ -46,9 +46,9 @@ static bool isValidNameChar(char ch) {
static void appendInputDeviceConfigurationFileRelativePath(std::string& path,
const std::string& name, InputDeviceConfigurationFileType type) {
- path += CONFIGURATION_FILE_DIR[type];
+ path += CONFIGURATION_FILE_DIR[static_cast<int32_t>(type)];
path += name;
- path += CONFIGURATION_FILE_EXTENSION[type];
+ path += CONFIGURATION_FILE_EXTENSION[static_cast<int32_t>(type)];
}
std::string getInputDeviceConfigurationFilePathByDeviceIdentifier(
diff --git a/libs/input/Keyboard.cpp b/libs/input/Keyboard.cpp
index 56900c129e..25025f2963 100644
--- a/libs/input/Keyboard.cpp
+++ b/libs/input/Keyboard.cpp
@@ -105,8 +105,7 @@ bool KeyMap::probeKeyMap(const InputDeviceIdentifier& deviceIdentifier,
status_t KeyMap::loadKeyLayout(const InputDeviceIdentifier& deviceIdentifier,
const std::string& name) {
- std::string path(getPath(deviceIdentifier, name,
- INPUT_DEVICE_CONFIGURATION_FILE_TYPE_KEY_LAYOUT));
+ std::string path(getPath(deviceIdentifier, name, InputDeviceConfigurationFileType::KEY_LAYOUT));
if (path.empty()) {
return NAME_NOT_FOUND;
}
@@ -122,8 +121,8 @@ status_t KeyMap::loadKeyLayout(const InputDeviceIdentifier& deviceIdentifier,
status_t KeyMap::loadKeyCharacterMap(const InputDeviceIdentifier& deviceIdentifier,
const std::string& name) {
- std::string path = getPath(deviceIdentifier, name,
- INPUT_DEVICE_CONFIGURATION_FILE_TYPE_KEY_CHARACTER_MAP);
+ std::string path =
+ getPath(deviceIdentifier, name, InputDeviceConfigurationFileType::KEY_CHARACTER_MAP);
if (path.empty()) {
return NAME_NOT_FOUND;
}
diff --git a/services/inputflinger/host/InputDriver.cpp b/services/inputflinger/host/InputDriver.cpp
index 683c05d8a0..ff69800968 100644
--- a/services/inputflinger/host/InputDriver.cpp
+++ b/services/inputflinger/host/InputDriver.cpp
@@ -217,8 +217,10 @@ input_property_map_t* InputDriver::inputGetDevicePropertyMap(input_device_identi
idi.product = id->productId;
idi.version = id->version;
- std::string configFile = getInputDeviceConfigurationFilePathByDeviceIdentifier(
- idi, INPUT_DEVICE_CONFIGURATION_FILE_TYPE_CONFIGURATION);
+ std::string configFile =
+ getInputDeviceConfigurationFilePathByDeviceIdentifier(idi,
+ InputDeviceConfigurationFileType::
+ CONFIGURATION);
if (configFile.empty()) {
ALOGD("No input device configuration file found for device '%s'.",
idi.name.c_str());
diff --git a/services/inputflinger/reader/EventHub.cpp b/services/inputflinger/reader/EventHub.cpp
index a1514af668..6e9394317f 100644
--- a/services/inputflinger/reader/EventHub.cpp
+++ b/services/inputflinger/reader/EventHub.cpp
@@ -1613,8 +1613,10 @@ void EventHub::addDeviceLocked(Device* device) {
}
void EventHub::loadConfigurationLocked(Device* device) {
- device->configurationFile = getInputDeviceConfigurationFilePathByDeviceIdentifier(
- device->identifier, INPUT_DEVICE_CONFIGURATION_FILE_TYPE_CONFIGURATION);
+ device->configurationFile =
+ getInputDeviceConfigurationFilePathByDeviceIdentifier(device->identifier,
+ InputDeviceConfigurationFileType::
+ CONFIGURATION);
if (device->configurationFile.empty()) {
ALOGD("No input device configuration file found for device '%s'.",
device->identifier.name.c_str());