smed-client
Client for smed, a Linux driver daemon for the 3Dconnexion SpaceMouse Enterprise.
smed owns the device and reports it to any number of clients over a Unix socket at
$XDG_RUNTIME_DIR/smed/api.sock, in JSON lines. It reports the six raw axes, every key by its
3Dconnexion button ID with short or long press, and the rotation lock, which clients can also
set, and draws the LCD for the application that has the focus. This crate holds the message
types both sides use, the table of key names and a small blocking client. The protocol is
specified in
docs/api.md.
use ;
With API 2, an application puts its commands on keys 1–12 and the device's LCD: it sends its
command catalogue (labels, SVG or PNG icons) and environments, says when its window has the
focus, and smed reports a command when a key with a command goes down:
use ;
The message enums and structs are #[non_exhaustive]: later API versions can add message
types, values, and fields of the structs (App, Command, Environment, DeviceInfo)
without breaking your code. Match messages with a _ arm and .., build the structs with
new, and send through the Client methods. A new field in a message variant still needs a
new minor version of this crate.
An application that reads the socket in its own loop (with a read timeout, or other work between
reads) pushes what it reads into a Lines decoder, which hands out whole messages; Client
reads through it too.
Not affiliated with or endorsed by 3Dconnexion.
Licence
MIT or Apache-2.0, at your option.