Skip to content

Modules and Features

Plugins can extend their capabilities beyond basic USB reads and writes using two systems: Modules and Features. Understanding the difference between them helps you discover what’s available and use the right mechanism for the job.

ModulesFeatures
How to useimport { x } from "@SignalRGB/name"device.addFeature("name") in Initialize()
PurposeUtility services (networking, encoding, system info)Device capabilities (battery, input injection)
NamespaceModule’s own exported namesdevice.featureName.*
InstancesOne per pluginCan have multiple

Import these at the top of your plugin file.

Import pathPurpose
@SignalRGB/serialSerial/COM port communication
@SignalRGB/tcpTCP socket communication
@SignalRGB/udpUDP socket communication
@SignalRGB/base64Base64 encoding and decoding
@SignalRGB/performancePerformance profiling and frame timers
@SignalRGB/appInfoSignalRGB application version info
@SignalRGB/systeminfoSystem hardware information
@SignalRGB/permissionsCheck user permission state

See Advanced Communication for serial, tcp, and udp usage examples.


Call device.addFeature("name") in your Initialize() export. The feature creates a global object with the same name as the feature.

Feature nameNamespacePurpose
"keyboard"keyboardInject keystrokes or route keyboard events to SignalRGB macros
"mouse"mouseInject mouse input or route mouse events to SignalRGB macros
"battery"batteryReport battery level and charge state for wireless devices
"dtls"dtlsDTLS-encrypted UDP with PSK authentication

For plugins that represent keyboard devices. Lets you inject real keystrokes into the OS or fire events that can trigger SignalRGB macros.

export function Initialize() {
device.addFeature("keyboard");
}

Sends a raw keystroke directly to the operating system via keybd_event. The key appears as real input to all applications — it bypasses the macro system entirely.

ParameterTypeDescriptionExample
vkCodeNumberWindows Virtual Key code0x41 (A key)
options.releasedBoolean (required)true for key-up, false for key-downfalse
keyboard.sendHid(0x41, { released: false }); // Press A
keyboard.sendHid(0x41, { released: true }); // Release A

Routes a keyboard event through the SignalRGB macro system. Macros with an onKey trigger can match these events. Does not inject a real keystroke — only SignalRGB macros see this event.

The macro system automatically enriches the event with live modifier state (Ctrl, Shift, Alt, Win) from the physical keyboard before dispatching it.

ParameterTypeDescriptionExample
eventDataObject or StringEvent data. Include key (string name) and optionally keyCode (number) for key matching.{ key: "A", keyCode: 0x41 }
eventTypeStringEvent type label"KeyPress"
keyboard.sendEvent({ key: "A", keyCode: 0x41, released: false }, "KeyPress");

Macro scripts receive event.Sender (the plugin’s UID) and event.SenderType ("Device"), so they can distinguish plugin-sourced events from real hardware keystrokes.


For plugins that represent mouse or pointer devices.

export function Initialize() {
device.addFeature("mouse");
}

Sends a raw mouse event to the OS via SendInput. Mouse movement (MOUSEEVENTF_MOVE, MOUSEEVENTF_ABSOLUTE) is blocked for safety.

ParameterTypeDescription
buttonCodeNumberWindows MOUSEEVENTF_* flag
options.XButtonNumberRequired for X-button events — 1 (X1) or 2 (X2)
options.WheelDeltaNumberRequired for scroll wheel events — positive scrolls up, negative scrolls down

Common button codes:

CodeConstantDescription
0x0002MOUSEEVENTF_LEFTDOWNLeft button press
0x0004MOUSEEVENTF_LEFTUPLeft button release
0x0008MOUSEEVENTF_RIGHTDOWNRight button press
0x0010MOUSEEVENTF_RIGHTUPRight button release
0x0020MOUSEEVENTF_MIDDLEDOWNMiddle button press
0x0040MOUSEEVENTF_MIDDLEUPMiddle button release
0x0800MOUSEEVENTF_WHEELVertical scroll
0x01000MOUSEEVENTF_HWHEELHorizontal scroll
0x0080MOUSEEVENTF_XDOWNX-button press (requires XButton option)
0x0100MOUSEEVENTF_XUPX-button release (requires XButton option)
// Left click
mouse.sendHid(0x0002, {}); // down
mouse.sendHid(0x0004, {}); // up
// Scroll up one notch
mouse.sendHid(0x0800, { WheelDelta: 120 });
// X1 button press
mouse.sendHid(0x0080, { XButton: 1 });
mouse.sendHid(0x0100, { XButton: 1 });

Routes a custom mouse event through the SignalRGB macro system. Macro scripts with an onMouse trigger can match these events. Does not inject any OS-level mouse input.

mouse.sendEvent({ button: "LeftClick" }, "ButtonPress");

For wireless devices that report battery status. After adding the feature, update the battery level and state whenever your device reports them.

export function Initialize() {
device.addFeature("battery");
}
MethodDescription
battery.setBatteryLevel(level)Set battery percentage (0–100)
battery.setBatteryState(state)Set the charge state using a state constant

State constants (access via battery.<name>):

ConstantDescription
battery.disabledBattery reporting disabled
battery.unknownState not yet known
battery.drainingRunning on battery
battery.chargingCharging via cable
battery.fullChargingCharging and already full
battery.fullFull charge, not charging
battery.wirelessChargingWireless charging

These properties reflect the last values set:

PropertyTypeDescription
battery.batteryLevelNumberCurrent level (0–100)
battery.batteryStateNumberCurrent state value
battery.stateStringStringHuman-readable state label
export function Initialize() {
device.addFeature("battery");
}
export function Render() {
// Non-blocking read — check if the device sent a battery report this frame
var data = device.read([], 64, 0);
if(device.getLastReadSize() > 0 && data[0] === 0x02) {
var level = data[1]; // 0–100
var charging = data[2] === 0x01;
battery.setBatteryLevel(level);
battery.setBatteryState(
charging ? battery.charging : battery.draining
);
}
}