DayZ 1.24
Loading...
Searching...
No Matches
Input Class Reference

Private Member Functions

proto native void ChangeGameFocus (int add, int input_device=-1)
 Change game focus number.
 
proto native void ResetGameFocus (int input_device=-1)
 Reset game focus number (set to 0)
 
proto native bool HasGameFocus (int input_device=-1)
 Check if game should have focus.
 
proto native int GetActionGroupsCount ()
 
proto native int GetActionGroupSize (int group_index)
 
proto int GetActionGroupName (int group_index, out string name)
 
proto int GetActionDesc (int action_index, out string desc)
 
proto native float LocalValue_ID (int action, bool check_focus=true)
 Get action state.
 
proto native float LocalValue (string action, bool check_focus=true)
 
proto native bool LocalPress_ID (int action, bool check_focus=true)
 Returns true just in frame, when action was invoked (button was pressed)
 
proto native bool LocalPress (string action, bool check_focus=true)
 
proto native bool LocalRelease_ID (int action, bool check_focus=true)
 Returns true just in frame, when release action happened (button was released)
 
proto native bool LocalRelease (string action, bool check_focus=true)
 
proto native bool LocalHold_ID (int action, bool check_focus=true)
 Returns true just in frame, when hold action invoked (button is hold)
 
proto native bool LocalHold (string action, bool check_focus=true)
 
proto native bool LocalDbl_ID (int action, bool check_focus=true)
 Returns true just in frame, when double click action invoked (button double clicked)
 
proto native bool LocalDbl (string action, bool check_focus=true)
 
proto native void DisableKey (int key)
 Disable key until end of frame.
 
proto native void EnableMouseAndKeyboard (bool enable)
 Enable mouse and keyboard (on consoles)
 
proto native bool IsEnabledMouseAndKeyboard ()
 
proto native bool IsEnabledMouseAndKeyboardEvenOnServer ()
 
proto native bool IsMouseConnected ()
 
proto native bool IsKeyboardConnected ()
 
proto native int GetCurrentProfile ()
 gets currently selected profile
 
proto native void GetCurrentProfileActionKeys (int action_index, out TIntArray keys)
 
proto int GetProfileName (int profile_index, out string name)
 gets profile by index
 
proto native int GetProfilesCount ()
 gets profile by name
 
proto native int SetProfile (int index)
 setting active profile
 
proto native int GetDevicesCount ()
 
proto int GetDeviceName (int device_index, out string name)
 
proto native int IsDeviceXInput (int device_index)
 
proto native int IsDeviceEnabled (int device_index)
 
proto native void SetDeviceEnabled (int device_index, bool enabled)
 
proto bool GetGamepadThumbDirection (GamepadButton thumbButton, out float angle, out float value)
 return true if was deflected button.
 
proto native void ResetActiveGamepad ()
 clears active gamepad
 
proto native void SelectActiveGamepad (int gamepad)
 
proto native void GetGamepadList (out array< int > gamepads)
 
proto void GetGamepadUser (int gamepad, out BiosUser user)
 
proto native void IdentifyGamepad (GamepadButton button)
 the on OnGamepadIdentification callback will return the first gamepad where the button was pressed
 
proto native bool IsActiveGamepadSelected ()
 returns true if there is an active gamepad selected.
 
bool IsAnyInputDeviceActive ()
 returns true if 'Gamepad' or 'Mouse and Keyboard' is connected
 
bool AreAllAllowedInputDevicesActive (out array< int > unavailableDeviceList=null)
 returns true if 'Gamepad' or if 'Mouse/Keyboard' control is allowed locally and on server, and the respective input devicse are connected. Gamepad takes priority.
 
void FillUnavailableDeviceArray (int device, inout array< int > filler)
 
void UpdateConnectedInputDeviceList ()
 currently lists only available Gamepad, Mouse, and Keyboard. Extendable as needed.
 
proto native EInputDeviceType GetCurrentInputDevice ()
 
proto native GamepadButton GetEnterButton ()
 
void OnGamepadConnected (int gamepad)
 callback that is fired when a new gamepad is connected
 
