Legacy:Functions/Input
From Spherical
Contents
Input
Player Input
API:GetPlayerKey(player, player_key) - Returns the key constant associated with the configurable player key of 'player'. Allowed 'player' values are 0 - 3 or: PLAYER_1 PLAYER_2 PLAYER_3 PLAYER_4 Allowed 'player_key' values are: PLAYER_KEY_MENU PLAYER_KEY_UP PLAYER_KEY_DOWN PLAYER_KEY_LEFT PLAYER_KEY_RIGHT PLAYER_KEY_A PLAYER_KEY_B PLAYER_KEY_X PLAYER_KEY_Y
Keyboard
Key code translation
- API:GetKeyString(key, shift): Converts the given key into a string, KEY_A will become "a", etc. If shift is true, returns uppercase/special value of key. Control keys return an empty string.
Key status
- API:IsAnyKeyPressed(): Check if any key is being held down.
- API:IsKeyPressed(key): Check if the given key is being held down.
- API:GetToggleState(key): Checks if Caps Lock, Num Lock or Scroll Lock are active.
- Allowed key values:
- KEY_CAPSLOCK
- KEY_NUMLOCK
- KEY_SCROLLOCK (Note: only two Ls)
Key queue
- API:AreKeysLeft(): Check if keys are left in the key buffer.
- API:GetKey(): Get a key from the key buffer, waits for one if there isn't.
Mouse
Cursor location
- API:GetMouseX(): Get X coordinate of mouse cursor on the screen.
- API:GetMouseY(): Get Y coordinate of mouse cursor on the screen.
- API:SetMousePosition(x, y): Set mouse cursor location.
Mouse button status
- API:IsMouseButtonPressed(mouse_button): Check if a mouse button is being held down.
Mouse wheel event queue
- API:GetMouseWheelEvent(): Returns a single mouse wheel event.
- API:GetNumMouseWheelEvents(): Returns the length of the mouse wheel event queue.
Joystick
- API:GetNumJoysticks(): Returns the number of joysticks available on the system.
- API:GetNumJoystickButtons(joystick): Returns the number of buttons available on this joystick.
- API:GetNumJoystickAxes(joystick): Returns the number of available axes on the given joystick.
- API:GetTalkActivationButton(): Get joystick button used to activate talk scripts.
- API:SetTalkActivationButton(button): Set joystick button used to activate talk scripts.
Button status
- API:IsJoystickButtonPressed(joystick, button): Find if a button on a joystick is being held down.
Orientation
- API:GetJoystickAxis(joystick, axis): Returns the current joystick axis position in normalized coordinates fro -1 to 1.
- Allowed axis values:
- JOYSTICK_AXIS_X
- JOYSTICK_AXIS_Y
- JOYSTICK_AXIS_Z
- JOYSTICK_AXIS_R (rotation)