Medius - Native APIInject

Inject

Press and release any input

INJECT sets a momentary input on top of whatever the user is physically doing: a mouse button, a keyboard key or modifier, or a media key. One verb covers all three, tagged by a class byte, so the same press / release logic works for every input class. The continuous axes (cursor and wheel) have their own verb, MOVE.

INJECT

Momentary-usage override

INJECT sets a per-usage override, the box's own held decision layered over the physical input. The class byte picks the input kind, id picks the usage within that class, and action is the same tri-state for all three. Opcode 0x03.

INJECT 0x03 · payload 4 bytes

Fire-and-forget

PAYLOAD
OffsetFieldTypeNotes
0classu80=button 1=key 2=media (the input kind)
1idu16the usage within the class, little-endian (see each class below)
3actionu80=soft-release 1=press 2=force-release
CLASSES
ClassValueid is
button0a semantic button id (0=Left .. 4=Side2)
key1a HID keyboard usage (0xE0-0xE7 = modifier)
media2a 16-bit Consumer usage
ACTIONS
ActionValueEffect
press1Force the usage active regardless of physical state.
soft-release0Drop our override (whether it was a press or a force-release); a physical hold stays active.
force-release2Force the usage inactive, masking a physical hold too. The release the safety auto-clear uses.
RESULT THE PC SEES

The two releases differ only when the user is physically holding the same input:

ActionUser holds nothingUser is holding it
pressactiveactive
soft-releaseinactiveactive (physical wins)
force-releaseinactiveinactive (masks physical)
RULES
additive   layers over the user at the same merge point as MOVE;
           never evicts the user's own input
no click   no firmware click or chord; send a press, then your
           own client-timed soft-release
RESET      releases every override at once

A usage the cloned device can't report is a silent no-op. Check CAPS before you rely on it.

Library binding: inject.

class = button

Mouse button override

With class = 0, id is a semantic button id (0=Left, 1=Right, 2=Middle, 3=Side1, 4=Side2), bound at clone time to the real mouse's buttons. The override sets that button's bit in the report the PC sees. Library bindings: inject / press / release / force_release.

EXAMPLE

Press Left: class 0x00, id 0x0000, action 0x01:

+--------+--------+--------+--------+--------+--------+--------+--------+
| A5     | 03     | 00     | 04 00  | 00     | 00 00  | 01     | lo hi  |
+--------+--------+--------+--------+--------+--------+--------+--------+
| SOF    | TYPE   | SEQ    | LEN    | class  | id     | action | CRC16  |
+--------+--------+--------+--------+--------+--------+--------+--------+

class = key

Keyboard key and modifier override

With class = 1, id is a HID keyboard usage. A usage of 0xE0-0xE7 folds into the modifier byte; anything else fills a keycode slot (or sets its NKRO bit) in the report the PC sees. Physical keys keep their slots, so injection never evicts the user's typing; past the board's rollover limit it emits the board's own ErrorRollOver. A keycode the cloned board can't report is a no-op. Library bindings: inject / press / release / force_release.

EXAMPLE

Press A: class 0x01, id 0x0004, action 0x01:

+--------+--------+--------+--------+--------+--------+--------+--------+
| A5     | 03     | 00     | 04 00  | 01     | 04 00  | 01     | lo hi  |
+--------+--------+--------+--------+--------+--------+--------+--------+
| SOF    | TYPE   | SEQ    | LEN    | class  | id     | action | CRC16  |
+--------+--------+--------+--------+--------+--------+--------+--------+

class = media

Media key override

With class = 2, id is a 16-bit Consumer usage (e.g. 0xCD Play/Pause, 0xE9 Volume Up), merged onto the cloned keyboard's Consumer report. Present-gated to a board that declares a Consumer collection, read from the CAPS CONSUMER flag; otherwise a no-op. Library bindings: inject / press / release / force_release.

EXAMPLE

Press Volume Up: class 0x02, id 0x00E9, action 0x01:

+--------+--------+--------+--------+--------+--------+--------+--------+
| A5     | 03     | 00     | 04 00  | 02     | E9 00  | 01     | lo hi  |
+--------+--------+--------+--------+--------+--------+--------+--------+
| SOF    | TYPE   | SEQ    | LEN    | class  | id     | action | CRC16  |
+--------+--------+--------+--------+--------+--------+--------+--------+