C# Class GarrysModLuaShared.input

The input library allows you to gather information about the clients input devices (mouse & keyboard), such as the cursor position and whether a key is pressed or not.
Show file Open project: OmegaExtern/gmod-csharp-binary-module

Public Methods

Method Description
CheckKeyTrapping ( LuaState luaState ) : KEY

Returns the last key captured by key trapping.

GetCursorPos ( LuaState luaState ) : double>.Tuple

Returns the cursor's position on the screen.

GetCursorPos ( LuaState luaState, double &mouseX, double &mouseY ) : void

Returns the cursor's position on the screen.

GetKeyName ( LuaState luaState, BUTTON button ) : string

Gets the name of the button index.

IsButtonDown ( LuaState luaState, BUTTON button ) : bool

Gets whether the specified button code is down. Unlike input.IsKeyDown this can also detect joystick presses from JOYSTICK enum.

IsControlDown ( LuaState luaState ) : bool

Returns whether a control key is being pressed.

IsKeyDown ( LuaState luaState, KEY key ) : bool

Gets whether a key is down.

IsKeyTrapping ( LuaState luaState ) : bool

Returns whether key trapping is activate and the next key press will be captured.

IsMouseDown ( LuaState luaState, MOUSE mouseKey ) : bool

Gets whether a mouse button is down.

IsShiftDown ( LuaState luaState ) : bool

Gets whether a shift key is being pressed.

LookupBinding ( LuaState luaState, string binding, bool exact = false ) : string

Gets the match uppercase key for the specified binding.

LookupKeyBinding ( LuaState luaState, KEY key ) : string

Returns the bind string that the given key is bound to.

SetCursorPos ( LuaState luaState, double mouseX, double mouseY ) : void

Sets the cursor's position on the screen, relative to the topleft corner of the window.

StartKeyTrapping ( LuaState luaState ) : void

Starts key trap.

WasKeyPressed ( LuaState luaState, KEY key ) : bool

Returns whether a key was initially pressed in the same frame this function was called. This function only works in Move hooks, and will detect key presses even in main menu or when a typing in a text field.

WasKeyReleased ( LuaState luaState, KEY key ) : bool

Returns whether a key was released in the same frame this function was called. This function only works in Move hooks, and will detect key releases even in main menu or when a typing in a text field.

WasKeyTyped ( LuaState luaState, KEY key ) : bool

Returns whether the key is being held down or not. This function only works in Move hooks, and will detect key events even in main menu or when a typing in a text field.

WasMouseDoublePressed ( LuaState luaState, MOUSE button ) : bool

Returns whether a mouse key was double pressed in the same frame this function was called. If this function returns true, WasMousePressed will return false. This function only works in Move hooks, and will detect mouse events even in main menu or when a typing in a text field.

WasMousePressed ( LuaState luaState, MOUSE button ) : bool

Returns whether a mouse key was initially pressed in the same frame this function was called. If WasMouseDoublePressed returns true, this function will return false. This function only works in Move hooks, and will detect mouse events even in main menu or when a typing in a text field.

Method Details

CheckKeyTrapping() public static method

Returns the last key captured by key trapping.
public static CheckKeyTrapping ( LuaState luaState ) : KEY
luaState LuaState Pointer to lua_State struct.
return KEY

GetCursorPos() public static method

Returns the cursor's position on the screen.
public static GetCursorPos ( LuaState luaState ) : double>.Tuple
luaState LuaState Pointer to lua_State struct.
return double>.Tuple

GetCursorPos() public static method

Returns the cursor's position on the screen.
public static GetCursorPos ( LuaState luaState, double &mouseX, double &mouseY ) : void
luaState LuaState Pointer to lua_State struct.
mouseX double Mouse X coordinate.
mouseY double Mouse Y coordinate.
return void

GetKeyName() public static method

Gets the name of the button index.
public static GetKeyName ( LuaState luaState, BUTTON button ) : string
luaState LuaState Pointer to lua_State struct.
button BUTTON The button.
return string

IsButtonDown() public static method

