diff --git a/.gitignore b/.gitignore index 01a745e..6493d2c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ /bin/ *.test /testdata/hid/local/ +/vendor/ +/.flatpak-builder/ +/build-flatpak/ +/.flatpak-repo/ diff --git a/README.md b/README.md index a3a5c82..a430091 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,10 @@ On-screen HUD for Steam Input in **KDE Plasma (Wayland) Desktop Mode** on the St - **Radial menu HUD**: see which radial item you're selecting, as in Game Mode. - **Key-chord toasts**: see which keys a button just sent (`[R4] → Meta + Shift + .`). -- **Action set / layer banner**: see when you switch sets or hold a layer (cheat sheet next). +- **Layer cheat sheet**: see what every control does when you switch action sets or hold a layer, + or on demand with `deckhudd peek`. Bind that command to a KDE shortcut, then map a Steam button to it. -Overlays are translucent and click-through, and follow your KDE accent colour, including wallpaper-derived accents. +Overlays are translucent and click-through, and follow your KDE accent colour live (via the settings portal), even with a wallpaper slideshow. > Status: early development. See [docs/PLAN.md](docs/PLAN.md). @@ -15,7 +16,7 @@ Overlays are translucent and click-through, and follow your KDE accent colour, i `deckhudd` (Go) reads the Deck controller's raw HID reports passively alongside Steam. It also parses your active Steam Input config, using Steam's `controller.txt` log to find it, and replays Steam's activator/layer/radial logic. Events go over a token-protected loopback WebSocket to a QML overlay, -which runs on SteamOS's own Qt with LayerShellQt and Kirigami. Nothing touches the read-only root, and +which runs on SteamOS's own Qt with LayerShellQt. Nothing touches the read-only root, and nothing needs root. ## Try it @@ -29,9 +30,18 @@ mise run build ./bin/deckhudd demo ui # scripted preview of the overlay (no controller needed) ./bin/deckhudd run ui # the real thing, from the source tree ./bin/deckhudd events # no overlay; print events as JSON lines +./bin/deckhudd peek # toggle the layer cheat sheet in the running daemon ``` -## Install (per user) +![Radial menu](docs/screenshots/radial.png) + +## Install + +### Flatpak + +See [packaging/flatpak](packaging/flatpak/README.md). Flathub submission is in progress. + +### From source (per user) ```sh mise run install diff --git a/cmd/deckhudd/main.go b/cmd/deckhudd/main.go index 1b31cb1..621bd17 100644 --- a/cmd/deckhudd/main.go +++ b/cmd/deckhudd/main.go @@ -15,6 +15,7 @@ import ( "time" "github.com/RustyRaptor/deckhud/internal/appwatch" + "github.com/RustyRaptor/deckhud/internal/autostart" "github.com/RustyRaptor/deckhud/internal/binding" "github.com/RustyRaptor/deckhud/internal/control" "github.com/RustyRaptor/deckhud/internal/hid" @@ -24,10 +25,12 @@ import ( const usage = `usage: deckhudd commands: - run [ui-dir] run the daemon and launch the overlay from ui-dir + run [ui-dir] (default) run the daemon and launch the overlay from ui-dir (default: ../share/deckhud/ui next to the binary) events run without the overlay, printing events as JSON lines demo [ui-dir] play a scripted session through the overlay (no controller needed) + autostart on|off start with Plasma via the Background portal (Flatpak); + native installs use the systemd user unit instead peek toggle the cheat sheet in the running daemon (bind it to a KDE shortcut, then map a Steam button to that) find print the Deck controller hidraw device @@ -38,8 +41,7 @@ commands: func main() { if len(os.Args) < 2 { - fmt.Fprint(os.Stderr, usage) - os.Exit(2) + os.Args = append(os.Args, "run") // launched from the menu or autostart } ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt) defer stop() @@ -51,7 +53,7 @@ func main() { if len(os.Args) > 2 { dir = os.Args[2] } - err = run(ctx, runOpts{uiDir: dir}) + err = run(ctx, runOpts{uiDir: dir, autostart: true}) case "demo": dir := defaultUIDir() if len(os.Args) > 2 { @@ -60,6 +62,12 @@ func main() { err = demo(ctx, dir) case "events": err = run(ctx, runOpts{print: true}) + case "autostart": + enable := len(os.Args) < 3 || os.Args[2] != "off" + var granted bool + if granted, err = autostart.Request(ctx, enable, []string{"deckhudd", "run"}); err == nil { + fmt.Println("autostart:", map[bool]string{true: "on", false: "off"}[granted]) + } case "peek": err = control.Send(control.DefaultPath(), "peek") case "find": @@ -156,9 +164,17 @@ func record(ctx context.Context, path string) error { return err } +// steamRoot finds the Steam data directory of a native or Flatpak Steam. func steamRoot() string { home, _ := os.UserHomeDir() - return filepath.Join(home, ".local", "share", "Steam") + native := filepath.Join(home, ".local", "share", "Steam") + flatpak := filepath.Join(home, ".var", "app", "com.valvesoftware.Steam", ".local", "share", "Steam") + if _, err := os.Stat(native); err != nil { + if _, err := os.Stat(flatpak); err == nil { + return flatpak + } + } + return native } // activeConfig replays Steam's controller log and loads the config it points at. diff --git a/cmd/deckhudd/run.go b/cmd/deckhudd/run.go index 8d6a005..c78cb79 100644 --- a/cmd/deckhudd/run.go +++ b/cmd/deckhudd/run.go @@ -17,6 +17,7 @@ import ( "github.com/RustyRaptor/deckhud/internal/accent" "github.com/RustyRaptor/deckhud/internal/appwatch" + "github.com/RustyRaptor/deckhud/internal/autostart" "github.com/RustyRaptor/deckhud/internal/control" "github.com/RustyRaptor/deckhud/internal/engine" "github.com/RustyRaptor/deckhud/internal/hid" @@ -27,9 +28,10 @@ import ( const protocolVersion = 1 type runOpts struct { - uiDir string // directory holding main.qml; empty = don't launch the UI - print bool // print events as JSON lines on stdout - script []demoStep // play this instead of reading the controller + uiDir string // directory holding main.qml; empty = don't launch the UI + print bool // print events as JSON lines on stdout + autostart bool // ask the Background portal for autostart (Flatpak) + script []demoStep // play this instead of reading the controller } // daemon owns the engine and the config it was built from. @@ -69,6 +71,13 @@ func run(ctx context.Context, opts runOpts) error { defer srv.Close() url := fmt.Sprintf("ws://%s/%s", ln.Addr(), token) + if opts.autostart && os.Getenv("FLATPAK_ID") != "" { + go func() { // ask once; KDE remembers the answer + if _, err := autostart.Request(ctx, true, []string{"deckhudd", "run"}); err != nil { + fmt.Fprintln(os.Stderr, "deckhudd: autostart:", err) + } + }() + } if err := d.reload(true); err != nil { fmt.Fprintln(os.Stderr, "deckhudd: config:", err) } @@ -128,7 +137,8 @@ func (d *daemon) command(cmd string) error { func accentMsg(hex string) map[string]any { return map[string]any{"type": "accent", "color": hex} } func (d *daemon) configMsg() map[string]any { - return map[string]any{"type": "config", "app": d.app.App, "title": d.cfg.Title} + icons := filepath.Join(steamRoot(), "tenfoot", "resource", "images", "library", "controller", "binding_icons") + return map[string]any{"type": "config", "app": d.app.App, "title": d.cfg.Title, "iconDir": "file://" + icons} } func (d *daemon) emit(v any) { @@ -228,11 +238,22 @@ func (d *daemon) readController(ctx context.Context) { } } +// uiCommand prefers the bundled deckhud-ui launcher (Flatpak, packaged +// installs) and falls back to the system qml runner. +func uiCommand(ctx context.Context, dir, url string) *exec.Cmd { + if exe, err := os.Executable(); err == nil { + launcher := filepath.Join(filepath.Dir(exe), "deckhud-ui") + if _, err := os.Stat(launcher); err == nil { + return exec.CommandContext(ctx, launcher, filepath.Join(dir, "main.qml"), url) + } + } + return exec.CommandContext(ctx, "/usr/lib/qt6/bin/qml", filepath.Join(dir, "main.qml"), "--", url) +} + // superviseUI keeps the QML overlay running, restarting it if it exits. func superviseUI(ctx context.Context, dir, url string) { - qml := "/usr/lib/qt6/bin/qml" for ctx.Err() == nil { - cmd := exec.CommandContext(ctx, qml, filepath.Join(dir, "main.qml"), "--", url) + cmd := uiCommand(ctx, dir, url) cmd.Env = append(os.Environ(), "QT_FORCE_STDERR_LOGGING=1") cmd.Stdout, cmd.Stderr = os.Stderr, os.Stderr cmd.SysProcAttr = &syscall.SysProcAttr{Pdeathsig: syscall.SIGTERM} diff --git a/data/io.github.RustyRaptor.deckhud.desktop b/data/io.github.RustyRaptor.deckhud.desktop new file mode 100644 index 0000000..089a3bb --- /dev/null +++ b/data/io.github.RustyRaptor.deckhud.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Type=Application +Name=deckhud +GenericName=Steam Input HUD +Comment=On-screen radial menus, key-chord feedback and layer cheat sheets for Steam Input in Desktop Mode +Exec=deckhudd run +Icon=io.github.RustyRaptor.deckhud +Terminal=false +StartupNotify=false +NoDisplay=false +Categories=Utility; +Keywords=steam;deck;controller;gamepad;radial;overlay;hud;input; diff --git a/data/io.github.RustyRaptor.deckhud.metainfo.xml b/data/io.github.RustyRaptor.deckhud.metainfo.xml new file mode 100644 index 0000000..8a9d0cb --- /dev/null +++ b/data/io.github.RustyRaptor.deckhud.metainfo.xml @@ -0,0 +1,73 @@ + + + io.github.RustyRaptor.deckhud + deckhud + See your Steam Input radial menus, key chords and layers on the desktop + CC0-1.0 + MIT + + RustyRaptor + + +

