1 .在tp的驱动文件中添加以下代码实现按键功能
[plain] view plain copy
- static ssize_t
- ft5x06_virtual_keys_register(struct kobject *kobj,
- struct kobj_attribute *attr,
- char *buf)
- {
- return snprintf(buf, 200,
- __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":120:840:80:60"
- ":" __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":360:840:80:60"
- "\n");
- }
- static struct kobj_attribute ft5x06_virtual_keys_attr = {
- .attr = {
- .name = "virtualkeys.ft5x06_ts",
- .mode = S_IRUGO,
- },
- .show = &ft5x06_virtual_keys_register,
- };
- static struct attribute *ft5x06_virtual_key_properties_attrs[] = {
- &ft5x06_virtual_keys_attr.attr,
- NULL,
- };
- static struct attribute_group ft5x06_virtual_key_properties_attr_group = {
- .attrs = ft5x06_virtual_key_properties_attrs,
- };
- struct kobject *ft5x06_virtual_key_properties_kobj;
- static void __init ft5x06_touchpad_setup(void)
- {
- int rc;
- ft5x06_virtual_key_properties_kobj =
- kobject_create_and_add("board_properties", NULL);
- if (ft5x06_virtual_key_properties_kobj)
- rc = sysfs_create_group(ft5x06_virtual_key_properties_kobj,
- &ft5x06_virtual_key_properties_attr_group);
- if (!ft5x06_virtual_key_properties_kobj || rc)
- pr_err("%s: failed to create board_properties\n", __func__);
- }
另外需要在-mtp.dtsi文件中配置TP的参数和gen_vkeys
[plain] view plain copy
- i2c@f9923000{
- focaltech@38{
- compatible = "focaltech,5x06";
- reg = <0x38>;
- interrupt-parent = <&msmgpio>;
- interrupts = <1 0x2>;
- vdd-supply = <&pm8110_l19>;
- vcc_i2c-supply = <&pm8110_l14>;
- focaltech,family-id = <0x06>;
- focaltech,reset-gpio = <&msmgpio 0 0x00>;
- focaltech,irq-gpio = <&msmgpio 1 0x00>;
- focaltech,display-coords = <0 0 480 854>;
- focaltech,panel-coords = <0 0 480 946>;
- focaltech,button-map= <139 102 158>;
- focaltech,no-force-update;
- focaltech,i2c-pull-up;
这里主要配置touch panel的按键:
[plain] view plain copy
- gen-vkeys {
- compatible = "qcom,gen-vkeys";
- label = "ft5x06_ts";
- qcom,disp-maxx = <480>;
- qcom,disp-maxy = <800>;
- qcom,panel-maxx = <481>;
- qcom,panel-maxy = <940>;
- qcom,key-codes = <102 158 >; //按键码,TP需要几个就写几个
- qcom,y-offset = <0>;
- };
key_codes究竟是多少,在头文件kernel/include/linux/input.h 中定义,解析这些参数的函数是在driver/input/touchscreen/gen_vkeys.c,其中用的的函数还是这个
vkey_obj = kobject_create_and_add("board_properties", NULL);
if (!vkey_obj) {
dev_err(&pdev->dev, "unable to create kobject\n");
return -ENOMEM;
}
ret = sysfs_create_group(vkey_obj, &vkey_grp);
if (ret) {
dev_err(&pdev->dev, "failed to create attributes\n");
goto destroy_kobj;
}
这个实现的方法跟8x25的基本一样,只不过这里注册成了驱动。记住如果使能这个功能的话,在配置文件中CONFIG_TOUCHSCREEN_GEN_VKEYS=y
下面是成功添加后的截图
- 顶
- 0
- 踩
- 0
- 上一篇