britzldefold-input
britzl/defold-input/in.mapper
Cross-platform input handling for Defold: keyboard, mouse, gamepad, touch, and on-screen controls.
- GitHub: britzl/defold-input — pinned to
4.9.0- Pick a release from britzl/defold-input releases and add its Source code (zip) URL (or a packaged
.zipasset, if the library ships one) togame.projectunder[project]dependencies, then Fetch Libraries in the Defold editor. - Run
bunx @defold-typescript/cli resolveto materialize its types. - Import it under a namespace alias of your choice:
import * as mapper from "in.mapper"
- Pick a release from britzl/defold-input releases and add its Source code (zip) URL (or a packaged
Functions
bind(trigger: {}, action: {}, player?: any, gamepad?: any): unknownU
Bind an input trigger to an action, optionally associating the binding to a specific player
Parameters
trigger:{}— The input trigger to bind (key, gamepad, mouse etc)action:{}— The action that will be generated by the triggerplayer?:any— Optional id for a player to bind input trigger togamepad?:any— Gamepad index to bind the trigger to. 0️⃣ 0-based; passed toin.mapperunchanged.
Returns
unknown— Any previous action bound to the trigger
unbind(trigger: {}, player?: any)U
Unbind (remove) an existing input binding
Parameters
trigger:{}— The input trigger to unbind (key, gamepad, mouse etc)player?:any— Optional id for a player to unbind input trigger from
unbind_all(player?: any)U
Unbind (remove) all input trigger bindings
Parameters
player?:any— Optional id for a player to unbind input triggers from
on_input(trigger: {}, player?: any, gamepad?: any): {} | undefinedU
Handle incoming input trigger from a script by finding an binding and returning the bound action
Parameters
trigger:{}— The input trigger received from on_input funcion (ie action_id)player?:any— Optional id for a player to get input trigger binding forgamepad?:any— Gamepad index the trigger came from,action.gamepad. 0️⃣ 0-based; passed toin.mapperunchanged.
Returns
{} | undefined— The bound action or nil if no binding exists