+ deckhud brings the Steam Deck's controller feedback to KDE Plasma's Desktop Mode, where Steam + does not draw its own overlay. It shows translucent, click-through overlays tinted with your + KDE accent colour: +

+
    +
  • Radial menu HUD: see which radial item your stick is pointing at before you let go
  • +
  • Key-chord toasts: see which keys a button just sent, for example R4 → Meta + Shift + .
  • +
  • Layer cheat sheet: see what every control does when you switch action sets or hold a layer
  • +
+

+ deckhud reads your existing Steam Input layout and the controller's state; it never changes + either. It needs KDE Plasma on Wayland and a Steam Deck's built-in controller. +

+
+ io.github.RustyRaptor.deckhud.desktop + https://github.com/RustyRaptor/deckhud + https://github.com/RustyRaptor/deckhud/issues + https://github.com/RustyRaptor/deckhud + + + Radial menu selection + https://raw.githubusercontent.com/RustyRaptor/deckhud/v0.1.0/docs/screenshots/radial.png + + + Key-chord feedback + https://raw.githubusercontent.com/RustyRaptor/deckhud/v0.1.0/docs/screenshots/chords.png + + + Layer cheat sheet + https://raw.githubusercontent.com/RustyRaptor/deckhud/v0.1.0/docs/screenshots/sheet.png + + + + Utility + + + Steam + Steam Deck + controller + radial menu + overlay + + + 768 + + + gamepad + + + + #c9c5f2 + #2b2a3a + + + + +

