< GeeXLab Reference Guide />

> Back to Reference Guide Index


gh_input Library

Description

gh_input is the module that manages user's input: mouse, keyboard...


Number of functions: 13

  1. gh_input.keyboard_is_key_down (Lua - Python)
  2. gh_input.keyboard_update_buffer (Lua - Python)
  3. gh_input.keyboard_clear_key_buffer (Lua - Python)
  4. gh_input.mouse_get_button_state (Lua - Python)
  5. gh_input.mouse_get_position (Lua - Python)
  6. gh_input.mouse_set_position (Lua - Python)
  7. gh_input.mouse_get_wheel_delta (Lua - Python)
  8. gh_input.mouse_reset_wheel_delta (Lua - Python)
  9. gh_input.mouse_show_cursor (Lua - Python)
  10. gh_input.joystick_get_num (Lua - Python)
  11. gh_input.joystick_get_status (Lua - Python)
  12. gh_input.joystick_get_button_state (Lua - Python)
  13. gh_input.joystick_get_position (Lua - Python)



gh_input.keyboard_is_key_down

Description

Returns the pressed state of a keyboard key.

Languages

Lua - Python

Parameters

  • key [INTEGER]: key code.

    Return Values

  • state [INTEGER]: key state: 1 if down (pressed) or 0 if up (not pressed).

    Code sample

        
    -- More key codes can be found in GeeXLab forum.            
    local KC_W = 17
    local KC_S = 31
    local KC_A = 30
    local KC_D = 32
    
    local KC_LEFT = 75
    local KC_RIGHT = 77
    local KC_UP = 72
    local KC_DOWN = 80
    local KC_SPACE = 57
                
    local is_down = gh_input.keyboard_is_key_down(KC_SPACE)
    if (is_down == 1)  then
      -- pressed!
    end  
                


    gh_input.keyboard_update_buffer

    Description

    Windows platforms only. Updates the keyboard buffer. Call this function before keyboard_is_key_down().

    Languages

    Lua - Python

    Parameters

    This function has no input parameter(s).

    Return Values

    This function has no return value(s).

    Code sample

        
    gh_input.keyboard_update_buffer()
    local is_down = gh_input.keyboard_is_key_down(KC_SPACE)
                


    gh_input.keyboard_clear_key_buffer

    Description

    Windows platforms only. Clears the keyboard buffer. Call this function once per frame.

    Languages

    Lua - Python

    Parameters

    This function has no input parameter(s).

    Return Values

    This function has no return value(s).

    Code sample

        
    gh_input.keyboard_clear_key_buffer()
                


    gh_input.mouse_get_button_state

    Description

    Returns the state of a mouse button.

    Languages

    Lua - Python

    Parameters

  • button [INTEGER]: mouse button identifier: left button (1) or right button (2).

    Return Values

  • state [INTEGER]: button state: 1 if down (pressed) or 0 if up (not pressed).

    Code sample

        
    local LEFT_BUTTON = 1            
    local RIGHT_BUTTON = 2   
    local is_down = gh_input.mouse_get_button_state(LEFT_BUTTON)
                


    gh_input.mouse_get_position

    Description

    Returns the position of the mouse cursor in screen coordinates. The top-left position is the {0, 0} position.

    Languages

    Lua - Python

    Parameters

    This function has no input parameter(s).

    Return Values

  • x, y [INTEGER]: mouse position

    Code sample

        
    mx, my = gh_input.mouse_get_position()
                


    gh_input.mouse_set_position

    Description

    Sets the position of the mouse cursor.

    Languages

    Lua - Python

    Parameters

  • x, y [INTEGER]: mouse position

    Return Values

    This function has no return value(s).

    Code sample

        
    gh_input.mouse_set_position(x, y)
                


    gh_input.mouse_get_wheel_delta

    Description

    Returns the delta of the mouse wheel.

    Languages

    Lua - Python

    Parameters

    This function has no input parameter(s).

    Return Values

  • delta [INTEGER]: mouse wheel delta

    Code sample

        
    delta = gh_input.mouse_get_wheel_delta()
                


    gh_input.mouse_reset_wheel_delta

    Description

    Reset the delta value of the mouse wheel.

    Languages

    Lua - Python

    Parameters

    This function has no input parameter(s).

    Return Values

    This function has no return value(s).

    Code sample

        
    gh_input.mouse_reset_wheel_delta()
                


    gh_input.mouse_show_cursor

    Description

    Shows or hide the mouse cursor (Windows only).

    Languages

    Lua - Python

    Parameters

  • state [INTEGER]: show (1) or hide (0)

    Return Values

    This function has no return value(s).

    Code sample

        
    gh_input.mouse_show_cursor(0)
                


    gh_input.joystick_get_num

    Description

    Returns the number of joysticks supported. WINDOWS only.

    Languages

    Lua - Python

    Parameters

    This function has no input parameter(s).

    Return Values

  • num_joys [INTEGER]: number of joysticks

    Code sample

        
    num_joys = gh_input.joystick_get_num()
                


    gh_input.joystick_get_status

    Description

    Gets the status of a particular joystick. WINDOWS only - only two joysticks are supported

    Languages

    Lua - Python

    Parameters

  • joy_index [INTEGER]: joystick index - currently 0 or 1

    Return Values

  • status [INTEGER]: joystick status: 1 (initialized) or 0 (error or not plugged)

    Code sample

        
    status = gh_input.joystick_get_status(joy_index)
                


    gh_input.joystick_get_button_state

    Description

    Gets the status of a particular button of a joystick. WINDOWS only - only four buttons are supported

    Languages

    Lua - Python

    Parameters

  • joy_index [INTEGER]: joystick index - currently 0 or 1
  • button_index [INTEGER]: button index - currently 0, 1, 2 or 3

    Return Values

  • status [INTEGER]: button status: 1 (pressed) or 0 (released)

    Code sample

        
    status = gh_input.joystick_get_button_state(joy_index, button_index)
                


    gh_input.joystick_get_position

    Description

    Gets the position of a joystick along X, Y and Z axis. WINDOWS only

    Languages

    Lua - Python

    Parameters

  • joy_index [INTEGER]: joystick index - currently 0 or 1

    Return Values

  • x, y, z [REAL]: position along X, Y and Z axis

    Code sample

        
    x, y, z = gh_input.joystick_get_position(joy_index)
                






    GeeXLab Rootard Guide | Downloads | Contact | Newsletter