void OnGamepadDisconnected (int gamepad)
 callback that is fired when gamepad is disconnected
 
void OnGamepadIdentification (int gamepad)
 callback that is fired when identification was requested
 
int GetUserGamepad (BiosUser user)
 
bool IsInactiveGamepadOrUserSelected (int gamepad=-1)
 
void OnMouseConnected ()
 
void OnMouseDisconnected ()
 
void OnKeyboardConnected ()
 
void OnKeyboardDisconnected ()
 
void OnLastInputDeviceChanged (EInputDeviceType inputDevice)
 called from code on different input device use
 

Detailed Description

Definition at line 10 of file input.c.

Member Function Documentation

◆ AreAllAllowedInputDevicesActive()

bool Input::AreAllAllowedInputDevicesActive ( out array< int > unavailableDeviceList = null)
inlineprivate

returns true if 'Gamepad' or if 'Mouse/Keyboard' control is allowed locally and on server, and the respective input devicse are connected. Gamepad takes priority.

Parameters
unavailableDeviceListlists all devices that SHOULD be available, but aren't. Optional.

Definition at line 165 of file input.c.

166 {
167 bool passed = true;
169 bool mouse = IsMouseConnected();
171 bool MnKEnabled;
172
173 if (g_Game.GetGameState() != DayZGameState.IN_GAME)
175 else if (g_Game.GetGameState() != DayZGameState.MAIN_MENU)
177 else
178 return true;
179
180 if (!MnKEnabled)
181 {
182 if (!gamepad)
183 {
184 passed = false;
186 }
187 }
188 else
189 {
190 if (!gamepad)
191 {
192 if (!mouse)
193 {
194 passed = false;
196 }
197 if (!keyboard)
198 {
199 passed = false;
201 }
202
203 if (!passed)
205 }
206 }
207 return passed;
208 }
DayZGame g_Game
Definition DayZGame.c:3528
void FillUnavailableDeviceArray(int device, inout array< int > filler)
Definition input.c:210
proto native bool IsKeyboardConnected()
proto native bool IsActiveGamepadSelected()
returns true if there is an active gamepad selected.
proto native bool IsEnabledMouseAndKeyboard()
proto native bool IsEnabledMouseAndKeyboardEvenOnServer()
proto native bool IsMouseConnected()

References FillUnavailableDeviceArray(), g_Game, IsActiveGamepadSelected(), IsEnabledMouseAndKeyboard(), IsEnabledMouseAndKeyboardEvenOnServer(), IsKeyboardConnected(), and IsMouseConnected().

◆ ChangeGameFocus()

proto native void Input::ChangeGameFocus ( int add,
int input_device = -1 )
private

Change game focus number.

Parameters
addnumber to add to focus number
input_deviceif equals -1, works globally on all devices, see INPUT_DEVICE_* values in constants.h
See also
HasGameFocus()

◆ DisableKey()

proto native void Input::DisableKey ( int key)
private

Disable key until end of frame.

Parameters
keyid of key, defined in KeyCode
GetGame().GetInput().DisableKey(KeyCode.KC_RETURN);
proto native CGame GetGame()
KeyCode
Definition EnSystem.c:157

◆ EnableMouseAndKeyboard()

proto native void Input::EnableMouseAndKeyboard ( bool enable)
private

Enable mouse and keyboard (on consoles)

◆ FillUnavailableDeviceArray()

void Input::FillUnavailableDeviceArray ( int device,
inout array< int > filler )
inlineprivate

Definition at line 210 of file input.c.

211 {
212 if (filler)
213 filler.Insert(device);
214 }

Referenced by AreAllAllowedInputDevicesActive().

◆ GetActionDesc()

proto int Input::GetActionDesc ( int action_index,
out string desc )
private

◆ GetActionGroupName()

proto int Input::GetActionGroupName ( int group_index,
out string name )
private

◆ GetActionGroupsCount()

proto native int Input::GetActionGroupsCount ( )
private

◆ GetActionGroupSize()

proto native int Input::GetActionGroupSize ( int group_index)
private

