Package openmw.inputΒΆ

openmw.input can be used only in scripts attached to a player.

Usage:

local input = require('openmw.input')

Type input

input.ACTION

Values that can be used with isActionPressed.

input.CONTROLLER_AXIS

Values that can be used with getAxisValue.

input.CONTROLLER_BUTTON

Values that can be passed to onControllerButtonPress/onControllerButtonRelease engine handlers.

input.CONTROL_SWITCH

Values that can be used with getControlSwitch/setControlSwitch.

input.getAxisValue(axisId)

Get value of an axis of a game controller.

input.getControlSwitch(key)

Get state of a control switch.

input.getMouseMoveX()

Horizontal mouse movement during the last frame.

input.getMouseMoveY()

Vertical mouse movement during the last frame.

input.isActionPressed(actionId)

Is a specific control currently pressed.

input.isIdle()

Is player idle.

input.isMouseButtonPressed(buttonId)

Is a mouse button currently pressed.

input.setControlSwitch(key, value)

Set state of a control switch.

Type ACTION

ACTION.Activate
ACTION.AlwaysRun
ACTION.AutoMove
ACTION.Console
ACTION.CycleSpellLeft
ACTION.CycleSpellRight
ACTION.CycleWeaponLeft
ACTION.CycleWeaponRight
ACTION.GameMenu
ACTION.Inventory
ACTION.Journal
ACTION.Jump
ACTION.MoveBackward
ACTION.MoveForward
ACTION.MoveLeft
ACTION.MoveRight
ACTION.QuickKey1
ACTION.QuickKey10
ACTION.QuickKey2
ACTION.QuickKey3
ACTION.QuickKey4
ACTION.QuickKey5
ACTION.QuickKey6
ACTION.QuickKey7
ACTION.QuickKey8
ACTION.QuickKey9
ACTION.QuickKeysMenu
ACTION.QuickLoad
ACTION.QuickMenu
ACTION.QuickSave
ACTION.Run
ACTION.Screenshot
ACTION.Sneak
ACTION.Spell
ACTION.ToggleDebug
ACTION.ToggleHUD
ACTION.TogglePOV
ACTION.ToggleSneak
ACTION.ToggleSpell
ACTION.ToggleWeapon
ACTION.Use
ACTION.Weapon
ACTION.ZoomIn
ACTION.ZoomOut

Type CONTROLLER_AXIS

CONTROLLER_AXIS.LeftX

Left stick horizontal axis (from -1 to 1)

CONTROLLER_AXIS.LeftY

Left stick vertical axis (from -1 to 1)

CONTROLLER_AXIS.LookLeftRight

View direction horizontal axis (RightX by default, can be mapped to another axis in Options/Controls menu)

CONTROLLER_AXIS.LookUpDown

View direction vertical axis (RightY by default, can be mapped to another axis in Options/Controls menu)

CONTROLLER_AXIS.MoveForwardBackward

Movement forward/backward (LeftY by default, can be mapped to another axis in Options/Controls menu)

CONTROLLER_AXIS.MoveLeftRight

Side movement (LeftX by default, can be mapped to another axis in Options/Controls menu)

CONTROLLER_AXIS.RightX

Right stick horizontal axis (from -1 to 1)

CONTROLLER_AXIS.RightY

Right stick vertical axis (from -1 to 1)

CONTROLLER_AXIS.TriggerLeft

Left trigger (from 0 to 1)

CONTROLLER_AXIS.TriggerRight

Right trigger (from 0 to 1)

Type CONTROLLER_BUTTON

CONTROLLER_BUTTON.A
CONTROLLER_BUTTON.B
CONTROLLER_BUTTON.Back
CONTROLLER_BUTTON.DPadDown
CONTROLLER_BUTTON.DPadLeft
CONTROLLER_BUTTON.DPadRight
CONTROLLER_BUTTON.DPadUp
CONTROLLER_BUTTON.Guide
CONTROLLER_BUTTON.LeftShoulder
CONTROLLER_BUTTON.LeftStick
CONTROLLER_BUTTON.RightShoulder
CONTROLLER_BUTTON.RightStick
CONTROLLER_BUTTON.Start
CONTROLLER_BUTTON.X
CONTROLLER_BUTTON.Y

Type CONTROL_SWITCH

CONTROL_SWITCH.Controls

Ability to move

CONTROL_SWITCH.Fighting

Ability to attack

CONTROL_SWITCH.Jumping

Ability to jump

CONTROL_SWITCH.Looking

Ability to change view direction

CONTROL_SWITCH.Magic

Ability to use magic

CONTROL_SWITCH.VanityMode

Vanity view if player doesn't touch controls for a long time

CONTROL_SWITCH.ViewMode

Ability to toggle 1st/3rd person view

Type KeyboardEvent

KeyboardEvent.code

Key code.

KeyboardEvent.symbol

The pressed symbol (1-symbol string).

KeyboardEvent.withAlt

Is Alt key pressed.

KeyboardEvent.withCtrl

Is Control key pressed.

KeyboardEvent.withShift

Is Shift key pressed.

KeyboardEvent.withSuper

Is Super/Win key pressed.

Type input

Field(s)

#ACTION input.ACTION

Values that can be used with isActionPressed.

#CONTROLLER_AXIS input.CONTROLLER_AXIS

Values that can be used with getAxisValue.

#CONTROLLER_BUTTON input.CONTROLLER_BUTTON

Values that can be passed to onControllerButtonPress/onControllerButtonRelease engine handlers.

#CONTROL_SWITCH input.CONTROL_SWITCH

Values that can be used with getControlSwitch/setControlSwitch.

input.getAxisValue(axisId)

Get value of an axis of a game controller.

Parameter

Return value

