# `tecs.platform.gamepadnative` The `tecsgamepad` binding behind the gamepad backend contract. Loading this module loads `libtecsgamepad` through `tecs.internal.nativelibrary`, so a build that cannot find the library raises here rather than anywhere later. `tecs.input` requires it through `pcall` for exactly that reason and falls back to `tecs.platform.gamepadbackend.none` when it is absent, which is what makes a headless test and a machine with no controller support behave the same. Observations cross as one contiguous C array per drain. Nothing in the library ever calls a Nupp function. `gilrs` runs a thread of its own on macOS, where `IOHIDManager` needs a `CFRunLoop`, and entering Nupp from a thread the Lua virtual machine never created is undefined, so that thread posts to a channel the library drains on the frame thread instead. This binding therefore declares no function pointer anywhere. ```nupp local backend = assert(tecs.platform.gamepadnative.open()) ``` ## Functions ### `open` _function_ ```nupp function open(): gamepadbackend.Backend?, string? ``` Opens the platform's gamepad source and returns it as a backend. A machine with no controller support still opens: the backend reports `available` false, answers every call, and never sees a device. #### Returns | Type | Description | | --- | --- | | `gamepadbackend.Backend?` | the backend, or nil when the library opened nothing | | `string?` | the reason, when the first return is nil | ### `openDetached` _function_ ```nupp function openDetached(): gamepadbackend.Backend?, string? ``` Opens a context with no platform source, for a deterministic native test. This proves the binding itself against the real library without needing a controller plugged in, which is what a headless suite can check. #### Returns | Type | Description | | --- | --- | | `gamepadbackend.Backend?` | the backend, or nil when the library opened nothing | | `string?` | the reason, when the first return is nil |