◆ GetCurrentInputDevice()

proto native EInputDeviceType Input::GetCurrentInputDevice ( )
private
Returns
Input device, with the last input event ('mouse and keyboard', 'controller' or 'unknown' if none input event was fired from the beginning).

◆ GetCurrentProfile()

proto native int Input::GetCurrentProfile ( )
private

gets currently selected profile

◆ GetCurrentProfileActionKeys()

proto native void Input::GetCurrentProfileActionKeys ( int action_index,
out TIntArray keys )
private

◆ GetDeviceName()

proto int Input::GetDeviceName ( int device_index,
out string name )
private

◆ GetDevicesCount()

proto native int Input::GetDevicesCount ( )
private

◆ GetEnterButton()

proto native GamepadButton Input::GetEnterButton ( )
private
Note
For PlayStation, Enter button in Asia territory is typically Circle button (B button), but in Europe and America it is Cross button (A button).
Returns
Button, which represent Enter/Accept button.

◆ GetGamepadList()

proto native void Input::GetGamepadList ( out array< int > gamepads)
private

Referenced by GetUserGamepad().

◆ GetGamepadThumbDirection()

proto bool Input::GetGamepadThumbDirection ( GamepadButton thumbButton,
out float angle,
out float value )
private

return true if was deflected button.

◆ GetGamepadUser()

proto void Input::GetGamepadUser ( int gamepad,
out BiosUser user )
private

◆ GetProfileName()

proto int Input::GetProfileName ( int profile_index,
out string name )
private

gets profile by index

◆ GetProfilesCount()

proto native int Input::GetProfilesCount ( )
private

gets profile by name

◆ GetUserGamepad()

int Input::GetUserGamepad ( BiosUser user)
inlineprivate

Definition at line 307 of file input.c.

308 {
311 for (int i = 0; i < gamepads.Count(); i++)
312 {
315 if (user == user2)
316 return gamepads[i];
317 }
318 return -1;
319 }
proto void GetGamepadUser(int gamepad, out BiosUser user)
proto native void GetGamepadList(out array< int > gamepads)

References GetGamepadList(), and GetGamepadUser().

◆ HasGameFocus()

proto native bool Input::HasGameFocus ( int input_device = -1)
private

Check if game should have focus.

Parameters
input_deviceif equals -1, checks all devices, see INPUT_DEVICE_* values in constants.h
Returns
true if focus number == 0, false otherwise

◆ IdentifyGamepad()

proto native void Input::IdentifyGamepad ( GamepadButton button)
private

the on OnGamepadIdentification callback will return the first gamepad where the button was pressed

Parameters
buttonthe button that needs to be pressed for the identification

◆ IsActiveGamepadSelected()

proto native bool Input::IsActiveGamepadSelected ( )
private

◆ IsAnyInputDeviceActive()

bool Input::IsAnyInputDeviceActive ( )
inlineprivate

returns true if 'Gamepad' or 'Mouse and Keyboard' is connected

Definition at line 156 of file input.c.

157 {
159 }

References IsActiveGamepadSelected(), IsKeyboardConnected(), and IsMouseConnected().

◆ IsDeviceEnabled()

proto native int Input::IsDeviceEnabled ( int device_index)
private

◆ IsDeviceXInput()

proto native int Input::IsDeviceXInput ( int device_index)
private

◆ IsEnabledMouseAndKeyboard()

proto native bool Input::IsEnabledMouseAndKeyboard ( )
private
Returns
state of support mouse and keyboard (on consoles)

Referenced by AreAllAllowedInputDevicesActive().

◆ IsEnabledMouseAndKeyboardEvenOnServer()

proto native bool Input::IsEnabledMouseAndKeyboardEvenOnServer ( )
private
Returns
state of support mouse and keyboard. If client playing on server where mouse and keyboard is disabled, then return false. (on consoles)

Referenced by AreAllAllowedInputDevicesActive().

◆ IsInactiveGamepadOrUserSelected()

bool Input::IsInactiveGamepadOrUserSelected ( int gamepad = -1)
inlineprivate

