Skip to content

API InputController

Derek edited this page May 30, 2016 · 3 revisions

InputController

constructor(canvas, camera)

Initializes the InputController with the canvas and camera objects

  • Arguments:

  • {Canvas} canvas

  • {Camera} camera

  • Usage:

    Ludic.input = new InputController(canvas, camera)
addEventListener(listener)

Adds an event listener to the controller

  • Arguments:
  • {InputEventListener} listener - listener to be added
removeEventListener(listener)

Removes the listener from the controller

  • Arguments:
  • {InputEventListener} listener - listener to be removed
newEventListener(keyConfig[[, binder], alsoAdd])

Creates a new event listener. Can also add the listener to the controller

  • Arguments:

  • {Object} keyConfig - Options object for mapping keys to methods/actions

  • {Object} [binder] - [optional] object used for binding the call of listener methods

  • {boolean} [alsoAdd] - [optional] tells the controller to also add the returns listener to the controller

  • Returns:

  • {InputEventListener} - A new InputEventListener for which to mount callbacks

  • Usage:

  • See API Guide

step()

Steps the polling process when processing Gamepad usage. Not required for keyboard/mouse input handling. Add this function to the main loop to handle Gamepad event processing.

getDeadZone(gamepadIndex)

Gets the dead zone number for a specific gamepad. If no specific dead zone was set for the gamepad, the global dead zone is returned.

  • Arguments:

  • {Number} gamepadIndex - index of the gamepad to retrieve dead zone from

  • Returns:

  • {Number} dead zone - either the dead zone set for the specific gamepad, or the global dead zone setting

setDeadZone(deadZone[, gamepadIndex])

Sets the dead zone for a specific gamepad. If no gamepadIndex is supplied, the deadZone is set as the global setting.

  • Arguments:
  • {Number} deadZone - a value between 0-1 to be used as the dead zone on the analog sticks for the gamepads
  • {Number} [gamepadIndex] - [optional] index for a specific gamepad to set dead zone for