API ReferenceGE Extensionscoreinput
Virtual Input
Creates and manages virtual input devices (joysticks/gamepads) from Lua. Used by the remote controller extension and other systems that need to inject synthetic input events.
Creates and manages virtual input devices (joysticks/gamepads) from Lua. Used by the remote controller extension and other systems that need to inject synthetic input events.
Public Functions
| Function | Signature | Description |
|---|---|---|
M.createDevice | (productName, vidpid, axes, buttons, povs) → deviceInstance, info | Registers a virtual input device with the engine |
M.deleteDevice | (deviceInstance) | Unregisters and removes a virtual input device |
M.getDeviceInfo | (vidpid) → deviceInstance, info | Looks up a device by its VID/PID string |
M.emit | (deviceInstance, objType, objectInstance, action, val) | Emits an input event from a virtual device |
Module State
| Field | Type | Description |
|---|
Usage Example
local vi = extensions.core_input_virtualInput
-- Create a virtual gamepad with 2 axes, 4 buttons, 0 POV hats
local inst, info = vi.createDevice("MyVirtualPad", "mydevice01", 2, 4, 0)
-- Emit a button press
vi.emit(inst, "button", 0, "down", 1)
-- Emit an axis change (value 0-1)
vi.emit(inst, "axis", 0, "change", 0.75)
-- Emit button release
vi.emit(inst, "button", 0, "up", 0)
-- Clean up
vi.deleteDevice(inst)Device Naming
Virtual devices are registered with the engine as "vinput" .. deviceInstance. The engine's getVirtualInputManager() handles the low-level registration.
Event Parameters
| Parameter | Values | Description |
|---|---|---|
objType | "button", "axis" | Type of input object |
objectInstance | number | Zero-based index of the button/axis |
action | "down", "up", "change" | Event action type |
val | number | Value (0/1 for buttons, 0.0–1.0 for axes) |
Notes
- Timestamps use
os.clockhp()for high-precision timing. - If
getVirtualInputManager()returns nil, all operations log errors and return nil. - Used by
core_remoteControllerfor phone-based steering input.
See Also
- remoteController - Phone remote control using virtual input
- vibrationDebug - Vibration parameter tuning