Definition at line 321 of file input.c.

322 {
323#ifdef PLATFORM_XBOX
324 return !IsActiveGamepadSelected();
325#endif
326#ifdef PLATFORM_PS4
329 return (user == GetGame().GetUserManager().GetSelectedUser());
330#endif
331 return false;
332 }

References GetGame(), GetGamepadUser(), and IsActiveGamepadSelected().

Referenced by OnGamepadDisconnected().

◆ IsKeyboardConnected()

◆ IsMouseConnected()

proto native bool Input::IsMouseConnected ( )
private
Returns
Console: Last state queried from the platform operating system for the active gamepad. PC: Always true.

Referenced by AreAllAllowedInputDevicesActive(), IsAnyInputDeviceActive(), and UpdateConnectedInputDeviceList().

◆ LocalDbl()

proto native bool Input::LocalDbl ( string action,
bool check_focus = true )
private

◆ LocalDbl_ID()

proto native bool Input::LocalDbl_ID ( int action,
bool check_focus = true )
private

Returns true just in frame, when double click action invoked (button double clicked)

Parameters
actionid of action, defined in 4_World/Classes/UserActionsComponent/_constants.c
check_focusif true and game is unfocused, returns 0; otherwise returns actual value
Returns
true if action was released in that frame, false otherwise
See also
LocalDbl()

◆ LocalHold()

proto native bool Input::LocalHold ( string action,
bool check_focus = true )
private

◆ LocalHold_ID()

proto native bool Input::LocalHold_ID ( int action,
bool check_focus = true )
private

Returns true just in frame, when hold action invoked (button is hold)

Parameters
actionid of action, defined in 4_World/Classes/UserActionsComponent/_constants.c
check_focusif true and game is unfocused, returns 0; otherwise returns actual value
Returns
true if action was released in that frame, false otherwise
See also
LocalHold()

◆ LocalPress()

proto native bool Input::LocalPress ( string action,
bool check_focus = true )
private

◆ LocalPress_ID()

proto native bool Input::LocalPress_ID ( int action,
bool check_focus = true )
private

Returns true just in frame, when action was invoked (button was pressed)

Note
if the input is limited (click, hold, doubleclick), 'Press' event is limited as well, and reacts to the limiter only! Otherwise it registeres the first event, usually 'press' (change of value from 0)
Parameters
actionid of action, defined in 4_World/Classes/UserActionsComponent/_constants.c
check_focusif true and game is unfocused, returns 0; otherwise returns actual value
Returns
true if action was invoked in that frame, false otherwise
See also
LocalPress()

◆ LocalRelease()

proto native bool Input::LocalRelease ( string action,
bool check_focus = true )
private

◆ LocalRelease_ID()

proto native bool Input::LocalRelease_ID ( int action,
bool check_focus = true )
private

Returns true just in frame, when release action happened (button was released)

Parameters
actionid of action, defined in 4_World/Classes/UserActionsComponent/_constants.c
check_focusif true and game is unfocused, returns 0; otherwise returns actual value
Returns
true if action was released in that frame, false otherwise
See also
LocalRelease()

◆ LocalValue()

proto native float Input::LocalValue ( string action,
bool check_focus = true )
private

◆ LocalValue_ID()

proto native float Input::LocalValue_ID ( int action,
bool check_focus = true )
private

Get action state.

Parameters
actionid of action, defined in 4_World/Classes/UserActionsComponent/_constants.c
check_focusif true and game is unfocused, returns 0; otherwise returns actual value
Returns
actual action state as float, for regular two state buttons returns 0 or 1, for analog buttons/axes returns value in interval <0, 1> with consideration of defined deadzones
See also
LocalValue()

◆ OnGamepadConnected()

void Input::OnGamepadConnected ( int gamepad)
inlineprivate

callback that is fired when a new gamepad is connected

Definition at line 243 of file input.c.

