Drag[en]gine Script Module DragonScript  1.21
Dragengine.Commands.DefaultBindingHelper Class Reference

Generate default bindings. More...

Inheritance diagram for Dragengine.Commands.DefaultBindingHelper:

Public Member Functions

Constructors
DefaultBindingHelper new ()
 Create default binding helper using BaseGameApp. More...
 
DefaultBindingHelper new (BindingManager bindingManager, CommandManager commandManager)
 Create default binding helper for binding manager. More...
 
General
BindingManager getBindingManager ()
 Binding manager to update once finished. More...
 
CommandManager getCommandManager ()
 Command manager to use for bindings. More...
 
void reset ()
 Remove all bindings. More...
 
void updateBindingManager (bool clear)
 Update binding manager with found bindings. More...
 
bool mouseBindWheel (int wheel, String command)
 Bind command to mouse wheel. More...
 
bool mouseBindWheel (int wheel, String up, String down)
 Bind commands to mouse wheel. More...
 
bool mouseBindLMR (String left, String middle, String right)
 Bind command to left, right and middle mouse buttons. More...
 
bool mouseBindAux (int number, String command)
 Bind command to auxiliary mouse button. More...
 
Keyboard Input Device
bool hasKeyboard ()
 Keyboard device is present. More...
 
InputDevice getKeyboard ()
 First keyboard device or null. More...
 
void keyboardClear ()
 Remove all keyboard bindings. More...
 
bool keyboardBindKeyCode (int keyCode, String command)
 Bind command to keyboard key matching key code. More...
 
bool keyboardBindKeyCode (int keyCode, InputEventKeyLocation location, String command)
 Bind command to keyboard key matching key code. More...
 
bool keyboardBindCharacter (int character, String command)
 Bind command to keyboard key matching character. More...
 
bool keyboardBindCharacter (int character, InputEventKeyLocation location, String command)
 Bind command to keyboard key matching character. More...
 
Gamepad Binding
bool hasGamepad ()
 Gamepad device is present. More...
 
InputDevice getGamepad ()
 First gamepad device or null. More...
 
void gamepadClear ()
 Remove all gamepad bindings. More...
 
bool gamepadBindStick (int stick, String horizontal, String vertical)
 Bind command to gamepad stick. More...
 
bool gamepadBindStick (int stick, String left, String right, String up, String down)
 Bind command to gamepad stick. More...
 
bool gamepadBindHat (int hat, String horizontal, String vertical)
 Bind command to gamepad hat or directional pad. More...
 
bool gamepadBindHat (int hat, String left, String right, String up, String down)
 Bind command to gamepad hat or directional pad. More...
 
bool gamepadBindTrigger (int trigger, String command)
 Bind command to gamepad trigger. More...
 
bool gamepadBindTrigger (int trigger, String pull, String release)
 Bind command to gamepad trigger. More...
 
bool gamepadBindButton (int button, String command)
 Bind command to gamepad button. More...
 
bool gamepadBindButton (int button, InputDeviceButtonType type, String command)
 Bind command to gamepad button. More...
 
VR Controller Binding
bool hasVRHand (bool rightHand)
 One or more VR hand controller device is present. More...
 
InputDevice getVRHand (bool rightHand)
 First VR hand controller device or null. More...
 
Array getAllVRHands (bool rightHand)
 All VR hand controller devices as Array of InputDevice. More...
 
bool bindButton (InputDevice device, int button, String command)
 Bind command to button on device. More...
 
bool bindButton (InputDevice device, InputDeviceButtonType type, int button, String command)
 Bind command to button on device. More...
 
bool bindTrigger (InputDevice device, InputDeviceAxisType type, int trigger, String name)
 Bind command to trigger. More...
 
bool bindTrigger (InputDevice device, InputDeviceAxisType type, int trigger, String pull, String release)
 Bind command to trigger. More...
 
bool bindStick (InputDevice device, InputDeviceAxisType type, int stick, String horizontal, String vertical, bool inverse)
 Bind command to joystick. More...
 
bool bindStick (InputDevice device, InputDeviceAxisType type, int stick, String left, String right, String up, String down, bool inverse)
 Bind command to joystick. More...
 
void removeAllDeviceBindings (InputDevice device)
 Remove all bindings for device. More...
 

Detailed Description

Generate default bindings.

Helper for games running for the first time requiring a useful initial binding configuration the user can then adjust. The problem with initial binding configuration is that the user does not tap the keys for bindings but the game has to add some reasonable bindings for input devices it has little knowledge about. This class provides a simple way to achieve this goal. It uses the buttonMatchingKeyCode and buttonMatchingKeyChar methods to find suitable bindings.

