DayZ 1.24
Loading...
Searching...
No Matches
input.c
Go to the documentation of this file.
1
8
9//-----------------------------------------------------------------------------
10class Input
11{
12 // input locking
13
21
28
35
36 // actions
41
42 // getting action state
50 proto native float LocalValue_ID(int action, bool check_focus = true);
51 proto native float LocalValue(string action, bool check_focus = true);
52
62 proto native bool LocalPress(string action, bool check_focus = true);
63
72 proto native bool LocalRelease(string action, bool check_focus = true);
73
81 proto native bool LocalHold_ID(int action, bool check_focus = true);
82 proto native bool LocalHold(string action, bool check_focus = true);
83
91 proto native bool LocalDbl_ID(int action, bool check_focus = true);
92 proto native bool LocalDbl(string action, bool check_focus = true);
93
102
112
119
122 // gets currently selected profile keys for action
130
131
132 // devices - joystick only!
138
141
154
160
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 }
209
211 {
212 if (filler)
213 filler.Insert(device);
214 }
215
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 }
228
234
241
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 }
265
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 }
284
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 }
306
308 {
311 for (int i = 0; i < gamepads.Count(); i++)
312 {
315 if (user == user2)
316 return gamepads[i];
317 }
318 return -1;
319 }
320
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 }
333
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 }
346
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 }
359
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 }
372
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 }
385
388 {
389 if (GetGame().GetMission())
390 GetGame().GetMission().GetOnInputDeviceChanged().Invoke(inputDevice);
391 }
392};
393
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DayZGame g_Game
Definition DayZGame.c:3528
Definition input.c:11
proto native int GetActionGroupSize(int group_index)
proto native void DisableKey(int key)
Disable key until end of frame.
proto void GetGamepadUser(int gamepad, out BiosUser user)
void OnGamepadConnected(int gamepad)
callback that is fired when a new gamepad is connected
Definition input.c:243
proto native GamepadButton GetEnterButton()
proto native EInputDeviceType GetCurrentInputDevice()
proto native bool LocalPress(string action, bool check_focus=true)
proto native int GetProfilesCount()
gets profile by name
proto native void EnableMouseAndKeyboard(bool enable)
Enable mouse and keyboard (on consoles)
proto int GetDeviceName(int device_index, out string name)
proto native void ResetActiveGamepad()
clears active gamepad
proto bool GetGamepadThumbDirection(GamepadButton thumbButton, out float angle, out float value)
return true if was deflected button.
proto native bool LocalHold(string action, bool check_focus=true)
proto native void SelectActiveGamepad(int gamepad)
proto native int SetProfile(int index)
setting active profile
proto native int GetActionGroupsCount()
void FillUnavailableDeviceArray(int device, inout array< int > filler)
Definition input.c:210
proto native void ChangeGameFocus(int add, int input_device=-1)
Change game focus number.
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
proto int GetActionGroupName(int group_index, out string name)
proto native int GetDevicesCount()
proto native void GetGamepadList(out array< int > gamepads)
proto native bool IsKeyboardConnected()
proto native bool LocalRelease_ID(int action, bool check_focus=true)
Returns true just in frame, when release action happened (button was released)
bool AreAllAllowedInputDevicesActive(out array< int > unavailableDeviceList=null)
returns true if 'Gamepad' or if 'Mouse/Keyboard' control is allowed locally and on server,...
Definition input.c:165
proto native bool LocalDbl(string action, bool check_focus=true)
proto int GetActionDesc(int action_index, out string desc)
void OnGamepadDisconnected(int gamepad)
callback that is fired when gamepad is disconnected
Definition input.c:267
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 float LocalValue(string action, bool check_focus=true)
bool IsAnyInputDeviceActive()
returns true if 'Gamepad' or 'Mouse and Keyboard' is connected
Definition input.c:156
int GetUserGamepad(BiosUser user)
Definition input.c:307
void OnLastInputDeviceChanged(EInputDeviceType inputDevice)
called from code on different input device use
Definition input.c:387
proto native void SetDeviceEnabled(int device_index, bool enabled)
proto native bool IsActiveGamepadSelected()
returns true if there is an active gamepad selected.
proto native bool HasGameFocus(int input_device=-1)
Check if game should have focus.
proto int GetProfileName(int profile_index, out string name)
gets profile by index
void OnKeyboardDisconnected()
Definition input.c:375
proto native void IdentifyGamepad(GamepadButton button)
the on OnGamepadIdentification callback will return the first gamepad where the button was pressed
void OnKeyboardConnected()
Definition input.c:362
proto native bool IsEnabledMouseAndKeyboard()
proto native bool IsEnabledMouseAndKeyboardEvenOnServer()
proto native int GetCurrentProfile()
gets currently selected profile
void OnMouseConnected()
Definition input.c:336
proto native bool LocalRelease(string action, bool check_focus=true)
void OnMouseDisconnected()
Definition input.c:349
void OnGamepadIdentification(int gamepad)
callback that is fired when identification was requested
Definition input.c:286
proto native void GetCurrentProfileActionKeys(int action_index, out TIntArray keys)
proto native void ResetGameFocus(int input_device=-1)
Reset game focus number (set to 0)
proto native int IsDeviceXInput(int device_index)
proto native bool IsMouseConnected()
proto native float LocalValue_ID(int action, bool check_focus=true)
Get action state.
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 int IsDeviceEnabled(int device_index)
proto native bool LocalPress_ID(int action, bool check_focus=true)
Returns true just in frame, when action was invoked (button was pressed)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
GamepadButton
Definition EnSystem.c:341
EInputDeviceType
Definition input.c:3
@ CONTROLLER
Definition input.c:6
@ UNKNOWN
Definition input.c:4
@ MOUSE_AND_KEYBOARD
Definition input.c:5