Disconnect a hardware gamepad (:disconnect)
This method is available in versions after 20260805
Declaration
success, err = pad:disconnect()
Returns
- success Boolean. True if the gamepad was disconnected; false on failure
- err String. Error message when the operation fails
Description
disconnectmay be called repeatedly- On explicit disconnection, Lua garbage collection, or script termination, all buttons are released, the analog sticks and directional pad are centered, and then the gamepad disconnects
- If input delivery fails, the gamepad resets and disconnects
- A failed gamepad operation is not retried through keyboard, touch, or another input method
Example
local pad = assert(gamepad.connect())
local success, err = pad:disconnect()
assert(success, err)