Path: blob/master/drivers/hid/bpf/progs/Huion__Kamvas13Gen3.bpf.c
38242 views
// SPDX-License-Identifier: GPL-2.0-only1/* Copyright (c) 2025 Nicholas LaPointe2*/34#include "vmlinux.h"5#include "hid_bpf.h"6#include "hid_bpf_helpers.h"7#include "hid_report_helpers.h"8#include <bpf/bpf_tracing.h>910#define VID_HUION 0x256c11#define PID_KAMVAS13_GEN3 0x20081213#define VENDOR_DESCRIPTOR_LENGTH 3614#define TABLET_DESCRIPTOR_LENGTH 36815#define WHEEL_DESCRIPTOR_LENGTH 1081617#define VENDOR_REPORT_ID 818#define VENDOR_REPORT_LENGTH 141920#define VENDOR_REPORT_SUBTYPE_PEN 0x0821#define VENDOR_REPORT_SUBTYPE_PEN_OUT 0x0022#define VENDOR_REPORT_SUBTYPE_BUTTONS 0x0e23#define VENDOR_REPORT_SUBTYPE_WHEELS 0x0f2425/* For the reports that we create ourselves */26#define CUSTOM_PAD_REPORT_ID 92728HID_BPF_CONFIG(29HID_DEVICE(BUS_USB, HID_GROUP_ANY, VID_HUION, PID_KAMVAS13_GEN3),30);313233/*34* This tablet can send reports using one of two different data formats,35* depending on what "mode" the tablet is in.36*37* By default, the tablet will send reports that can be decoded using its38* included HID descriptors (descriptors 1 and 2, shown below).39* This mode will be called "firmware mode" throughout this file.40*41* The HID descriptor that describes pen events in firmware mode (descriptor 1)42* has multiple bugs:43* * "Secondary Tip Switch" instead of "Secondary Barrel Switch"44* * "Invert" instead of (or potentially shared with) third barrel button45* * Specified tablet area of 2048 in³ instead of 293.8 x 165.2mm46* * Specified tilt range of -90 to +90 instead of -60 to +6047*48* While these can be easily patched up by editing the descriptor, a larger49* problem with the firmware mode exists: it is impossible to tell which of the50* two wheels are being rotated (or having their central button pressed).51*52*53* By using a tool such as huion-switcher (https://github.com/whot/huion-switcher),54* the tablet can be made to send reports using a proprietary format that is not55* adequately described by its relevant descriptor (descriptor 0, shown below).56* This mode will be called "vendor mode" throughout this file.57*58* The reports sent while in vendor mode allow for proper decoding of the wheels.59*60* For simplicity and maximum functionality, this BPF focuses strictly on61* enabling one to make use of the vendor mode.62*/6364/*65* DESCRIPTORS66* DESCRIPTOR 067* # 0x06, 0x00, 0xff, // Usage Page (Vendor Defined Page FF00) 068* # 0x09, 0x01, // Usage (Vendor Usage 0x01) 369* # 0xa1, 0x01, // Collection (Application) 570* # ┅ 0x85, 0x08, // Report ID (8) 771* # 0x75, 0x68, // Report Size (104) 972* # 0x95, 0x01, // Report Count (1) 1173* # 0x09, 0x01, // Usage (Vendor Usage 0x01) 1374* # ┇ 0x81, 0x02, // Input (Data,Var,Abs) 1575* # 0xc0, // End Collection 1776* # 0x06, 0x00, 0xff, // Usage Page (Vendor Defined Page FF00) 1877* # 0x09, 0x01, // Usage (Vendor Usage 0x01) 2178* # 0xa1, 0x01, // Collection (Application) 2379* # ┅ 0x85, 0x16, // Report ID (22) 2580* # 0x75, 0x08, // Report Size (8) 2781* # 0x95, 0x07, // Report Count (7) 2982* # 0x09, 0x01, // Usage (Vendor Usage 0x01) 3183* # ║ 0xb1, 0x02, // Feature (Data,Var,Abs) 3384* # 0xc0, // End Collection 3585* R: 36 06 00 ff 09 01 a1 01 85 08 75 68 95 01 09 01 81 02 c0 06 00 ff 09 01 a1 01 85 16 75 08 95 07 09 01 b1 02 c086* N: HUION Huion Tablet_GS133387* I: 3 256c 200888*89* DESCRIPTOR 190* # 0x05, 0x0d, // Usage Page (Digitizers) 091* # 0x09, 0x02, // Usage (Pen) 292* # 0xa1, 0x01, // Collection (Application) 493* # ┅ 0x85, 0x0a, // Report ID (10) 694* # 0x09, 0x20, // Usage (Stylus) 895* # 0xa1, 0x01, // Collection (Application) 1096* # 0x09, 0x42, // Usage (Tip Switch) 1297* # 0x09, 0x44, // Usage (Barrel Switch) 1498* # 0x09, 0x43, // Usage (Secondary Tip Switch) 1699* # 0x09, 0x3c, // Usage (Invert) 18100* # 0x09, 0x45, // Usage (Eraser) 20101* # 0x15, 0x00, // Logical Minimum (0) 22102* # 0x25, 0x01, // Logical Maximum (1) 24103* # 0x75, 0x01, // Report Size (1) 26104* # 0x95, 0x06, // Report Count (6) 28105* # ┇ 0x81, 0x02, // Input (Data,Var,Abs) 30106* # 0x09, 0x32, // Usage (In Range) 32107* # 0x75, 0x01, // Report Size (1) 34108* # 0x95, 0x01, // Report Count (1) 36109* # ┇ 0x81, 0x02, // Input (Data,Var,Abs) 38110* # ┇ 0x81, 0x03, // Input (Cnst,Var,Abs) 40111* # 0x05, 0x01, // Usage Page (Generic Desktop) 42112* # 0x09, 0x30, // Usage (X) 44113* # 0x09, 0x31, // Usage (Y) 46114* # 0x55, 0x0d, // Unit Exponent (-3) 48115* # 0x65, 0x33, // Unit (EnglishLinear: in³) 50116* # 0x26, 0xff, 0x7f, // Logical Maximum (32767) 52117* # 0x35, 0x00, // Physical Minimum (0) 55118* # 0x46, 0x00, 0x08, // Physical Maximum (2048) 57119* # 0x75, 0x10, // Report Size (16) 60120* # 0x95, 0x02, // Report Count (2) 62121* # ┇ 0x81, 0x02, // Input (Data,Var,Abs) 64122* # 0x05, 0x0d, // Usage Page (Digitizers) 66123* # 0x09, 0x30, // Usage (Tip Pressure) 68124* # 0x26, 0xff, 0x3f, // Logical Maximum (16383) 70125* # 0x75, 0x10, // Report Size (16) 73126* # 0x95, 0x01, // Report Count (1) 75127* # ┇ 0x81, 0x02, // Input (Data,Var,Abs) 77128* # 0x09, 0x3d, // Usage (X Tilt) 79129* # 0x09, 0x3e, // Usage (Y Tilt) 81130* # 0x15, 0xa6, // Logical Minimum (-90) 83131* # 0x25, 0x5a, // Logical Maximum (90) 85132* # 0x75, 0x08, // Report Size (8) 87133* # 0x95, 0x02, // Report Count (2) 89134* # ┇ 0x81, 0x02, // Input (Data,Var,Abs) 91135* # 0xc0, // End Collection 93136* # 0xc0, // End Collection 94137* # 0x05, 0x0d, // Usage Page (Digitizers) 95138* # 0x09, 0x04, // Usage (Touch Screen) 97139* # 0xa1, 0x01, // Collection (Application) 99140* # ┅ 0x85, 0x04, // Report ID (4) 101141* # 0x09, 0x22, // Usage (Finger) 103142* # 0xa1, 0x02, // Collection (Logical) 105143* # 0x05, 0x0d, // Usage Page (Digitizers) 107144* # 0x95, 0x01, // Report Count (1) 109145* # 0x75, 0x06, // Report Size (6) 111146* # 0x09, 0x51, // Usage (Contact Identifier) 113147* # 0x15, 0x00, // Logical Minimum (0) 115148* # 0x25, 0x3f, // Logical Maximum (63) 117149* # ┇ 0x81, 0x02, // Input (Data,Var,Abs) 119150* # 0x09, 0x42, // Usage (Tip Switch) 121151* # 0x25, 0x01, // Logical Maximum (1) 123152* # 0x75, 0x01, // Report Size (1) 125153* # 0x95, 0x01, // Report Count (1) 127154* # ┇ 0x81, 0x02, // Input (Data,Var,Abs) 129155* # 0x75, 0x01, // Report Size (1) 131156* # 0x95, 0x01, // Report Count (1) 133157* # ┇ 0x81, 0x03, // Input (Cnst,Var,Abs) 135158* # 0x05, 0x01, // Usage Page (Generic Desktop) 137159* # 0x75, 0x10, // Report Size (16) 139160* # 0x55, 0x0e, // Unit Exponent (-2) 141161* # 0x65, 0x11, // Unit (SILinear: cm) 143162* # 0x09, 0x30, // Usage (X) 145163* # 0x26, 0xff, 0x7f, // Logical Maximum (32767) 147164* # 0x35, 0x00, // Physical Minimum (0) 150165* # 0x46, 0x15, 0x0c, // Physical Maximum (3093) 152166* # ┇ 0x81, 0x42, // Input (Data,Var,Abs,Null) 155167* # 0x09, 0x31, // Usage (Y) 157168* # 0x26, 0xff, 0x7f, // Logical Maximum (32767) 159169* # 0x46, 0xcb, 0x06, // Physical Maximum (1739) 162170* # ┇ 0x81, 0x42, // Input (Data,Var,Abs,Null) 165171* # 0x05, 0x0d, // Usage Page (Digitizers) 167172* # 0x09, 0x30, // Usage (Tip Pressure) 169173* # 0x26, 0xff, 0x1f, // Logical Maximum (8191) 171174* # 0x75, 0x10, // Report Size (16) 174175* # 0x95, 0x01, // Report Count (1) 176176* # ┇ 0x81, 0x02, // Input (Data,Var,Abs) 178177* # 0xc0, // End Collection 180178* # 0x05, 0x0d, // Usage Page (Digitizers) 181179* # 0x09, 0x22, // Usage (Finger) 183180* # 0xa1, 0x02, // Collection (Logical) 185181* # 0x05, 0x0d, // Usage Page (Digitizers) 187182* # 0x95, 0x01, // Report Count (1) 189183* # 0x75, 0x06, // Report Size (6) 191184* # 0x09, 0x51, // Usage (Contact Identifier) 193185* # 0x15, 0x00, // Logical Minimum (0) 195186* # 0x25, 0x3f, // Logical Maximum (63) 197187* # ┇ 0x81, 0x02, // Input (Data,Var,Abs) 199188* # 0x09, 0x42, // Usage (Tip Switch) 201189* # 0x25, 0x01, // Logical Maximum (1) 203190* # 0x75, 0x01, // Report Size (1) 205191* # 0x95, 0x01, // Report Count (1) 207192* # ┇ 0x81, 0x02, // Input (Data,Var,Abs) 209193* # 0x75, 0x01, // Report Size (1) 211194* # 0x95, 0x01, // Report Count (1) 213195* # ┇ 0x81, 0x03, // Input (Cnst,Var,Abs) 215196* # 0x05, 0x01, // Usage Page (Generic Desktop) 217197* # 0x75, 0x10, // Report Size (16) 219198* # 0x55, 0x0e, // Unit Exponent (-2) 221199* # 0x65, 0x11, // Unit (SILinear: cm) 223200* # 0x09, 0x30, // Usage (X) 225201* # 0x26, 0xff, 0x7f, // Logical Maximum (32767) 227202* # 0x35, 0x00, // Physical Minimum (0) 230203* # 0x46, 0x15, 0x0c, // Physical Maximum (3093) 232204* # ┇ 0x81, 0x42, // Input (Data,Var,Abs,Null) 235205* # 0x09, 0x31, // Usage (Y) 237206* # 0x26, 0xff, 0x7f, // Logical Maximum (32767) 239207* # 0x46, 0xcb, 0x06, // Physical Maximum (1739) 242208* # ┇ 0x81, 0x42, // Input (Data,Var,Abs,Null) 245209* # 0x05, 0x0d, // Usage Page (Digitizers) 247210* # 0x09, 0x30, // Usage (Tip Pressure) 249211* # 0x26, 0xff, 0x1f, // Logical Maximum (8191) 251212* # 0x75, 0x10, // Report Size (16) 254213* # 0x95, 0x01, // Report Count (1) 256214* # ┇ 0x81, 0x02, // Input (Data,Var,Abs) 258215* # 0xc0, // End Collection 260216* # 0x05, 0x0d, // Usage Page (Digitizers) 261217* # 0x09, 0x56, // Usage (Scan Time) 263218* # 0x55, 0x00, // Unit Exponent (0) 265219* # 0x65, 0x00, // Unit (None) 267220* # 0x27, 0xff, 0xff, 0xff, 0x7f, // Logical Maximum (2147483647) 269221* # 0x95, 0x01, // Report Count (1) 274222* # 0x75, 0x20, // Report Size (32) 276223* # ┇ 0x81, 0x02, // Input (Data,Var,Abs) 278224* # 0x09, 0x54, // Usage (Contact Count) 280225* # 0x25, 0x7f, // Logical Maximum (127) 282226* # 0x95, 0x01, // Report Count (1) 284227* # 0x75, 0x08, // Report Size (8) 286228* # ┇ 0x81, 0x02, // Input (Data,Var,Abs) 288229* # 0x75, 0x08, // Report Size (8) 290230* # 0x95, 0x08, // Report Count (8) 292231* # ┇ 0x81, 0x03, // Input (Cnst,Var,Abs) 294232* # ┅ 0x85, 0x05, // Report ID (5) 296233* # 0x09, 0x55, // Usage (Contact Count Maximum) 298234* # 0x25, 0x0a, // Logical Maximum (10) 300235* # 0x75, 0x08, // Report Size (8) 302236* # 0x95, 0x01, // Report Count (1) 304237* # ║ 0xb1, 0x02, // Feature (Data,Var,Abs) 306238* # 0x06, 0x00, 0xff, // Usage Page (Vendor Defined Page FF00) 308239* # 0x09, 0xc5, // Usage (Vendor Usage 0xc5) 311240* # ┅ 0x85, 0x06, // Report ID (6) 313241* # 0x15, 0x00, // Logical Minimum (0) 315242* # 0x26, 0xff, 0x00, // Logical Maximum (255) 317243* # 0x75, 0x08, // Report Size (8) 320244* # 0x96, 0x00, 0x01, // Report Count (256) 322245* # ║ 0xb1, 0x02, // Feature (Data,Var,Abs) 325246* # 0xc0, // End Collection 327247* # 0x05, 0x01, // Usage Page (Generic Desktop) 328248* # 0x09, 0x06, // Usage (Keyboard) 330249* # 0xa1, 0x01, // Collection (Application) 332250* # ┅ 0x85, 0x03, // Report ID (3) 334251* # 0x05, 0x07, // Usage Page (Keyboard/Keypad) 336252* # 0x19, 0xe0, // UsageMinimum (224) 338253* # 0x29, 0xe7, // UsageMaximum (231) 340254* # 0x15, 0x00, // Logical Minimum (0) 342255* # 0x25, 0x01, // Logical Maximum (1) 344256* # 0x75, 0x01, // Report Size (1) 346257* # 0x95, 0x08, // Report Count (8) 348258* # ┇ 0x81, 0x02, // Input (Data,Var,Abs) 350259* # 0x05, 0x07, // Usage Page (Keyboard/Keypad) 352260* # 0x19, 0x00, // UsageMinimum (0) 354261* # 0x29, 0xff, // UsageMaximum (255) 356262* # 0x26, 0xff, 0x00, // Logical Maximum (255) 358263* # 0x75, 0x08, // Report Size (8) 361264* # 0x95, 0x06, // Report Count (6) 363265* # ┇ 0x81, 0x00, // Input (Data,Arr,Abs) 365266* # 0xc0, // End Collection 367267* R: 368 05 0d 09 02 a1 01 85 0a 09 20 a1 01 09 42 09 44 09 43 09 3c 09 45 15 00 25 01 75 01 95 06 81 02 09 32 75 01 95 01 81 02 81 03 05 01 09 30 09 31 55 0d 65 33 26 ff 7f 35 00 46 00 08 75 10 95 02 81 02 05 0d 09 30 26 ff 3f 75 10 95 01 81 02 09 3d 09 3e 15 a6 25 5a 75 08 95 02 81 02 c0 c0 05 0d 09 04 a1 01 85 04 09 22 a1 02 05 0d 95 01 75 06 09 51 15 00 25 3f 81 02 09 42 25 01 75 01 95 01 81 02 75 01 95 01 81 03 05 01 75 10 55 0e 65 11 09 30 26 ff 7f 35 00 46 15 0c 81 42 09 31 26 ff 7f 46 cb 06 81 42 05 0d 09 30 26 ff 1f 75 10 95 01 81 02 c0 05 0d 09 22 a1 02 05 0d 95 01 75 06 09 51 15 00 25 3f 81 02 09 42 25 01 75 01 95 01 81 02 75 01 95 01 81 03 05 01 75 10 55 0e 65 11 09 30 26 ff 7f 35 00 46 15 0c 81 42 09 31 26 ff 7f 46 cb 06 81 42 05 0d 09 30 26 ff 1f 75 10 95 01 81 02 c0 05 0d 09 56 55 00 65 00 27 ff ff ff 7f 95 01 75 20 81 02 09 54 25 7f 95 01 75 08 81 02 75 08 95 08 81 03 85 05 09 55 25 0a 75 08 95 01 b1 02 06 00 ff 09 c5 85 06 15 00 26 ff 00 75 08 96 00 01 b1 02 c0 05 01 09 06 a1 01 85 03 05 07 19 e0 29 e7 15 00 25 01 75 01 95 08 81 02 05 07 19 00 29 ff 26 ff 00 75 08 95 06 81 00 c0268* N: HUION Huion Tablet_GS1333269* I: 3 256c 2008270*271* DESCRIPTOR 2272* # 0x05, 0x01, // Usage Page (Generic Desktop) 0273* # 0x09, 0x0e, // Usage (System Multi-Axis Controller) 2274* # 0xa1, 0x01, // Collection (Application) 4275* # ┅ 0x85, 0x11, // Report ID (17) 6276* # 0x05, 0x0d, // Usage Page (Digitizers) 8277* # 0x09, 0x21, // Usage (Puck) 10278* # 0xa1, 0x02, // Collection (Logical) 12279* # 0x15, 0x00, // Logical Minimum (0) 14280* # 0x25, 0x01, // Logical Maximum (1) 16281* # 0x75, 0x01, // Report Size (1) 18282* # 0x95, 0x01, // Report Count (1) 20283* # 0xa1, 0x00, // Collection (Physical) 22284* # 0x05, 0x09, // Usage Page (Button) 24285* # 0x09, 0x01, // Usage (Button 1) 26286* # ┇ 0x81, 0x02, // Input (Data,Var,Abs) 28287* # 0x05, 0x0d, // Usage Page (Digitizers) 30288* # 0x09, 0x33, // Usage (Touch) 32289* # ┇ 0x81, 0x02, // Input (Data,Var,Abs) 34290* # 0x95, 0x06, // Report Count (6) 36291* # ┇ 0x81, 0x03, // Input (Cnst,Var,Abs) 38292* # 0xa1, 0x02, // Collection (Logical) 40293* # 0x05, 0x01, // Usage Page (Generic Desktop) 42294* # 0x09, 0x37, // Usage (Dial) 44295* # 0x16, 0x00, 0x80, // Logical Minimum (-32768) 46296* # 0x26, 0xff, 0x7f, // Logical Maximum (32767) 49297* # 0x75, 0x10, // Report Size (16) 52298* # 0x95, 0x01, // Report Count (1) 54299* # ┇ 0x81, 0x06, // Input (Data,Var,Rel) 56300* # 0x35, 0x00, // Physical Minimum (0) 58301* # 0x46, 0x10, 0x0e, // Physical Maximum (3600) 60302* # 0x15, 0x00, // Logical Minimum (0) 63303* # 0x26, 0x10, 0x0e, // Logical Maximum (3600) 65304* # 0x09, 0x48, // Usage (Resolution Multiplier) 68305* # ║ 0xb1, 0x02, // Feature (Data,Var,Abs) 70306* # 0x45, 0x00, // Physical Maximum (0) 72307* # 0xc0, // End Collection 74308* # 0x75, 0x08, // Report Size (8) 75309* # 0x95, 0x01, // Report Count (1) 77310* # ┇ 0x81, 0x01, // Input (Cnst,Arr,Abs) 79311* # 0x75, 0x08, // Report Size (8) 81312* # 0x95, 0x01, // Report Count (1) 83313* # ┇ 0x81, 0x01, // Input (Cnst,Arr,Abs) 85314* # 0x75, 0x08, // Report Size (8) 87315* # 0x95, 0x01, // Report Count (1) 89316* # ┇ 0x81, 0x01, // Input (Cnst,Arr,Abs) 91317* # 0x75, 0x08, // Report Size (8) 93318* # 0x95, 0x01, // Report Count (1) 95319* # ┇ 0x81, 0x01, // Input (Cnst,Arr,Abs) 97320* # 0x75, 0x08, // Report Size (8) 99321* # 0x95, 0x01, // Report Count (1) 101322* # ┇ 0x81, 0x01, // Input (Cnst,Arr,Abs) 103323* # 0xc0, // End Collection 105324* # 0xc0, // End Collection 106325* # 0xc0, // End Collection 107326* R: 108 05 01 09 0e a1 01 85 11 05 0d 09 21 a1 02 15 00 25 01 75 01 95 01 a1 00 05 09 09 01 81 02 05 0d 09 33 81 02 95 06 81 03 a1 02 05 01 09 37 16 00 80 26 ff 7f 75 10 95 01 81 06 35 00 46 10 0e 15 00 26 10 0e 09 48 b1 02 45 00 c0 75 08 95 01 81 01 75 08 95 01 81 01 75 08 95 01 81 01 75 08 95 01 81 01 75 08 95 01 81 01 c0 c0 c0327* N: HUION Huion Tablet_GS1333328* I: 3 256c 2008329*330*331*332*333*334*335*336*337* VENDOR MODE338* HUION_FIRMWARE_ID="HUION_M22c_240606"339* HUION_MAGIC_BYTES="140388e500108100ff3fd8130307008008004010"340*341* MAGIC BYTES342* [LogicalMaximum, X] [LogicalMaximum, Y] [LogicalMaximum, Pressure] [ LPI]343* 14 03 [ 88 e5] 00 [ 10 81] 00 [ ff 3f] [d8 13] 03 07 00 80 08 00 40 10344*345*346* HIDRAW 0347* DESCRIPTIONS348* report_subtype = (data[1] >> 4) & 0x0f349*350* REPORT SUBTYPES351* 0x0e Buttons352* (data[4] & 0x01) button 1353* (data[4] & 0x02) button 2354* (data[4] & 0x04) button 3355* (data[4] & 0x08) button 4356* (data[4] & 0x10) button 5357* (data[4] & 0x20) button 6 (top wheel button)358* (data[4] & 0x40) button 7 (bottom wheel button)359*360* All tablet buttons release with the same report:361* 08 e0 01 01 00 00 00 00 00 00 00 00 00 00362*363* Despite data[4] looking like a bit field, only one button364* can be unambiguously tracked at a time.365* (See NOTES ON SIMULTANEOUS BUTTON HOLDS at the end of this366* comment for examples of the confusion this can create.)367*368* All buttons, with the exceptions of 6 and 7, will repeatedly369* report a press event approximately every 225ms while held.370*371* 0x0f Wheels372* data[3] == 1: top wheel373* data[3] == 2: bottom wheel374* data[5] == 1: clockwise375* data[5] == 2: counter-clockwise376*377* 0x08/0x00 Pen378* report_subtype == 0x08: in-range379* report_subtype == 0x00: out-of-range380* For clarity, this is also equivalent to:381* (data[1] & 0x80) in-range382*383* Switches384* (data[1] & 0x01) tip switch385* (data[1] & 0x02) barrel switch386* (data[1] & 0x04) secondary barrel switch387* (data[1] & 0x08) third barrel switch388*389* Unfortunately, I don't have a pen with an eraser, so I can't390* confirm where the invert and eraser bits reside.391* If we guess using the definitions from HID descriptor 1,392* then they might be...393* (data[1] & 0x08) invert (conflicts with third barrel switch)394* (data[1] & 0x10) eraser395*396* data[2], data[3] X (little-endian, maximum 0xe588)397*398* data[4], data[5] Y (little-endian, maximum 0x8110)399*400* data[6], data[7] Pressure (little-endian, maximum 0x3fff)401*402* data[10] X tilt (signed, -60 to +60)403* data[11] Y tilt (signed, -60 to +60, inverted)404*405*406* EXAMPLE REPORTS407* Top wheel button, press, hold, then release408* E: 000000.000040 14 08 e0 01 01 20 00 00 00 00 00 00 00 00 00409* E: 000001.531559 14 08 e0 01 01 00 00 00 00 00 00 00 00 00 00410*411* Bottom wheel button, press, hold, then release412* E: 000002.787603 14 08 e0 01 01 40 00 00 00 00 00 00 00 00 00413* E: 000004.215609 14 08 e0 01 01 00 00 00 00 00 00 00 00 00 00414*415*416* Top wheel rotation, one detent CW417* E: 000194.003899 14 08 f1 01 01 00 01 00 00 00 00 00 00 00 00418*419* Top wheel rotation, one detent CCW420* E: 000194.997812 14 08 f1 01 01 00 02 00 00 00 00 00 00 00 00421*422* Bottom wheel rotation, one detent CW423* E: 000196.693840 14 08 f1 01 02 00 01 00 00 00 00 00 00 00 00424*425* Bottom wheel rotation, one detent CCW426* E: 000197.757895 14 08 f1 01 02 00 02 00 00 00 00 00 00 00 00427*428*429* Button 1, press, hold, then release430* E: 000000.000149 14 08 e0 01 01 01 00 00 00 00 00 00 00 00 00 < press431* E: 000000.447598 14 08 e0 01 01 01 00 00 00 00 00 00 00 00 00 < starting to auto-repeat, every ~225ms432* E: 000000.673586 14 08 e0 01 01 01 00 00 00 00 00 00 00 00 00433* E: 000000.900582 14 08 e0 01 01 01 00 00 00 00 00 00 00 00 00434* E: 000001.126703 14 08 e0 01 01 01 00 00 00 00 00 00 00 00 00435* E: 000001.347706 14 08 e0 01 01 01 00 00 00 00 00 00 00 00 00436* E: 000001.533721 14 08 e0 01 01 00 00 00 00 00 00 00 00 00 00 < release437*438* Button 2, press, hold, then release439* E: 000003.304735 14 08 e0 01 01 02 00 00 00 00 00 00 00 00 00 < press440* E: 000003.746743 14 08 e0 01 01 02 00 00 00 00 00 00 00 00 00 < starting to auto-repeat, every ~225ms441* E: 000003.973741 14 08 e0 01 01 02 00 00 00 00 00 00 00 00 00442* E: 000004.199832 14 08 e0 01 01 02 00 00 00 00 00 00 00 00 00443* E: 000004.426732 14 08 e0 01 01 02 00 00 00 00 00 00 00 00 00444* E: 000004.647738 14 08 e0 01 01 02 00 00 00 00 00 00 00 00 00445* E: 000004.874733 14 08 e0 01 01 02 00 00 00 00 00 00 00 00 00446* E: 000004.930713 14 08 e0 01 01 00 00 00 00 00 00 00 00 00 00 < release447*448* Button 3, press, hold, then release449* E: 000006.650346 14 08 e0 01 01 04 00 00 00 00 00 00 00 00 00 < press450* E: 000007.051782 14 08 e0 01 01 04 00 00 00 00 00 00 00 00 00 < starting to auto-repeat, every ~225ms451* E: 000007.273738 14 08 e0 01 01 04 00 00 00 00 00 00 00 00 00452* E: 000007.499794 14 08 e0 01 01 04 00 00 00 00 00 00 00 00 00453* E: 000007.726725 14 08 e0 01 01 04 00 00 00 00 00 00 00 00 00454* E: 000007.947765 14 08 e0 01 01 04 00 00 00 00 00 00 00 00 00455* E: 000008.174755 14 08 e0 01 01 04 00 00 00 00 00 00 00 00 00456* E: 000008.328786 14 08 e0 01 01 00 00 00 00 00 00 00 00 00 00 < release457*458* Button 4, press, hold, then release459* E: 000009.893820 14 08 e0 01 01 08 00 00 00 00 00 00 00 00 00 < press460* E: 000010.274781 14 08 e0 01 01 08 00 00 00 00 00 00 00 00 00 < starting to auto-repeat, every ~225ms461* E: 000010.500931 14 08 e0 01 01 08 00 00 00 00 00 00 00 00 00462* E: 000010.722777 14 08 e0 01 01 08 00 00 00 00 00 00 00 00 00463* E: 000010.948778 14 08 e0 01 01 08 00 00 00 00 00 00 00 00 00464* E: 000011.175799 14 08 e0 01 01 08 00 00 00 00 00 00 00 00 00465* E: 000011.401153 14 08 e0 01 01 08 00 00 00 00 00 00 00 00 00466* E: 000011.432114 14 08 e0 01 01 00 00 00 00 00 00 00 00 00 00 < release467*468* Button 5, press, hold, then release469* E: 000013.007778 14 08 e0 01 01 10 00 00 00 00 00 00 00 00 00 < press470* E: 000013.424741 14 08 e0 01 01 10 00 00 00 00 00 00 00 00 00 < starting to auto-repeat, every ~225ms471* E: 000013.651715 14 08 e0 01 01 10 00 00 00 00 00 00 00 00 00472* E: 000013.872763 14 08 e0 01 01 10 00 00 00 00 00 00 00 00 00473* E: 000014.099789 14 08 e0 01 01 10 00 00 00 00 00 00 00 00 00474* E: 000014.325734 14 08 e0 01 01 10 00 00 00 00 00 00 00 00 00475* E: 000014.438080 14 08 e0 01 01 00 00 00 00 00 00 00 00 00 00 < release476*477*478* Pen: Top-left, then out of range479* E: 000368.572184 14 08 80 00 00 00 00 00 00 00 00 fb ed 03 00480* E: 000368.573030 14 08 00 00 00 00 00 00 00 00 00 fb ed 03 00481*482* Pen: Bottom-right, then out of range483* E: 000544.433185 14 08 80 88 e5 10 81 00 00 00 00 00 00 03 00484* E: 000544.434183 14 08 00 88 e5 10 81 00 00 00 00 00 00 03 00485*486* Pen: Max Y tilt (tip of pen points down)487* E: 000002.231927 14 08 80 f5 5d 6c 36 00 00 00 00 09 3c 03 00488*489* Pen: Min Y Tilt (tip of pen points up)490* E: 000657.593338 14 08 80 5f 69 fa 2c 00 00 00 00 fe c4 03 00491*492* Pen: Max X tilt (tip of pen points left)493* E: 000742.246503 14 08 80 2a 4f c4 38 00 00 00 00 3c ed 03 00494*495* Pen: Min X Tilt (tip of pen points right)496* E: 000776.404446 14 08 00 18 85 7c 3b 00 00 00 00 c4 ed 03 00497*498* Pen: Tip switch, max pressure, then low pressure499* E: 001138.935675 14 08 81 d2 66 04 40 ff 3f 00 00 00 08 03 00500*501* E: 001142.403715 14 08 81 9d 69 47 3e 82 04 00 00 00 07 03 00502*503* Pen: Barrel switch504* E: 001210.645652 14 08 82 0d 72 ea 2b 00 00 00 00 db c4 03 00505*506* Pen: Secondary barrel switch507* E: 001211.519729 14 08 84 2c 71 51 2b 00 00 00 00 da c4 03 00508*509* Pen: Third switch510* E: 001212.443722 14 08 88 1d 72 df 2b 00 00 00 00 dc c4 03 00511*512*513* HIDRAW 1514* No reports515*516*517* HIDRAW 2518* No reports519*520*521*522*523*524*525*526*527* FIRMWARE MODE528* HIDRAW 0529* No reports530*531*532* HIDRAW 1533* EXAMPLE REPORTS534* Top wheel button, *release*535* E: 000067.043739 8 03 00 00 00 00 00 00 00536*537* Bottom wheel button, *release*538* E: 000068.219161 8 03 00 00 00 00 00 00 00539*540*541* Button 1, press, then release542* E: 000163.767870 8 03 00 05 00 00 00 00 00543* E: 000165.969193 8 03 00 00 00 00 00 00 00544*545* Button 2, press, then release546* E: 000261.728935 8 03 05 11 00 00 00 00 00547* E: 000262.956220 8 03 00 00 00 00 00 00 00548*549* Button 3, press, then release550* E: 000289.127881 8 03 01 16 00 00 00 00 00551* E: 000290.014594 8 03 00 00 00 00 00 00 00552*553* Button 4, press, then release554* E: 000303.025839 8 03 00 2c 00 00 00 00 00555* E: 000303.994479 8 03 00 00 00 00 00 00 00556*557* Button 5, press, then release558* E: 000315.500835 8 03 05 1d 00 00 00 00 00559* E: 000316.603274 8 03 00 00 00 00 00 00 00560*561* BUTTON SUMMARY562* 1 E: 000163.767870 8 03 00 05 00 00 00 00 00 Keyboard: B563* 2 E: 000261.728935 8 03 05 11 00 00 00 00 00 Keyboard: LCtrl+LAlt N564* 3 E: 000289.127881 8 03 01 16 00 00 00 00 00 Keyboard: LCtrl S565* 4 E: 000303.025839 8 03 00 2c 00 00 00 00 00 Keyboard: Space566* 5 E: 000315.500835 8 03 05 1d 00 00 00 00 00 Keyboard: LCtrl+LAlt567*568* All buttons (including the wheel buttons) release the same way:569* 03 00 00 00 00 00 00 00570*571*572* Pen: Top-left, then out of range573* E: 000063.196828 10 0a c0 00 00 00 00 00 00 00 02574* E: 000063.197762 10 0a 00 00 00 00 00 00 00 00 02575*576* Pen: Bottom-right, then out of range577* E: 000197.123138 10 0a c0 ff 7f ff 7f 00 00 00 00578* E: 000197.124915 10 0a 00 ff 7f ff 7f 00 00 00 00579*580* Pen: Max Y Tilt (tip of pen points up)581* E: 000291.399541 10 0a c0 19 32 0b 58 00 00 00 3c582*583* Pen: Min Y tilt (tip of pen points down)584* E: 000340.888288 10 0a c0 85 40 89 6e 00 00 17 c4585*586* Pen: Max X tilt (tip of pen points left)587* E: 000165.575115 10 0a c0 a7 34 99 42 00 00 3c f4588*589* Pen: Min X Tilt (tip of pen points right)590* E: 000129.507883 10 0a c0 ea 4b 08 40 00 00 c4 1a591*592* Pen: Tip switch, max pressure, then low pressure593* E: 000242.077160 10 0a c1 7e 3c 12 31 ff 3f 03 fd594*595* E: 000339.139188 10 0a c1 ee 3a 9e 32 b5 00 06 f6596*597* Pen: Barrel switch598* E: 000037.949777 10 0a c2 5c 28 47 2a 00 00 f6 3c599*600* Pen: Secondary barrel switch601* E: 000038.320840 10 0a c4 e4 27 fd 29 00 00 f3 38602*603* Pen: Third switch604* E: 000038.923822 10 0a c8 97 27 5f 29 00 00 f2 33605*606*607* HIDRAW 2608* EXAMPLE REPORTS609* Either wheel rotation, one detent CW610* E: 000097.276573 9 11 00 01 00 00 00 00 00 00611*612* Either wheel rotation, one detent CCW613* E: 000153.416538 9 11 00 ff ff 00 00 00 00 00614*615* Either wheel rotation, increasing rotation speed CW616* (Note that the wheels on my particular tablet may be617* damaged, so the false rotation direction changes618* that can be observed might not happen on other units.)619* E: 000210.514925 9 11 00 01 00 00 00 00 00 00620* E: 000210.725718 9 11 00 01 00 00 00 00 00 00621* E: 000210.924009 9 11 00 01 00 00 00 00 00 00622* E: 000211.205629 9 11 00 01 00 00 00 00 00 00623* E: 000211.280521 9 11 00 0b 00 00 00 00 00 00624* E: 000211.340121 9 11 00 0e 00 00 00 00 00 00625* E: 000211.404018 9 11 00 0d 00 00 00 00 00 00626* E: 000211.462060 9 11 00 0e 00 00 00 00 00 00627* E: 000211.544886 9 11 00 0a 00 00 00 00 00 00628* E: 000211.606130 9 11 00 0d 00 00 00 00 00 00629* E: 000211.674560 9 11 00 0c 00 00 00 00 00 00630* E: 000211.712039 9 11 00 16 00 00 00 00 00 00631* E: 000211.748076 9 11 00 17 00 00 00 00 00 00632* E: 000211.786016 9 11 00 17 00 00 00 00 00 00633* E: 000211.832960 9 11 00 11 00 00 00 00 00 00634* E: 000211.874081 9 11 00 14 00 00 00 00 00 00635* E: 000211.925094 9 11 00 10 00 00 00 00 00 00636* E: 000211.959048 9 11 00 18 00 00 00 00 00 00637* E: 000212.006937 9 11 00 11 00 00 00 00 00 00638* E: 000212.050055 9 11 00 13 00 00 00 00 00 00639* E: 000212.091947 9 11 00 14 00 00 00 00 00 00640* E: 000212.122989 9 11 00 1a 00 00 00 00 00 00641* E: 000212.160866 9 11 00 16 00 00 00 00 00 00642* E: 000212.194002 9 11 00 19 00 00 00 00 00 00643* E: 000212.242249 9 11 00 11 00 00 00 00 00 00644* E: 000212.278061 9 11 00 18 00 00 00 00 00 00645* E: 000212.328899 9 11 00 10 00 00 00 00 00 00646* E: 000212.354005 9 11 00 22 00 00 00 00 00 00647* E: 000212.398995 9 11 00 12 00 00 00 00 00 00648* E: 000212.432050 9 11 00 19 00 00 00 00 00 00649* E: 000212.471164 9 11 00 16 00 00 00 00 00 00650* E: 000212.507047 9 11 00 17 00 00 00 00 00 00651* E: 000212.540964 9 11 00 19 00 00 00 00 00 00652* E: 000212.567942 9 11 00 1f 00 00 00 00 00 00653* E: 000212.610007 9 11 00 14 00 00 00 00 00 00654* E: 000212.641101 9 11 00 1b 00 00 00 00 00 00655* E: 000212.674113 9 11 00 19 00 00 00 00 00 00656* E: 000212.674909 9 11 00 01 00 00 00 00 00 00657* E: 000212.677062 9 11 00 00 02 00 00 00 00 00658* E: 000212.679048 9 11 00 55 01 00 00 00 00 00659* E: 000212.682166 9 11 00 55 01 00 00 00 00 00660* E: 000212.682788 9 11 00 ff ff 00 00 00 00 00661* E: 000212.683899 9 11 00 01 00 00 00 00 00 00662* E: 000212.685827 9 11 00 67 fe 00 00 00 00 00663* E: 000212.686941 9 11 00 00 08 00 00 00 00 00664* E: 000212.727840 9 11 00 14 00 00 00 00 00 00665* E: 000212.772884 9 11 00 13 00 00 00 00 00 00666* E: 000212.810975 9 11 00 16 00 00 00 00 00 00667* E: 000212.811793 9 11 00 00 08 00 00 00 00 00668* E: 000212.812683 9 11 00 01 00 00 00 00 00 00669* E: 000212.813905 9 11 00 01 00 00 00 00 00 00670* E: 000212.814909 9 11 00 00 04 00 00 00 00 00671* E: 000212.816942 9 11 00 01 00 00 00 00 00 00672* E: 000212.817851 9 11 00 ff ff 00 00 00 00 00673* E: 000212.818752 9 11 00 01 00 00 00 00 00 00674* E: 000212.819910 9 11 00 56 fd 00 00 00 00 00675* E: 000212.820781 9 11 00 ff ff 00 00 00 00 00676* E: 000212.821811 9 11 00 00 04 00 00 00 00 00677* E: 000212.822920 9 11 00 00 08 00 00 00 00 00678* E: 000212.823861 9 11 00 00 02 00 00 00 00 00679* E: 000212.828781 9 11 00 ba 00 00 00 00 00 00680* E: 000212.874097 9 11 00 12 00 00 00 00 00 00681* E: 000212.874872 9 11 00 00 fc 00 00 00 00 00682* E: 000212.876136 9 11 00 00 fc 00 00 00 00 00683* E: 000212.877036 9 11 00 00 f8 00 00 00 00 00684* E: 000212.877993 9 11 00 00 f8 00 00 00 00 00685* E: 000212.879748 9 11 00 01 00 00 00 00 00 00686* E: 000212.880728 9 11 00 01 00 00 00 00 00 00687* E: 000212.881956 9 11 00 00 04 00 00 00 00 00688* E: 000212.885065 9 11 00 ff ff 00 00 00 00 00689* E: 000212.917060 9 11 00 1a 00 00 00 00 00 00690* E: 000212.936458 9 11 00 2d 00 00 00 00 00 00691* E: 000212.957860 9 11 00 25 00 00 00 00 00 00692* E: 000212.984019 9 11 00 20 00 00 00 00 00 00693* E: 000213.017915 9 11 00 19 00 00 00 00 00 00694* E: 000213.039973 9 11 00 27 00 00 00 00 00 00695* E: 000213.065933 9 11 00 21 00 00 00 00 00 00696* E: 000213.085807 9 11 00 28 00 00 00 00 00 00697* E: 000213.108888 9 11 00 25 00 00 00 00 00 00698* E: 000213.129726 9 11 00 29 00 00 00 00 00 00699* E: 000213.172043 9 11 00 14 00 00 00 00 00 00700* E: 000213.195873 9 11 00 23 00 00 00 00 00 00701* E: 000213.222884 9 11 00 20 00 00 00 00 00 00702* E: 000213.243220 9 11 00 2a 00 00 00 00 00 00703* E: 000213.266778 9 11 00 24 00 00 00 00 00 00704* E: 000213.285951 9 11 00 2b 00 00 00 00 00 00705* E: 000213.306045 9 11 00 2a 00 00 00 00 00 00706* E: 000213.306796 9 11 00 ff ff 00 00 00 00 00707* E: 000213.307755 9 11 00 ff ff 00 00 00 00 00708* E: 000213.308820 9 11 00 ff ff 00 00 00 00 00709* E: 000213.309971 9 11 00 ff ff 00 00 00 00 00710* E: 000213.310980 9 11 00 01 00 00 00 00 00 00711* E: 000213.311853 9 11 00 01 00 00 00 00 00 00712* E: 000213.312861 9 11 00 aa 02 00 00 00 00 00713* E: 000213.313884 9 11 00 00 f8 00 00 00 00 00714* E: 000213.315111 9 11 00 ff ff 00 00 00 00 00715* E: 000213.315992 9 11 00 01 00 00 00 00 00 00716* E: 000213.316955 9 11 00 00 08 00 00 00 00 00717* E: 000213.346065 9 11 00 1d 00 00 00 00 00 00718* E: 000213.346963 9 11 00 ff ff 00 00 00 00 00719* E: 000213.347874 9 11 00 00 08 00 00 00 00 00720* E: 000213.348736 9 11 00 00 08 00 00 00 00 00721* E: 000213.349795 9 11 00 00 04 00 00 00 00 00722* E: 000213.350791 9 11 00 01 00 00 00 00 00 00723* E: 000213.351791 9 11 00 01 00 00 00 00 00 00724* E: 000213.352729 9 11 00 00 f8 00 00 00 00 00725* E: 000213.353811 9 11 00 01 00 00 00 00 00 00726* E: 000213.354755 9 11 00 00 f8 00 00 00 00 00727* E: 000213.355795 9 11 00 00 f8 00 00 00 00 00728* E: 000213.356813 9 11 00 01 00 00 00 00 00 00729* E: 000213.357817 9 11 00 00 04 00 00 00 00 00730* E: 000213.393838 9 11 00 17 00 00 00 00 00 00731* E: 000213.394719 9 11 00 00 04 00 00 00 00 00732* E: 000213.395682 9 11 00 00 08 00 00 00 00 00733* E: 000213.396679 9 11 00 00 04 00 00 00 00 00734* E: 000213.397651 9 11 00 00 fc 00 00 00 00 00735* E: 000213.398661 9 11 00 ff ff 00 00 00 00 00736* E: 000213.400308 9 11 00 56 fd 00 00 00 00 00737* E: 000213.400909 9 11 00 00 f8 00 00 00 00 00738* E: 000213.401837 9 11 00 01 00 00 00 00 00 00739*740* Either wheel rotation, increasing rotation speed CCW741* (Note that the wheels on my particular tablet may be742* damaged, so the false rotation direction changes743* that can be observed might not happen on other units.)744* E: 000040.527820 9 11 00 ff ff 00 00 00 00 00745* E: 000040.816644 9 11 00 ff ff 00 00 00 00 00746* E: 000040.880423 9 11 00 f3 ff 00 00 00 00 00747* E: 000040.882570 9 11 00 ff ff 00 00 00 00 00748* E: 000040.883381 9 11 00 ff ff 00 00 00 00 00749* E: 000040.885463 9 11 00 aa 02 00 00 00 00 00750* E: 000040.924106 9 11 00 ea ff 00 00 00 00 00751* E: 000041.006155 9 11 00 f6 ff 00 00 00 00 00752* E: 000041.085799 9 11 00 f6 ff 00 00 00 00 00753* E: 000041.168492 9 11 00 f6 ff 00 00 00 00 00754* E: 000041.233453 9 11 00 f3 ff 00 00 00 00 00755* E: 000041.296641 9 11 00 f3 ff 00 00 00 00 00756* E: 000041.370302 9 11 00 f5 ff 00 00 00 00 00757* E: 000041.437410 9 11 00 f4 ff 00 00 00 00 00758* E: 000041.474514 9 11 00 e9 ff 00 00 00 00 00759* E: 000041.522171 9 11 00 ef ff 00 00 00 00 00760* E: 000041.568160 9 11 00 ee ff 00 00 00 00 00761* E: 000041.608146 9 11 00 ec ff 00 00 00 00 00762* E: 000041.627132 9 11 00 d3 ff 00 00 00 00 00763* E: 000041.656151 9 11 00 e3 ff 00 00 00 00 00764* E: 000041.682264 9 11 00 e0 ff 00 00 00 00 00765* E: 000041.714186 9 11 00 e6 ff 00 00 00 00 00766* E: 000041.740339 9 11 00 e0 ff 00 00 00 00 00767* E: 000041.772087 9 11 00 e5 ff 00 00 00 00 00768* E: 000041.801093 9 11 00 e3 ff 00 00 00 00 00769* E: 000041.834051 9 11 00 e7 ff 00 00 00 00 00770* E: 000041.863094 9 11 00 e3 ff 00 00 00 00 00771* E: 000041.901016 9 11 00 ea ff 00 00 00 00 00772* E: 000041.901956 9 11 00 00 04 00 00 00 00 00773* E: 000041.902837 9 11 00 00 fe 00 00 00 00 00774* E: 000041.903927 9 11 00 01 00 00 00 00 00 00775* E: 000041.905066 9 11 00 01 00 00 00 00 00 00776* E: 000041.907214 9 11 00 00 fe 00 00 00 00 00777* E: 000041.909011 9 11 00 01 00 00 00 00 00 00778* E: 000041.909953 9 11 00 01 00 00 00 00 00 00779* E: 000041.910917 9 11 00 00 08 00 00 00 00 00780* E: 000041.913280 9 11 00 00 fe 00 00 00 00 00781* E: 000041.914121 9 11 00 56 fd 00 00 00 00 00782* E: 000041.915346 9 11 00 ff ff 00 00 00 00 00783* E: 000041.962101 9 11 00 ee ff 00 00 00 00 00784* E: 000041.964062 9 11 00 56 fd 00 00 00 00 00785* E: 000041.964978 9 11 00 00 fc 00 00 00 00 00786* E: 000041.968058 9 11 00 24 01 00 00 00 00 00787* E: 000041.968880 9 11 00 56 fd 00 00 00 00 00788* E: 000041.970977 9 11 00 aa 02 00 00 00 00 00789* E: 000041.971932 9 11 00 ff ff 00 00 00 00 00790* E: 000041.972943 9 11 00 01 00 00 00 00 00 00791* E: 000041.975291 9 11 00 ff ff 00 00 00 00 00792* E: 000041.978274 9 11 00 01 00 00 00 00 00 00793* E: 000042.035079 9 11 00 01 00 00 00 00 00 00794* E: 000042.041283 9 11 00 ff ff 00 00 00 00 00795* E: 000042.042057 9 11 00 00 04 00 00 00 00 00796* E: 000042.045169 9 11 00 ff ff 00 00 00 00 00797* E: 000042.051242 9 11 00 ff ff 00 00 00 00 00798* E: 000042.056099 9 11 00 63 ff 00 00 00 00 00799* E: 000042.106329 9 11 00 ef ff 00 00 00 00 00800* E: 000042.108601 9 11 00 ff ff 00 00 00 00 00801* E: 000042.116259 9 11 00 6b 00 00 00 00 00 00802* E: 000042.119140 9 11 00 55 01 00 00 00 00 00803* E: 000042.126101 9 11 00 88 ff 00 00 00 00 00804* E: 000042.158009 9 11 00 e6 ff 00 00 00 00 00805* E: 000042.172108 9 11 00 be ff 00 00 00 00 00806* E: 000042.207417 9 11 00 e8 ff 00 00 00 00 00807* E: 000042.223155 9 11 00 cc ff 00 00 00 00 00808* E: 000042.255185 9 11 00 e6 ff 00 00 00 00 00809* E: 000042.276280 9 11 00 d7 ff 00 00 00 00 00810* E: 000042.302128 9 11 00 e0 ff 00 00 00 00 00811* E: 000042.317423 9 11 00 c8 ff 00 00 00 00 00812* E: 000042.345226 9 11 00 e1 ff 00 00 00 00 00813* E: 000042.357243 9 11 00 bc ff 00 00 00 00 00814* E: 000042.381308 9 11 00 dc ff 00 00 00 00 00815* E: 000042.383180 9 11 00 dc fe 00 00 00 00 00816* E: 000042.412288 9 11 00 e3 ff 00 00 00 00 00817* E: 000042.451216 9 11 00 eb ff 00 00 00 00 00818* E: 000042.478372 9 11 00 e0 ff 00 00 00 00 00819* E: 000042.502116 9 11 00 dd ff 00 00 00 00 00820* E: 000042.520105 9 11 00 d3 ff 00 00 00 00 00821* E: 000042.540345 9 11 00 d6 ff 00 00 00 00 00822* E: 000042.541021 9 11 00 00 08 00 00 00 00 00823* E: 000042.542009 9 11 00 01 00 00 00 00 00 00824* E: 000042.543045 9 11 00 00 04 00 00 00 00 00825* E: 000042.544279 9 11 00 ff ff 00 00 00 00 00826* E: 000042.545097 9 11 00 ff ff 00 00 00 00 00827* E: 000042.546074 9 11 00 00 08 00 00 00 00 00828* E: 000042.547237 9 11 00 00 08 00 00 00 00 00829* E: 000042.548029 9 11 00 ff ff 00 00 00 00 00830* E: 000042.549304 9 11 00 00 f8 00 00 00 00 00831* E: 000042.553123 9 11 00 00 ff 00 00 00 00 00832* E: 000042.581186 9 11 00 e1 ff 00 00 00 00 00833* E: 000042.582238 9 11 00 00 f8 00 00 00 00 00834* E: 000042.583150 9 11 00 00 fc 00 00 00 00 00835* E: 000042.584273 9 11 00 00 f8 00 00 00 00 00836* E: 000042.585019 9 11 00 00 fc 00 00 00 00 00837* E: 000042.586059 9 11 00 01 00 00 00 00 00 00838* E: 000042.589012 9 11 00 67 fe 00 00 00 00 00839* E: 000042.590066 9 11 00 00 fc 00 00 00 00 00840* E: 000042.592916 9 11 00 dc fe 00 00 00 00 00841* E: 000042.621124 9 11 00 e1 ff 00 00 00 00 00842* E: 000042.622092 9 11 00 ff ff 00 00 00 00 00843* E: 000042.623069 9 11 00 01 00 00 00 00 00 00844* E: 000042.624030 9 11 00 ff ff 00 00 00 00 00845* E: 000042.625006 9 11 00 00 08 00 00 00 00 00846* E: 000042.626068 9 11 00 00 04 00 00 00 00 00847* E: 000042.626876 9 11 00 00 08 00 00 00 00 00848* E: 000042.628392 9 11 00 00 08 00 00 00 00 00849* E: 000042.628918 9 11 00 01 00 00 00 00 00 00850* E: 000042.630009 9 11 00 ff ff 00 00 00 00 00851* E: 000042.631934 9 11 00 00 fe 00 00 00 00 00852* E: 000042.656285 9 11 00 dd ff 00 00 00 00 00853* E: 000042.659870 9 11 00 cc 00 00 00 00 00 00854* E: 000042.666128 9 11 00 9d 00 00 00 00 00 00855* E: 000042.672458 9 11 00 80 ff 00 00 00 00 00856* E: 000042.696106 9 11 00 dc ff 00 00 00 00 00857* E: 000042.705129 9 11 00 61 00 00 00 00 00 00858* E: 000042.731303 9 11 00 e0 ff 00 00 00 00 00859* E: 000042.741278 9 11 00 ab ff 00 00 00 00 00860* E: 000042.788181 9 11 00 ee ff 00 00 00 00 00861* E: 000042.810441 9 11 00 db ff 00 00 00 00 00862* E: 000042.838073 9 11 00 e1 ff 00 00 00 00 00863* E: 000042.852235 9 11 00 c4 ff 00 00 00 00 00864* E: 000042.882290 9 11 00 e4 ff 00 00 00 00 00865*866* Either wheel button, press, hold, then release867* E: 000202.084982 9 11 02 00 00 00 00 00 00 00868* E: 000202.090172 9 11 03 00 00 00 00 00 00 00869* E: 000202.094139 9 11 03 00 00 00 00 00 00 00870* E: 000202.099172 9 11 03 00 00 00 00 00 00 00871* E: 000202.105055 9 11 03 00 00 00 00 00 00 00872* E: 000202.109132 9 11 03 00 00 00 00 00 00 00873* E: 000202.114185 9 11 03 00 00 00 00 00 00 00874* E: 000202.119212 9 11 03 00 00 00 00 00 00 00875* E: 000202.124264 9 11 03 00 00 00 00 00 00 00876* E: 000202.130147 9 11 03 00 00 00 00 00 00 00877* E: 000202.135138 9 11 03 00 00 00 00 00 00 00878* E: 000202.140072 9 11 03 00 00 00 00 00 00 00879* E: 000202.145146 9 11 03 00 00 00 00 00 00 00880* E: 000202.150157 9 11 03 00 00 00 00 00 00 00881* E: 000202.155339 9 11 03 00 00 00 00 00 00 00882* E: 000202.160064 9 11 03 00 00 00 00 00 00 00883* E: 000202.165026 9 11 03 00 00 00 00 00 00 00884* E: 000202.170037 9 11 03 00 00 00 00 00 00 00885* E: 000202.175154 9 11 03 00 00 00 00 00 00 00886* E: 000202.180044 9 11 03 00 00 00 00 00 00 00887* E: 000202.186280 9 11 03 00 00 00 00 00 00 00888* E: 000202.191281 9 11 03 00 00 00 00 00 00 00889* E: 000202.196106 9 11 03 00 00 00 00 00 00 00890* E: 000202.201083 9 11 03 00 00 00 00 00 00 00891* E: 000202.206166 9 11 03 00 00 00 00 00 00 00892* E: 000202.211084 9 11 03 00 00 00 00 00 00 00893* E: 000202.216175 9 11 03 00 00 00 00 00 00 00894* E: 000202.221036 9 11 03 00 00 00 00 00 00 00895* E: 000202.226271 9 11 03 00 00 00 00 00 00 00896* E: 000202.231150 9 11 03 00 00 00 00 00 00 00897* E: 000202.235924 9 11 03 00 00 00 00 00 00 00898* E: 000202.242046 9 11 03 00 00 00 00 00 00 00899* E: 000202.247164 9 11 03 00 00 00 00 00 00 00900* E: 000202.252359 9 11 03 00 00 00 00 00 00 00901* E: 000202.257295 9 11 03 00 00 00 00 00 00 00902* E: 000202.262167 9 11 03 00 00 00 00 00 00 00903* E: 000202.267081 9 11 03 00 00 00 00 00 00 00904* E: 000202.272175 9 11 03 00 00 00 00 00 00 00905* E: 000202.277085 9 11 03 00 00 00 00 00 00 00906* E: 000202.282596 9 11 03 00 00 00 00 00 00 00907* E: 000202.287078 9 11 03 00 00 00 00 00 00 00908* E: 000202.292191 9 11 03 00 00 00 00 00 00 00909* E: 000202.298196 9 11 03 00 00 00 00 00 00 00910* E: 000202.303004 9 11 03 00 00 00 00 00 00 00911* E: 000202.308113 9 11 03 00 00 00 00 00 00 00912* E: 000202.313079 9 11 03 00 00 00 00 00 00 00913* E: 000202.318243 9 11 03 00 00 00 00 00 00 00914* E: 000202.323309 9 11 03 00 00 00 00 00 00 00915* E: 000202.328190 9 11 03 00 00 00 00 00 00 00916* E: 000202.333050 9 11 03 00 00 00 00 00 00 00917* E: 000202.338162 9 11 03 00 00 00 00 00 00 00918* E: 000202.343022 9 11 03 00 00 00 00 00 00 00919* E: 000202.348113 9 11 03 00 00 00 00 00 00 00920* E: 000202.354133 9 11 03 00 00 00 00 00 00 00921* E: 000202.359132 9 11 03 00 00 00 00 00 00 00922* E: 000202.364053 9 11 03 00 00 00 00 00 00 00923* E: 000202.369034 9 11 03 00 00 00 00 00 00 00924* E: 000202.374144 9 11 03 00 00 00 00 00 00 00925* E: 000202.379027 9 11 03 00 00 00 00 00 00 00926* E: 000202.384238 9 11 03 00 00 00 00 00 00 00927* E: 000202.389249 9 11 03 00 00 00 00 00 00 00928* E: 000202.394049 9 11 03 00 00 00 00 00 00 00929* E: 000202.398949 9 11 03 00 00 00 00 00 00 00930* E: 000202.404203 9 11 03 00 00 00 00 00 00 00931* E: 000202.410098 9 11 03 00 00 00 00 00 00 00932* E: 000202.415237 9 11 00 00 00 00 00 00 00 00933*934*935* Top wheel button press and release while holding bottom wheel button936* (The reverse action (a bottom wheel button press while holding the top wheel button) is invisible.)937* E: 000071.126966 9 11 03 00 00 00 00 00 00 00938* E: 000071.133117 9 11 03 00 00 00 00 00 00 00939* E: 000071.137481 9 11 03 00 00 00 00 00 00 00940* E: 000071.142036 9 11 03 00 00 00 00 00 00 00941* E: 000071.147027 9 11 03 00 00 00 00 00 00 00942* E: 000071.151988 9 11 03 00 00 00 00 00 00 00943* E: 000071.157945 9 11 03 00 00 00 00 00 00 00944* E: 000071.163657 9 11 03 00 00 00 00 00 00 00945* E: 000071.168240 9 11 03 00 00 00 00 00 00 00946* E: 000071.173109 9 11 02 00 00 00 00 00 00 00 < top wheel button press?947* E: 000071.178119 9 11 03 00 00 00 00 00 00 00948* E: 000071.183046 9 11 03 00 00 00 00 00 00 00949* E: 000071.187983 9 11 03 00 00 00 00 00 00 00950* E: 000071.192996 9 11 03 00 00 00 00 00 00 00951* E: 000071.198341 9 11 03 00 00 00 00 00 00 00952* E: 000071.203122 9 11 03 00 00 00 00 00 00 00953* E: 000071.208998 9 11 03 00 00 00 00 00 00 00954* E: 000071.214037 9 11 03 00 00 00 00 00 00 00955* E: 000071.218945 9 11 03 00 00 00 00 00 00 00956* E: 000071.223835 9 11 03 00 00 00 00 00 00 00957* E: 000071.228987 9 11 03 00 00 00 00 00 00 00958* E: 000071.234082 9 11 03 00 00 00 00 00 00 00959* E: 000071.239028 9 11 03 00 00 00 00 00 00 00960* E: 000071.244307 9 11 00 00 00 00 00 00 00 00 < top wheel button release?961* E: 000071.245867 9 11 03 00 00 00 00 00 00 00 < continued hold of bottom button962* E: 000071.249959 9 11 03 00 00 00 00 00 00 00963* E: 000071.255032 9 11 03 00 00 00 00 00 00 00964* E: 000071.259972 9 11 03 00 00 00 00 00 00 00965* E: 000071.265409 9 11 03 00 00 00 00 00 00 00966* E: 000071.270156 9 11 03 00 00 00 00 00 00 00967* E: 000071.275530 9 11 03 00 00 00 00 00 00 00968* E: 000071.279975 9 11 03 00 00 00 00 00 00 00969* E: 000071.285046 9 11 03 00 00 00 00 00 00 00970* E: 000071.290906 9 11 03 00 00 00 00 00 00 00971* E: 000071.296146 9 11 03 00 00 00 00 00 00 00972* E: 000071.301288 9 11 03 00 00 00 00 00 00 00973*974* Top wheel button hold while top wheel rotate CCW975* (I did not test the other combinations of this)976* E: 000022.253144 9 11 03 00 00 00 00 00 00 00977* E: 000022.258157 9 11 03 00 00 00 00 00 00 00978* E: 000022.262011 9 11 00 ff ff 00 00 00 00 00979* E: 000022.264015 9 11 03 00 00 00 00 00 00 00980* E: 000022.268976 9 11 03 00 00 00 00 00 00 00981*982*983*984*985*986*987*988*989* NOTES ON SIMULTANEOUS BUTTON HOLDS990* (applies to vendor mode only)991* Value replacements for ease of reading:992* .7 = 0x40 (button 7, a wheel button)993* .1 = 0x01 (button 1, a pad button)994* rr = 0x00 (no buttons pressed)995*996* Press 7997* Press 1998* Release 7999* Release 11000* B: 000000.000152 42 08 e0 01 01 .7 00 00 00 00 00 00 00 00 001001* B: 000000.781784 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001002* B: 000000.869845 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001003* B: 000001.095688 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001004* B: 000001.322635 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001005* B: 000001.543643 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001006* B: 000001.770652 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001007* B: 000001.885659 42 08 e0 01 01 rr 00 00 00 00 00 00 00 00 00 release of 71008* B: 000001.993620 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001009* B: 000002.220671 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001010* B: 000002.446589 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001011* B: 000002.672559 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001012* B: 000002.765183 42 08 e0 01 01 rr 00 00 00 00 00 00 00 00 00 release of 11013*1014* Press 71015* Press 11016* Release 11017* Release 71018* B: 000017.071517 42 08 e0 01 01 .7 00 00 00 00 00 00 00 00 001019* B: 000018.270461 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001020* B: 000018.419486 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001021* B: 000018.646438 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001022* B: 000018.872493 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001023* B: 000019.094422 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001024* B: 000019.320488 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001025* B: 000020.360505 42 08 e0 01 01 rr 00 00 00 00 00 00 00 00 00 release of 1 is not reported until 7 is released, then both are rapidly reported1026* B: 000020.361091 42 08 e0 01 01 rr 00 00 00 00 00 00 00 00 001027*1028* Press 11029* Press 71030* Release 71031* Release 11032* B: 000031.516315 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001033* B: 000031.922299 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001034* B: 000032.144165 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001035* B: 000032.370262 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001036* B: 000032.396242 42 08 e0 01 01 .7 00 00 00 00 00 00 00 00 001037* B: 000032.597270 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001038* B: 000032.818187 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001039* B: 000033.045143 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001040* B: 000033.267535 42 08 e0 01 01 rr 00 00 00 00 00 00 00 00 00 release of 71041* B: 000033.272602 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001042* B: 000033.494246 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001043* B: 000033.721266 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001044* B: 000033.947237 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001045* B: 000034.169294 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001046* B: 000034.183585 42 08 e0 01 01 rr 00 00 00 00 00 00 00 00 00 release of 11047*1048* Press 11049* Press 71050* Release 11051* Release 71052* B: 000056.628429 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001053* B: 000057.046348 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001054* B: 000057.272044 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001055* B: 000057.494434 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001056* B: 000057.601224 42 08 e0 01 01 .7 00 00 00 00 00 00 00 00 001057* B: 000057.719262 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001058* B: 000057.946941 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001059* B: 000058.172346 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001060* B: 000058.393994 42 08 e0 01 01 .1 00 00 00 00 00 00 00 00 001061* B: 000059.434576 42 08 e0 01 01 rr 00 00 00 00 00 00 00 00 00 release of 1 is not reported until 7 is released, then both are rapidly reported1062* B: 000059.435857 42 08 e0 01 01 rr 00 00 00 00 00 00 00 00 001063*/106410651066/* Filled in by udev-hid-bpf */1067char UDEV_PROP_HUION_FIRMWARE_ID[64];10681069char EXPECTED_FIRMWARE_ID[] = "HUION_M22c_";10701071__u8 last_button_state;10721073static const __u8 disabled_rdesc_tablet[] = {1074FixedSizeVendorReport(28) /* Input report 4 */1075};10761077static const __u8 disabled_rdesc_wheel[] = {1078FixedSizeVendorReport(9) /* Input report 17 */1079};10801081static const __u8 fixed_rdesc_vendor[] = {1082UsagePage_Digitizers1083Usage_Dig_Pen1084CollectionApplication(1085ReportId(VENDOR_REPORT_ID)1086UsagePage_Digitizers1087Usage_Dig_Pen1088CollectionPhysical(1089/*1090* I have only examined the tablet's behavior while using1091* the PW600L pen, which does not have an eraser.1092* Because of this, I don't know where the Eraser and Invert1093* bits will go, or if they work as one would expect.1094*1095* For the time being, there is no expectation that a pen1096* with an eraser will work without modifications here.1097*/1098ReportSize(1)1099LogicalMinimum_i8(0)1100LogicalMaximum_i8(1)1101ReportCount(3)1102Usage_Dig_TipSwitch1103Usage_Dig_BarrelSwitch1104Usage_Dig_SecondaryBarrelSwitch1105Input(Var|Abs)1106PushPop(1107ReportCount(1)1108UsagePage_Button1109Usage_i8(0x4a) /* (BTN_STYLUS3 + 1) & 0xff */1110Input(Var|Abs)1111)1112ReportCount(3)1113Input(Const)1114ReportCount(1)1115Usage_Dig_InRange1116Input(Var|Abs)1117ReportSize(16)1118ReportCount(1)1119PushPop(1120UsagePage_GenericDesktop1121Unit(cm)1122UnitExponent(-2)1123LogicalMinimum_i16(0)1124PhysicalMinimum_i16(0)1125/*1126* The tablet has a logical maximum of 58760 x 330401127* and a claimed resolution of 5080 LPI (200 L/mm)1128* This works out to a physical maximum of1129* 293.8 x 165.2mm, which matches Huion's advertised1130* active area dimensions from1131* https://www.huion.com/products/pen_display/Kamvas/kamvas-13-gen-3.html1132*/1133LogicalMaximum_i16(58760)1134PhysicalMaximum_i16(2938)1135Usage_GD_X1136Input(Var|Abs)1137LogicalMaximum_i16(33040)1138PhysicalMaximum_i16(1652)1139Usage_GD_Y1140Input(Var|Abs)1141)1142LogicalMinimum_i16(0)1143LogicalMaximum_i16(16383)1144Usage_Dig_TipPressure1145Input(Var|Abs)1146ReportCount(1)1147Input(Const)1148ReportSize(8)1149ReportCount(2)1150PushPop(1151Unit(deg)1152UnitExponent(0)1153LogicalMinimum_i8(-60)1154PhysicalMinimum_i8(-60)1155LogicalMaximum_i8(60)1156PhysicalMaximum_i8(60)1157Usage_Dig_XTilt1158Usage_Dig_YTilt1159Input(Var|Abs)1160)1161)1162)1163UsagePage_GenericDesktop1164Usage_GD_Keypad1165CollectionApplication(1166ReportId(CUSTOM_PAD_REPORT_ID)1167LogicalMinimum_i8(0)1168LogicalMaximum_i8(1)1169UsagePage_Digitizers1170Usage_Dig_TabletFunctionKeys1171CollectionPhysical(1172/*1173* The first 3 bytes are somewhat vestigial and will1174* always be set to zero. Their presence here is needed1175* to ensure that this device will be detected as a1176* tablet pad by software that otherwise wouldn't know1177* any better.1178*/1179/* (data[1] & 0x01) barrel switch */1180ReportSize(1)1181ReportCount(1)1182Usage_Dig_BarrelSwitch1183Input(Var|Abs)1184ReportCount(7)1185Input(Const)1186/* data[2] X */1187/* data[3] Y */1188ReportSize(8)1189ReportCount(2)1190UsagePage_GenericDesktop1191Usage_GD_X1192Usage_GD_Y1193Input(Var|Abs)1194/*1195* (data[4] & 0x01) button 11196* (data[4] & 0x02) button 21197* (data[4] & 0x04) button 31198* (data[4] & 0x08) button 41199* (data[4] & 0x10) button 51200* (data[4] & 0x20) button 6 (top wheel button)1201* (data[4] & 0x40) button 7 (bottom wheel button)1202*/1203ReportSize(1)1204ReportCount(7)1205UsagePage_Button1206UsageMinimum_i8(1)1207UsageMaximum_i8(7)1208Input(Var|Abs)1209ReportCount(1)1210Input(Const)1211/* data[5] top wheel (signed, positive clockwise) */1212ReportSize(8)1213ReportCount(1)1214UsagePage_GenericDesktop1215Usage_GD_Wheel1216LogicalMinimum_i8(-1)1217LogicalMaximum_i8(1)1218Input(Var|Rel)1219/* data[6] bottom wheel (signed, positive clockwise) */1220UsagePage_Consumer1221Usage_Con_ACPan1222Input(Var|Rel)1223)1224/*1225* The kernel will drop reports that are bigger than the1226* largest report specified in the HID descriptor.1227* Therefore, our modified descriptor needs to have at least one1228* HID report that is as long as, or longer than, the largest1229* report in the original descriptor.1230*1231* This macro expands to a no-op report that is padded to the1232* provided length.1233*/1234FixedSizeVendorReport(VENDOR_REPORT_LENGTH)1235)1236};12371238SEC(HID_BPF_RDESC_FIXUP)1239int BPF_PROG(hid_fix_rdesc_huion_kamvas13_gen3, struct hid_bpf_ctx *hid_ctx)1240{1241__u8 *data = hid_bpf_get_data(hid_ctx, 0 /* offset */, HID_MAX_DESCRIPTOR_SIZE /* size */);1242__s32 rdesc_size = hid_ctx->size;1243__u8 have_fw_id;12441245if (!data)1246return 0; /* EPERM check */12471248have_fw_id = __builtin_memcmp(UDEV_PROP_HUION_FIRMWARE_ID,1249EXPECTED_FIRMWARE_ID,1250sizeof(EXPECTED_FIRMWARE_ID) - 1) == 0;12511252if (have_fw_id) {1253/*1254* Tablet should be in vendor mode.1255* Disable the unused devices1256*/1257if (rdesc_size == TABLET_DESCRIPTOR_LENGTH) {1258__builtin_memcpy(data, disabled_rdesc_tablet,1259sizeof(disabled_rdesc_tablet));1260return sizeof(disabled_rdesc_tablet);1261}12621263if (rdesc_size == WHEEL_DESCRIPTOR_LENGTH) {1264__builtin_memcpy(data, disabled_rdesc_wheel,1265sizeof(disabled_rdesc_wheel));1266return sizeof(disabled_rdesc_wheel);1267}1268}12691270/*1271* Regardless of which mode the tablet is in, always fix the vendor1272* descriptor in case the udev property just happened to not be set1273*/1274if (rdesc_size == VENDOR_DESCRIPTOR_LENGTH) {1275__builtin_memcpy(data, fixed_rdesc_vendor, sizeof(fixed_rdesc_vendor));1276return sizeof(fixed_rdesc_vendor);1277}12781279return 0;1280}12811282SEC(HID_BPF_DEVICE_EVENT)1283int BPF_PROG(hid_fix_event_huion_kamvas13_gen3, struct hid_bpf_ctx *hid_ctx)1284{1285__u8 *data = hid_bpf_get_data(hid_ctx, 0 /* offset */, VENDOR_REPORT_LENGTH /* size */);12861287if (!data)1288return 0; /* EPERM check */12891290/* Handle vendor reports only */1291if (hid_ctx->size != VENDOR_REPORT_LENGTH)1292return 0;1293if (data[0] != VENDOR_REPORT_ID)1294return 0;12951296__u8 report_subtype = (data[1] >> 4) & 0x0f;12971298if (report_subtype == VENDOR_REPORT_SUBTYPE_PEN ||1299report_subtype == VENDOR_REPORT_SUBTYPE_PEN_OUT) {1300/* Invert Y tilt */1301data[11] = -data[11];13021303} else if (report_subtype == VENDOR_REPORT_SUBTYPE_BUTTONS ||1304report_subtype == VENDOR_REPORT_SUBTYPE_WHEELS) {1305struct pad_report {1306__u8 report_id;1307__u8 btn_stylus:1;1308__u8 padding:7;1309__u8 x;1310__u8 y;1311__u8 buttons;1312__s8 top_wheel;1313__s8 bottom_wheel;1314} __attribute__((packed)) *pad_report;13151316__s8 top_wheel = 0;1317__s8 bottom_wheel = 0;13181319switch (report_subtype) {1320case VENDOR_REPORT_SUBTYPE_WHEELS:1321/*1322* The wheel direction byte is 1 for clockwise rotation1323* and 2 for counter-clockwise.1324* Change it to 1 and -1, respectively.1325*/1326switch (data[3]) {1327case 1:1328top_wheel = (data[5] == 1) ? 1 : -1;1329break;1330case 2:1331bottom_wheel = (data[5] == 1) ? 1 : -1;1332break;1333}1334break;13351336case VENDOR_REPORT_SUBTYPE_BUTTONS:1337/*1338* If a button is already being held, ignore any new1339* button event unless it's a release.1340*1341* The tablet only cleanly handles one button being held1342* at a time, and trying to hold multiple buttons1343* (particularly wheel+pad buttons) can result in sequences1344* of reports that look like imaginary presses and releases.1345*1346* This is an imperfect way to filter out some of these1347* reports.1348*/1349if (last_button_state != 0x00 && data[4] != 0x00)1350break;13511352last_button_state = data[4];1353break;1354}135513561357pad_report = (struct pad_report *)data;13581359pad_report->report_id = CUSTOM_PAD_REPORT_ID;1360pad_report->btn_stylus = 0;1361pad_report->x = 0;1362pad_report->y = 0;1363pad_report->buttons = last_button_state;1364pad_report->top_wheel = top_wheel;1365pad_report->bottom_wheel = bottom_wheel;13661367return sizeof(struct pad_report);1368}13691370return 0;1371}13721373HID_BPF_OPS(huion_kamvas13_gen3) = {1374.hid_device_event = (void *)hid_fix_event_huion_kamvas13_gen3,1375.hid_rdesc_fixup = (void *)hid_fix_rdesc_huion_kamvas13_gen3,1376};13771378SEC("syscall")1379int probe(struct hid_bpf_probe_args *ctx)1380{1381switch (ctx->rdesc_size) {1382case VENDOR_DESCRIPTOR_LENGTH:1383case TABLET_DESCRIPTOR_LENGTH:1384case WHEEL_DESCRIPTOR_LENGTH:1385ctx->retval = 0;1386break;1387default:1388ctx->retval = -EINVAL;1389}13901391return 0;1392}13931394char _license[] SEC("license") = "GPL";139513961397