Skip to content

Commit 1324c5a

Browse files
spbnickJiri Kosina
authored andcommitted
HID: uclogic: Support Huion tilt reporting
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> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent a254a9d commit 1324c5a

4 files changed

Lines changed: 23 additions & 1 deletion

File tree

drivers/hid/hid-uclogic-core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ static int uclogic_raw_event(struct hid_device *hdev,
304304
mod_timer(&drvdata->inrange_timer,
305305
jiffies + msecs_to_jiffies(100));
306306
}
307+
/* If we report tilt and Y direction is flipped */
308+
if (size >= 12 && params->pen.tilt_y_flipped)
309+
data[11] = -data[11];
307310
}
308311

309312
/* Tweak frame control reports, if necessary */

drivers/hid/hid-uclogic-params.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ static int uclogic_params_pen_init_v2(struct uclogic_params_pen *pen,
369369
pen->id = UCLOGIC_RDESC_PEN_V2_ID;
370370
pen->inrange = UCLOGIC_PARAMS_PEN_INRANGE_NONE;
371371
pen->fragmented_hires = true;
372+
pen->tilt_y_flipped = true;
372373
found = true;
373374
finish:
374375
*pfound = found;

drivers/hid/hid-uclogic-params.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ struct uclogic_params_pen {
6262
* Only valid if "id" is not zero.
6363
*/
6464
bool fragmented_hires;
65+
/*
66+
* True if the pen reports tilt in bytes at offset 10 (X) and 11 (Y),
67+
* and the Y tilt direction is flipped.
68+
* Only valid if "id" is not zero.
69+
*/
70+
bool tilt_y_flipped;
6571
};
6672

6773
/*
@@ -171,6 +177,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
171177
".pen.id = %u\n" \
172178
".pen.inrange = %s\n" \
173179
".pen.fragmented_hires = %s\n" \
180+
".pen.tilt_y_flipped = %s\n" \
174181
".frame.desc_ptr = %p\n" \
175182
".frame.desc_size = %u\n" \
176183
".frame.id = %u\n" \
@@ -189,6 +196,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
189196
(_params)->pen.id, \
190197
uclogic_params_pen_inrange_to_str((_params)->pen.inrange), \
191198
((_params)->pen.fragmented_hires ? "true" : "false"), \
199+
((_params)->pen.tilt_y_flipped ? "true" : "false"), \
192200
(_params)->frame.desc_ptr, \
193201
(_params)->frame.desc_size, \
194202
(_params)->frame.id, \

drivers/hid/hid-uclogic-rdesc.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,17 @@ const __u8 uclogic_rdesc_pen_v2_template_arr[] = {
633633
0x27, UCLOGIC_RDESC_PEN_PH(PRESSURE_LM),
634634
/* Logical Maximum (PLACEHOLDER), */
635635
0x81, 0x02, /* Input (Variable), */
636-
0x81, 0x03, /* Input (Constant, Variable), */
636+
0x54, /* Unit Exponent (0), */
637+
0x65, 0x14, /* Unit (Degrees), */
638+
0x35, 0xC4, /* Physical Minimum (-60), */
639+
0x45, 0x3C, /* Physical Maximum (60), */
640+
0x15, 0xC4, /* Logical Minimum (-60), */
641+
0x25, 0x3C, /* Logical Maximum (60), */
642+
0x75, 0x08, /* Report Size (8), */
643+
0x95, 0x02, /* Report Count (2), */
644+
0x09, 0x3D, /* Usage (X Tilt), */
645+
0x09, 0x3E, /* Usage (Y Tilt), */
646+
0x81, 0x02, /* Input (Variable), */
637647
0xC0, /* End Collection, */
638648
0xC0 /* End Collection */
639649
};

0 commit comments

Comments
 (0)