All posts
·Rebind

Luau Scripting on Dedicated Hardware: How Rebind Works

Rebind runs Luau — a typed, fast variant of Lua — on a Rust-backed SDK on a dedicated USB microcontroller. Here's what that means in practice and what you can build with it.

rebind lualua macrorebind scriptluaurebind device

Rebind's scripting engine runs Luau on top of a Rust-backed SDK, executing on a dedicated Teensy 4.x microcontroller at up to 8,000 Hz. If you're familiar with Lua — or with Roblox's scripting environment, where Luau originated — the language will feel familiar immediately. If you're not, it's a clean, minimal scripting language that's easier to learn than Python and significantly more capable than the macro editors built into peripheral software.

This article covers what Luau is, why it's the right choice for hardware scripting, and what the Rebind SDK exposes.

What is Luau?

Luau is a fast, typed variant of Lua developed by Roblox. It's fully backward-compatible with Lua 5.1 and adds optional type annotations, improved performance, and a stricter mode for catching errors early. On Rebind hardware, Luau runs on top of a Rust runtime that handles the low-level timing loop, USB communication, and host awareness — you write logic, the runtime handles the hardware interface.

The relevant properties for a scripting engine:

  • Real control flow. if, for, while, repeat, functions, closures. Not a sequence recorder.
  • Coroutines. You can write asynchronous sequences — wait for a condition, yield mid-script, resume — without callbacks or complex state machines.
  • State management. Variables persist across events. You can build counters, toggle states, track sequences across multiple inputs.
  • Standard library. String manipulation, math, table operations, and a full set of Rebind-specific SDK functions.

The scripting model

Every Rebind script responds to input events. When you press a key or move a mouse, the runtime fires your script with the event details. Your script can:

  • Pass the event through unchanged — the output device sends it to the OS as normal
  • Block the event — the input is consumed, nothing reaches the OS
  • Transform it — intercept a right click, emit a different key combination instead
  • Generate new events — trigger mouse movements, keystrokes, or sequences that weren't in the original input

Because this runs on the microcontroller, not on the PC, the OS never sees your physical input at all. It only sees what the Rebind output device sends.

Coroutines for sequences

One of the most useful features is coroutines. A macro that needs to fire a sequence of events with precise timing looks like this in most tools: a flat list of steps with hardcoded delays. In Luau on Rebind, you write it as a coroutine:

-- press a key, wait, press another, wait, release both
local function combo()
  press("shift")
  sleep(15)
  press("a")
  sleep(20)
  release("a")
  release("shift")
end

The sleep calls yield the coroutine without blocking the input processing loop. Other events continue to be handled while the sequence is in progress. This lets you build multi-step automations that don't stall the entire engine.

Per-application context

Scripts on Rebind can read what's happening on the host PC. The SDK includes window focus awareness — you can bind different behaviors to the same key depending on which application is active:

if window.active() == "Photoshop" then
  -- remap ctrl+z differently
end

This is the same capability that peripheral software like G Hub and Synapse offer with their "application profiles" feature, but it's implemented in script logic rather than a graphical profile switcher — which means you can express conditions that a profile editor can't.

What the SDK exposes

The full SDK is documented in the SDK Reference, but the major capability areas:

  • Key remapping and modifier combos — remap any key to any other key or combination
  • Text expansion — type an abbreviation, emit a full string
  • Mouse transforms — scale, smooth, or redirect mouse movement
  • Clipboard access — read and write the system clipboard
  • Shell execution — run a command, capture output
  • PCRE regex — pattern matching on strings
  • TOML config I/O — read and write structured config files from disk
  • Audio playback — WAV, MP3, OGG, FLAC
  • Pixel color sampling — read screen colors to make input-reactive scripts
  • HTTP client and server — full GET, POST, PUT, PATCH, DELETE, HEAD; and a listener for inbound requests
  • File system access — read, write, list files
  • Window manipulation — focus, move, resize windows
  • Shared memory IPC — communicate with external processes (Python scripts, AI models, other tools) via named pipes

That last point is worth highlighting: the HTTP client and shared memory IPC mean Rebind scripts can communicate with the outside world. A script can call a local API, receive a response, and adjust its behavior accordingly — all in real time, triggered by hardware input.

Who this is for

If you've been using AutoHotkey for input automation and want hardware-level execution and portability, Rebind uses a language in the same family with more modern tooling. If you're coming from peripheral software and want to use your existing hardware without vendor lock-in, the Luau scripting model gives you capabilities no profile editor can match. If you're starting from scratch, the learning curve is shallow — Luau is a small language and the SDK is consistent.

The Scripting Guide in the documentation covers the full API with examples. The marketplace has ready-made scripts if you want to start without writing code.

Back to all posts