diff options
author | Nikolai Kondrashov <spbnick@gmail.com> | 2022-03-03 10:47:31 +0300 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2022-04-11 17:51:52 +0300 |
commit | d170e8e02729ad3bc4924005cec1ad38409d82af (patch) | |
tree | 4901885314c38b02f114a0d1a2d67dd533910ce2 /drivers/hid/hid-uclogic-core.c | |
parent | 5e206459f670b579da9b7861a0f3ce3b989a68b6 (diff) | |
download | linux-d170e8e02729ad3bc4924005cec1ad38409d82af.tar.xz |
HID: uclogic: Add support for touch ring reports
Add support for touch ring to UC-Logic driver. The touch ring reports
can be flipped around a specific point to match the orientation and
direction reported by the Wacom drivers. The proximity will also be
reported similar to the Wacom drivers.
Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-uclogic-core.c')
-rw-r--r-- | drivers/hid/hid-uclogic-core.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 05147f2d7564..b448616dacb9 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -90,6 +90,8 @@ static int uclogic_input_configured(struct hid_device *hdev, const char *suffix = NULL; struct hid_field *field; size_t len; + size_t i; + const struct uclogic_params_frame *frame; /* no report associated (HID_QUIRK_MULTI_INPUT not set) */ if (!hi->report) @@ -104,6 +106,19 @@ static int uclogic_input_configured(struct hid_device *hdev, drvdata->pen_input = hi->input; } + /* If it's one of the frame devices */ + for (i = 0; i < ARRAY_SIZE(params->frame_list); i++) { + frame = ¶ms->frame_list[i]; + if (hi->report->id == frame->id) { + /* + * Disable EV_MSC reports for touch ring interfaces to + * make the Wacom driver pickup touch ring extents + */ + if (frame->touch_ring_byte > 0) + __clear_bit(EV_MSC, hi->input->evbit); + } + } + field = hi->report->field[0]; switch (field->application) { @@ -313,8 +328,16 @@ static int uclogic_raw_event_frame( /* If need to, and can, set pad device ID for Wacom drivers */ if (frame->dev_id_byte > 0 && frame->dev_id_byte < size) { - data[frame->dev_id_byte] = 0xf; + /* If we also have a touch ring and the finger left it */ + if (frame->touch_ring_byte > 0 && + frame->touch_ring_byte < size && + data[frame->touch_ring_byte] == 0) { + data[frame->dev_id_byte] = 0; + } else { + data[frame->dev_id_byte] = 0xf; + } } + /* If need to, and can, read rotary encoder state change */ if (frame->re_lsb > 0 && frame->re_lsb / 8 < size) { unsigned int byte = frame->re_lsb / 8; @@ -341,6 +364,20 @@ static int uclogic_raw_event_frame( drvdata->re_state = state; } + /* If need to, and can, transform the touch ring reports */ + if (frame->touch_ring_byte > 0 && frame->touch_ring_byte < size && + frame->touch_ring_flip_at != 0) { + __s8 value = data[frame->touch_ring_byte]; + + if (value != 0) { + value = frame->touch_ring_flip_at - value; + if (value < 0) + value = frame->touch_ring_max + value; + + data[frame->touch_ring_byte] = value; + } + } + return 0; } |