Upon creating an instance of DefaultBindingHelper the present input devices are examine for typical candidates. The first found mouse, keyboard and gamepad type input device is stored. The user can then query the devices for some parameters for example how many buttons and axes a gamepad has if present. For each device the user can then add a binding using key code and/or key char. The first key matching the parameters is added. If required the user can examine the return value to learn if the binding has been assigned or not. This can be used to try a fallback assignment or trying a different layout altogether.

All changes are recorded in the DefaultBindingHelper instance. Once suitable the user can apply the changes to the binding manager.

Member Function Documentation

◆ bindButton() [1/2]

bool Dragengine.Commands.DefaultBindingHelper.bindButton ( InputDevice  device,
InputDeviceButtonType  type,
int  button,
String  command 
)

Bind command to button on device.

Version
1.7
Parameters
deviceDevice containing axis.
buttonIndex of button to bind.
commandName of command to bind.
Returns
true if button is present on device and bound to command.

◆ bindButton() [2/2]

bool Dragengine.Commands.DefaultBindingHelper.bindButton ( InputDevice  device,
int  button,
String  command 
)

Bind command to button on device.

Parameters
deviceDevice containing axis.
buttonIndex of button to bind.
commandName of command to bind.
Returns
true if button is present on device and bound to command.

◆ bindStick() [1/2]

bool Dragengine.Commands.DefaultBindingHelper.bindStick ( InputDevice  device,
InputDeviceAxisType  type,
int  stick,
String  horizontal,
String  vertical,
bool  inverse 
)

Bind command to joystick.

Version
1.6
Parameters
typeType of stick
stickNumber of stick of given type.
horizontalName of command to bind to horizontal movement or null.
verticalName of command to bind to vertical movement or null.
Returns
true if device is present and all commands have been bound.

◆ bindStick() [2/2]

bool Dragengine.Commands.DefaultBindingHelper.bindStick ( InputDevice  device,
InputDeviceAxisType  type,
int  stick,
String  left,
String  right,
String  up,
String  down,
bool  inverse 
)

Bind command to joystick.

Version
1.6
Parameters
typeType of stick.
stickNumber of stick of given type.
leftName of command to bind to left movement or null.
rightName of command to bind to right movement or null.
upName of command to bind to up movement or null.
downName of command to bind to down movement or null.
Returns
true if device is present and all commands have been bound.

◆ bindTrigger() [1/2]

bool Dragengine.Commands.DefaultBindingHelper.bindTrigger ( InputDevice  device,
InputDeviceAxisType  type,
int  trigger,
String  name 
)

Bind command to trigger.

Version
1.6
Parameters
Devicedevice.
typeType of trigger.
triggerNumber of trigger of given type.
nameName of command to bind to horizontal movement or null.
Returns
true if controller is present and command has been bound.

◆ bindTrigger() [2/2]

bool Dragengine.Commands.DefaultBindingHelper.bindTrigger ( InputDevice  device,
InputDeviceAxisType  type,
int  trigger,
String  pull,
String  release 
)

Bind command to trigger.

Version
1.6
Parameters
Devicedevice.
typeType of trigger.
triggerNumber of trigger of given type.
pullName of command to bind to pull movement or null.
releaseName of command to bind to release movement or null.
Returns
true if device is present and all commands have been bound.

◆ gamepadBindButton() [1/2]

bool Dragengine.Commands.DefaultBindingHelper.gamepadBindButton ( int  button,
InputDeviceButtonType  type,
String  command 
)

Bind command to gamepad button.

Parameters
buttonNumber of button starting with 0 for the first.
typeType of button.
commandName of command to bind to button or null.
Returns
true if gamepad is present and command has been bound.

◆ gamepadBindButton() [2/2]

bool Dragengine.Commands.DefaultBindingHelper.gamepadBindButton ( int  button,
String  command 
)

Bind command to gamepad button.

Parameters
buttonNumber of button starting with 0 for the first.
commandName of command to bind to button or null.
Returns
true if gamepad is present and command has been bound.

◆ gamepadBindHat() [1/2]

bool Dragengine.Commands.DefaultBindingHelper.gamepadBindHat ( int  hat,
String  horizontal,
String  vertical 
)

Bind command to gamepad hat or directional pad.

Parameters
hatNumber of hat starting with 0 for the first.
horizontalName of command to bind to left/right press or null.
verticalName of command to bind to up/down press or null.
Returns
true if gamepad is present and all commands have been bound.

