DIGImend / digimend-kernel-drivers

DIGImend graphics tablet drivers for the Linux kernel
GNU General Public License v2.0
1.17k stars 173 forks source link

Add support for XP-Pen Star G960 #446

Open jmoy opened 4 years ago

jmoy commented 4 years ago

I would like to add support for the XP-Pen Star G960, VID 0x28bd, PID: 0x0920. This is a tablet with 4 keys on the frame.

I'm attaching the files suggested by the project site.

I've been trying to decipher the reports from the device. The format seems to be:

  1. Flags byte
  2. 16 bits little-endian Y coordinate (max 32767)
  3. 16 bits little-endian X coordinate (max 32767)
  4. 16 bits little endian pressure (max 8191)

I've not been able to fully decipher the flag byte. The first 4 bits are either hex 'c' if the stylus is out of range or hex 'a' if the stylus is in range. The next four bits consists of an OR of 1 for stylus touching the tablet and 2 for stylus button pressed.

I know C and fighting with this tablet has given me some idea of how USB works and I'd be ready to work on adding support for this but would appreciate any pointers on how to start.

descriptors.txt hid_report_descriptors.txt key1.txt key2.txt key3.txt key4.txt pen_buttons.txt pen_coords.txt pen_pressure.txt probe.txt

kurikaesu commented 3 years ago

Hi jmoy, I'm following up adding support for your device in my PR here: https://github.com/DIGImend/digimend-kernel-drivers/pull/557

I need you to push the special handshake key to interface 1 then resubmit the data for:

The special handshake key can be sent to the tablet using the python script provided by @Korvox in one of the issues/PRs:

#! /usr/bin/env python3

import usb.core
import usb.util

dev = usb.core.find(idVendor=0x28bd, idProduct=0x0920)

if dev.is_kernel_driver_active(1):
    dev.detach_kernel_driver(1)

cfg = dev.get_active_configuration()
intf = cfg[(1,0)]
ei = intf[0]
eo = intf[1]

eo.write(bytes.fromhex('02b00400000000000000'))

while(True):
    print(''.join(format(x, '02x') for x in ei.read(12)))

pyusb needs to be installed for the root user since writing on the USB device requires root permissions. Can be installed with sudo pip3 install pyusb

You can ignore the USBTimeoutError that it spits out at the end.

Once the key has been sent to the tablet, when you start capturing the data like Pen Coordinates, the prefix byte should switch to 01 like: 01 f0 00 00 04 00 00 00 00 13. It is fine if the length of the data differs as it is important to know that it is different.