S2ENGINE HD  1.4.6
Official manual about S2Engine HD editor and programming
Input

S2Engine HD input subsystem implements support for 3 devices:

  • Mouse
  • Keyboard
  • Gamepad
Note
The only tested Gamepad is the Xbox Pad.

S2Engine HD lets you to configure an input map (see Input Mapping) for associating input values coming from one or more devices to user defined identification names.
However in the standard scripting library there are some basic functions to simply retrieving raw input values:

Upon these functions there is a more high-level system for retrieving input: Input Mapping. This system is based on two main notions:

  • Input Axis float assuming values in [-1,1] interval (that can be scaled, see Input Mapping) depending on the position of input sticks (gamepads) or cursor (mouse) or simply a key value (1.0 if pressed). In other words it represents the position on an axis.
  • Input Action boolean assuming 0 or 1 values depending on if an input button or key is pressed. In other word it represent an action in response to an event.

In order to retrieving these values you must first configure the input map, see Input Mapping. Suppose you have configured input map, there is a set of functions for retrieving the values associated to user defined Id names of the input map.

See also
Action Classes to know how to manage input map using GameMachine

Input Axis

The following is the set of functions of standard library designed to managing values of input axes:

  • GetInputAxis
  • GetNumInputAxisCodes
  • GetInputAxisCode
  • SetInputAxisCode

Suppose you have configured an input map axis as following:

Name Input Scale
MoveForward
  • w
  • s
  • @padLY
  • 1.0
  • -1.0
  • 1.2

If you want to know "how much" player is moving forward you can write:

var float moveFwd;
moveFwd = GetInputAxis("shoot");

In this case variable moveFwd will assume [0.0,1.0] values if pressing w key, [-1.0,0.0] if pressing s key or [-1.2,1.2] if moving gamepad Left stick on vertical axis.

Input Action

The following is the set of functions of standard library designed to managing values of input actions:

  • GetInputAction
  • GetNumInputActionCodes
  • GetInputActionCode
  • SetInputActionCode

Suppose you have configured an input map action as following:

Name Input
Shoot
  • @mouseButton0
  • e
  • @padRThumb

If you want to know if player shoots you can write

var bool isShooting;
isShooting = GetInputAction("shoot");

In this case variable isShooting will assume "true" value if mouse button 0 or e key or Pad R Thumb are pressed, otherwise it assumes "false" value