» Back To Index
Demoniak3D/LUA API: User's inputs handling library
The
HYP_Input library allows to control the user inputs through the keyboard, the mouse or the joystick.
HYP_Input.DisableDefaultKeyboardFunctionalities
HYP_Input.EnableDefaultKeyboardFunctionalities
HYP_Input.GetJoystickButtonState
HYP_Input.GetJoystickPosition
HYP_Input.GetKeyboardLayout
HYP_Input.GetMouseButtonState
HYP_Input.GetMousePos
HYP_Input.SetMousePos
HYP_Input.GetMouseWheelDelta
HYP_Input.HideMouseCursor
HYP_Input.IsKeyboardKeyPressed
HYP_Input.IsJoystickEnabled
HYP_Input.ShowMouseCursor
HYP_Input.SetDefaultInputManagementState
HYP_Input.GetDefaultInputManagementState
GetJoystickButtonState
Allows to know if a joystick button has been pressed.
Currently Hyperion supports only the first 4 buttons of the joystick.
Syntax
state = HYP_Input.GetJoystickButtonState( joy_id, button );
- joy_id - [INTEGER] - specifies the joystick to be tested: 1 or 2.
- button - [INTEGER] - specifies the button to be tested: 0, 1, 2 or 3.
- state - [INTEGER] - state equals 1 if the button has been pressed and 0 if not.
GetJoystickPosition
GetJoystickPosition allows to get the joystick position on the X and Y axis.
Syntax
x, y = HYP_Input.GetJoystickPosition( joy_id );
- joy_id - [INTEGER] - specifies the joystick to be tested: 1 or 2.
- x - [INTEGER] - X position of the joystick.
- y - [INTEGER] - Y position of the joystick.
IsJoystickEnabled
IsJoystickEnabled allows to check that a particular joystick has correctly been initialized.
Currently, Hyperion supports only 2 joysticks.
Syntax
state = HYP_Input.IsJoystickEnabled( joy_id );
- joy_id - [INTEGER] - specifies the joystick to be tested: 1 or 2.
- state - [INTEGER] - state equals 1 if the joystick is correctly initialized and 0 if not.
GetMouseButtonState
GetMouseButtonState allows to know the state of mouse's buttons.
Syntax
state = HYP_Input.GetMouseButtonState(button) ;
- button - [INTEGER] - specifies the button of the mouse to be tested: 1 (left) or 2 (right).
- state - [INTEGER] - state equals 1 if the button is pressed or 0 if not.
Example
is_pressed = HYP_Input.GetMouseButtonState(1);
if (is_pressed==1) then
-- Fire...
end
GetMousePos
GetMousePos allows to get the position of the mouse cursor in screen
coordinates (the (0, 0) coordinates is in the left upper corner of the screen).
Syntax
x, y = HYP_Input.GetMousePos();
SetMousePos
SetMousePos allows to set the position of the mouse cursor in screen
coordinates (the (0, 0) coordinates is in the left upper corner of the screen).
Syntax
HYP_Input.SetMousePos(x, y);
GetMouseWheelDelta
GetMouseWheelDelta allows to get the delta of the serrated mouse wheel. This delta can be
positive or negative.
Syntax
delta = HYP_Input.GetMouseWheelDelta();
HideMouseCursor
HideMouseCursor makes it possible to hide the mouse cursor.
Syntax
HYP_Input.HideMouseCursor();
ShowMouseCursor
ShowMouseCursor makes it possible to show the mouse cursor.
Syntax
HYP_Input.ShowMouseCursor();
EnableDefaultKeyboardFunctionalities
EnableDefaultKeyboardFunctionalities makes it possible to activate the standard keyboard functions
defined in Hyperion.
Functionalities that are not keyboard dependent:
- [UP]: camera forward
- [DOWN]: camera backward
- [LEFT]: camera left strafe
- [RIGHT]: camera right strafe
Functionalities that are keyboard dependent (Swiss, French or English):
- Keyboard with a Swiss layout
- [W]: camera forward
- [S]: camera backward
- [A]: camera left strafe
- [D]: camera right strafe
- Keyboard with a French or English layout (USA)
- [Z]: camera forward
- [S]: camera backward
- [Q]: camera left strafe
- [D]: camera right strafe
Syntax
HYP_Input.EnableDefaultKeyboardFunctionalities();
DisableDefaultKeyboardFunctionalities
DisableDefaultKeyboardFunctionalities allows to disable the standard functions of the keyboard defined in Hyperion and to replace them
by the user's ones.
Syntax
HYP_Input.DisableDefaultKeyboardFunctionalities();
IsKeyboardKeyPressed
IsKeyboardKeyPressed allows to know the state of a key in the current frame.
Syntax
is_pressed = HYP_Input.IsKeyboardKeyPressed( key_id );
- key_id - [INTEGER] - specifies the key by an identifier (integer value). The identifiers list is given
below. You can also use the Hyperion_Keycodes.exe utility which will provide the numeric digital code of a particular key.
- is_pressed - [INTEGER] - is_pressed state equals 1 if the button is pressed or 0 if not.
Example
is_pressed = HYP_Input.IsKeyboardKeyPressed( );
if(is_pressed==1) then
-- Do something...
end
Main keyboard codes list:
HYP_KEY_LBUTTON = 1;
HYP_KEY_RBUTTON = 2;
HYP_KEY_MBUTTON = 4;
HYP_KEY_TAB = 9;
HYP_KEY_ENTER = 13;
HYP_KEY_SHIFT = 16;
HYP_KEY_CTRL = 17;
HYP_KEY_SPACE = 32;
HYP_KEY_PAGE_UP = 33;
HYP_KEY_PAGE_DOWN = 34;
HYP_KEY_END = 35;
HYP_KEY_HOME = 36;
HYP_KEY_LEFT = 37;
HYP_KEY_UP = 38;
HYP_KEY_RIGHT = 39;
HYP_KEY_DOWN = 40;
HYP_KEY_INSERT = 45;
HYP_KEY_DELETE = 46;
HYP_KEY_A = 65;
HYP_KEY_B = 66;
HYP_KEY_C = 67;
HYP_KEY_D = 68;
HYP_KEY_E = 69;
HYP_KEY_F = 70;
HYP_KEY_G = 71;
HYP_KEY_H = 72;
HYP_KEY_I = 73;
HYP_KEY_J = 74;
HYP_KEY_K = 75;
HYP_KEY_L = 76;
HYP_KEY_M = 77;
HYP_KEY_N = 78;
HYP_KEY_O = 79;
HYP_KEY_P = 80;
HYP_KEY_Q = 81;
HYP_KEY_R = 82;
HYP_KEY_S = 83;
HYP_KEY_T = 84;
HYP_KEY_U = 85;
HYP_KEY_V = 86;
HYP_KEY_W = 87;
HYP_KEY_X = 88;
HYP_KEY_Y = 89;
HYP_KEY_Z = 90;
HYP_KEY_NUMPAD_0 = 96;
HYP_KEY_NUMPAD_1 = 97;
HYP_KEY_NUMPAD_2 = 98;
HYP_KEY_NUMPAD_3 = 99;
HYP_KEY_NUMPAD_4 = 100;
HYP_KEY_NUMPAD_5 = 101;
HYP_KEY_NUMPAD_6 = 102;
HYP_KEY_NUMPAD_7 = 103;
HYP_KEY_NUMPAD_8 = 104;
HYP_KEY_NUMPAD_9 = 105;
HYP_KEY_MULT = 106;
HYP_KEY_ADD = 107;
HYP_KEY_SUBTRACT = 109;
HYP_KEY_DECIMAL = 110;
HYP_KEY_DIVIDE = 111;
HYP_KEY_F1 = 112;
HYP_KEY_F2 = 113;
HYP_KEY_F3 = 114;
HYP_KEY_F4 = 115;
HYP_KEY_F5 = 116;
HYP_KEY_F6 = 117;
HYP_KEY_F7 = 118;
HYP_KEY_F8 = 119;
HYP_KEY_F9 = 120;
HYP_KEY_F10 = 121;
HYP_KEY_F11 = 122;
HYP_KEY_F12 = 123;
GetKeyboardLayout
GetKeyboardLayout give the type of layout used for the keyboard keys mapping. .
Syntax
layout = HYP_Input.GetKeyboardLayout();
- layout - [INTEGER] - type of mapping:
- 1 : Swiss keyboard
- 2 : American keyboard
- 3 : French keyboard
SetDefaultInputManagementState
SetDefaultInputManagementState enables or disables the user input default management (keyboard,
mouse). It is recommended to totally disable the default management of Hyperion in case
that a total camera control is required (regarding its position and its orientation).
Syntax
HYP_Input.SetDefaultInputManagementState( state );
- state - [INTEGER] - TRUE=1 to enable or FALSE=0 to disable.
GetDefaultInputManagementState
GetDefaultInputManagementState allows to know the state of the user input default management
(keyboard, mouse).
Syntax
state = HYP_Input.GetDefaultInputManagementState();
- state - [INTEGER] - TRUE=1 (state enabled) or FALSE=0 (state disabled).