Module ncine.input

The table containing the input manager related functions

Functions

ncine.input.mouse_state () Returns current mouse state
ncine.input.key_state () Returns current keyboard state
ncine.input.joy_present (joy_id) Returns true if the specified joystick is connected
ncine.input.joy_name (joy_id) Returns the name of the specified joystick
ncine.input.joy_guid (joy_id) Returns the GUID of the specified joystick
ncine.input.joy_num_buttons (joy_id) Returns the number of available buttons for the specified joystick
ncine.input.joy_num_hats (joy_id) Returns the number of available hats for the specified joystick
ncine.input.joy_num_axes (joy_id) Returns the number of available axes for the specified joystick
ncine.input.joy_state () Returns the state of the joystick
ncine.input.joy_mapped (joy_id) Returns true if the joystick has a valid mapping configuration
ncine.input.joymapped_state () Returns the state of the mapped joystick
ncine.input.deadzone_normalize (joy_vector, deadzone_value) Modifies the joystick axis vector to account for a dead zone
ncine.input.add_joymappings_from_file (filename) Adds joystick mapping configurations from a text file
ncine.input.add_joymappings_from_strings (strings) Adds joystick mapping configurations from a strings array
ncine.input.num_joymappings (strings) Returns the current number of valid joystick mappings
ncine.input.get_mouse_cursor_mode (joy_id) Returns current mouse cursor mode
ncine.input.set_mouse_cursor_mode (mouse_cursor_mode) Sets the mouse cursor mode
ncine.input.key_down (key_state, keysym) Returns true if the specified key is down
ncine.input.joy_button_pressed (joystick_state, button_id) Returns true if the specified joystick button is pressed
ncine.input.joy_button_pressed (joystick_state, button_name) Returns true if the specified mapped joystick button is pressed
ncine.input.joy_hat_state (joystick_state, hat_id) Returns the state of the specified hat
ncine.input.joy_axis_value (joystick_state, axis_id) Returns a value between -32768 and 32767 for a joystick axis
ncine.input.joy_axis_value (joystick_state, axis_name) Returns the value of the specified mapped joystick axis
ncine.input.joy_axis_normvalue (joystick_state, axis_id) Returns a normalized value between -1.0 and 1.0 for a joystick axis

Tables

keystateObj The light user data of a keyboard state object
joystickstateObj The light user data of a joystick state object
joymappedstateObj The light user data of a mapped joystick state object
mouse_state Table with information about the mouse state
ncine.mouse_cursor_mode Mouse cursor modes (enumeration)
ncine.joy_dead_zone Joystick dead zone values for various axes.

input_events Functions

keyboard_event Table with information about a keyboard event
text_input_event Table with information about a text input event
pointer Table with information about a single pointer touching the screen
touch_event Table with information about a screen touch event.
accelerometer_event Table with information about an accelerometer event
ncine.mouse_button Mouse buttons (enumeration)
mouse_event Table with information about a mouse event
scroll_event Table with information about a scroll event (mouse wheel, touchpad gesture, etc.)
joy_button_event Table with information about a joystick button event
ncine.joy_hat_state Joystick hat states (enumeration)
joy_hat_event Table with information about a joystick hat event
joy_axis_event Table with information about a joystick axis event
ncine.joy_button Joystick button names (enumeration)
joy_mapped_button_event Table with information about a joystick mapped button event
ncine.joy_axis Joystick axis names (enumeration)
joy_mapped_axis_event Table with information about a joystick mapped axis event
joy_connection_event Table with information about a joystick connection event


Functions

ncine.input.mouse_state ()
Returns current mouse state

Returns:

    mouse_state
ncine.input.key_state ()
Returns current keyboard state

Returns:

    keystateObj
ncine.input.joy_present (joy_id)
Returns true if the specified joystick is connected

Parameters:

  • joy_id integer

Returns:

    boolean
ncine.input.joy_name (joy_id)
Returns the name of the specified joystick

Parameters:

  • joy_id integer

Returns:

    string
ncine.input.joy_guid (joy_id)
Returns the GUID of the specified joystick

Parameters:

  • joy_id integer

Returns:

    string
ncine.input.joy_num_buttons (joy_id)
Returns the number of available buttons for the specified joystick

Parameters:

  • joy_id integer

Returns:

    integer
ncine.input.joy_num_hats (joy_id)
Returns the number of available hats for the specified joystick

Parameters:

  • joy_id integer

Returns:

    integer
ncine.input.joy_num_axes (joy_id)
Returns the number of available axes for the specified joystick

Parameters:

  • joy_id integer

Returns:

    integer
ncine.input.joy_state ()
Returns the state of the joystick

Returns:

    joystickstateObj
ncine.input.joy_mapped (joy_id)
Returns true if the joystick has a valid mapping configuration

Parameters:

  • joy_id integer

Returns:

    boolean
ncine.input.joymapped_state ()
Returns the state of the mapped joystick

Returns:

    joymappedstateObj
ncine.input.deadzone_normalize (joy_vector, deadzone_value)
Modifies the joystick axis vector to account for a dead zone

Parameters:

  • joy_vector ncine.vec2
  • deadzone_value number
ncine.input.add_joymappings_from_file (filename)
Adds joystick mapping configurations from a text file

Parameters:

ncine.input.add_joymappings_from_strings (strings)
Adds joystick mapping configurations from a strings array

Parameters:

ncine.input.num_joymappings (strings)
Returns the current number of valid joystick mappings

Parameters:

  • strings

Returns:

    integer
ncine.input.get_mouse_cursor_mode (joy_id)
Returns current mouse cursor mode

Parameters:

  • joy_id

Returns:

    ncine.mouse_cursor_mode
ncine.input.set_mouse_cursor_mode (mouse_cursor_mode)
Sets the mouse cursor mode

Parameters:

  • mouse_cursor_mode ncine.mouse_cursor_mode
ncine.input.key_down (key_state, keysym)
Returns true if the specified key is down

Parameters:

Returns:

    boolean
ncine.input.joy_button_pressed (joystick_state, button_id)
Returns true if the specified joystick button is pressed

Parameters:

Returns:

    boolean
ncine.input.joy_button_pressed (joystick_state, button_name)
Returns true if the specified mapped joystick button is pressed

Parameters:

Returns:

    boolean
ncine.input.joy_hat_state (joystick_state, hat_id)
Returns the state of the specified hat

Parameters:

Returns:

    ncine.joy_hat_state
ncine.input.joy_axis_value (joystick_state, axis_id)
Returns a value between -32768 and 32767 for a joystick axis

Parameters:

Returns:

    integer
ncine.input.joy_axis_value (joystick_state, axis_name)
Returns the value of the specified mapped joystick axis

Parameters:

Returns:

    number
ncine.input.joy_axis_normvalue (joystick_state, axis_id)
Returns a normalized value between -1.0 and 1.0 for a joystick axis

Parameters:

Returns:

    number

Tables

keystateObj
The light user data of a keyboard state object
joystickstateObj
The light user data of a joystick state object
joymappedstateObj
The light user data of a mapped joystick state object
mouse_state
Table with information about the mouse state

Fields:

  • x integer Pointer position on the X axis
  • y integer Pointer position on the Y axis
  • left_pressed boolean It is true if the left mouse button is pressed
  • middle_pressed boolean It is true if the middle mouse button is pressed
  • right_pressed boolean It is true if the right mouse button is pressed
  • fourth_pressed boolean It is true if the fourth mouse button is pressed
  • fifth_pressed boolean It is true if the fifth mouse button is pressed
ncine.mouse_cursor_mode
Mouse cursor modes (enumeration)

Fields:

  • NORMAL
  • HIDDEN
  • DISABLED
ncine.joy_dead_zone
Joystick dead zone values for various axes.

From XInput.h in DirectX SDK.

Fields:

  • LEFT_STICK
  • RIGHT_STICK
  • TRIGGER

input_events Functions

keyboard_event
Table with information about a keyboard event

Fields:

  • scancode integer
  • sym integer
  • mod integer
text_input_event
Table with information about a text input event

Fields:

pointer
Table with information about a single pointer touching the screen

Fields:

  • id integer
  • x number
  • y number
touch_event

Table with information about a screen touch event.

To access a pointer table use the subscript operator:

local pointer0 = event[0]

Fields:

  • pointers (pointer[])
  • count integer
  • action_index integer
accelerometer_event
Table with information about an accelerometer event

Fields:

  • x number
  • y number
  • z number
ncine.mouse_button
Mouse buttons (enumeration)

Fields:

  • LEFT
  • MIDDLE
  • RIGHT
  • FOURTH
  • FIFTH
mouse_event
Table with information about a mouse event

Fields:

  • button (ncine.mouse_button)
  • x number
  • y number
scroll_event
Table with information about a scroll event (mouse wheel, touchpad gesture, etc.)

Fields:

  • x number
  • y number
joy_button_event
Table with information about a joystick button event

Fields:

  • joy_id integer
  • button_id integer
ncine.joy_hat_state
Joystick hat states (enumeration)

Fields:

  • CENTERED
  • UP
  • RIGHT
  • DOWN
  • LEFT
  • RIGHT_UP
  • RIGHT_DOWN
  • LEFT_UP
  • LEFT_DOWN
joy_hat_event
Table with information about a joystick hat event

Fields:

  • hat_state (ncine.joy_hat_state)
  • joy_id integer
  • hat_id integer
joy_axis_event
Table with information about a joystick axis event

Fields:

  • joy_id integer
  • axis_id integer
  • value number
  • norm_value number
ncine.joy_button
Joystick button names (enumeration)

Fields:

  • UNKNOWN
  • A
  • B
  • X
  • Y
  • BACK
  • GUIDE
  • START
  • LSTICK
  • RSTICK
  • LBUMPER
  • RBUMPER
  • DPAD_UP
  • DPAD_DOWN
  • DPAD_LEFT
  • DPAD_RIGHT
  • MISC1
  • PADDLE1
  • PADDLE2
  • PADDLE3
  • PADDLE4
joy_mapped_button_event
Table with information about a joystick mapped button event

Fields:

  • button (ncine.joy_button)
  • joy_id integer
ncine.joy_axis
Joystick axis names (enumeration)

Fields:

  • LX
  • LY
  • RX
  • RY
  • LTRIGGER
  • RTRIGGER
joy_mapped_axis_event
Table with information about a joystick mapped axis event

Fields:

  • axis (ncine.joy_axis)
  • joy_id integer
  • value number
joy_connection_event
Table with information about a joystick connection event

Fields:

  • joy_id integer
generated by LDoc 1.5.0 Last updated 2024-12-18 15:08:56