DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
input.c
См. документацию.
1
8
9//-----------------------------------------------------------------------------
10class Input
11{
12 // input locking
13
20 proto native void ChangeGameFocus(int add, int input_device = -1);
21
27 proto native void ResetGameFocus(int input_device = -1);
28
34 proto native bool HasGameFocus(int input_device = -1);
35
36 // actions
37 proto native int GetActionGroupsCount();
38 proto native int GetActionGroupSize(int group_index);
39 proto int GetActionGroupName(int group_index, out string name);
40 proto int GetActionDesc(int action_index, out string desc);
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
61 proto native bool LocalPress_ID(int action, bool check_focus = true);
62 proto native bool LocalPress(string action, bool check_focus = true);
63
71 proto native bool LocalRelease_ID(int action, bool check_focus = true);
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
101 proto native void DisableKey(int key);
102
104 proto native void EnableMouseAndKeyboard(bool enable);
106 proto native bool IsEnabledMouseAndKeyboard();
107
109 proto native void EnableGamepad(bool enable);
111 // NOTE: not actually supported, just keeping naming consistent.
112 // Required as we need to disable gamepad on windows when in the server browser to prevent
113 // the client from freezing on gamepad queries while refreshing the server list .
114 proto native bool IsEnabledGamepad();
120
125 proto native bool IsMouseConnected();
126 proto native bool IsKeyboardConnected();
127
129 proto native int GetCurrentProfile();
130 // gets currently selected profile keys for action
131 proto native void GetCurrentProfileActionKeys(int action_index, out TIntArray keys);
133 proto int GetProfileName(int profile_index, out string name);
135 proto native int GetProfilesCount();
137 proto native int SetProfile(int index);
138
139
140 // devices - joystick only!
141 proto native int GetDevicesCount();
142 proto int GetDeviceName(int device_index, out string name);
143 proto native int IsDeviceXInput(int device_index);
144 proto native int IsDeviceEnabled(int device_index);
145 proto native void SetDeviceEnabled(int device_index, bool enabled);
146
148 proto bool GetGamepadThumbDirection(GamepadButton thumbButton, out float angle, out float value);
149
151 proto native void ResetActiveGamepad();
152 proto native void SelectActiveGamepad(int gamepad);
153 proto native void GetGamepadList(out array<int> gamepads);
154 proto void GetGamepadUser(int gamepad, out BiosUser user);
159 proto native void IdentifyGamepad(GamepadButton button);
161 proto native bool IsActiveGamepadSelected();
162
168
173 bool AreAllAllowedInputDevicesActive(out array<int> unavailableDeviceList = null)
174 {
175 bool passed = true;
176 bool gamepad = IsActiveGamepadSelected();
177 bool mouse = IsMouseConnected();
178 bool keyboard = IsKeyboardConnected();
179 bool MnKEnabled;
180
181 if (g_Game.GetGameState() != DayZGameState.IN_GAME)
182 {
183 MnKEnabled = IsEnabledMouseAndKeyboard();
184 }
185 else if (g_Game.GetGameState() != DayZGameState.MAIN_MENU)
186 {
188 }
189 else
190 {
191 return true;
192 }
193
194 if (!MnKEnabled)
195 {
196 if (!gamepad)
197 {
198 passed = false;
199 FillUnavailableDeviceArray(EUAINPUT_DEVICE_CONTROLLER,unavailableDeviceList);
200 }
201 }
202 else
203 {
204 if (!gamepad)
205 {
206 if (!mouse)
207 {
208 passed = false;
209 FillUnavailableDeviceArray(EUAINPUT_DEVICE_MOUSE,unavailableDeviceList);
210 }
211 if (!keyboard)
212 {
213 passed = false;
214 FillUnavailableDeviceArray(EUAINPUT_DEVICE_KEYBOARD,unavailableDeviceList);
215 }
216
217 if (!passed)
218 {
219 FillUnavailableDeviceArray(EUAINPUT_DEVICE_CONTROLLER,unavailableDeviceList);
220 }
221 }
222 }
223 return passed;
224 }
225
226 void FillUnavailableDeviceArray(int device, inout array<int> filler)
227 {
228 if (filler)
229 {
230 filler.Insert(device);
231 }
232 }
233
236 {
237 g_Game.GetConnectedInputDeviceList().Clear();
238
240 g_Game.GetConnectedInputDeviceList().Insert(EUAINPUT_DEVICE_CONTROLLER);
241 if (IsMouseConnected())
242 g_Game.GetConnectedInputDeviceList().Insert(EUAINPUT_DEVICE_MOUSE);
244 g_Game.GetConnectedInputDeviceList().Insert(EUAINPUT_DEVICE_KEYBOARD);
245 }
246
252
259
261 void OnGamepadConnected(int gamepad)
262 {
263 if (!g_Game)
264 return;
265
266 #ifdef PLATFORM_PS4
267 BiosUser user;
268 GetGamepadUser( gamepad, user );
269 if (user && user == g_Game.GetUserManager().GetSelectedUser())
270 {
271 SelectActiveGamepad(gamepad);
272 Mission mission = g_Game.GetMission();
273 if (mission)
274 mission.GetOnInputDeviceConnected().Invoke(EUAINPUT_DEVICE_CONTROLLER); //only for PS, xbox handles it on identification
275 }
276 #endif
277
278 #ifdef PLATFORM_XBOX
279 if (gamepad == g_Game.GetPreviousGamepad())
280 {
281 SelectActiveGamepad(g_Game.GetPreviousGamepad());
282 Mission mission = g_Game.GetMission();
283 if (mission)
284 mission.GetOnInputDeviceConnected().Invoke(EUAINPUT_DEVICE_CONTROLLER); //only for PS, xbox handles it on identification
285 }
286 #endif
287 }
288
290 void OnGamepadDisconnected(int gamepad)
291 {
292 if (!g_Game)
293 return;
294
296 {
298
299 if (!g_Game.IsLoading())
300 {
301 DayZLoadState state = g_Game.GetLoadState();
302 if (state != DayZLoadState.MAIN_MENU_START && state != DayZLoadState.MAIN_MENU_USER_SELECT)
303 {
304 Mission mission = g_Game.GetMission();
305 if (mission)
306 mission.GetOnInputDeviceDisconnected().Invoke(EUAINPUT_DEVICE_CONTROLLER);
307 }
308 }
309 }
310 }
311
313 void OnGamepadIdentification(int gamepad)
314 {
315 if (!g_Game)
316 return;
317
318 if (gamepad > -1)
319 {
320 DayZLoadState state = g_Game.GetLoadState();
321
323 SelectActiveGamepad(gamepad);
324 g_Game.SelectUser(gamepad);
325 g_Game.SetPreviousGamepad(gamepad);
326 Mission mission = g_Game.GetMission();
327 if (state == DayZLoadState.MAIN_MENU_START || state == DayZLoadState.MAIN_MENU_USER_SELECT)
328 {
329 if (mission)
330 mission.Reset();
331 }
332
333 if (mission && mission.GetOnInputDeviceConnected())
334 mission.GetOnInputDeviceConnected().Invoke(EUAINPUT_DEVICE_CONTROLLER);
335 }
336 }
337
339 {
340 array<int> gamepads = new array<int>;
341 GetGamepadList( gamepads );
342 for( int i = 0; i < gamepads.Count(); i++ )
343 {
344 BiosUser user2;
345 GetGamepadUser( gamepads[i], user2 );
346 if( user == user2 )
347 return gamepads[i];
348 }
349 return -1;
350 }
351
352 bool IsInactiveGamepadOrUserSelected( int gamepad = -1 )
353 {
354 if (!g_Game)
355 return false;
356
357 #ifdef PLATFORM_CONSOLE
358 if (!g_Game.GetUserManager())
359 return false;
360 #ifdef PLATFORM_XBOX
361 return !IsActiveGamepadSelected();
362 #endif
363 #ifdef PLATFORM_PS4
364 BiosUser user;
365 GetGamepadUser( gamepad, user );
366 return (user == g_Game.GetUserManager().GetSelectedUser());
367 #endif
368 #endif
369 return false;
370 }
371
375 {
376 if (!g_Game)
377 return;
378
380 if (!g_Game.IsLoading() && g_Game.GetMission())
381 {
382 DayZLoadState state = g_Game.GetLoadState();
383 if (state != DayZLoadState.MAIN_MENU_START && state != DayZLoadState.MAIN_MENU_USER_SELECT)
384 {
385 g_Game.GetMission().GetOnInputDeviceConnected().Invoke(EUAINPUT_DEVICE_MOUSE);
386 }
387 }
388 }
389
393 {
394 if (!g_Game)
395 return;
396
398 if (!g_Game.IsLoading() && g_Game.GetMission())
399 {
400 DayZLoadState state = g_Game.GetLoadState();
401 if (state != DayZLoadState.MAIN_MENU_START && state != DayZLoadState.MAIN_MENU_USER_SELECT)
402 {
403 g_Game.GetMission().GetOnInputDeviceDisconnected().Invoke(EUAINPUT_DEVICE_MOUSE);
404 }
405 }
406 }
407
411 {
412 if (!g_Game)
413 return;
414
416 if (!g_Game.IsLoading() && g_Game.GetMission())
417 {
418 DayZLoadState state = g_Game.GetLoadState();
419 if (state != DayZLoadState.MAIN_MENU_START && state != DayZLoadState.MAIN_MENU_USER_SELECT)
420 {
421 g_Game.GetMission().GetOnInputDeviceConnected().Invoke(EUAINPUT_DEVICE_KEYBOARD);
422 }
423 }
424 }
425
429 {
430 if (!g_Game)
431 return;
432
434 if (!g_Game.IsLoading() && g_Game.GetMission())
435 {
436 DayZLoadState state = g_Game.GetLoadState();
437 if (state != DayZLoadState.MAIN_MENU_START && state != DayZLoadState.MAIN_MENU_USER_SELECT)
438 {
439 g_Game.GetMission().GetOnInputDeviceDisconnected().Invoke(EUAINPUT_DEVICE_KEYBOARD);
440 }
441 }
442 }
443
446 {
447 if (!g_Game)
448 return;
449
450 if (g_Game.GetMission())
451 {
452 g_Game.GetMission().GetOnInputDeviceChanged().Invoke(inputDevice);
453 }
454 }
455};
456
@ UNKNOWN
24 - Any other error. Can be returned from any call.
Определения BIOSErrorModule.c:56
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DayZGame g_Game
Определения DayZGame.c:3942
Mission mission
Определения DisplayStatus.c:28
@ CONTROLLER
Определения RadialMenu.c:4
Определения BiosUserManager.c:9
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
Определения input.c:261
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)
Определения input.c:226
proto native void ChangeGameFocus(int add, int input_device=-1)
Change game focus number.
bool IsInactiveGamepadOrUserSelected(int gamepad=-1)
Определения input.c:352
void UpdateConnectedInputDeviceList()
currently lists only available Gamepad, Mouse, and Keyboard. Extendable as needed.
Определения input.c:235
proto int GetActionGroupName(int group_index, out string name)
proto native int GetDevicesCount()
proto native void GetGamepadList(out array< int > gamepads)
proto native void EnableGamepad(bool enable)
Enable gamepad (on PC)
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,...
Определения input.c:173
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
Определения input.c:290
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
Определения input.c:164
int GetUserGamepad(BiosUser user)
Определения input.c:338
void OnLastInputDeviceChanged(EInputDeviceType inputDevice)
called from code on different input device use
Определения input.c:445
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()
Определения input.c:428
proto native void IdentifyGamepad(GamepadButton button)
the on OnGamepadIdentification callback will return the first gamepad where the button was pressed
void OnKeyboardConnected()
Определения input.c:410
proto native bool IsEnabledMouseAndKeyboard()
proto native bool IsEnabledMouseAndKeyboardEvenOnServer()
proto native int GetCurrentProfile()
gets currently selected profile
void OnMouseConnected()
Определения input.c:374
proto native bool LocalRelease(string action, bool check_focus=true)
void OnMouseDisconnected()
Определения input.c:392
void OnGamepadIdentification(int gamepad)
callback that is fired when identification was requested
Определения input.c:313
proto native bool IsEnabledGamepad()
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)
Определения input.c:11
Mission class.
Определения gameplay.c:686
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
array< int > TIntArray
Определения EnScript.c:714
GamepadButton
Определения EnSystem.c:341
EInputDeviceType
Определения input.c:3
@ MOUSE_AND_KEYBOARD
Определения input.c:5