1 .在tp的驱动文件中添加以下代码实现按键功能
- 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__);
- }
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
- 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;
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;
- 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>;
- };
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>;
};
下面是成功添加后的截图