◆ gamepadBindHat() [2/2]

bool Dragengine.Commands.DefaultBindingHelper.gamepadBindHat ( int  hat,
String  left,
String  right,
String  up,
String  down 
)

Bind command to gamepad hat or directional pad.

Parameters
hatNumber of hat starting with 0 for the first.
leftName of command to bind to left press or null.
rightName of command to bind to right press or null.
upName of command to bind to up press or null.
downName of command to bind to down press or null.
Returns
true if gamepad is present and all commands have been bound.

◆ gamepadBindStick() [1/2]

bool Dragengine.Commands.DefaultBindingHelper.gamepadBindStick ( int  stick,
String  horizontal,
String  vertical 
)

Bind command to gamepad stick.

Parameters
stickNumber of stick starting with 0 for the first.
horizontalName of command to bind to horizontal movement or null.
verticalName of command to bind to vertical movement or null.
Returns
true if gamepad is present and all commands have been bound.

◆ gamepadBindStick() [2/2]

bool Dragengine.Commands.DefaultBindingHelper.gamepadBindStick ( int  stick,
String  left,
String  right,
String  up,
String  down 
)

Bind command to gamepad stick.

Parameters
stickNumber of stick starting with 0 for the first.
leftName of command to bind to left movement or null.
rightName of command to bind to right movement or null.
upName of command to bind to up movement or null.
downName of command to bind to down movement or null.
Returns
true if gamepad is present and all commands have been bound.

◆ gamepadBindTrigger() [1/2]

bool Dragengine.Commands.DefaultBindingHelper.gamepadBindTrigger ( int  trigger,
String  command 
)

Bind command to gamepad trigger.

Version
1.20
Parameters
triggerNumber of trigger starting with 0 for the first.
commandName of command to bind to horizontal movement or null.
Returns
true if gamepad is present and all commands have been bound.

◆ gamepadBindTrigger() [2/2]

bool Dragengine.Commands.DefaultBindingHelper.gamepadBindTrigger ( int  trigger,
String  pull,
String  release 
)

Bind command to gamepad trigger.

Version
1.20
Parameters
triggerNumber of trigger starting with 0 for the first.
pullName of command to bind to pull or null.
releaseName of command to bind to release or null.
Returns
true if gamepad is present and all commands have been bound.

◆ gamepadClear()

void Dragengine.Commands.DefaultBindingHelper.gamepadClear ( )

Remove all gamepad bindings.

◆ getAllVRHands()

Array Dragengine.Commands.DefaultBindingHelper.getAllVRHands ( bool  rightHand)

All VR hand controller devices as Array of InputDevice.

Version
1.10
Parameters
rightHandTrue for right hand controller otherwise left hand controller.

◆ getBindingManager()

BindingManager Dragengine.Commands.DefaultBindingHelper.getBindingManager ( )

Binding manager to update once finished.

◆ getCommandManager()

CommandManager Dragengine.Commands.DefaultBindingHelper.getCommandManager ( )

Command manager to use for bindings.

◆ getGamepad()

InputDevice Dragengine.Commands.DefaultBindingHelper.getGamepad ( )

First gamepad device or null.

◆ getKeyboard()

InputDevice Dragengine.Commands.DefaultBindingHelper.getKeyboard ( )

First keyboard device or null.

◆ getVRHand()

InputDevice Dragengine.Commands.DefaultBindingHelper.getVRHand ( bool  rightHand)

First VR hand controller device or null.

Version
1.6
Parameters
rightHandTrue for right hand controller otherwise left hand controller.

◆ hasGamepad()

bool Dragengine.Commands.DefaultBindingHelper.hasGamepad ( )

Gamepad device is present.

◆ hasKeyboard()

bool Dragengine.Commands.DefaultBindingHelper.hasKeyboard ( )

Keyboard device is present.

◆ hasVRHand()

bool Dragengine.Commands.DefaultBindingHelper.hasVRHand ( bool  rightHand)

One or more VR hand controller device is present.

Version
1.6
Parameters
rightHandTrue to check right hand controller otherwise left hand controller.

◆ keyboardBindCharacter() [1/2]

bool Dragengine.Commands.DefaultBindingHelper.keyboardBindCharacter ( int  character,
InputEventKeyLocation  location,
String  command 
)

Bind command to keyboard key matching character.

Version
1.7

Tries to find key matching character. If found binding is added. Supports distinguishing between duplicate keys in different locations like left and right shift key.

Parameters
characterCharacter to find.
locationKey location.
commandName of command to bind.
Returns
true if matching key is present and bound to command.