Gets whether the specified button code is down. Unlike input.IsKeyDown this can also detect joystick presses from JOYSTICK enum.
public static IsButtonDown ( LuaState luaState, BUTTON button ) : bool
luaState LuaState Pointer to lua_State struct.
button BUTTON The button, valid values are in the range of enum.
return bool

IsControlDown() public static method

Returns whether a control key is being pressed.
public static IsControlDown ( LuaState luaState ) : bool
luaState LuaState Pointer to lua_State struct.
return bool

IsKeyDown() public static method

Gets whether a key is down.
public static IsKeyDown ( LuaState luaState, KEY key ) : bool
luaState LuaState Pointer to lua_State struct.
key KEY The key.
return bool

IsKeyTrapping() public static method

Returns whether key trapping is activate and the next key press will be captured.
public static IsKeyTrapping ( LuaState luaState ) : bool
luaState LuaState Pointer to lua_State struct.
return bool

IsMouseDown() public static method

Gets whether a mouse button is down.
public static IsMouseDown ( LuaState luaState, MOUSE mouseKey ) : bool
luaState LuaState Pointer to lua_State struct.
mouseKey MOUSE The mouse key.
return bool

IsShiftDown() public static method

Gets whether a shift key is being pressed.
public static IsShiftDown ( LuaState luaState ) : bool
luaState LuaState Pointer to lua_State struct.
return bool

LookupBinding() public static method

Gets the match uppercase key for the specified binding.
public static LookupBinding ( LuaState luaState, string binding, bool exact = false ) : string
luaState LuaState Pointer to lua_State struct.
binding string The binding name.
exact bool True if the binding should match exactly.
return string

LookupKeyBinding() public static method

Returns the bind string that the given key is bound to.
public static LookupKeyBinding ( LuaState luaState, KEY key ) : string
luaState LuaState Pointer to lua_State struct.
key KEY The key.
return string

SetCursorPos() public static method

Sets the cursor's position on the screen, relative to the topleft corner of the window.
public static SetCursorPos ( LuaState luaState, double mouseX, double mouseY ) : void
luaState LuaState Pointer to lua_State struct.
mouseX double X coordinate for mouse position.
mouseY double Y coordinate for mouse position.
return void

StartKeyTrapping() public static method

Starts key trap.
public static StartKeyTrapping ( LuaState luaState ) : void
luaState LuaState Pointer to lua_State struct.
return void

WasKeyPressed() public static method

Returns whether a key was initially pressed in the same frame this function was called. This function only works in Move hooks, and will detect key presses even in main menu or when a typing in a text field.
public static WasKeyPressed ( LuaState luaState, KEY key ) : bool
luaState LuaState Pointer to lua_State struct.
key KEY The key.
return bool

WasKeyReleased() public static method

Returns whether a key was released in the same frame this function was called. This function only works in Move hooks, and will detect key releases even in main menu or when a typing in a text field.
public static WasKeyReleased ( LuaState luaState, KEY key ) : bool
luaState LuaState Pointer to lua_State struct.
key KEY The key.
return bool

WasKeyTyped() public static method

Returns whether the key is being held down or not. This function only works in Move hooks, and will detect key events even in main menu or when a typing in a text field.
public static WasKeyTyped ( LuaState luaState, KEY key ) : bool
luaState LuaState Pointer to lua_State struct.
key KEY The key.
return bool

WasMouseDoublePressed() public static method

Returns whether a mouse key was double pressed in the same frame this function was called. If this function returns true, WasMousePressed will return false. This function only works in Move hooks, and will detect mouse events even in main menu or when a typing in a text field.
public static WasMouseDoublePressed ( LuaState luaState, MOUSE button ) : bool
luaState LuaState Pointer to lua_State struct.
button MOUSE The mouse button to test.
return bool

WasMousePressed() public static method

Returns whether a mouse key was initially pressed in the same frame this function was called. If WasMouseDoublePressed returns true, this function will return false. This function only works in Move hooks, and will detect mouse events even in main menu or when a typing in a text field.
public static WasMousePressed ( LuaState luaState, MOUSE button ) : bool
luaState LuaState Pointer to lua_State struct.
button MOUSE The mouse button to test.
return bool