244 {
245#ifdef PLATFORM_PS4
248 if (user && user == GetGame().GetUserManager().GetSelectedUser())
249 {
251 if (GetGame().GetMission())
252 GetGame().GetMission().GetOnInputDeviceConnected().Invoke(EUAINPUT_DEVICE_CONTROLLER); //only for PS, xbox handles it on identification
253 }
254#endif
255
256#ifdef PLATFORM_XBOX
257 if (gamepad == g_Game.GetPreviousGamepad())
258 {
259 SelectActiveGamepad(g_Game.GetPreviousGamepad());
260 if (GetGame().GetMission())
261 GetGame().GetMission().GetOnInputDeviceConnected().Invoke(EUAINPUT_DEVICE_CONTROLLER); //only for PS, xbox handles it on identification
262 }
263#endif
264 }
proto native void SelectActiveGamepad(int gamepad)

References g_Game, GetGame(), GetGamepadUser(), and SelectActiveGamepad().

◆ OnGamepadDisconnected()

void Input::OnGamepadDisconnected ( int gamepad)
inlineprivate

callback that is fired when gamepad is disconnected

Definition at line 267 of file input.c.

268 {
270 {
272
273 if (!g_Game.IsLoading())
274 {
275 DayZLoadState state = g_Game.GetLoadState();
276 if (state != DayZLoadState.MAIN_MENU_START && state != DayZLoadState.MAIN_MENU_USER_SELECT)
277 {
278 if (GetGame().GetMission())
279 GetGame().GetMission().GetOnInputDeviceDisconnected().Invoke(EUAINPUT_DEVICE_CONTROLLER);
280 }
281 }
282 }
283 }
bool IsInactiveGamepadOrUserSelected(int gamepad=-1)
Definition input.c:321
void UpdateConnectedInputDeviceList()
currently lists only available Gamepad, Mouse, and Keyboard. Extendable as needed.
Definition input.c:217

References g_Game, GetGame(), IsInactiveGamepadOrUserSelected(), and UpdateConnectedInputDeviceList().

◆ OnGamepadIdentification()

void Input::OnGamepadIdentification ( int gamepad)
inlineprivate

callback that is fired when identification was requested

Definition at line 286 of file input.c.

287 {
288 if (gamepad > -1)
289 {
290 DayZLoadState state = g_Game.GetLoadState();
291
294 g_Game.SelectUser(gamepad);
295 g_Game.SetPreviousGamepad(gamepad);
296 if (state == DayZLoadState.MAIN_MENU_START || state == DayZLoadState.MAIN_MENU_USER_SELECT)
297 {
298 if (GetGame().GetMission())
299 GetGame().GetMission().Reset();
300 }
301
302 if (GetGame() && GetGame().GetMission() && GetGame().GetMission().GetOnInputDeviceConnected())
303 GetGame().GetMission().GetOnInputDeviceConnected().Invoke(EUAINPUT_DEVICE_CONTROLLER);
304 }
305 }

References g_Game, GetGame(), SelectActiveGamepad(), and UpdateConnectedInputDeviceList().

◆ OnKeyboardConnected()

void Input::OnKeyboardConnected ( )
inlineprivate

callback that is fired when keyboard is connected (PS: and assigned to the user) does not fire on PC - mouse/keyboard assumed to always be connected

Definition at line 362 of file input.c.

363 {
365 if (!g_Game.IsLoading() && GetGame().GetMission())
366 {
367 DayZLoadState state = g_Game.GetLoadState();
368 if (state != DayZLoadState.MAIN_MENU_START && state != DayZLoadState.MAIN_MENU_USER_SELECT)
369 GetGame().GetMission().GetOnInputDeviceConnected().Invoke(EUAINPUT_DEVICE_KEYBOARD);
370 }
371 }

References g_Game, GetGame(), and UpdateConnectedInputDeviceList().

◆ OnKeyboardDisconnected()

void Input::OnKeyboardDisconnected ( )
inlineprivate

callback that is fired when keyboard is disconnected does not fire on PC - mouse/keyboard assumed to always be connected

Definition at line 375 of file input.c.

