]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - drivers/hid/hid-egalax.c
HID: Add and use hid_<level>: dev_<level> equivalents
[mirror_ubuntu-artful-kernel.git] / drivers / hid / hid-egalax.c
index 8ca7f65cf2f804d32120fadfa81cc9b900dfd94a..bbab6cff3518e5e7eb657be32f2c8afe8ebeef6d 100644 (file)
@@ -31,7 +31,7 @@ struct egalax_data {
        bool first;             /* is this the first finger in the frame? */
        bool valid;             /* valid finger data, or just placeholder? */
        bool activity;          /* at least one active finger previously? */
-       __u16 lastx, lasty;     /* latest valid (x, y) in the frame */
+       __u16 lastx, lasty, lastz;      /* latest valid (x, y, z) in the frame */
 };
 
 static int egalax_input_mapping(struct hid_device *hdev, struct hid_input *hi,
@@ -79,6 +79,10 @@ static int egalax_input_mapping(struct hid_device *hdev, struct hid_input *hi,
                case HID_DG_TIPPRESSURE:
                        hid_map_usage(hi, usage, bit, max,
                                        EV_ABS, ABS_MT_PRESSURE);
+                       /* touchscreen emulation */
+                       input_set_abs_params(hi->input, ABS_PRESSURE,
+                                               field->logical_minimum,
+                                               field->logical_maximum, 0, 0);
                        return 1;
                }
                return 0;
@@ -109,8 +113,8 @@ static void egalax_filter_event(struct egalax_data *td, struct input_dev *input)
        if (td->valid) {
                /* emit multitouch events */
                input_event(input, EV_ABS, ABS_MT_TRACKING_ID, td->id);
-               input_event(input, EV_ABS, ABS_MT_POSITION_X, td->x);
-               input_event(input, EV_ABS, ABS_MT_POSITION_Y, td->y);
+               input_event(input, EV_ABS, ABS_MT_POSITION_X, td->x >> 3);
+               input_event(input, EV_ABS, ABS_MT_POSITION_Y, td->y >> 3);
                input_event(input, EV_ABS, ABS_MT_PRESSURE, td->z);
 
                input_mt_sync(input);
@@ -121,6 +125,7 @@ static void egalax_filter_event(struct egalax_data *td, struct input_dev *input)
                 */
                td->lastx = td->x;
                td->lasty = td->y;
+               td->lastz = td->z;
        }
 
        /*
@@ -129,8 +134,9 @@ static void egalax_filter_event(struct egalax_data *td, struct input_dev *input)
         * the oldest on the panel, the one we want for single touch
         */
        if (!td->first && td->activity) {
-               input_event(input, EV_ABS, ABS_X, td->lastx);
-               input_event(input, EV_ABS, ABS_Y, td->lasty);
+               input_event(input, EV_ABS, ABS_X, td->lastx >> 3);
+               input_event(input, EV_ABS, ABS_Y, td->lasty >> 3);
+               input_event(input, EV_ABS, ABS_PRESSURE, td->lastz);
        }
 
        if (!td->valid) {
@@ -217,7 +223,7 @@ static int egalax_probe(struct hid_device *hdev, const struct hid_device_id *id)
 
        td = kmalloc(sizeof(struct egalax_data), GFP_KERNEL);
        if (!td) {
-               dev_err(&hdev->dev, "cannot allocate eGalax data\n");
+               hid_err(hdev, "cannot allocate eGalax data\n");
                return -ENOMEM;
        }
        hid_set_drvdata(hdev, td);