Drag[en]gine Script Module DragonScript  1.23
Dragengine.Gui.GamepadController Class Reference

Gamepad controller generating mouse and keyboard input. More...

Inheritance diagram for Dragengine.Gui.GamepadController:
Dragengine.Utils.FrameUpdateListener

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...
 

Detailed Description

Gamepad controller generating mouse and keyboard input.

Version
1.20

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.

InputDeviceAxisType.stick

Generates mouse movement events. All sticks can be used to control the mouse pointer directly.

InputDeviceAxisType.trigger

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 .

InputDeviceAxisType.hat

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.

Input Capturing

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.

Usage

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.

Member Function Documentation

◆ clear()

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.

◆ combinedMouseMove()

Vector2 Dragengine.Gui.GamepadController.combinedMouseMove ( )

All mouse movement combined.

◆ dispose()

void Dragengine.Gui.GamepadController.dispose ( )

Dispose of gamepad controller.

◆ frameUpdate()

void Dragengine.Gui.GamepadController.frameUpdate ( float  elapsed)

Frame update.

Reimplemented from Dragengine.Utils.FrameUpdateListener.

◆ getEnabled()

bool Dragengine.Gui.GamepadController.getEnabled ( )

Sending events is enabled.

◆ getMouseMovementAcceleration()

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.

◆ getMouseSpeed()

float Dragengine.Gui.GamepadController.getMouseSpeed ( )

Mouse speed in pixels per second.

◆ getWidget()

Widget Dragengine.Gui.GamepadController.getWidget ( )

Widget to send event to.

◆ invalidateDevices()

void Dragengine.Gui.GamepadController.invalidateDevices ( )

Invalidate devices.

◆ mapMouseMovement()

float Dragengine.Gui.GamepadController.mapMouseMovement ( float  factor)
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.

◆ new() [1/2]

GamepadController Dragengine.Gui.GamepadController.new ( GlobalEvents  globalEvents,
Widget  widget 
)

Create controller sending events to widget.

◆ new() [2/2]

GamepadController Dragengine.Gui.GamepadController.new ( Widget  widget)

Create controller sending events to widget.

◆ prepareDevices()

void Dragengine.Gui.GamepadController.prepareDevices ( )
protected

Prepare devices.

◆ processEvent()

void Dragengine.Gui.GamepadController.processEvent ( Event  event)

Process event.

◆ processEventAxisMove()

void Dragengine.Gui.GamepadController.processEventAxisMove ( GamepadEvent  event)
protected

Process axis move event.

◆ processEventButtonRelease()

void Dragengine.Gui.GamepadController.processEventButtonRelease ( GamepadEvent  event)
protected

Process button release event.

◆ processFocus()

void Dragengine.Gui.GamepadController.processFocus ( float  elapsed)
protected

Generate focus events.

◆ processMouseMovement()

void Dragengine.Gui.GamepadController.processMouseMovement ( float  elapsed)
protected

Generate mouse movement events.

◆ releaseMouseButton()

void Dragengine.Gui.GamepadController.releaseMouseButton ( )

Release mouse button.

◆ sendMouseButtonRelease()

void Dragengine.Gui.GamepadController.sendMouseButtonRelease ( )

Send event mouse button release if enabled.

◆ sendMouseMoved()

void Dragengine.Gui.GamepadController.sendMouseMoved ( Point  distance)

Send event mouse moved if enabled.

◆ setEnabled()

void Dragengine.Gui.GamepadController.setEnabled ( bool  enable)

Enable sending events.

◆ setMouseMovementAcceleration()

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.

◆ setMouseSpeed()

void Dragengine.Gui.GamepadController.setMouseSpeed ( float  speed)

Set mouse speed in pixels per second.

◆ setWidget()

void Dragengine.Gui.GamepadController.setWidget ( Widget  widget)

Set widget to send event to.

◆ trackDeviceAxes()

void Dragengine.Gui.GamepadController.trackDeviceAxes ( InputEventSource  system,
int  deviceIndex,
InputDevice  device 
)
protected

Track device axes.

◆ updateInputDevices()

void Dragengine.Gui.GamepadController.updateInputDevices ( )
protected

Update input devices.

Member Data Documentation

◆ pAxisStates

Array Dragengine.Gui.GamepadController.pAxisStates

◆ pButtonPressCount

int Dragengine.Gui.GamepadController.pButtonPressCount

◆ pDirtyDevices

bool Dragengine.Gui.GamepadController.pDirtyDevices

◆ pEnabled

bool Dragengine.Gui.GamepadController.pEnabled

◆ pGlobalEvents

GlobalEvents Dragengine.Gui.GamepadController.pGlobalEvents

◆ pInvalidateDevices

InvalidateDevices Dragengine.Gui.GamepadController.pInvalidateDevices

◆ pMouseMoveAccum

Vector2 Dragengine.Gui.GamepadController.pMouseMoveAccum

◆ pMouseMovementAcceleration

float Dragengine.Gui.GamepadController.pMouseMovementAcceleration

◆ pMouseSpeed

float Dragengine.Gui.GamepadController.pMouseSpeed

◆ pWidget

Widget Dragengine.Gui.GamepadController.pWidget

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