-
Notifications
You must be signed in to change notification settings - Fork 1
Input Handling
The Input Handling module is concerned with combining and consolidating inputs. It provides an interface for generic input types, a generic input device, as well as wrappers for gamepad, mouse and keyboard inputs.
Dependencies: Core, Logging(Logger)
InputDevice is a generic consolidator of GenericInputs. You define the "shape" of your input device, and then bind GenericInputs to it. Because of how this feature works, the names is, inputs, input, and add_input are reserved and can not be input names.
- inputs - the names of the inputs you would like to be able to bind to this device
var _input = new InputDevice( "jump", "shoot" );
_input.jump.bind( new KeyboardKey( vk_space ) );
_input.shoot.bind( new MouseButton( mb_left ) );
input( a ) - constructor: returns a new input named a, has the following methods: bind, pressed, held, released, raw add_input( a ) - adds a new input source, a, to this device
inputs - the array of inputs that have been added to this device
A wrapper for gamepads that includes connection and disconnection handling, as well as common button features. Gamepads are connected to virtual "ports" to track who they belong to.
var _gamepad = new Gamepad();
_gamepad.dpad_left = new _gamepad.input( gp_padl, _gamepad )
_gamepad.lstick = new _gamepad.inputAxis( gp_axislh, gp_axislv, _gamepad );
if ( _gamepad.dpad_left.held() || _gamepad.lstick.left() ) {
show_debug_message( "Left pressed!" );
}
Controller connects and disconnect listening is handled by __FASTtool
input( constant, gamepad ) - constructor: for buttons and triggers, provides the following methods: pressed, held, released, magnitude inputAxis( axish, axisv, gamepad ) - constructor: for joysticks, provides the following methods: degree, magnitude, horizontal, vertical, left, right, up, down, set_threshold set_deadzone( a ) - sets the dead zone for this gamepad to a
padIndex - the gamepad id this Gamepad is using port - the virtual port this gamepad is connected to
Provides a preconfigured Gamepad for an Xbox controller.
var _gamepad = new GamepadXbox();
if ( _gamepad.x.pressed() ) {
show_debug_message( "X pressed!" );
}
Implements Input Handling: Gamepad.
- left - left on the directional pad
- right - right on the directional pad
- up - up on the direction pad
- down - down on the directional pad
- x - the x button
- y - the y button
- a - the a button
- b - the b button
- lclick - clicking down on the left stick
- rclick - clicking down on the right stick
- lb - the left bumper
- rb - the right bumper
- lt - the left trigger
- rt - the right trigger
- back - the back button
- menu - the menu button
- lstick - axis: the left stick
- rstick - axis: the right stick
Provides a preconfigured Gamepad for an Playstation controller.
var _gamepad = new GamepadTriangle();
if ( _gamepad.triangle.pressed() ) {
show_debug_message( "Triangle pressed!" );
}
Implements Input Handling: Gamepad.
- left - left on the directional pad
- right - right on the directional pad
- up - up on the direction pad
- down - down on the directional pad
- x - the x button
- triangle - the triangle button
- circle - the circle button
- square - the square button
- lclick - clicking down on the left stick
- rclick - clicking down on the right stick
- l1 - the left bumper
- r1 - the right bumper
- l2 - the left trigger
- r2 - the right trigger
- share - the share button
- option - the option button
- lstick - axis: the left stick
- rstick - axis: the right stick
- KeyboardKey( constant ) - a generic input wrapper for keyboard inputs
- MouseButton( constant ) - a generic input wrapper for mouse inputs
- ComboInput( inputs... ) - a generic input wrapper for combination inputs
Devon Mullane 2020