1.idc是什么?
idc 是Input Device Configuration的缩写,输入设备配置文件(.idc 文件)包含特定设备的配置属性,这些属性会影响输入设备的行为。
输入设备配置文件通常并非标准外围设备(例如 HID 键盘和鼠标)所必需的,因为默认的系统行为通常可确保它们即插即用。另一方面,内置的嵌入式设备(尤其是触摸屏)几乎总是需要输入设备配置文件来指定其行为。
2.idc位置按顺序查阅以下路径。
/odm/usr/idc/Vendor_XXXX_Product_XXXX_Version_XXXX.idc
/vendor/usr/idc/Vendor_XXXX_Product_XXXX_Version_XXXX.idc
/system/usr/idc/Vendor_XXXX_Product_XXXX_Version_XXXX.idc
/data/system/devices/idc/Vendor_XXXX_Product_XXXX_Version_XXXX.idc
/odm/usr/idc/Vendor_XXXX_Product_XXXX.idc
/vendor/usr/idc/Vendor_XXXX_Product_XXXX.idc
/system/usr/idc/Vendor_XXXX_Product_XXXX.idc
/data/system/devices/idc/Vendor_XXXX_Product_XXXX.idc
/odm/usr/idc/device-name.idc
/vendor/usr/idc/device-name.idc
/system/usr/idc/device-name.idc
/data/system/devices/idc/device-name.idc
当构建包含设备名称的文件路径时,设备名称中除“0-9”、“a-z”、“A-Z”、“-”或“_”之外的所有字符将替换为“_”。
3.idc文件常用配置属性
#=0 外部设备 =1内部设备
device.internal = 0
#定义:keyboard.layout = <name>
#指定与输入设备关联的键布局文件的名称,不包括.kl扩展名。 如果找不到此文件,输入系统将使用默认键布局。
keyboard.layout = qwerty
#定义:keyboard.characterMap = <name>
#指定与输入设备关联的键字符映射文件的名称,不包括.kcm扩展名。 如果找不到此文件,输入系统将使用默认的键字符映射。
#在查找期间,名称中的空格将转换为下划线。
keyboard.characterMap = qwerty
#定义:keyboard.orientationAware = 0 |1
#指定键盘是否应对显示方向更改做出反应。
#如果值为1,则在关联的显示方向改变时旋转方向键盘键。
#如果值为0,则键盘不受显示方向更改的影响。
#默认值为0。
#方向感知用于支持方向键盘键的旋转,例如Motorola Droid上的旋转。 例如,当设备从其自然方向顺时针旋转90度时,
#KEYCODE_DPAD_UP被重新映射以产生KEYCODE_DPAD_RIGHT,因为当设备保持在该方向时,“向上”键最终指向“右”。
keyboard.orientationAware = 1
#定义:keyboard.builtIn = 0 |1
#指定键盘是否为内置(物理连接)键盘。
#如果设备名称以-keypad结尾,则默认值为1,否则为0。
#内置键盘的设备ID始终为0.其他非内置键盘将分配唯一的非零设备ID。
#对于内置键盘使用id为0对于保持与KeyCharacterMap.BUILT_IN_KEYBOARD字段的兼容性非常重要,该字段指定内置键盘的id并且值为0.
#此字段已在API中弃用但较旧 应用程序可能仍在使用它。
#无论此属性的设置如何,特殊功能键盘(其键字符映射指定SPECIAL_FUNCTION的类型)将永远不会注册为内置键盘。
#这是因为根据定义,特殊功能键盘不打算用于通用键入。
keyboard.builtIn = 1
4.idc代码流程
Eventhub在打开设备时会读取设备的idc文件
->Eventhub.openDeviceLocked->loadConfigurationLocked
void EventHub::loadConfigurationLocked(Device* device) {
device->configurationFile = getInputDeviceConfigurationFilePathByDeviceIdentifier(
device->identifier, INPUT_DEVICE_CONFIGURATION_FILE_TYPE_CONFIGURATION);
if (device->configurationFile.isEmpty()) {
ALOGD("No input device configuration file found for device '%s'.",
device->identifier.name.string());
} else {
status_t status = PropertyMap::load(device->configurationFile,
&device->configuration);
if (status) {
ALOGE("Error loading input device configuration file for device '%s'. "
"Using default configuration.",
device->identifier.name.string());
}
}
}
idc文件的加载顺序如下,如果找到了idc文件则直接返回不会再加载后面的idc文件
Vendor_XXXX_Product_XXXX_Version_XXXX.idc
Vendor_XXXX_Product_XXXX.idc
device-name.idc
String8 getInputDeviceConfigurationFilePathByDeviceIdentifier(
const InputDeviceIdentifier& deviceIdentifier,
InputDeviceConfigurationFileType type) {
if (deviceIdentifier.vendor !=0 && deviceIdentifier.product != 0) {
if (deviceIdentifier.version != 0) {
// Try vendor product version.
String8 versionPath(getInputDeviceConfigurationFilePathByName(
String8::format("Vendor_%04x_Product_%04x_Version_%04x",
deviceIdentifier.vendor, deviceIdentifier.product,
deviceIdentifier.version),
type));
if (!versionPath.isEmpty()) {
return versionPath;
}
}
// Try vendor product.
String8 productPath(getInputDeviceConfigurationFilePathByName(
String8::format("Vendor_%04x_Product_%04x",
deviceIdentifier.vendor, deviceIdentifier.product),
type));
if (!productPath.isEmpty()) {
return productPath;
}
}
// Try device name.
return getInputDeviceConfigurationFilePathByName(deviceIdentifier.name, type);
}
String8 getInputDeviceConfigurationFilePathByName(
const String8& name, InputDeviceConfigurationFileType type) {
// Search system repository.
String8 path;
path.setTo(getenv("ANDROID_ROOT"));
path.append("/usr/");
appendInputDeviceConfigurationFileRelativePath(path, name, type);
#if DEBUG_PROBE
ALOGD("Probing for system provided input device configuration file: path='%s'", path.string());
#endif
if (!access(path.string(), R_OK)) {
#if DEBUG_PROBE
ALOGD("Found");
#endif
return path;
}
// Search user repository.
// TODO Should only look here if not in safe mode.
path.setTo(getenv("ANDROID_DATA"));
path.append("/system/devices/");
appendInputDeviceConfigurationFileRelativePath(path, name, type);
#if DEBUG_PROBE
ALOGD("Probing for system user input device configuration file: path='%s'", path.string());
#endif
if (!access(path.string(), R_OK)) {
#if DEBUG_PROBE
ALOGD("Found");
#endif
return path;
}
// Not found.
#if DEBUG_PROBE
ALOGD("Probe failed to find input device configuration file: name='%s', type=%d",
name.string(), type);
#endif
return String8();
}
参考博客:
https://source.android.com/devices/input/validate-keymaps.html
https://www.cnblogs.com/guolinjie/p/10791991.html
Android idc文件配置
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- Android在外接物理键盘时,如何强制调用系统软键盘? 第一次写,写的不好请见谅 参考: http://blog...
- 1.contexts contexts(self): Returns the contexts within th...
- 前言: Appium Python API全集,不知道哪个大神整理的,这里贴出来分享给大家。 1.contex...