No description
  • Zig 83.7%
  • Nix 16.3%
Find a file
2022-02-25 20:13:56 +01:00
src hid: cleanup 2022-02-25 11:37:32 +01:00
.envrc initial setup 2022-02-20 22:45:44 +01:00
.gitignore initial setup 2022-02-20 22:45:44 +01:00
build.zig flakes: add libudev 2022-02-22 11:27:06 +01:00
flake.lock initial setup 2022-02-20 22:45:44 +01:00
flake.nix fixed copy-paste error 2022-02-25 20:13:56 +01:00
LICENSE add LICENSE 2022-02-25 18:27:14 +01:00
README.md elaborate on README 2022-02-25 18:56:56 +01:00

Virtual Tablet Mode Switch for Surface Pro Typecovers

This programs listens to HID reports via hidraw to detect whether to emit a SW_TABLET_MODE event. It activates tablet mode when the typecover is folded back or removed. Tablet mode is deactivated when the typecover is reattached or brought back into normal position.

It needs to access /dev/hidraw[x] and /dev/uinput, it's probably easiest to just run it as root in a systemd service.

It logs the relevant HID report (ReportID 0x23) to stdout. When it is installed as a systemd service, you can look at the logs with journalctl -xef -u tablet-mode.service.

Binary release

You can download the binary from here: https://dev.ostylk.de/NixDistro/tablet-mode/releases/tag/v0.1

Compiling

Dependencies:

libudev
libevdev

zig 0.9.1 compiler (https://ziglang.org/download/0.9.1/zig-linux-x86_64-0.9.1.tar.xz)

Just enter the projects directory and execute:

zig build -Drelease-safe

The binary is located at ./zig-out/bin/tablet-mode.

systemd service file

A basic systemd service might look like this (provided the binary is under /usr/local/bin/tablet-mode):

[Unit]
Description=Surface Pro Typecover tablet mode switch service

[Service]
ExecStart=/usr/local/bin/tablet-mode

[Install]
WantedBy=multi-user.target