How to add a function about "pressure"
CaffreySun opened this issue · comments
Hi friend, i want add a function about "pressure" in VirtualHIDPointing, and i added USAGE (Tip Pressure)
in
reportDescriptor_[]
0x05, 0x0d, // USAGE_PAGE (Digitizers)
0x09, 0x30, // USAGE (Tip Pressure)
0x26, 0xff, 0x03, // LOGICAL_MAXIMUM (1023)
0x81, 0x02, // INPUT (Data,Var,Abs)
And i modified pqrs::karabiner::driverkit::virtual_hid_device::hid_report::pointing_input
buttons buttons;
uint8_t x;
uint8_t y;
uint8_t vertical_wheel;
uint8_t horizontal_wheel;
uint16_t tip_pressur;
But this cannot work.
I found a "Report" about "Windows pen device" at Sample Report Descriptors, But I don't know how to use it.
// Integrated Windows Pen TLC
0x05, 0x0d, // USAGE_PAGE (Digitizers)
0x09, 0x02, // USAGE (Pen)
0xa1, 0x01, // COLLECTION (Application)
0x85, REPORTID_PEN, // REPORT_ID (Pen)
0x09, 0x20, // USAGE (Stylus)
0xa1, 0x00, // COLLECTION (Physical)
0x09, 0x42, // USAGE (Tip Switch)
0x09, 0x44, // USAGE (Barrel Switch)
0x09, 0x3c, // USAGE (Invert)
0x09, 0x45, // USAGE (Eraser Switch)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x04, // REPORT_COUNT (4)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x03, // INPUT (Cnst,Var,Abs)
0x09, 0x32, // USAGE (In Range)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x95, 0x02, // REPORT_COUNT (2)
0x81, 0x03, // INPUT (Cnst,Var,Abs)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x30, // USAGE (X)
0x75, 0x10, // REPORT_SIZE (16)
0x95, 0x01, // REPORT_COUNT (1)
0xa4, // PUSH
0x55, 0x0d, // UNIT_EXPONENT (-3)
0x65, 0x13, // UNIT (Inch,EngLinear)
0x35, 0x00, // PHYSICAL_MINIMUM (0)
0x46, 0x3a, 0x20, // PHYSICAL_MAXIMUM (8250)
0x26, 0xf8, 0x52, // LOGICAL_MAXIMUM (21240)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x09, 0x31, // USAGE (Y)
0x46, 0x2c, 0x18, // PHYSICAL_MAXIMUM (6188)
0x26, 0x6c, 0x3e, // LOGICAL_MAXIMUM (15980)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xb4, // POP
0x05, 0x0d, // USAGE_PAGE (Digitizers)
0x09, 0x30, // USAGE (Tip Pressure)
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x75, 0x08, // REPORT_SIZE (8)
0x09, 0x3d, // USAGE (X Tilt)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x09, 0x3e, // USAGE (Y Tilt)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0, // END_COLLECTION
0xc0 // END_COLLECTION
I don't know well the pen device, but I guess you should change the root usage page and page of reportDescriptor_ and the primary usage page and usage.
https://github.com/pqrs-org/Karabiner-DriverKit-VirtualHIDDevice/blob/master/src/DriverKit/Karabiner-DriverKit-VirtualHIDDevice/org_pqrs_Karabiner_DriverKit_VirtualHIDPointing.cpp#L13-L14
https://github.com/pqrs-org/Karabiner-DriverKit-VirtualHIDDevice/blob/master/src/DriverKit/Karabiner-DriverKit-VirtualHIDDevice/org_pqrs_Karabiner_DriverKit_VirtualHIDPointing.cpp#L176-L184
It's worth to try replacing the entire reportDescriptor_ with your Windows pen device sample.
Thanks for your answer, Thank you very much!