Skip to Content
defold-typescript libraries
britzldefold-input

britzl/defold-input/in.onscreen

Cross-platform input handling for Defold: keyboard, mouse, gamepad, touch, and on-screen controls.

  • GitHub: britzl/defold-input — pinned to 4.9.0
    1. Pick a release from britzl/defold-input releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as onscreen from "in.onscreen"

Functions

create(config?: { touch: Hash; }): OnscreenInstance

Create an instance of the onscreen controls.

Parameters

  • config?: { touch: Hash; } — Optional settings. touch is the action id bound to single touch.
    • touch: Hash

Returns

  • OnscreenInstance — The instance the register and input functions operate on.

reset(instance?: OnscreenInstance)

Parameters

  • instance?: OnscreenInstance

register_button(node: Opaque<"node">, settings: {} | undefined, fn: (action: Hash, node: Opaque<"node">, touch: {}) => void, instance?: OnscreenInstance)

Parameters

  • node: Opaque<"node">
  • settings: {} | undefined
  • fn: (action: Hash, node: Opaque<"node">, touch: {}) => void
  • instance?: OnscreenInstance

register_analog(node: Opaque<"node">, settings: { radius?: number; threshold?: number; } | undefined, fn: (action: Hash, node: Opaque<"node">, touch: {}) => void, instance?: OnscreenInstance)

Parameters

  • node: Opaque<"node">
  • settings: { radius?: number; threshold?: number; } | undefined
  • fn: (action: Hash, node: Opaque<"node">, touch: {}) => void
  • instance?: OnscreenInstance

on_input(action_id: Hash, action: {}, instance?: OnscreenInstance): boolean

Parameters

  • action_id: Hash
  • action: {}
  • instance?: OnscreenInstance

Returns

  • boolean

Variables

BUTTON: Hash

ANALOG: Hash

BUTTON_PRESSED: Hash

BUTTON_RELEASED: Hash

ANALOG_PRESSED: Hash

ANALOG_RELEASED: Hash

ANALOG_MOVED: Hash

ANALOG_LEFT: Hash

ANALOG_RIGHT: Hash

ANALOG_UP: Hash

ANALOG_DOWN: Hash

Types

OnscreenInstance

OnscreenInstance.reset: () => void

OnscreenInstance.register_button: (node: Opaque<"node">, settings: {} | undefined, fn: (action: Hash, node: Opaque<"node">, touch: {}) => void) => void

OnscreenInstance.register_analog: (node: Opaque<"node">, settings: { radius?: number; threshold?: number; } | undefined, fn: (action: Hash, node: Opaque<"node">, touch: {}) => void) => void

OnscreenInstance.on_input: (action_id: Hash, action: {}) => boolean

On this page