Joystick

By using InputManager::GetJoystick you can access extra information about a specific gamepad or joystick.

Member Functions

GetName

string GetName()

Returns

The device name of the joystick.

GetButtonCount

number GetButtonCount()

Returns

How many buttons this joystick/gamepad has.

GetID

number GetID()

Returns

The ID of this joystick.  Starts a 0.

GetLeftStickPosition

Vector2 GetLeftStickPosition()

Although you can use <InputManager:AddBinding> to map to easily map to a joysticks directions, it’s useless if you want true 360 degree analog data.

This lets you poll a sticks position at any time yourself.

Returns

A Vector2 object containing this sticks’ current position as a unit vector.  (Ie, -1, 0 would mean moving left 100%, 0,0 would mean not pushing in any direction)

GetRightStickPosition

Vector2 GetRightStickPosition()

Although you can use <InputManager:AddBinding> to map to easily map to a joysticks directions, it’s useless if you want true 360 degree analog data.

This lets you poll a sticks position at any time yourself.

Note

Not all game controllers have a right stick, and even if they do, they tend to use different axis for them.  See SetRightStickAxis.

Returns

A Vector2 object containing this sticks’ current position as a unit vector.  (Ie, -1, 0 would mean moving left 100%, 0,0 would mean not pushing in any direction)

SetRightStickAxis

nil SetRightStickAxis(number axisX, number axisY)

This lets you setup which axis are used for a specific stick on this controller.  We don’t have a SetLeftStickAxis because that is always 0 (x) and 1 (y).

The engine will attempt to use detect the controller by name and setup this itself, check base/script/dialog.gui to see where I detect XBOX controllers and setup for them.

If you have an additional setting I should add, please email it to me.  (Seth)

I plan on adding a nice Joystick setup utility in a base script for controllers that need to be remapped that any app can use/customize.

Note

Not all game controllers have a right stick, and even if they do, they tend to use different axis for them.  See SetRightStickAxis.

Returns

A Vector2 object containing this sticks’ current position as a unit vector.  (Ie, -1, 0 would mean moving left 100%, 0,0 would mean not pushing in any direction)

The Vector2 object.