376 {
378 if (!g_Game.IsLoading() && GetGame().GetMission())
379 {
380 DayZLoadState state = g_Game.GetLoadState();
381 if (state != DayZLoadState.MAIN_MENU_START && state != DayZLoadState.MAIN_MENU_USER_SELECT)
382 GetGame().GetMission().GetOnInputDeviceDisconnected().Invoke(EUAINPUT_DEVICE_KEYBOARD);
383 }
384 }

References g_Game, GetGame(), and UpdateConnectedInputDeviceList().

◆ OnLastInputDeviceChanged()

void Input::OnLastInputDeviceChanged ( EInputDeviceType inputDevice)
inlineprivate

called from code on different input device use

Definition at line 387 of file input.c.

388 {
389 if (GetGame().GetMission())
390 GetGame().GetMission().GetOnInputDeviceChanged().Invoke(inputDevice);
391 }

References GetGame().

◆ OnMouseConnected()

void Input::OnMouseConnected ( )
inlineprivate

callback that is fired when mouse is connected (PS: and assigned to the user) does not fire on PC - mouse/keyboard assumed to always be connected

Definition at line 336 of file input.c.

337 {
339 if (!g_Game.IsLoading() && GetGame().GetMission())
340 {
341 DayZLoadState state = g_Game.GetLoadState();
342 if (state != DayZLoadState.MAIN_MENU_START && state != DayZLoadState.MAIN_MENU_USER_SELECT)
343 GetGame().GetMission().GetOnInputDeviceConnected().Invoke(EUAINPUT_DEVICE_MOUSE);
344 }
345 }

References g_Game, GetGame(), and UpdateConnectedInputDeviceList().

◆ OnMouseDisconnected()

void Input::OnMouseDisconnected ( )
inlineprivate

callback that is fired when mouse is disconnected does not fire on PC - mouse/keyboard assumed to always be connected

Definition at line 349 of file input.c.

350 {
352 if (!g_Game.IsLoading() && GetGame().GetMission())
353 {
354 DayZLoadState state = g_Game.GetLoadState();
355 if (state != DayZLoadState.MAIN_MENU_START && state != DayZLoadState.MAIN_MENU_USER_SELECT)
356 GetGame().GetMission().GetOnInputDeviceDisconnected().Invoke(EUAINPUT_DEVICE_MOUSE);
357 }
358 }

References g_Game, GetGame(), and UpdateConnectedInputDeviceList().

◆ ResetActiveGamepad()

proto native void Input::ResetActiveGamepad ( )
private

clears active gamepad

◆ ResetGameFocus()

proto native void Input::ResetGameFocus ( int input_device = -1)
private

Reset game focus number (set to 0)

Parameters
input_deviceif equals -1, works globally on all devices, see INPUT_DEVICE_* values in constants.h
See also
HasGameFocus()

◆ SelectActiveGamepad()

proto native void Input::SelectActiveGamepad ( int gamepad)
private

◆ SetDeviceEnabled()

proto native void Input::SetDeviceEnabled ( int device_index,
bool enabled )
private

◆ SetProfile()

proto native int Input::SetProfile ( int index)
private

setting active profile

◆ UpdateConnectedInputDeviceList()

void Input::UpdateConnectedInputDeviceList ( )
inlineprivate

currently lists only available Gamepad, Mouse, and Keyboard. Extendable as needed.

Definition at line 217 of file input.c.

218 {
219 g_Game.GetConnectedInputDeviceList().Clear();
220
222 g_Game.GetConnectedInputDeviceList().Insert(EUAINPUT_DEVICE_CONTROLLER);
223 if (IsMouseConnected())
224 g_Game.GetConnectedInputDeviceList().Insert(EUAINPUT_DEVICE_MOUSE);
226 g_Game.GetConnectedInputDeviceList().Insert(EUAINPUT_DEVICE_KEYBOARD);
227 }

References g_Game, IsActiveGamepadSelected(), IsKeyboardConnected(), and IsMouseConnected().

Referenced by OnGamepadDisconnected(), OnGamepadIdentification(), OnKeyboardConnected(), OnKeyboardDisconnected(), OnMouseConnected(), and OnMouseDisconnected().


The documentation for this class was generated from the following file: