Skip to main content

Inputs

Players can control the game using various input methods.

Button presses

The ButtonDown and ButtonUp functions signal when a particular button is pressed by a particular player. Buttons can be keyboard keys, mouse buttons, gamepad buttons or touchscreen taps. See Keycodes for a full list of all possible buttons that can be pressed.

Remapping

The KeyRebindingBlock user interface element allows a player to remap keys. When they select the elemet, the player can choose a new key they would like to press instead of the original key.

ButtonRemap is a way to introduce a remapping programmatically. It can be used to provide additional ways to trigger a particular key. For example, a game might normally require a player to press Spacebar to jump, but ButtonRemap(Click, KeySpacebar) would allow the player to jump by clicking the mouse as well.

Key remappings are handled transparently by the engine. The actual key that was pressed will be translated to the remapped key and only the remapped key will be signalled. The Easel program never receives the actual key pressed and does not need to be aware of the remapping.

Pointers

Normally a pointer refers to a mouse.

The Pointer prop contains the last position of a player's mouse pointer. The IsPointerActive property will be true if the mouse is within the boundaries of the game window, and false otherwise.

The TouchscreenVirtualPointer function can make the game simulate a virtual mouse pointer from the player's touch. Any swipes across the screen will be translated to relative movements of the virtual mouse pointer. When the player is using a touchscreen as the pointer, IsPointerActive will only be true if the player is currently touching the screen.

Touchscreens

The TouchscreenMode function can be used to determine whether a player is using a touchscreen device. Sometimes the value will be undefined initially as it requires waiting the user to use their mouse or touch the screen before it can be determined. You can await TouchscreenMode to watch for any changes to this property.

Gamepads

The IsGamepadConnected function can be used to determine whether a gamepad is connected. Gamepad may not be supported on all devices and all platforms. Currently Google Chrome has the best support for gamepads. Gamepads may also have differing layouts and capabilities.

Gamepads can have up to two joysticks, these can be read using the Joystick and Joystick2 functions. The VirtualJoystick and VirtualJoystick2 functions allow you to create a simulated on-screen joystick for mouse or touchscreen users. The KeyboardVirtualJoystick function allows you to map keyboard keys to a virtual joystick. This can be used to support common control schemes like WASD or Arrow keys in a unified manner.

Simulating input

A common method for implementing bot players is to simulate input. This can be done by simply calling the same functions that are used to signal input from a real player. Pointers can be simulated by assigning to the Pointer or IsPointerActive props. Button presses can be simulated by calling ButtonDown or ButtonUp. Joystick movements can be simulated by setting the Joystick or Joystick2 props.