Kneedeck

Drive Kneedeck

For Kneedeck 0.42.0 and later.

Kneedeck can be driven from another program of the PC: the Stream Deck, VoiceAttack, a script in Python, Lua or C. Commands go through the command line, or through messages.

1. The command line

A shortcut, the Stream Deck (System action, Open) or VoiceAttack (run an application) starts Kneedeck with a command. A Kneedeck already running does it without opening a second time.

kneedeck.exe --action next-page --repeat 3
kneedeck.exe --tab "Carte LFXX" --page 3
kneedeck.exe --tab-number 2
kneedeck.exe --profile "Mirage F1"
kneedeck.exe --brightness 60
--actionAn action, from the list below.
--repeatThe action that many times, 50 at most.
--tab, --pageThe tab of that name, and its page, from 1.
--tab-numberThe tab at that place on the tablet, from 1, with --page if wanted.
--profileThe profile of that name, or of that id.
--brightnessThe tablet's brightness, in percent.

The actions:

toggle, show, hideShow or hide the tablet, show it, hide it.
mouse, keyboardThe mouse to the game or to the tablet, the keyboard to the tablet or to the game.
next-page, previous-pageNext page, previous page.
next-tab, previous-tabNext tab, previous tab.
next-profile, previous-profileNext profile, previous profile.
zoom-in, zoom-outZoom in, zoom out.
rotate-tabTurn the tab a quarter.
toggle-bookmark, next-bookmark, previous-bookmarkBookmark the page or remove its bookmark, next bookmark, previous bookmark.
toggle-pinPin the page or unpin it.
brighter, darkerBrighter, darker.
tint, tint-on, tint-offThe night tint: switch, turn on, turn off.

2. Messages from programs

A program of the PC sends Kneedeck a JSON text by UDP, to 127.0.0.1, port 47831: one object, or a list of objects done in their order. Kneedeck only listens to the programs of this PC, and answers nothing.

{"action": "next-page", "repeat": 3}An action, that many times.
{"tab": "Carte LFXX", "page": 3}A tab by its name, and its page from 1.
{"tabNumber": 2, "page": 1}A tab by its place on the tablet.
{"profile": "Mirage F1"}A profile by its name or its id.
{"brightness": 60}, {"brightness": "+10"}The brightness in percent, or a few points up or down.
{"module": "dupont.minuteur", "message": …}A message for a module, by its id (see part 3).

Python

import kneedeck

kneedeck.send({"tab": "Carte LFXX", "page": 3})
kneedeck.send([{"profile": "Mirage F1"}, {"action": "show"}])

kneedeck.py, next to the script. It also runs on its own: python kneedeck.py "{\"action\": \"toggle\"}".

Lua, for DCS World

local kneedeck = dofile(lfs.writedir() .. "Scripts\\kneedeck.lua")

kneedeck.send('{"tab": "Carte LFXX", "page": 3}')

kneedeck.lua, in Saved Games\DCS\Scripts. It works in Export.lua as in a DCS script, and in any Lua with LuaSocket.

C and C++

#include "kneedeck.h"

kneedeck_send("{\"tab\": \"Carte LFXX\", \"page\": 3}");

kneedeck.h, for Windows, linked with ws2_32.

3. Messages to modules

A module gets the messages sent to it, if it is in a tab of the tablet: those of the programs of the PC, of the tablet's web pages and of the other modules.

Kneedeck.on("message", (message, from) => {
  // from: "pc", the site of a web page, or the id of another module
});
Kneedeck.send("dupont.checklist", { tick: 3 });

The rest is in Write a module.

4. Web pages

A web page in a tab talks with Kneedeck through postMessage, each message carrying kneedeck: 1 and its type.

parent.postMessage({ kneedeck: 1, type: "ready" }, "*");
parent.postMessage({ kneedeck: 1, type: "pages", count: 5 }, "*");

addEventListener("message", (event) => {
  const message = event.data;
  if (event.source !== parent || message?.kneedeck !== 1) return;
  if (message.type === "hello" || message.type === "page") show(message.page);
});

What the page sends:

readyThe page is ready: Kneedeck answers hello.
pages (count)It has that many pages, 1000 at most: the tablet turns them as those of a PDF.
size (width, height)The size it is made for, in pixels: the tablet shows it whole, smaller or larger.
title (title)Its title, which the tab takes if the player chose “Name taken from the page”.
message (to, message)A message for the module whose id is to.

What Kneedeck sends:

hello (games, page)The data of the games the player gives the tab, and the page to show, from 0.
games (games)The games' data, at each change.
page (page)The player turned the page.

The games' data are the modules' own, described in Write a module. A page kept on the PC (an HTML tab) sends and gets the same messages, without the games' data or the messages to modules.

To look at a page closely: Settings, Developer tools, choose the page, then “Open”. It opens in your browser, with its tools.