#number: Value in range [-1, 1].

input.getControlSwitch(key)

Get state of a control switch.

I.e. is player able to move/fight/jump/etc.

Parameter

Return value

#boolean:

input.getMouseMoveX()

Horizontal mouse movement during the last frame.

Return value

#number:

input.getMouseMoveY()

Vertical mouse movement during the last frame.

Return value

#number:

input.isActionPressed(actionId)

Is a specific control currently pressed.

Input bindings can be changed ingame using Options/Controls menu.

Parameter

Return value

#boolean:

input.isIdle()

Is player idle.

Return value

#boolean:

input.isMouseButtonPressed(buttonId)

Is a mouse button currently pressed.

Parameter

  • #number buttonId : Button index (1 - left, 2 - middle, 3 - right, 4 - X1, 5 - X2)

Return value

#boolean:

input.setControlSwitch(key, value)

Set state of a control switch.

I.e. forbid or allow player to move/fight/jump/etc.

Parameters

Type ACTION

Field(s)

#number ACTION.Activate
#number ACTION.AlwaysRun
#number ACTION.AutoMove
#number ACTION.Console
#number ACTION.CycleSpellLeft
#number ACTION.CycleSpellRight
#number ACTION.CycleWeaponLeft
#number ACTION.CycleWeaponRight
#number ACTION.GameMenu
#number ACTION.Inventory
#number ACTION.Journal
#number ACTION.Jump
#number ACTION.MoveBackward
#number ACTION.MoveForward
#number ACTION.MoveLeft
#number ACTION.MoveRight
#number ACTION.QuickKey1
#number ACTION.QuickKey10
#number ACTION.QuickKey2
#number ACTION.QuickKey3
#number ACTION.QuickKey4
#number ACTION.QuickKey5
#number ACTION.QuickKey6
#number ACTION.QuickKey7
#number ACTION.QuickKey8
#number ACTION.QuickKey9
#number ACTION.QuickKeysMenu
#number ACTION.QuickLoad
#number ACTION.QuickMenu
#number ACTION.QuickSave
#number ACTION.Run
#number ACTION.Screenshot
#number ACTION.Sneak
#number ACTION.Spell
#number ACTION.ToggleDebug
#number ACTION.ToggleHUD
#number ACTION.TogglePOV
#number ACTION.ToggleSneak
#number ACTION.ToggleSpell
#number ACTION.ToggleWeapon
#number ACTION.Use
#number ACTION.Weapon
#number ACTION.ZoomIn
#number ACTION.ZoomOut

Type CONTROLLER_AXIS

Ids of game controller axises.

Used as an argument in getAxisValue.

Field(s)

#number CONTROLLER_AXIS.LeftX

Left stick horizontal axis (from -1 to 1)

#number CONTROLLER_AXIS.LeftY

Left stick vertical axis (from -1 to 1)

#number CONTROLLER_AXIS.LookLeftRight

View direction horizontal axis (RightX by default, can be mapped to another axis in Options/Controls menu)

#number CONTROLLER_AXIS.LookUpDown

View direction vertical axis (RightY by default, can be mapped to another axis in Options/Controls menu)

#number CONTROLLER_AXIS.MoveForwardBackward

Movement forward/backward (LeftY by default, can be mapped to another axis in Options/Controls menu)

#number CONTROLLER_AXIS.MoveLeftRight

Side movement (LeftX by default, can be mapped to another axis in Options/Controls menu)

#number CONTROLLER_AXIS.RightX

Right stick horizontal axis (from -1 to 1)

#number CONTROLLER_AXIS.RightY

Right stick vertical axis (from -1 to 1)

#number CONTROLLER_AXIS.TriggerLeft

Left trigger (from 0 to 1)

#number CONTROLLER_AXIS.TriggerRight

Right trigger (from 0 to 1)

Type CONTROLLER_BUTTON

Field(s)

#number CONTROLLER_BUTTON.A
#number CONTROLLER_BUTTON.B
#number CONTROLLER_BUTTON.Back
#number CONTROLLER_BUTTON.DPadDown
#number CONTROLLER_BUTTON.DPadLeft
#number CONTROLLER_BUTTON.DPadRight
#number CONTROLLER_BUTTON.DPadUp
#number CONTROLLER_BUTTON.Guide
#number CONTROLLER_BUTTON.LeftShoulder
#number CONTROLLER_BUTTON.LeftStick
#number CONTROLLER_BUTTON.RightShoulder
#number CONTROLLER_BUTTON.RightStick
#number CONTROLLER_BUTTON.Start
#number CONTROLLER_BUTTON.X
#number CONTROLLER_BUTTON.Y

Type CONTROL_SWITCH

Field(s)

#string CONTROL_SWITCH.Controls

Ability to move

#string CONTROL_SWITCH.Fighting

Ability to attack

#string CONTROL_SWITCH.Jumping

Ability to jump

#string CONTROL_SWITCH.Looking

Ability to change view direction

#string CONTROL_SWITCH.Magic

Ability to use magic

#string CONTROL_SWITCH.VanityMode

Vanity view if player doesn't touch controls for a long time

#string CONTROL_SWITCH.ViewMode

Ability to toggle 1st/3rd person view

Type KeyboardEvent

The argument of onKeyPress/onKeyRelease engine handlers.

Field(s)

#string KeyboardEvent.code

Key code.

#string KeyboardEvent.symbol

The pressed symbol (1-symbol string).

#boolean KeyboardEvent.withAlt

Is Alt key pressed.

#boolean KeyboardEvent.withCtrl

Is Control key pressed.

#boolean KeyboardEvent.withShift

Is Shift key pressed.

#boolean KeyboardEvent.withSuper

Is Super/Win key pressed.