Universal Stylus Initiative testing tool https://universalstylus.org/

Clone this repo:
  1. ca7b4b6 Add oppressive language presubmit by Harry Cutts · 4 months ago factory-dedede-13683.B factory-test-13683.B factory-zork-13700.B firmware-asurada-13885.B firmware-quiche-13883.B firmware-volteer-13672.39.B firmware-volteer-13672.47.B firmware-volteer-13672.81.B firmware-volteer-13672.B main release-R89-13729.B release-R90-13816.B release-R91-13904.B stabilize-13729.16.B stabilize-13729.45.B stabilize-13729.49.B stabilize-13729.56.B stabilize-13729.57.B stabilize-13729.72.B stabilize-13768.B stabilize-13799.B stabilize-13816.40.B stabilize-13816.51.B stabilize-13821.B stabilize-13836.B stabilize-13851.B stabilize-13856.B stabilize-13895.B stabilize-coil-13902.B stabilize-glibc-13901.B stabilize-quickfix-13729.60.B stabilize-quickfix-13729.73.B stabilize-quickfix-13729.84.B stabilize-rust-13720.B stabilize-rust-13776.B stabilize-rust-13795.B stabilize-rust-13836.B
  2. 2c47301 Add usi-test tool by Sean O'Brien · 7 months ago factory-test-13517.B factory-volteer-13600.B firmware-dedede-13606.B firmware-trogdor-13577.B firmware-volteer-13521.B master release-R87-13505.B release-R88-13597.B stabilize-13482.B stabilize-13505.1.B stabilize-13505.100.B stabilize-13505.111.B stabilize-13505.63.B stabilize-13505.65.B stabilize-13505.73.B stabilize-13505.85.B stabilize-13525.B stabilize-13532.B stabilize-13591.B stabilize-13597.103.B stabilize-13597.105.B stabilize-13597.66.B stabilize-13597.67.B stabilize-13597.68.B stabilize-13597.69.B stabilize-13597.70.B stabilize-13597.71.B stabilize-13597.84.B stabilize-13597.85.B stabilize-13597.90.B stabilize-13597.94.B stabilize-13597.95.B stabilize-13597.97.B stabilize-13605.B stabilize-13654.B stabilize-ambassador-13597.79.B stabilize-quickfix-13597.30.B stabilize-rust-13514.B stabilize-rust-13555.B stabilize-rust-13562.B stabilize-rust-13613.B
  3. 4f232c9 Initial empty repository by LaMont Jones · 7 months ago

USI Test Tool


This repository contains a tool for testing a Universal Stylus Initiative (USI) digitizer and stylus at the HID protocol level.

Setting up

Make sure that your device has a dev or test image. You can use cros flash to flash a test image. Then you will need to enter the command prompt. Finally, you can run the tool with the usi-test command.


usi-test has five subcommands: descriptor, data, get, set, and diagnostic.

For any of these commands, you can set the path to the device with the -p or --path option. The default device path is /dev/hidraw0.


This command simply prints out the report descriptor in human-readable format.


$ usi-test --path /dev/hidraw0 descriptor


This command prints incoming events from the device in human-readable format. You can quit with Ctl-C.


$ usi-test -p /dev/hidraw0 data


This command sends a HID feature request to the device and prints the response. All of these commands query a stylus paired with the device, which can be specified with the -i or --index option. This is the temporary index assigned to the stylus by the digitizer when it pairs. The default index is 1.

This command will wait for the specified stylus to pair with the digitizer, so you can send the command without having the stylus pressed to the digitizer.

The values you can query are:

  • color: The current color of the stylus stroke
  • width: The current width of the stylus stroke
  • style: The current style of the stylus stroke (ink, pencil, etc.)
  • buttons: The mapping from physical stylus buttons to the button types they are set to be emulating.
  • firmware: The vendor ID, product ID, and firmware version of the stylus.
  • usi_version: The USI protocol version this pen is using.


$ usi-test -p /dev/hidraw0 get color
$ usi-test get width --index 1
$ usi-test get buttons -i 2


This command sets the specified values for the stylus using a HID feature report. The stylus index is specified the same as with the get command.

This command will wait for the specified stylus to pair with the digitizer, so you can send the command without having the stylus pressed to the digitizer.

The values you can set are:

  • --color, -c: Values between 0 and 255. See the USI spec for color mapping.
  • --width, -w: Values between 0 and 255, in 0.1 mm increments. For example, A value of 25 gives a stroke width of 2.5 mm.
  • --style, -s: Choose from ink, pencil, highlighter, marker, brush, and none
  • --button, -b: This option requires two arguments. It will set the first button argument to emulate the second button argument. The first (physical) button may be (barrel, secondary, eraser), and the second (emulated) button may be (barrel, secondary, eraser, disabled)

You may set one or all of the values in the same command. The button option can be set once for each physical button.


$ usi-test set --color 50
$ usi-test set -c 50
$ usi-test set --style pencil --index 2
$ usi-test set -c 50 -w 20 -s pencil
  # set the barrel button to act as the secondary button:
$ usi-test set --button barrel secondary
$ usi-test set --button barrel secondary --button secondary eraser


This command sends a diagnostic command to the stylus and reads the response. If you want you can set the preamble and cyclic redundancy check (CRC) manually, but by default this tool will calculate and send the preamble and CRC defined by the USI spec. The stylus index can be set the same as with the get command.

This command expects the command ID as the first argument, and the data as the second argument.

It will print the full reponse from the stylus, and break the response into the error bit, error code, and command response.


  # send the echo command, with value 8
$ usi-test diagnostic 52 8
full response: 0x0000000000000008
error information available? 0
error code: 0x00
command response: 0x0008
$ usi-test diagnostic 52 7 --preamble 2 --crc 3