Drag[en]gine Script Module DragonScript
1.23
|
Gamepad controller generating mouse and keyboard input. More...
Classes | |
class | AxisState |
Axis state. More... | |
Public Member Functions | |
void | clear () |
Clear mouse movement and accumulated states. More... | |
Vector2 | combinedMouseMove () |
All mouse movement combined. More... | |
void | dispose () |
Dispose of gamepad controller. More... | |
void | frameUpdate (float elapsed) |
Frame update. More... | |
bool | getEnabled () |
Sending events is enabled. More... | |
float | getMouseMovementAcceleration () |
Mouse movement acceleration. More... | |
float | getMouseSpeed () |
Mouse speed in pixels per second. More... | |
Widget | getWidget () |
Widget to send event to. More... | |
void | invalidateDevices () |
Invalidate devices. More... | |
GamepadController | new (GlobalEvents globalEvents, Widget widget) |
Create controller sending events to widget. More... | |
GamepadController | new (Widget widget) |
Create controller sending events to widget. More... | |
void | processEvent (Event event) |
Process event. More... | |
void | releaseMouseButton () |
Release mouse button. More... | |
void | sendMouseButtonRelease () |
Send event mouse button release if enabled. More... | |
void | sendMouseMoved (Point distance) |
Send event mouse moved if enabled. More... | |
void | setEnabled (bool enable) |
Enable sending events. More... | |
void | setMouseMovementAcceleration (float acceleration) |
Mouse movement acceleration. More... | |
void | setMouseSpeed (float speed) |
Set mouse speed in pixels per second. More... | |
void | setWidget (Widget widget) |
Set widget to send event to. More... | |
Public Member Functions inherited from Dragengine.Utils.FrameUpdateListener | |
FrameUpdateManager | getFrameUpdateManager () |
Frame update manager the listener is registered at. More... | |
void | giveUp () |
Remove listener from manager if registered at one. More... | |
FrameUpdateListener | new () |
Create listener registered at default frame update listener. More... | |
FrameUpdateListener | new (FrameUpdateManager manager) |
Create listener registered at frame update manager. More... | |
Public Attributes | |
Array | pAxisStates |
int | pButtonPressCount |
bool | pDirtyDevices |
bool | pEnabled |
GlobalEvents | pGlobalEvents |
InvalidateDevices | pInvalidateDevices |
Vector2 | pMouseMoveAccum |
float | pMouseMovementAcceleration |
float | pMouseSpeed |
Widget | pWidget |
Protected Member Functions | |
float | mapMouseMovement (float factor) |
Mouse movement mapping. More... | |
void | prepareDevices () |
Prepare devices. More... | |
void | processEventAxisMove (GamepadEvent event) |
Process axis move event. More... | |
void | processEventButtonRelease (GamepadEvent event) |
Process button release event. More... | |
void | processFocus (float elapsed) |
Generate focus events. More... | |
void | processMouseMovement (float elapsed) |
Generate mouse movement events. More... | |
void | trackDeviceAxes (InputEventSource system, int deviceIndex, InputDevice device) |
Track device axes. More... | |
void | updateInputDevices () |
Update input devices. More... | |
Gamepad controller generating mouse and keyboard input.
For use by Desktop and other top level widgets. Allows the user to control the widget using gamepads. The following input events can be generated.
Generates mouse movement events. All sticks can be used to control the mouse pointer directly.
Generates mouse button press and release events. All triggers control the left mouse button.
A mouse button press event is send when the trigger value changes from less than 0.5 to larger than 0.5. A mouse button release event is send when the trigger value changes from larger than 0.5 to less than 0.5 .
Sets focus to the closest widget in the pressed direction. Then the trigger value changes from less than 0.5 to larger than 0.5 the closest widget is searched for and the focused shifted.
The GamepadController only works if InputSystem.getCaptureInputDevices() is true. If it is false the system mouse position is used which can not be controlled by the gamepad. If this value is false GamepadController behaves as if it is disabled.
To use the gamepad controller create an instance and store it in the Widget. Forward all events received in Widget.processEvent() to GamepadController.processEvent() in addition to processing them by the widget. The gamepad controller monitors itself changes in input devices and sends generated events as needed. Sending events can be temporarily disabled. Once the gamepad controller is not required anymore call dispose(). After creating the gamepad controller it is initially enabled.
void Dragengine.Gui.GamepadController.clear | ( | ) |
Clear mouse movement and accumulated states.
Call this after switching input processor away from the widget. This will clear all accumulated mouse movement to stop moving the mouse until the input processing switches back to the widget.
Vector2 Dragengine.Gui.GamepadController.combinedMouseMove | ( | ) |
All mouse movement combined.
void Dragengine.Gui.GamepadController.dispose | ( | ) |
Dispose of gamepad controller.
void Dragengine.Gui.GamepadController.frameUpdate | ( | float | elapsed | ) |
Frame update.
Reimplemented from Dragengine.Utils.FrameUpdateListener.
bool Dragengine.Gui.GamepadController.getEnabled | ( | ) |
Sending events is enabled.
float Dragengine.Gui.GamepadController.getMouseMovementAcceleration | ( | ) |
Mouse movement acceleration.
Applies a remapping of the mouse movement. With a value of 1 the mouse movement is not modified. With a value larger than 1 small mouse movement is slowed down while larger mouse movement is accelerated. This makes it easier to do precise mouse movement near the desired target while moving large distances is faster. The default value is 1.5 . Typical values are 1, 1.5 or 2. Values less than 1 are usually not that useful but can be experimented with if desired.
float Dragengine.Gui.GamepadController.getMouseSpeed | ( | ) |
Mouse speed in pixels per second.
void Dragengine.Gui.GamepadController.invalidateDevices | ( | ) |
Invalidate devices.
|
protected |
Mouse movement mapping.
Input is value in the range from 0 to 1. Output is mapped value in the range from 0 to 1. Mapping is used to make mouse movement for small stick value smaller for precise control and larger for large stick values. The default implementation applies the mouse acceleration as power to the input value.
GamepadController Dragengine.Gui.GamepadController.new | ( | GlobalEvents | globalEvents, |
Widget | widget | ||
) |
Create controller sending events to widget.
GamepadController Dragengine.Gui.GamepadController.new | ( | Widget | widget | ) |
Create controller sending events to widget.
|
protected |
Prepare devices.
void Dragengine.Gui.GamepadController.processEvent | ( | Event | event | ) |
Process event.
|
protected |
Process axis move event.
|
protected |
Process button release event.
|
protected |
Generate focus events.
|
protected |
Generate mouse movement events.
void Dragengine.Gui.GamepadController.releaseMouseButton | ( | ) |
Release mouse button.
void Dragengine.Gui.GamepadController.sendMouseButtonRelease | ( | ) |
Send event mouse button release if enabled.
void Dragengine.Gui.GamepadController.sendMouseMoved | ( | Point | distance | ) |
Send event mouse moved if enabled.
void Dragengine.Gui.GamepadController.setEnabled | ( | bool | enable | ) |
Enable sending events.
void Dragengine.Gui.GamepadController.setMouseMovementAcceleration | ( | float | acceleration | ) |
Mouse movement acceleration.
Applies a remapping of the mouse movement. With a value of 1 the mouse movement is not modified. With a value larger than 1 small mouse movement is slowed down while larger mouse movement is accelerated. This makes it easier to do precise mouse movement near the desired target while moving large distances is faster. The default value is 1.5 . Typical values are 1, 1.5 or 2. Values less than 1 are usually not that useful but can be experimented with if desired.
void Dragengine.Gui.GamepadController.setMouseSpeed | ( | float | speed | ) |
Set mouse speed in pixels per second.
void Dragengine.Gui.GamepadController.setWidget | ( | Widget | widget | ) |
Set widget to send event to.
|
protected |
Track device axes.
|
protected |
Update input devices.
Array Dragengine.Gui.GamepadController.pAxisStates |
int Dragengine.Gui.GamepadController.pButtonPressCount |
bool Dragengine.Gui.GamepadController.pDirtyDevices |
bool Dragengine.Gui.GamepadController.pEnabled |
GlobalEvents Dragengine.Gui.GamepadController.pGlobalEvents |
InvalidateDevices Dragengine.Gui.GamepadController.pInvalidateDevices |
Vector2 Dragengine.Gui.GamepadController.pMouseMoveAccum |
float Dragengine.Gui.GamepadController.pMouseMovementAcceleration |
float Dragengine.Gui.GamepadController.pMouseSpeed |
Widget Dragengine.Gui.GamepadController.pWidget |