◆ keyboardBindCharacter() [2/2]

bool Dragengine.Commands.DefaultBindingHelper.keyboardBindCharacter ( int  character,
String  command 
)

Bind command to keyboard key matching character.

Tries to find key matching character. If found binding is added.

Parameters
characterCharacter to find.
commandName of command to bind.
Returns
true if matching key is present and bound to command.

◆ keyboardBindKeyCode() [1/2]

bool Dragengine.Commands.DefaultBindingHelper.keyboardBindKeyCode ( int  keyCode,
InputEventKeyLocation  location,
String  command 
)

Bind command to keyboard key matching key code.

Version
1.7

Tries to find key matching key code. If found binding is added. Supports distinguishing between duplicate keys in different locations like left and right shift key.

Parameters
keyCodeKey code to find.
locationKey location.
commandName of command to bind.
Returns
true if matching button is present and bound to command.

◆ keyboardBindKeyCode() [2/2]

bool Dragengine.Commands.DefaultBindingHelper.keyboardBindKeyCode ( int  keyCode,
String  command 
)

Bind command to keyboard key matching key code.

Tries to find key matching key code. If found binding is added.

Parameters
keyCodeKey code to find.
commandName of command to bind.
Returns
true if matching button is present and bound to command.

◆ keyboardClear()

void Dragengine.Commands.DefaultBindingHelper.keyboardClear ( )

Remove all keyboard bindings.

◆ mouseBindAux()

bool Dragengine.Commands.DefaultBindingHelper.mouseBindAux ( int  number,
String  command 
)

Bind command to auxiliary mouse button.

These are buttons 4 upwards if present. Typically 4 is "browse forward" and 5 is "browse backward" but gaming mice can have any number of additional buttons with different usage. Auxiliary buttons are usually not present and tend to be unsuitable for an initial binding configuration.

Parameters
numberNumber of auxiliary button starting with 0 for the first.
commandName of command to bind to mouse button or null.
Returns
true if mouse is present and command has been bound.

◆ mouseBindLMR()

bool Dragengine.Commands.DefaultBindingHelper.mouseBindLMR ( String  left,
String  middle,
String  right 
)

Bind command to left, right and middle mouse buttons.

Parameters
leftName of command to bind to left mouse button or null.
middleName of command to bind to middle mouse button or null.
rightName of command to bind to right mouse button or null.
Returns
true if mouse is present and all commands have been bound.

◆ mouseBindWheel() [1/2]

bool Dragengine.Commands.DefaultBindingHelper.mouseBindWheel ( int  wheel,
String  command 
)

Bind command to mouse wheel.

Parameters
wheelNumber of wheel starting with 0 for the first wheel.
commandName of command to bind to mouse wheel or null.
Returns
true if mouse is present and command has been bound.

◆ mouseBindWheel() [2/2]

bool Dragengine.Commands.DefaultBindingHelper.mouseBindWheel ( int  wheel,
String  up,
String  down 
)

Bind commands to mouse wheel.

Parameters
wheelNumber of wheel starting with 0 for the first wheel.
upName of command to bind to up mouse wheel movement or null.
downName of command to bind to down mouse wheel movement or null.
Returns
true if mouse is present and all commands have been bound.

◆ new() [1/2]

DefaultBindingHelper Dragengine.Commands.DefaultBindingHelper.new ( )

Create default binding helper using BaseGameApp.

Stores the first mouse, keyboard and gamepad device found for quick access.

Parameters
bindingManagerBinding manager to update once finished.
commandManagerCommand manager to use for bindings.

◆ new() [2/2]

DefaultBindingHelper Dragengine.Commands.DefaultBindingHelper.new ( BindingManager  bindingManager,
CommandManager  commandManager 
)

Create default binding helper for binding manager.

Stores the first mouse, keyboard and gamepad device found for quick access.

Parameters
bindingManagerBinding manager to update once finished.
commandManagerCommand manager to use for bindings.

◆ removeAllDeviceBindings()

void Dragengine.Commands.DefaultBindingHelper.removeAllDeviceBindings ( InputDevice  device)

Remove all bindings for device.

◆ reset()

void Dragengine.Commands.DefaultBindingHelper.reset ( )

Remove all bindings.

◆ updateBindingManager()

void Dragengine.Commands.DefaultBindingHelper.updateBindingManager ( bool  clear)

Update binding manager with found bindings.

Parameters
clearRemoves first all bindings from binding manager. Set to false to add and overwrite found bindings leaving other bindings intact.

The documentation for this class was generated from the following file: