linux-surface / surface-pro-x

Tracking and meta repository for Surface Pro X support.
76 stars 6 forks source link

Support for Pen/Stylus #20

Closed qzed closed 1 year ago

qzed commented 2 years ago

Similar to multi-touch (#19), pen input requires some processing to yield useful events. As pen data is only supported in the multi-touch mode, this depends on #19. Refer to that issue for more details.

Unfortunately, the data format still needs some reverse engineering. This is already tracked at https://github.com/linux-surface/intel-precise-touch/issues/14. A prototype is available at https://github.com/quo/iptsd.

qzed commented 1 year ago

Experimental pen/stylus support can be found in the dft branch of iptsd (i.e. https://github.com/linux-surface/iptsd/tree/dft). At the moment, you likely need to adjust IPTS_DFT_BUTTON_MIN_MAG = 4000 in src/daemon/dft.cpp (at least if spurious button presses are detected).

liuyishengalan commented 1 year ago

I used rc7 kernel from linux-surface/aarch64-packages and install iptsd on archlinux. I got some errors here when I execute iptsd, and no ipts device under /dev. Is there any step I am missing? [alarm@surface-pro-x misc]$ iptsd [17:45:44.626] [error] You need to specify the hidraw device!

[alarm@surface-pro-x misc]$ ls /dev autofs kmsg snapshot tty29 tty54 vcs block log snd tty3 tty55 vcs1 btrfs-control loop-control stderr tty30 tty56 vcs2 bus mapper stdin tty31 tty57 vcs3 char mem stdout tty32 tty58 vcs4 console mqueue tty tty33 tty59 vcs5 core net tty0 tty34 tty6 vcs6 cpu_dma_latency ng0n1 tty1 tty35 tty60 vcsa cuse null tty10 tty36 tty61 vcsa1 disk nvme0 tty11 tty37 tty62 vcsa2 dri nvme0n1 tty12 tty38 tty63 vcsa3 fb0 nvme0n1p1 tty13 tty39 tty7 vcsa4 fd nvme0n1p2 tty14 tty4 tty8 vcsa5 full nvme0n1p3 tty15 tty40 tty9 vcsa6 fuse nvme0n1p4 tty16 tty41 ttyS0 vcsu gpiochip0 nvme0n1p5 tty17 tty42 ttyS1 vcsu1 gpiochip1 nvme0n1p6 tty18 tty43 ttyS2 vcsu2 gpiochip2 port tty19 tty44 ttyS3 vcsu3 gpiochip3 ppp tty2 tty45 uhid vcsu4 hidraw0 ptmx tty20 tty46 uinput vcsu5 hidraw1 pts tty21 tty47 urandom vcsu6 hidraw2 qcom_rmtfs_mem1 tty22 tty48 usbmon0 vfio hidraw3 qrtr-tun tty23 tty49 usbmon1 vga_arbiter hidraw4 random tty24 tty5 usbmon2 vhci hugepages rfkill tty25 tty50 usbmon3 vhost-net hwrng rtc tty26 tty51 usbmon4 vhost-vsock iio:device3 rtc0 tty27 tty52 usbmon5 zero input shm tty28 tty53 usbmon6

[alarm@surface-pro-x ~]$ systemctl status iptsd Unit iptsd.service could not be found.

qzed commented 1 year ago

You'll have to specify the hidraw device that iptsd should use. ls -l /sys/bus/spi/devices/spi0.0/001C:045E:0C21.0003/hidraw/ should tell you which one that is. Then run iptsd with that as argument (e.g. iptsd /dev/hidraw2). Alternatively, build and install the package via the PKGBUILD in the iptsd repo. The udev rules should then start it automatically.

liuyishengalan commented 1 year ago

It seems the device id is different from yours. [alarm@surface-pro-x spi0.0]$ ls 001C:045E:0996.0001 ready bus_error_count regulator_error_count device_initiated_reset_count statistics driver subsystem driver_override supplier:platform:3100000.pinctrl logic_error_count supplier:platform:ts-5p0-regulator modalias supplier:regulator:regulator.10 of_node uevent power 045E 0996

qzed commented 1 year ago

You have a SQ1, right? So it should be ls -l /sys/bus/spi/devices/spi0.0/001C:045E:0996.0001/hidraw. You'll also need to add a new config for ipts (in etc/config in the source directory). You can copy the existing SPX config for that and change the Product = 0x0C21 line to Product = 0x0996

liuyishengalan commented 1 year ago

Right, it's SQ1. It's working now.

qzed commented 1 year ago

I've pushed a config for the SQ1 to the iptsd repo. Seeing as pen support is now merged into the master branch, I'll close this issue as well. Other issues regarding pen/touch should probably be handled at the iptsd repo directly.