Path: blob/master/drivers/hid/bpf/progs/Huion__Dial-2.bpf.c
26285 views
// SPDX-License-Identifier: GPL-2.0-only1/* Copyright (c) 2024 Red Hat, Inc2*/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_DIAL_2 0x0060121314HID_BPF_CONFIG(15HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, VID_HUION, PID_DIAL_2),16);1718/* Filled in by udev-hid-bpf */19char UDEV_PROP_HUION_FIRMWARE_ID[64];2021/* The prefix of the firmware ID we expect for this device. The full firmware22* string has a date suffix, e.g. HUION_T21j_22122123*/24char EXPECTED_FIRMWARE_ID[] = "HUION_T216_";2526/* How this BPF program works: the tablet has two modes, firmware mode and27* tablet mode. In firmware mode (out of the box) the tablet sends button events28* and the dial as keyboard combinations. In tablet mode it uses a vendor specific29* hid report to report everything instead.30* Depending on the mode some hid reports are never sent and the corresponding31* devices are mute.32*33* To switch the tablet use e.g. https://github.com/whot/huion-switcher34* or one of the tools from the digimend project35*36* This BPF works for both modes. The huion-switcher tool sets the37* HUION_FIRMWARE_ID udev property - if that is set then we disable the firmware38* pad and pen reports (by making them vendor collections that are ignored).39* If that property is not set we fix all hidraw nodes so the tablet works in40* either mode though the drawback is that the device will show up twice if41* you bind it to all event nodes42*43* Default report descriptor for the first exposed hidraw node:44*45* # HUION Huion Tablet_Q630M46* # 0x06, 0x00, 0xff, // Usage Page (Vendor Defined Page 1) 047* # 0x09, 0x01, // Usage (Vendor Usage 1) 348* # 0xa1, 0x01, // Collection (Application) 549* # 0x85, 0x08, // Report ID (8) 750* # 0x75, 0x58, // Report Size (88) 951* # 0x95, 0x01, // Report Count (1) 1152* # 0x09, 0x01, // Usage (Vendor Usage 1) 1353* # 0x81, 0x02, // Input (Data,Var,Abs) 1554* # 0xc0, // End Collection 1755* R: 18 06 00 ff 09 01 a1 01 85 08 75 58 95 01 09 01 81 02 c056*57* This rdesc does nothing until the tablet is switched to raw mode, see58* https://github.com/whot/huion-switcher59*60*61* Second hidraw node is the Pen. This one sends events until the tablet is62* switched to raw mode, then it's mute.63*64* # Report descriptor length: 93 bytes65* # HUION Huion Tablet_Q630M66* # 0x05, 0x0d, // Usage Page (Digitizers) 067* # 0x09, 0x02, // Usage (Pen) 268* # 0xa1, 0x01, // Collection (Application) 469* # 0x85, 0x0a, // Report ID (10) 670* # 0x09, 0x20, // Usage (Stylus) 871* # 0xa1, 0x01, // Collection (Application) 1072* # 0x09, 0x42, // Usage (Tip Switch) 1273* # 0x09, 0x44, // Usage (Barrel Switch) 1474* # 0x09, 0x45, // Usage (Eraser) 1675* # 0x09, 0x3c, // Usage (Invert) 1876* # 0x15, 0x00, // Logical Minimum (0) 2077* # 0x25, 0x01, // Logical Maximum (1) 2278* # 0x75, 0x01, // Report Size (1) 2479* # 0x95, 0x06, // Report Count (6) 2680* # 0x81, 0x02, // Input (Data,Var,Abs) 2881* # 0x09, 0x32, // Usage (In Range) 3082* # 0x75, 0x01, // Report Size (1) 3283* # 0x95, 0x01, // Report Count (1) 3484* # 0x81, 0x02, // Input (Data,Var,Abs) 3685* # 0x81, 0x03, // Input (Cnst,Var,Abs) 3886* # 0x05, 0x01, // Usage Page (Generic Desktop) 4087* # 0x09, 0x30, // Usage (X) 4288* # 0x09, 0x31, // Usage (Y) 4489* # 0x55, 0x0d, // Unit Exponent (-3) 4690* # 0x65, 0x33, // Unit (EnglishLinear: in³) 4891* # 0x26, 0xff, 0x7f, // Logical Maximum (32767) 5092* # 0x35, 0x00, // Physical Minimum (0) 5393* # 0x46, 0x00, 0x08, // Physical Maximum (2048) 5594* # 0x75, 0x10, // Report Size (16) 5895* # 0x95, 0x02, // Report Count (2) 6096* # 0x81, 0x02, // Input (Data,Var,Abs) 6297* # 0x05, 0x0d, // Usage Page (Digitizers) 6498* # 0x09, 0x30, // Usage (Tip Pressure) 6699* # 0x26, 0xff, 0x1f, // Logical Maximum (8191) 68100* # 0x75, 0x10, // Report Size (16) 71101* # 0x95, 0x01, // Report Count (1) 73102* # 0x81, 0x02, // Input (Data,Var,Abs) 75103* # 0x09, 0x3d, // Usage (X Tilt) 77104* # 0x09, 0x3e, // Usage (Y Tilt) 79105* # 0x15, 0x81, // Logical Minimum (-127) 81106* # 0x25, 0x7f, // Logical Maximum (127) 83107* # 0x75, 0x08, // Report Size (8) 85108* # 0x95, 0x02, // Report Count (2) 87109* # 0x81, 0x02, // Input (Data,Var,Abs) 89110* # 0xc0, // End Collection 91111* # 0xc0, // End Collection 92112* R: 93 05 0d 09 02 a1 01 85 0a 09 20 a1 01 09 42 09 44 09 45 09 3c 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 1f 75 10 95 01 81 02 09 3d 09 3e 15 81 25 7f 75 08 95 02 81 02 c0 c0113*114* Third hidraw node is the pad which sends a combination of keyboard shortcuts until115* the tablet is switched to raw mode, then it's mute:116*117* # Report descriptor length: 148 bytes118* # HUION Huion Tablet_Q630M119* # 0x05, 0x01, // Usage Page (Generic Desktop) 0120* # 0x09, 0x0e, // Usage (System Multi-Axis Controller) 2121* # 0xa1, 0x01, // Collection (Application) 4122* # 0x85, 0x11, // Report ID (17) 6123* # 0x05, 0x0d, // Usage Page (Digitizers) 8124* # 0x09, 0x21, // Usage (Puck) 10125* # 0xa1, 0x02, // Collection (Logical) 12126* # 0x15, 0x00, // Logical Minimum (0) 14127* # 0x25, 0x01, // Logical Maximum (1) 16128* # 0x75, 0x01, // Report Size (1) 18129* # 0x95, 0x01, // Report Count (1) 20130* # 0xa1, 0x00, // Collection (Physical) 22131* # 0x05, 0x09, // Usage Page (Button) 24132* # 0x09, 0x01, // Usage (Vendor Usage 0x01) 26133* # 0x81, 0x02, // Input (Data,Var,Abs) 28134* # 0x05, 0x0d, // Usage Page (Digitizers) 30135* # 0x09, 0x33, // Usage (Touch) 32136* # 0x81, 0x02, // Input (Data,Var,Abs) 34137* # 0x95, 0x06, // Report Count (6) 36138* # 0x81, 0x03, // Input (Cnst,Var,Abs) 38139* # 0xa1, 0x02, // Collection (Logical) 40140* # 0x05, 0x01, // Usage Page (Generic Desktop) 42141* # 0x09, 0x37, // Usage (Dial) 44142* # 0x16, 0x00, 0x80, // Logical Minimum (-32768) 46143* # 0x26, 0xff, 0x7f, // Logical Maximum (32767) 49144* # 0x75, 0x10, // Report Size (16) 52145* # 0x95, 0x01, // Report Count (1) 54146* # 0x81, 0x06, // Input (Data,Var,Rel) 56147* # 0x35, 0x00, // Physical Minimum (0) 58148* # 0x46, 0x10, 0x0e, // Physical Maximum (3600) 60149* # 0x15, 0x00, // Logical Minimum (0) 63150* # 0x26, 0x10, 0x0e, // Logical Maximum (3600) 65151* # 0x09, 0x48, // Usage (Resolution Multiplier) 68152* # 0xb1, 0x02, // Feature (Data,Var,Abs) 70153* # 0x45, 0x00, // Physical Maximum (0) 72154* # 0xc0, // End Collection 74155* # 0x75, 0x08, // Report Size (8) 75156* # 0x95, 0x01, // Report Count (1) 77157* # 0x81, 0x01, // Input (Cnst,Arr,Abs) 79158* # 0x75, 0x08, // Report Size (8) 81159* # 0x95, 0x01, // Report Count (1) 83160* # 0x81, 0x01, // Input (Cnst,Arr,Abs) 85161* # 0x75, 0x08, // Report Size (8) 87162* # 0x95, 0x01, // Report Count (1) 89163* # 0x81, 0x01, // Input (Cnst,Arr,Abs) 91164* # 0x75, 0x08, // Report Size (8) 93165* # 0x95, 0x01, // Report Count (1) 95166* # 0x81, 0x01, // Input (Cnst,Arr,Abs) 97167* # 0x75, 0x08, // Report Size (8) 99168* # 0x95, 0x01, // Report Count (1) 101169* # 0x81, 0x01, // Input (Cnst,Arr,Abs) 103170* # 0xc0, // End Collection 105171* # 0xc0, // End Collection 106172* # 0xc0, // End Collection 107173* # 0x05, 0x01, // Usage Page (Generic Desktop) 108174* # 0x09, 0x06, // Usage (Keyboard) 110175* # 0xa1, 0x01, // Collection (Application) 112176* # 0x85, 0x03, // Report ID (3) 114177* # 0x05, 0x07, // Usage Page (Keyboard) 116178* # 0x19, 0xe0, // Usage Minimum (224) 118179* # 0x29, 0xe7, // Usage Maximum (231) 120180* # 0x15, 0x00, // Logical Minimum (0) 122181* # 0x25, 0x01, // Logical Maximum (1) 124182* # 0x75, 0x01, // Report Size (1) 126183* # 0x95, 0x08, // Report Count (8) 128184* # 0x81, 0x02, // Input (Data,Var,Abs) 130185* # 0x05, 0x07, // Usage Page (Keyboard) 132186* # 0x19, 0x00, // Usage Minimum (0) 134187* # 0x29, 0xff, // Usage Maximum (255) 136188* # 0x26, 0xff, 0x00, // Logical Maximum (255) 138189* # 0x75, 0x08, // Report Size (8) 141190* # 0x95, 0x06, // Report Count (6) 143191* # 0x81, 0x00, // Input (Data,Arr,Abs) 145192* # 0xc0, // End Collection 147193* R: 148 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 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 c0194*/195196#define PAD_REPORT_DESCRIPTOR_LENGTH 148197#define PEN_REPORT_DESCRIPTOR_LENGTH 93198#define VENDOR_REPORT_DESCRIPTOR_LENGTH 18199#define PAD_REPORT_ID 3200#define DIAL_REPORT_ID 17201#define PEN_REPORT_ID 10202#define VENDOR_REPORT_ID 8203#define PAD_REPORT_LENGTH 9204#define PEN_REPORT_LENGTH 10205#define VENDOR_REPORT_LENGTH 12206207208__u8 last_button_state;209210static const __u8 fixed_rdesc_pad[] = {211UsagePage_GenericDesktop212Usage_GD_Keypad213CollectionApplication(214// -- Byte 0 in report215ReportId(PAD_REPORT_ID)216LogicalMaximum_i8(0)217LogicalMaximum_i8(1)218UsagePage_Digitizers219Usage_Dig_TabletFunctionKeys220CollectionPhysical(221// Byte 1 in report - just exists so we get to be a tablet pad222Usage_Dig_BarrelSwitch // BTN_STYLUS223ReportCount(1)224ReportSize(1)225Input(Var|Abs)226ReportCount(7) // padding227Input(Const)228// Bytes 2/3 in report - just exists so we get to be a tablet pad229UsagePage_GenericDesktop230Usage_GD_X231Usage_GD_Y232ReportCount(2)233ReportSize(8)234Input(Var|Abs)235// Byte 4 in report is the dial236Usage_GD_Wheel237LogicalMinimum_i8(-1)238LogicalMaximum_i8(1)239ReportCount(1)240ReportSize(8)241Input(Var|Rel)242// Byte 5 is the button state243UsagePage_Button244UsageMinimum_i8(0x01)245UsageMaximum_i8(0x08)246LogicalMinimum_i8(0x0)247LogicalMaximum_i8(0x1)248ReportCount(7)249ReportSize(1)250Input(Var|Abs)251ReportCount(1) // padding252Input(Const)253)254// Make sure we match our original report length255FixedSizeVendorReport(PAD_REPORT_LENGTH)256)257};258259static const __u8 fixed_rdesc_pen[] = {260UsagePage_Digitizers261Usage_Dig_Pen262CollectionApplication(263// -- Byte 0 in report264ReportId(PEN_REPORT_ID)265Usage_Dig_Pen266CollectionPhysical(267// -- Byte 1 in report268Usage_Dig_TipSwitch269Usage_Dig_BarrelSwitch270Usage_Dig_SecondaryBarrelSwitch // maps eraser to BTN_STYLUS2271LogicalMinimum_i8(0)272LogicalMaximum_i8(1)273ReportSize(1)274ReportCount(3)275Input(Var|Abs)276ReportCount(4) // Padding277Input(Const)278Usage_Dig_InRange279ReportCount(1)280Input(Var|Abs)281ReportSize(16)282ReportCount(1)283PushPop(284UsagePage_GenericDesktop285Unit(cm)286UnitExponent(-1)287PhysicalMinimum_i16(0)288PhysicalMaximum_i16(266)289LogicalMinimum_i16(0)290LogicalMaximum_i16(32767)291Usage_GD_X292Input(Var|Abs) // Bytes 2+3293PhysicalMinimum_i16(0)294PhysicalMaximum_i16(166)295LogicalMinimum_i16(0)296LogicalMaximum_i16(32767)297Usage_GD_Y298Input(Var|Abs) // Bytes 4+5299)300UsagePage_Digitizers301Usage_Dig_TipPressure302LogicalMinimum_i16(0)303LogicalMaximum_i16(8191)304Input(Var|Abs) // Byte 6+7305ReportSize(8)306ReportCount(2)307LogicalMinimum_i8(-60)308LogicalMaximum_i8(60)309Usage_Dig_XTilt310Usage_Dig_YTilt311Input(Var|Abs) // Byte 8+9312)313)314};315316static const __u8 fixed_rdesc_vendor[] = {317UsagePage_Digitizers318Usage_Dig_Pen319CollectionApplication(320// Byte 0321// We leave the pen on the vendor report ID322ReportId(VENDOR_REPORT_ID)323Usage_Dig_Pen324CollectionPhysical(325// Byte 1 are the buttons326LogicalMinimum_i8(0)327LogicalMaximum_i8(1)328ReportSize(1)329Usage_Dig_TipSwitch330Usage_Dig_BarrelSwitch331Usage_Dig_SecondaryBarrelSwitch332ReportCount(3)333Input(Var|Abs)334ReportCount(4) // Padding335Input(Const)336Usage_Dig_InRange337ReportCount(1)338Input(Var|Abs)339ReportSize(16)340ReportCount(1)341PushPop(342UsagePage_GenericDesktop343Unit(cm)344UnitExponent(-1)345// Note: reported logical range differs346// from the pen report ID for x and y347LogicalMinimum_i16(0)348LogicalMaximum_i16(53340)349PhysicalMinimum_i16(0)350PhysicalMaximum_i16(266)351// Bytes 2/3 in report352Usage_GD_X353Input(Var|Abs)354LogicalMinimum_i16(0)355LogicalMaximum_i16(33340)356PhysicalMinimum_i16(0)357PhysicalMaximum_i16(166)358// Bytes 4/5 in report359Usage_GD_Y360Input(Var|Abs)361)362// Bytes 6/7 in report363LogicalMinimum_i16(0)364LogicalMaximum_i16(8191)365Usage_Dig_TipPressure366Input(Var|Abs)367// Bytes 8/9 in report368ReportCount(1) // Padding369Input(Const)370LogicalMinimum_i8(-60)371LogicalMaximum_i8(60)372// Byte 10 in report373Usage_Dig_XTilt374// Byte 11 in report375Usage_Dig_YTilt376ReportSize(8)377ReportCount(2)378Input(Var|Abs)379)380)381UsagePage_GenericDesktop382Usage_GD_Keypad383CollectionApplication(384// Byte 0385ReportId(PAD_REPORT_ID)386LogicalMinimum_i8(0)387LogicalMaximum_i8(1)388UsagePage_Digitizers389Usage_Dig_TabletFunctionKeys390CollectionPhysical(391// Byte 1 are the buttons392Usage_Dig_BarrelSwitch // BTN_STYLUS, needed so we get to be a tablet pad393ReportCount(1)394ReportSize(1)395Input(Var|Abs)396ReportCount(7) // Padding397Input(Const)398// Bytes 2/3 - x/y just exist so we get to be a tablet pad399UsagePage_GenericDesktop400Usage_GD_X401Usage_GD_Y402ReportCount(2)403ReportSize(8)404Input(Var|Abs)405// Byte 4 is the button state406UsagePage_Button407UsageMinimum_i8(0x1)408UsageMaximum_i8(0x8)409LogicalMinimum_i8(0x0)410LogicalMaximum_i8(0x1)411ReportCount(8)412ReportSize(1)413Input(Var|Abs)414// Byte 5 is the top dial415UsagePage_GenericDesktop416Usage_GD_Wheel417LogicalMinimum_i8(-1)418LogicalMaximum_i8(1)419ReportCount(1)420ReportSize(8)421Input(Var|Rel)422// Byte 6 is the bottom dial423UsagePage_Consumer424Usage_Con_ACPan425Input(Var|Rel)426)427// Make sure we match our original report length428FixedSizeVendorReport(VENDOR_REPORT_LENGTH)429)430};431432static const __u8 disabled_rdesc_pen[] = {433FixedSizeVendorReport(PEN_REPORT_LENGTH)434};435436static const __u8 disabled_rdesc_pad[] = {437FixedSizeVendorReport(PAD_REPORT_LENGTH)438};439440SEC(HID_BPF_RDESC_FIXUP)441int BPF_PROG(dial_2_fix_rdesc, struct hid_bpf_ctx *hctx)442{443__u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, HID_MAX_DESCRIPTOR_SIZE /* size */);444__s32 rdesc_size = hctx->size;445__u8 have_fw_id;446447if (!data)448return 0; /* EPERM check */449450/* If we have a firmware ID and it matches our expected prefix, we451* disable the default pad/pen nodes. They won't send events452* but cause duplicate devices.453*/454have_fw_id = __builtin_memcmp(UDEV_PROP_HUION_FIRMWARE_ID,455EXPECTED_FIRMWARE_ID,456sizeof(EXPECTED_FIRMWARE_ID) - 1) == 0;457if (rdesc_size == PAD_REPORT_DESCRIPTOR_LENGTH) {458if (have_fw_id) {459__builtin_memcpy(data, disabled_rdesc_pad, sizeof(disabled_rdesc_pad));460return sizeof(disabled_rdesc_pad);461}462463__builtin_memcpy(data, fixed_rdesc_pad, sizeof(fixed_rdesc_pad));464return sizeof(fixed_rdesc_pad);465}466if (rdesc_size == PEN_REPORT_DESCRIPTOR_LENGTH) {467if (have_fw_id) {468__builtin_memcpy(data, disabled_rdesc_pen, sizeof(disabled_rdesc_pen));469return sizeof(disabled_rdesc_pen);470}471472__builtin_memcpy(data, fixed_rdesc_pen, sizeof(fixed_rdesc_pen));473return sizeof(fixed_rdesc_pen);474}475/* Always fix the vendor mode so the tablet will work even if nothing sets476* the udev property (e.g. huion-switcher run manually)477*/478if (rdesc_size == VENDOR_REPORT_DESCRIPTOR_LENGTH) {479__builtin_memcpy(data, fixed_rdesc_vendor, sizeof(fixed_rdesc_vendor));480return sizeof(fixed_rdesc_vendor);481482}483return 0;484}485486SEC(HID_BPF_DEVICE_EVENT)487int BPF_PROG(dial_2_fix_events, struct hid_bpf_ctx *hctx)488{489__u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 16 /* size */);490static __u8 button;491492if (!data)493return 0; /* EPERM check */494495/* Only sent if tablet is in default mode */496if (data[0] == PAD_REPORT_ID) {497/* Nicely enough, this device only supports one button down at a time so498* the reports are easy to match. Buttons numbered from the top499* Button released: 03 00 00 00 00 00 00 00500* Button 1: 03 00 05 00 00 00 00 00 -> b501* Button 2: 03 00 08 00 00 00 00 00 -> e502* Button 3: 03 00 0c 00 00 00 00 00 -> i503* Button 4: 03 00 e0 16 00 00 00 00 -> Ctrl S504* Button 5: 03 00 2c 00 00 00 00 00 -> space505* Button 6: 03 00 e0 e2 1d 00 00 00 -> Ctrl Alt Z506*/507button &= 0xc0;508509switch ((data[2] << 16) | (data[3] << 8) | data[4]) {510case 0x000000:511break;512case 0x050000:513button |= BIT(0);514break;515case 0x080000:516button |= BIT(1);517break;518case 0x0c0000:519button |= BIT(2);520break;521case 0xe01600:522button |= BIT(3);523break;524case 0x2c0000:525button |= BIT(4);526break;527case 0xe0e21d:528button |= BIT(5);529break;530}531532__u8 report[8] = {PAD_REPORT_ID, 0x0, 0x0, 0x0, 0x00, button};533534__builtin_memcpy(data, report, sizeof(report));535return sizeof(report);536}537538/* Only sent if tablet is in default mode */539if (data[0] == DIAL_REPORT_ID) {540/*541* In default mode, both dials are merged together:542*543* Dial down: 11 00 ff ff 00 00 00 00 00 -> Dial -1544* Dial up: 11 00 01 00 00 00 00 00 00 -> Dial 1545*/546__u16 dial = data[3] << 8 | data[2];547548button &= 0x3f;549button |= !!data[1] << 6;550551__u8 report[] = {PAD_REPORT_ID, 0x0, 0x0, 0x0, dial, button};552553__builtin_memcpy(data, report, sizeof(report));554return sizeof(report);555}556557/* Nothing to do for the PEN_REPORT_ID, it's already mapped */558559/* Only sent if tablet is in raw mode */560if (data[0] == VENDOR_REPORT_ID) {561/* Pad reports */562if (data[1] & 0x20) {563/* See fixed_rdesc_pad */564struct pad_report {565__u8 report_id;566__u8 btn_stylus;567__u8 x;568__u8 y;569__u8 buttons;570__u8 dial_1;571__u8 dial_2;572} __attribute__((packed)) *pad_report;573__u8 dial_1 = 0, dial_2 = 0;574575/* Dial report */576if (data[1] == 0xf1) {577__u8 d = 0;578579if (data[5] == 2)580d = 0xff;581else582d = data[5];583584if (data[3] == 1)585dial_1 = d;586else587dial_2 = d;588} else {589/* data[4] are the buttons, mapped correctly */590last_button_state = data[4];591dial_1 = 0; // dial592dial_2 = 0;593}594595pad_report = (struct pad_report *)data;596597pad_report->report_id = PAD_REPORT_ID;598pad_report->btn_stylus = 0;599pad_report->x = 0;600pad_report->y = 0;601pad_report->buttons = last_button_state;602pad_report->dial_1 = dial_1;603pad_report->dial_2 = dial_2;604605return sizeof(struct pad_report);606}607608/* Pen reports need nothing done */609}610611return 0;612}613614HID_BPF_OPS(inspiroy_dial2) = {615.hid_device_event = (void *)dial_2_fix_events,616.hid_rdesc_fixup = (void *)dial_2_fix_rdesc,617};618619SEC("syscall")620int probe(struct hid_bpf_probe_args *ctx)621{622switch (ctx->rdesc_size) {623case PAD_REPORT_DESCRIPTOR_LENGTH:624case PEN_REPORT_DESCRIPTOR_LENGTH:625case VENDOR_REPORT_DESCRIPTOR_LENGTH:626ctx->retval = 0;627break;628default:629ctx->retval = -EINVAL;630}631632return 0;633}634635char _license[] SEC("license") = "GPL";636637638