Input consts¶
This module contains key codes for constants used to handle input states from buttons on the keyboard and gamepad (Xbox controller). There is also a type, KeyboardShifts, for uniform processing of duplicate keys such as SHIFT, CTRL, and ALT.
To add this module to your project, add the following line to your project file:
require engine.input_core // or require engine.core
Type aliases¶
- bitfield GamepadButtons¶
Button codes for gamepad (Xbox) controller
- Fields:
Up (0x1) -
Upon Xbox controllerDown (0x2) -
Downon Xbox controllerLeft (0x4) -
Lefton Xbox controllerRight (0x8) -
Righton Xbox controllerStart (0x10) -
Starton Xbox controller, hidden for engine use, do not bind actions to this buttonBack (0x20) -
Backon Xbox controllerL3 (0x40) -
L3(LSBorLeft Stick) on Xbox controllerR3 (0x80) -
R3(RSBorRight Stick) on Xbox controllerLeftBumper (0x100) -
LBon Xbox controllerRightBumper (0x200) -
RBon Xbox controllerRESERVED1 (0x400) - unused placeholder
RESERVED2 (0x800) - unused placeholder
A (0x1000) -
Aon Xbox controllerB (0x2000) -
Bon Xbox controllerX (0x4000) -
Xon Xbox controllerY (0x8000) -
Yon Xbox controllerLeftTrigger (0x10000) -
LT(orLeft Trigger) on Xbox controllerRightTrigger (0x20000) -
RT(orRight Trigger) on Xbox controller
- bitfield KeyboardShifts : uint8¶
Raw keyboard shift states
- Fields:
LShift (0x1) - Left shift
RShift (0x2) - Right shift
LCtrl (0x4) - Left control
RCtrl (0x8) - Right control
LAlt (0x10) - Left alt
RAlt (0x20) - Right alt
Shift (0x3) - Left or right shift
Ctrl (0xc) - Left or right control
Alt (0x30) - Left or right alt
- bitfield ActiveStateMask : uint8¶
Mask with bits set for each type of input that has any non-default value during the current frame: button pressed, sticks and triggers touched or mouse moved
- Fields:
KeyboardButton (0x1) - Any keyboard button is pressed
MouseButton (0x2) - Any mouse button is pressed
GamepadButton (0x4) - Any gamepad button is pressed
GamepadStick (0x8) - Any gamepad stick is touched (has non-zero value)
GamepadSlider (0x10) - Any gamepad slider is touched (has non-zero value)
MouseMove (0x20) - The mouse has moved since the last frame
- bitfield JustPressedMask : uint8¶
Mask with bits set for each type of button that was just pressed during the current frame. For example, if any keyboard button was just pressed, the KeyboardButton bit will be set.
- Fields:
KeyboardButton (0x1) - Any keyboard button was just pressed
MouseButton (0x2) - Any mouse button was just pressed
GamepadButton (0x4) - Any gamepad button was just pressed
- bitfield JustReleasedMask : uint8¶
Mask with bits set for each type of button that was just released during the current frame. For example, if any mouse button was just released, the MouseButton bit will be set.
- Fields:
KeyboardButton (0x1) - Any keyboard button was just released
MouseButton (0x2) - Any mouse button was just released
GamepadButton (0x4) - Any gamepad button was just released
Enumerations¶
- ControllerIndex¶
Indices of gamepad controllers
- Values:
Device0 = 0x0 - First controller
Device1 = 0x1 - Second controller
Device2 = 0x2 - Third controller
Device3 = 0x3 - Fourth controller
Device4 = 0x4 - Fifth controller
Device5 = 0x5 - Sixth controller
Device6 = 0x6 - Seventh controller
Device7 = 0x7 - Eighth controller
- GamepadButton¶
Button code for one button on gamepad (Xbox) controller
- Values:
Up = 0x0 -
Upon Xbox controllerDown = 0x1 -
Downon Xbox controllerLeft = 0x2 -
Lefton Xbox controllerRight = 0x3 -
Righton Xbox controllerStart = 0x4 -
Starton Xbox controller, hidden for engine use, do not bind actions to this buttonBack = 0x5 -
Backon Xbox controllerL3 = 0x6 -
L3(LSBorLeft Stick) on Xbox controllerR3 = 0x7 -
R3(RSBorRight Stick) on Xbox controllerLeftBumper = 0x8 -
LBon Xbox controllerRightBumper = 0x9 -
RBon Xbox controllerA = 0xc -
Aon Xbox controllerB = 0xd -
Bon Xbox controllerX = 0xe -
Xon Xbox controllerY = 0xf -
Yon Xbox controllerLeftTrigger = 0x10 -
LT(orLeft Trigger) on Xbox controllerRightTrigger = 0x11 -
RT(orRight Trigger) on Xbox controller
- KeyCode¶
Virtual key codes for keyboard buttons
- Values:
Escape = 0x1 -
Escapekey, hidden for engine use, do not bind actions to this key_1 = 0x2 -
1on main keyboard_2 = 0x3 -
2on main keyboard_3 = 0x4 -
3on main keyboard_4 = 0x5 -
4on main keyboard_5 = 0x6 -
5on main keyboard_6 = 0x7 -
6on main keyboard_7 = 0x8 -
7on main keyboard_8 = 0x9 -
8on main keyboard_9 = 0xa -
9on main keyboard_0 = 0xb -
0on main keyboardMinus = 0xc -
-on main keyboardEquals = 0xd -
=on main keyboardBack = 0xe -
backspaceTab = 0xf -
tabQ = 0x10 -
QW = 0x11 -
WE = 0x12 -
ER = 0x13 -
RT = 0x14 -
TY = 0x15 -
YU = 0x16 -
UI = 0x17 -
IO = 0x18 -
OP = 0x19 -
PLBracket = 0x1a -
[RBracket = 0x1b -
]Return = 0x1c -
Enteron main keyboardLControl = 0x1d -
Left ControlA = 0x1e -
AS = 0x1f -
SD = 0x20 -
DF = 0x21 -
FG = 0x22 -
GH = 0x23 -
HJ = 0x24 -
JK = 0x25 -
KL = 0x26 -
LSemicolon = 0x27 -
;Apostrophe = 0x28 -
'Grave = 0x29 -
`accent graveLShift = 0x2a -
Left ShiftBackslash = 0x2b -
\on main keyboardZ = 0x2c -
ZX = 0x2d -
XC = 0x2e -
CV = 0x2f -
VB = 0x30 -
BN = 0x31 -
NM = 0x32 -
MComma = 0x33 -
,on main keyboardPeriod = 0x34 -
.on main keyboardSlash = 0x35 -
/on main keyboardRShift = 0x36 -
Right ShiftRshift = 0x36 -
Right Shift (deprecated key code, use RShift instead)Multiply = 0x37 -
*on numeric keypadLAlt = 0x38 -
Left AltSpace = 0x39 -
SpacebarCapital = 0x3a -
Caps LockF1 = 0x3b -
F1F2 = 0x3c -
F2F3 = 0x3d -
F3F4 = 0x3e -
F4F5 = 0x3f -
F5F6 = 0x40 -
F6F7 = 0x41 -
F7F8 = 0x42 -
F8F9 = 0x43 -
F9F10 = 0x44 -
F10Numlock = 0x45 -
Num LockScroll = 0x46 -
Scroll LockNumpad7 = 0x47 -
7on numeric keypadNumpad8 = 0x48 -
8on numeric keypadNumpad9 = 0x49 -
9on numeric keypadSubtract = 0x4a -
-on numeric keypadNumpad4 = 0x4b -
4on numeric keypadNumpad5 = 0x4c -
5on numeric keypadNumpad6 = 0x4d -
6on numeric keypadAdd = 0x4e -
+on numeric keypadNumpad1 = 0x4f -
1on numeric keypadNumpad2 = 0x50 -
2on numeric keypadNumpad3 = 0x51 -
3on numeric keypadNumpad0 = 0x52 -
0on numeric keypadDecimal = 0x53 -
.on numeric keypadOem102 = 0x56 -
<>or\|on RT 102-key keyboard (Non-U.S.)F11 = 0x57 -
F11F12 = 0x58 -
F12F13 = 0x64 -
F13(NEC PC98)F14 = 0x65 -
F14(NEC PC98)F15 = 0x66 -
F15(NEC PC98)KANA = 0x70 - (Japanese keyboard)
ABNT_C1 = 0x73 -
/?on Brazilian keyboardCONVERT = 0x79 - (Japanese keyboard)
NOCONVERT = 0x7b - (Japanese keyboard)
YEN = 0x7d - (Japanese keyboard)
ABNT_C2 = 0x7e -
Numpad .on Brazilian keyboardNumpadEquals = 0x8d -
=on numeric keypad (NEC PC98)PrevTrack = 0x90 -
Previous Track(DIK_CIRCUMFLEX on Japanese keyboard)At = 0x91 - (NEC PC98)
Colon = 0x92 - (NEC PC98)
Underline = 0x93 - (NEC PC98)
Kanji = 0x94 - (Japanese keyboard)
Stop = 0x95 - (NEC PC98)
Ax = 0x96 - (Japan AX)
Unlabeled = 0x97 - (J3100)
NextTrack = 0x99 -
Next TrackNumpadEnter = 0x9c -
Enteron numeric keypadRControl = 0x9d -
Right ControlMute = 0xa0 -
MuteCalculator = 0xa1 -
CalculatorPlayPause = 0xa2 -
Play / PauseMediaStop = 0xa4 -
Media StopVolumeDown = 0xae -
Volume -VolumeUp = 0xb0 -
Volume +Webhome = 0xb2 -
Web homeNumpadComma = 0xb3 -
,on numeric keypad (NEC PC98)Divide = 0xb5 -
/on numeric keypadPrint = 0xb7 -
System Request / Print ScreenRAlt = 0xb8 -
Right AltPause = 0xc5 -
PauseHome = 0xc7 -
Homeon arrow keypadUp = 0xc8 -
UpArrowon arrow keypadPrior = 0xc9 -
PgUpon arrow keypadLeft = 0xcb -
LeftArrowon arrow keypadRight = 0xcd -
RightArrowon arrow keypadEnd = 0xcf -
Endon arrow keypadDown = 0xd0 -
DownArrowon arrow keypadNext = 0xd1 -
PgDnon arrow keypadInsert = 0xd2 -
Inserton arrow keypadDelete = 0xd3 -
Deleteon arrow keypadLWin = 0xdb -
Left WindowskeyRWin = 0xdc -
Right WindowskeyApps = 0xdd -
AppMenukey
- MouseButton¶
Mouse buttons
- Values:
Left = 0x0 - left mouse button
Right = 0x1 - right mouse button
Middle = 0x2 - middle mouse button (scroll wheel)
WheelUp = 0x5 - mouse wheel up
WheelDown = 0x6 - mouse wheel down
Functions¶
- ControllerIndex(idx: int): ControllerIndex
Converts an integer to a controller index enum
- Arguments:
idx : int
- GamepadButton&(a: GamepadButton; b: GamepadButtons): GamepadButtons¶
Bitwise AND operator for GamepadButton and GamepadButtons
- Arguments:
a : GamepadButton
b : GamepadButtons
- GamepadButtons&(a: GamepadButtons; b: GamepadButton): GamepadButtons¶
Bitwise AND operator for GamepadButtons and GamepadButton
- Arguments:
a : GamepadButtons
b : GamepadButton