From: "José Expósito" <jose.exposito89@gmail.com>
To: jikos@kernel.org
Cc: benjamin.tissoires@redhat.com, spbnick@gmail.com,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
"José Expósito" <jose.exposito89@gmail.com>
Subject: [PATCH 1/7] HID: uclogic: Support Huion tilt reporting
Date: Thu, 10 Feb 2022 20:04:31 +0100 [thread overview]
Message-ID: <20220210190437.50152-2-jose.exposito89@gmail.com> (raw)
In-Reply-To: <20220210190437.50152-1-jose.exposito89@gmail.com>
From: Nikolai Kondrashov <spbnick@gmail.com>
Add support for Huion v2 protocol tilt reporting. Describe reports as
angles in degrees, which is not exactly true, but there doesn't seem to
be a straightforward, consistent conversion possible, and what's
reported would have to be enough.
Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
drivers/hid/hid-uclogic-core.c | 3 +++
drivers/hid/hid-uclogic-params.c | 1 +
drivers/hid/hid-uclogic-params.h | 8 ++++++++
drivers/hid/hid-uclogic-rdesc.c | 12 +++++++++++-
4 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
index d8ab0139e5cd..823704bc02ef 100644
--- a/drivers/hid/hid-uclogic-core.c
+++ b/drivers/hid/hid-uclogic-core.c
@@ -304,6 +304,9 @@ static int uclogic_raw_event(struct hid_device *hdev,
mod_timer(&drvdata->inrange_timer,
jiffies + msecs_to_jiffies(100));
}
+ /* If we report tilt and Y direction is flipped */
+ if (size >= 12 && params->pen.tilt_y_flipped)
+ data[11] = -data[11];
}
/* Tweak frame control reports, if necessary */
diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c
index 3e70f969fb84..30e0f69ed5af 100644
--- a/drivers/hid/hid-uclogic-params.c
+++ b/drivers/hid/hid-uclogic-params.c
@@ -369,6 +369,7 @@ static int uclogic_params_pen_init_v2(struct uclogic_params_pen *pen,
pen->id = UCLOGIC_RDESC_PEN_V2_ID;
pen->inrange = UCLOGIC_PARAMS_PEN_INRANGE_NONE;
pen->fragmented_hires = true;
+ pen->tilt_y_flipped = true;
found = true;
finish:
*pfound = found;
diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h
index ba48b1c7a0e5..e8381bb77bd0 100644
--- a/drivers/hid/hid-uclogic-params.h
+++ b/drivers/hid/hid-uclogic-params.h
@@ -62,6 +62,12 @@ struct uclogic_params_pen {
* Only valid if "id" is not zero.
*/
bool fragmented_hires;
+ /*
+ * True if the pen reports tilt in bytes at offset 10 (X) and 11 (Y),
+ * and the Y tilt direction is flipped.
+ * Only valid if "id" is not zero.
+ */
+ bool tilt_y_flipped;
};
/*
@@ -171,6 +177,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
".pen.id = %u\n" \
".pen.inrange = %s\n" \
".pen.fragmented_hires = %s\n" \
+ ".pen.tilt_y_flipped = %s\n" \
".frame.desc_ptr = %p\n" \
".frame.desc_size = %u\n" \
".frame.id = %u\n" \
@@ -189,6 +196,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
(_params)->pen.id, \
uclogic_params_pen_inrange_to_str((_params)->pen.inrange), \
((_params)->pen.fragmented_hires ? "true" : "false"), \
+ ((_params)->pen.tilt_y_flipped ? "true" : "false"), \
(_params)->frame.desc_ptr, \
(_params)->frame.desc_size, \
(_params)->frame.id, \
diff --git a/drivers/hid/hid-uclogic-rdesc.c b/drivers/hid/hid-uclogic-rdesc.c
index 6dd6dcd09c8b..2607cbdf8ff2 100644
--- a/drivers/hid/hid-uclogic-rdesc.c
+++ b/drivers/hid/hid-uclogic-rdesc.c
@@ -633,7 +633,17 @@ const __u8 uclogic_rdesc_pen_v2_template_arr[] = {
0x27, UCLOGIC_RDESC_PEN_PH(PRESSURE_LM),
/* Logical Maximum (PLACEHOLDER), */
0x81, 0x02, /* Input (Variable), */
- 0x81, 0x03, /* Input (Constant, Variable), */
+ 0x54, /* Unit Exponent (0), */
+ 0x65, 0x14, /* Unit (Degrees), */
+ 0x35, 0xC4, /* Physical Minimum (-60), */
+ 0x45, 0x3C, /* Physical Maximum (60), */
+ 0x15, 0xC4, /* Logical Minimum (-60), */
+ 0x25, 0x3C, /* Logical Maximum (60), */
+ 0x75, 0x08, /* Report Size (8), */
+ 0x95, 0x02, /* Report Count (2), */
+ 0x09, 0x3D, /* Usage (X Tilt), */
+ 0x09, 0x3E, /* Usage (Y Tilt), */
+ 0x81, 0x02, /* Input (Variable), */
0xC0, /* End Collection, */
0xC0 /* End Collection */
};
--
2.25.1
next prev parent reply other threads:[~2022-02-10 19:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-10 19:04 [PATCH 0/7] DIGImend patches, part one José Expósito
2022-02-10 19:04 ` José Expósito [this message]
2022-02-10 19:04 ` [PATCH 2/7] HID: uclogic: Rename Huion HS64 PID to Huion Tablet 2 José Expósito
2022-02-10 19:04 ` [PATCH 3/7] HID: uclogic: Support Huion 13th frame button José Expósito
2022-02-10 19:04 ` [PATCH 4/7] HID: uclogic: Split pen and frame raw event handling José Expósito
2022-02-10 19:04 ` [PATCH 5/7] HID: uclogic: Access pen/frame params directly in raw_event handling José Expósito
2022-02-10 19:04 ` [PATCH 6/7] HID: uclogic: Skip non-input raw events earlier José Expósito
2022-02-10 19:04 ` [PATCH 7/7] HID: uclogic: Handle virtual frame reports José Expósito
2022-02-16 15:43 ` [PATCH 0/7] DIGImend patches, part one Jiri Kosina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220210190437.50152-2-jose.exposito89@gmail.com \
--to=jose.exposito89@gmail.com \
--cc=benjamin.tissoires@redhat.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=spbnick@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®