Medius - Native APILock

Lock

Block one physical input by class

LOCK stops the physical device from driving one input while leaving everything else alone. It's generic over the input class: a relative axis, a mouse button, a keyboard key, or a media usage, plus a blanket lock for a whole class. Host injection still drives a locked input, so a script can take one over; it's fire-and-forget.

LOCK

Lock or unlock a physical input

LOCK picks a class, an id within it, and a direction, then either blocks it or clears the block. A momentary usage shares INJECT's (class, id) space, so a button locks exactly like a key. Opcode 0x0A.

LOCK 0x0A · payload 5 bytes

Fire-and-forget

PAYLOAD
OffsetFieldTypeNotes
0classu8the input class (see below)
1idu16which input within the class, little-endian; 0xFFFF = the whole class
3directionu8which sign or which edge (see below)
4stateu81 = lock, 0 = unlock
CLASSES
ClassValueid is
button0a button id (0=Left .. 4=Side2)
key1a HID keyboard usage (0xE0-0xE7 = modifier)
media2a 16-bit Consumer usage
axis30=X, 1=Y, 2=wheel (the sign is the direction)

Classes 0-2 mirror INJECT. An id of 0xFFFF is a blanket: it locks every usage in that class in one command (every button, every key, or every media usage).

DIRECTION

What direction means depends on the input. For an axis it's a sign, so you can block scrolling up but not down. For a button, key, or media usage it's an edge, so you can block the press but not the release.

DirectionValueAxisButton / key / media
both0Both signs.Press and release.
positive1Positive sign only (+).Press only (0 to 1).
negative2Negative sign only (-).Release only (1 to 0).
PHYSICAL ONLY

A lock blocks the physical device and nothing else. Host injection still reaches a locked input, so a MOVE moves a locked axis and an INJECT drives a locked button or key. Lock an input the user shouldn't touch, then drive it yourself.

A LOCK CLEARS ON
unlock      you send the matching unlock (state = 0)
silence     ~1 s with no control-PC frame (same net as injection)
RESET       a RESET command
link loss   the inter-chip link drops

A lock isn't permanent. It auto-clears on the same safety net as injection, so hold it with a keepalive if the user has to stay locked out.

EFFECT

Locks are PC-owned and never visible to the game PC. QUERY(LOCKS) reads the active set across every class; the HEALTH LOCK_ON bit is set while any lock, of any class, is active. Library bindings: lock / unlock, and lock_all / unlock_all for a blanket.

EXAMPLE

Lock the wheel's negative (scroll-down) sign: class = 3 (axis), id = 2 (wheel), direction = 2, state = 1:

+--------+--------+--------+--------+--------+--------+--------+--------+--------+
| A5     | 0A     | 00     | 05 00  | 03     | 02 00  | 02     | 01     | lo hi  |
+--------+--------+--------+--------+--------+--------+--------+--------+--------+
| SOF    | TYPE   | SEQ    | LEN    | class  | id     | dir    | state  | CRC16  |
+--------+--------+--------+--------+--------+--------+--------+--------+--------+