First release: radial menu HUD, key-chord toasts and layer cheat sheet for KDE Plasma on Wayland.

+
+
+
+
diff --git a/data/io.github.RustyRaptor.deckhud.svg b/data/io.github.RustyRaptor.deckhud.svg new file mode 100644 index 0000000..b36e886 --- /dev/null +++ b/data/io.github.RustyRaptor.deckhud.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/screenshots/chords.png b/docs/screenshots/chords.png new file mode 100644 index 0000000..85a1c89 Binary files /dev/null and b/docs/screenshots/chords.png differ diff --git a/docs/screenshots/icon.png b/docs/screenshots/icon.png new file mode 100644 index 0000000..4f10fa8 Binary files /dev/null and b/docs/screenshots/icon.png differ diff --git a/docs/screenshots/radial.png b/docs/screenshots/radial.png new file mode 100644 index 0000000..ab6b0de Binary files /dev/null and b/docs/screenshots/radial.png differ diff --git a/docs/screenshots/sheet.png b/docs/screenshots/sheet.png new file mode 100644 index 0000000..0312ac9 Binary files /dev/null and b/docs/screenshots/sheet.png differ diff --git a/go.mod b/go.mod index 842d265..ffce688 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/RustyRaptor/deckhud -go 1.27.3 +go 1.25 require ( github.com/coder/websocket v1.8.15 diff --git a/internal/autostart/autostart.go b/internal/autostart/autostart.go new file mode 100644 index 0000000..965334a --- /dev/null +++ b/internal/autostart/autostart.go @@ -0,0 +1,72 @@ +// Package autostart asks the XDG Background portal to start deckhud with the +// session. Sandboxed apps can't install systemd units or autostart files +// themselves; the portal does it after asking the user. +package autostart + +import ( + "context" + "fmt" + + "github.com/godbus/dbus/v5" +) + +const ( + portalDest = "org.freedesktop.portal.Desktop" + portalPath = "/org/freedesktop/portal/desktop" +) + +// Request enables (or disables) autostart with commandline and reports +// whether the portal granted it. +func Request(ctx context.Context, enable bool, commandline []string) (bool, error) { + conn, err := dbus.ConnectSessionBus() + if err != nil { + return false, err + } + defer conn.Close() + + token := "deckhud_autostart" + sender := conn.Names()[0][1:] // ":1.42" -> "1.42" + for i := range sender { + if sender[i] == '.' { + sender = sender[:i] + "_" + sender[i+1:] + } + } + handle := dbus.ObjectPath("/org/freedesktop/portal/desktop/request/" + sender + "/" + token) + if err := conn.AddMatchSignalContext(ctx, + dbus.WithMatchObjectPath(handle), + dbus.WithMatchInterface("org.freedesktop.portal.Request"), + dbus.WithMatchMember("Response"), + ); err != nil { + return false, err + } + signals := make(chan *dbus.Signal, 1) + conn.Signal(signals) + + opts := map[string]dbus.Variant{ + "handle_token": dbus.MakeVariant(token), + "reason": dbus.MakeVariant("Show the Steam Input HUD whenever you use Desktop Mode"), + "autostart": dbus.MakeVariant(enable), + "commandline": dbus.MakeVariant(commandline), + } + var got dbus.ObjectPath + if err := conn.Object(portalDest, portalPath).CallWithContext(ctx, + "org.freedesktop.portal.Background.RequestBackground", 0, "", opts).Store(&got); err != nil { + return false, err + } + for { + select { + case <-ctx.Done(): + return false, ctx.Err() + case s := <-signals: + if s.Path != got || len(s.Body) < 2 { + continue + } + if code, _ := s.Body[0].(uint32); code != 0 { + return false, fmt.Errorf("autostart: request denied (response %d)", code) + } + results, _ := s.Body[1].(map[string]dbus.Variant) + granted, _ := results["autostart"].Value().(bool) + return granted, nil + } + } +} diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt new file mode 100644 index 0000000..cebee5a --- /dev/null +++ b/launcher/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.21) +project(deckhud-ui LANGUAGES CXX) +set(CMAKE_CXX_STANDARD 17) +find_package(Qt6 REQUIRED COMPONENTS Gui Qml) +add_executable(deckhud-ui main.cpp) +target_link_libraries(deckhud-ui PRIVATE Qt6::Gui Qt6::Qml) +install(TARGETS deckhud-ui) diff --git a/launcher/main.cpp b/launcher/main.cpp new file mode 100644 index 0000000..6bca462 --- /dev/null +++ b/launcher/main.cpp @@ -0,0 +1,22 @@ +// deckhud-ui: loads the overlay QML. Replaces the system `qml` runner where +// it isn't available (the Flatpak runtime only ships it in the SDK). +// Usage: deckhud-ui +#include +#include +#include + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + app.setApplicationName(QStringLiteral("deckhud")); + app.setDesktopFileName(QStringLiteral("io.github.RustyRaptor.deckhud")); + if (argc < 2) { + qCritical("usage: deckhud-ui "); + return 2; + } + QQmlApplicationEngine engine; + engine.load(QUrl::fromLocalFile(QString::fromLocal8Bit(argv[1]))); + if (engine.rootObjects().isEmpty()) + return 1; + return app.exec(); +} diff --git a/packaging/flatpak/README.md b/packaging/flatpak/README.md new file mode 100644 index 0000000..b9fd265 --- /dev/null +++ b/packaging/flatpak/README.md @@ -0,0 +1,34 @@ +# Flatpak + +Local build and install (needs `org.flatpak.Builder` from Flathub): + +```sh +flatpak run org.flatpak.Builder --user --force-clean --install-deps-from=flathub --install \ + --state-dir=.flatpak-builder build-flatpak packaging/flatpak/io.github.RustyRaptor.deckhud.yml +flatpak run io.github.RustyRaptor.deckhud # asks once to start with Plasma +flatpak run io.github.RustyRaptor.deckhud peek # toggle the cheat sheet +flatpak run io.github.RustyRaptor.deckhud autostart off +``` + +## Flathub + +The Flathub manifest is this file with the `type: dir` source replaced by the release tag: + +```yaml + - type: git + url: https://github.com/RustyRaptor/deckhud.git + tag: vX.Y.Z + commit: +``` + +When Go dependencies change, regenerate the `proxy.golang.org` archive sources and the inline +`vendor/modules.txt` (`go mod vendor` prints it) in the manifest. + +### Permission rationale (for reviewers) + +| Permission | Why | +|---|---| +| `--socket=wayland` only | The overlay is a `wlr-layer-shell` surface, which exists only on Wayland. No X11 fallback is possible | +| `--device=all` | Reads the Steam Deck controller's raw HID reports from `/dev/hidraw*` (read-only, alongside Steam). `--device=input` covers only `/dev/input/event*` | +| `~/.local/share/Steam:ro`, Flatpak Steam's equivalent `:ro` | Reads Steam Input layouts, `logs/controller.txt` (which layout is active) and binding icons. Never writes | +| (portals) | Settings portal for the accent colour, Background portal for autostart | diff --git a/packaging/flatpak/io.github.RustyRaptor.deckhud.yml b/packaging/flatpak/io.github.RustyRaptor.deckhud.yml new file mode 100644 index 0000000..ed60512 --- /dev/null +++ b/packaging/flatpak/io.github.RustyRaptor.deckhud.yml @@ -0,0 +1,88 @@ +# Development manifest: builds the working tree. The Flathub manifest is the +# same with the deckhud source switched to a git tag (see packaging/flatpak/README.md). +id: io.github.RustyRaptor.deckhud +runtime: org.kde.Platform +runtime-version: '6.11' +sdk: org.kde.Sdk +sdk-extensions: + - org.freedesktop.Sdk.Extension.golang +command: deckhudd +finish-args: + # Overlay on KDE Plasma (wlr-layer-shell). + - --socket=wayland + # Raw controller state from /dev/hidraw*; no narrower permission covers hidraw. + - --device=all + # Read-only: Steam Input layouts, controller.txt (active app) and binding icons. + - --filesystem=~/.local/share/Steam:ro + - --filesystem=~/.var/app/com.valvesoftware.Steam/.local/share/Steam:ro +modules: + - name: layer-shell-qt + buildsystem: cmake-ninja + config-opts: + - -DBUILD_TESTING=OFF + sources: + - type: git + url: https://invent.kde.org/plasma/layer-shell-qt.git + tag: v6.7.3 + commit: 4761442255ded65396ac3cd2af902969ef5dd5d8 + + - name: deckhud + buildsystem: simple + build-options: + append-path: /usr/lib/sdk/golang/bin + env: + CGO_ENABLED: '0' + GOFLAGS: -mod=vendor -trimpath + GOTOOLCHAIN: local + GOCACHE: /run/build/deckhud/.gocache + build-commands: + - go build -ldflags "-s -w" -o /app/bin/deckhudd ./cmd/deckhudd + - cmake -S launcher -B build-launcher -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/app + - cmake --build build-launcher + - cmake --install build-launcher + - install -Dm644 -t /app/share/deckhud/ui ui/main.qml + - install -Dm644 -t /app/share/deckhud/ui/components ui/components/*.qml + - install -Dm644 data/io.github.RustyRaptor.deckhud.desktop -t /app/share/applications + - install -Dm644 data/io.github.RustyRaptor.deckhud.metainfo.xml -t /app/share/metainfo + - install -Dm644 data/io.github.RustyRaptor.deckhud.svg -t /app/share/icons/hicolor/scalable/apps + sources: + - type: dir + path: ../.. + skip: + - .flatpak-builder + - build-flatpak + - bin + - vendor + # Go modules, rebuilt into vendor/ so the build works offline. + - type: archive + url: https://proxy.golang.org/github.com/coder/websocket/@v/v1.8.15.zip + sha256: 4f1d890bc5131f335737bbb6241e3958758c8774b3e6d1c905f713f604af6209 + strip-components: 3 + dest: vendor/github.com/coder/websocket + - type: archive + url: https://proxy.golang.org/github.com/godbus/dbus/v5/@v/v5.2.4.zip + sha256: 2a3a2996c274cbb735aa7f634dbcc0b292c0dff154447896d3a95955d078fb83 + strip-components: 4 + dest: vendor/github.com/godbus/dbus/v5 + - type: archive + url: https://proxy.golang.org/golang.org/x/sys/@v/v0.27.0.zip + sha256: e11dcde2289e0d45eabb06ea59aab05080870bab5753f524ed26df23ec8bddee + strip-components: 3 + dest: vendor/golang.org/x/sys + - type: inline + dest: vendor + dest-filename: modules.txt + contents: | + # github.com/coder/websocket v1.8.15 + ## explicit; go 1.23 + github.com/coder/websocket + github.com/coder/websocket/internal/bpool + github.com/coder/websocket/internal/errd + github.com/coder/websocket/internal/util + github.com/coder/websocket/internal/wsjs + # github.com/godbus/dbus/v5 v5.2.4 + ## explicit; go 1.20 + github.com/godbus/dbus/v5 + # golang.org/x/sys v0.27.0 + ## explicit; go 1.18 + golang.org/x/sys/unix diff --git a/packaging/screenshots/radial.json b/packaging/screenshots/radial.json new file mode 100644 index 0000000..40be44c --- /dev/null +++ b/packaging/screenshots/radial.json @@ -0,0 +1 @@ +{"type":"radial","radial":{"phase":"open","source":"right_joystick","items":[{"icon":"ghost_045_move_0010.png","keys":["Ctrl","V"]},{"icon":"ghost_070_setting_0300.png","keys":["Ctrl","Z"]},{"icon":"ghost_040_act_0331.png","keys":["Ctrl","X"]},{"icon":"ghost_070_setting_0303.png","keys":["Ctrl","C"]},{"icon":"ghost_070_setting_0304.png","keys":["Ctrl","A"]},{"icon":"ghost_075_utility_020.png","keys":["Ctrl","S"]},{"icon":"ghost_070_setting_0301.png","keys":["Ctrl","Shift","Z"]}],"index":0}} diff --git a/packaging/screenshots/render.qml b/packaging/screenshots/render.qml new file mode 100644 index 0000000..a332ae9 --- /dev/null +++ b/packaging/screenshots/render.qml @@ -0,0 +1,97 @@ +import QtQuick +import "../../ui/components" + +// Renders store screenshots offscreen: +// QML_XHR_ALLOW_FILE_READ=1 QT_QPA_PLATFORM=offscreen qml packaging/screenshots/render.qml -- +Window { + id: win + width: 1280 + height: 800 + visible: true + + readonly property string outDir: Qt.application.arguments[Qt.application.arguments.length - 1] + property var steps: [] + + function load(name) { + const xhr = new XMLHttpRequest() + xhr.open("GET", Qt.resolvedUrl(name), false) + xhr.send() + return JSON.parse(xhr.responseText) + } + + Rectangle { + anchors.fill: parent + gradient: Gradient { + GradientStop { position: 0; color: "#3a4a63" } + GradientStop { position: 1; color: "#1d2433" } + } + Grid { + anchors.centerIn: parent + columns: 8 + spacing: 60 + Repeater { + model: 40 + Rectangle { width: 90; height: 60; radius: 8; color: Qt.rgba(1, 1, 1, 0.05) } + } + } + } + + Hud { + id: hud + anchors.fill: parent + accent: "#9a93e3" + sheetTimeout: 100000 + toasts.timeout: 100000 + } + + Image { + id: icon + visible: false + source: "../../data/io.github.RustyRaptor.deckhud.svg" + sourceSize: Qt.size(256, 256) + } + + function shoot(item, name, next) { + item.grabToImage(r => { r.saveToFile(outDir + "/" + name); next() }) + } + + Timer { + interval: 600 + running: true + onTriggered: { + const radial = win.load("radial.json") + radial.radial.index = 2 + hud.handle(radial) + Qt.callLater(() => wait.start()) + } + } + Timer { + id: wait + interval: 500 + onTriggered: win.shoot(win.contentItem, "radial.png", () => { + hud.handle({ type: "radial", radial: { phase: "cancel", source: "right_joystick", index: 2 } }) + hud.handle({ type: "chord", chord: { button: "R4", keys: ["Meta", "Shift", "."] } }) + hud.handle({ type: "chord", chord: { button: "L5", keys: ["Ctrl", "Z"], label: "Undo" } }) + hud.handle({ type: "chord", chord: { button: "A", keys: ["Enter"] } }) + hud.handle({ type: "chord", chord: { button: "A", keys: ["Enter"] } }) + wait2.start() + }) + } + Timer { + id: wait2 + interval: 500 + onTriggered: win.shoot(win.contentItem, "chords.png", () => { + hud.toasts.clear() + hud.handle(win.load("state.json")) + wait3.start() + }) + } + Timer { + id: wait3 + interval: 500 + onTriggered: win.shoot(win.contentItem, "sheet.png", () => { + icon.visible = true + win.shoot(icon, "icon.png", () => Qt.quit()) + }) + } +} diff --git a/packaging/screenshots/state.json b/packaging/screenshots/state.json new file mode 100644 index 0000000..2f370fc --- /dev/null +++ b/packaging/screenshots/state.json @@ -0,0 +1 @@ +{"type":"state","state":{"set":"Desktop"},"sheet":{"set":"Desktop","controls":[{"glyph":"L2","source":"left_trigger","mode":"trigger","entries":[{"input":"click","activator":"Full_Press","keys":["Right Click"]},{"input":"edge","activator":"Full_Press","keys":["Right Click"]}]},{"glyph":"L1","source":"switch","mode":"switches","entries":[{"activator":"Full_Press","keys":["Alt"]}]},{"glyph":"L4","source":"switch","mode":"switches","entries":[{"activator":"Full_Press","keys":["Del"]},{"activator":"Long_Press","keys":["Action set 2"]}]},{"glyph":"L5","source":"switch","mode":"switches","entries":[{"activator":"Full_Press","keys":["Space"]}]},{"glyph":"View","source":"switch","mode":"switches","entries":[{"activator":"Double_Press","keys":["F11"]},{"activator":"Long_Press","keys":["F12"]},{"activator":"Full_Press","keys":["F10"]}]},{"glyph":"LS","source":"joystick","mode":"scrollwheel","entries":[{"input":"click","activator":"Full_Press","keys":["Middle Click"]},{"input":"scroll_clockwise","activator":"Full_Press","keys":["Scroll ↑"]},{"input":"scroll_counterclockwise","activator":"Full_Press","keys":["Scroll ↓"]}]},{"glyph":"D-pad","source":"dpad","mode":"dpad","entries":[{"input":"dpad_north","activator":"Double_Press","keys":["="]},{"input":"dpad_north","activator":"Full_Press","keys":["↑"]},{"input":"dpad_east","activator":"Full_Press","keys":["→"]},{"input":"dpad_south","activator":"Double_Press","keys":["-"]},{"input":"dpad_south","activator":"Full_Press","keys":["↓"]},{"input":"dpad_west","activator":"Full_Press","keys":["←"]}]},{"glyph":"LPad","source":"left_trackpad","mode":"2dscroll","entries":[{"input":"dpad_north","activator":"Full_Press","keys":["Scroll ↑"]},{"input":"dpad_south","activator":"Full_Press","keys":["Scroll ↓"]}]},{"glyph":"A","source":"button_diamond","mode":"four_buttons","entries":[{"activator":"Full_Press","keys":["Enter"]}]},{"glyph":"B","source":"button_diamond","mode":"four_buttons","entries":[{"activator":"Full_Press","keys":["Esc"]}]},{"glyph":"X","source":"button_diamond","mode":"four_buttons","entries":[{"activator":"Full_Press","keys":["Tab"]}]},{"glyph":"Y","source":"button_diamond","mode":"four_buttons","entries":[{"activator":"Full_Press","keys":["Shift"]}]},{"glyph":"Menu","source":"switch","mode":"switches","entries":[{"activator":"Double_Press","keys":["Screenshot"]},{"activator":"Full_Press","keys":["Meta"]}]},{"glyph":"RPad","source":"right_trackpad","mode":"absolute_mouse","entries":[]},{"glyph":"RS","source":"right_joystick","mode":"radial_menu","entries":[{"input":"touch_menu_button_1","activator":"Full_Press","keys":["Ctrl","V"]},{"input":"touch_menu_button_2","activator":"Full_Press","keys":["Ctrl","Z"]},{"input":"touch_menu_button_3","activator":"chord","keys":["Ctrl","X"]},{"input":"touch_menu_button_4","activator":"Full_Press","keys":["Ctrl","C"]},{"input":"touch_menu_button_5","activator":"Full_Press","keys":["Ctrl","A"]},{"input":"touch_menu_button_6","activator":"Full_Press","keys":["Ctrl","S"]},{"input":"touch_menu_button_7","activator":"Full_Press","keys":["Ctrl","Shift","Z"]}]},{"glyph":"R4","source":"switch","mode":"switches","entries":[{"activator":"Full_Press","keys":["Meta","Shift","."]}]},{"glyph":"R5","source":"switch","mode":"switches","entries":[{"activator":"Full_Press","keys":["Ctrl","V"]},{"activator":"Double_Press","keys":["Ctrl","Shift","V"]}]},{"glyph":"R1","source":"switch","mode":"switches","entries":[{"activator":"Full_Press","keys":["Ctrl"]}]},{"glyph":"R2","source":"right_trigger","mode":"trigger","entries":[{"input":"click","activator":"Full_Press","keys":["Left Click"]},{"input":"edge","activator":"Full_Press","keys":["Left Click"]}]}]}} diff --git a/ui/components/Hud.qml b/ui/components/Hud.qml index 67db08a..53a7f96 100644 --- a/ui/components/Hud.qml +++ b/ui/components/Hud.qml @@ -32,6 +32,10 @@ Item { if (/^#[0-9a-fA-F]{6}$/.test(msg.color ?? "")) accent = msg.color break + case "config": + if (msg.iconDir) + iconDir = msg.iconDir + break case "hello": quietNextState = true break diff --git a/ui/main.qml b/ui/main.qml index 7e0b896..7eec5c7 100644 --- a/ui/main.qml +++ b/ui/main.qml @@ -1,5 +1,4 @@ import QtQuick -import QtCore import QtWebSockets import org.kde.layershell as LayerShell import "components" @@ -26,8 +25,6 @@ Window { Hud { id: hud anchors.fill: parent - iconDir: StandardPaths.writableLocation(StandardPaths.GenericDataLocation) - + "/Steam/tenfoot/resource/images/library/controller/binding_icons" } WebSocket { diff --git a/ui/tests/tst_hud.qml b/ui/tests/tst_hud.qml index 1153b0e..0d0e7be 100644 --- a/ui/tests/tst_hud.qml +++ b/ui/tests/tst_hud.qml @@ -75,5 +75,12 @@ Item { wait(600) compare(h.accent, Qt.color("#f09cca"), "invalid colours are ignored") } + + function test_configSetsIconDir() { + const h = createTemporaryObject(hudComponent, root) + h.handle({ type: "config", app: "413080", title: "desk", iconDir: "file:///steam/icons" }) + compare(h.iconDir, "file:///steam/icons") + compare(h.radial.iconDir, "file:///steam/icons") + } } }