DayZ 1.28
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 == GetGame().GetUserManager().GetSelectedUser())
270 {
271 SelectActiveGamepad(gamepad);
272 if (GetGame().GetMission())
273 GetGame().GetMission().GetOnInputDeviceConnected().Invoke(EUAINPUT_DEVICE_CONTROLLER); //only for PS, xbox handles it on identification
274 }
275 #endif
276
277 #ifdef PLATFORM_XBOX
278 if (gamepad == g_Game.GetPreviousGamepad())
279 {
280 SelectActiveGamepad(g_Game.GetPreviousGamepad());
281 if (GetGame().GetMission())
282 GetGame().GetMission().GetOnInputDeviceConnected().Invoke(EUAINPUT_DEVICE_CONTROLLER); //only for PS, xbox handles it on identification
283 }
284 #endif
285 }
286
288 void OnGamepadDisconnected(int gamepad)
289 {
290 if (!g_Game)
291 return;
292
294 {
296
297 if (!g_Game.IsLoading())
298 {
299 DayZLoadState state = g_Game.GetLoadState();
300 if (state != DayZLoadState.MAIN_MENU_START && state != DayZLoadState.MAIN_MENU_USER_SELECT)
301 {
302 if (GetGame().GetMission())
303 GetGame().GetMission().GetOnInputDeviceDisconnected().Invoke(EUAINPUT_DEVICE_CONTROLLER);
304 }
305 }
306 }
307 }
308
310 void OnGamepadIdentification(int gamepad)
311 {
312 if (!g_Game)
313 return;
314
315 if (gamepad > -1)
316 {
317 DayZLoadState state = g_Game.GetLoadState();
318
320 SelectActiveGamepad(gamepad);
321 g_Game.SelectUser(gamepad);
322 g_Game.SetPreviousGamepad(gamepad);
323 if (state == DayZLoadState.MAIN_MENU_START || state == DayZLoadState.MAIN_MENU_USER_SELECT)
324 {
325 if (GetGame().GetMission())
327 }
328
329 if (GetGame() && GetGame().GetMission() && GetGame().GetMission().GetOnInputDeviceConnected())
330 GetGame().GetMission().GetOnInputDeviceConnected().Invoke(EUAINPUT_DEVICE_CONTROLLER);
331 }
332 }
333
335 {
336 array<int> gamepads = new array<int>;
337 GetGamepadList( gamepads );
338 for( int i = 0; i < gamepads.Count(); i++ )
339 {
340 BiosUser user2;
341 GetGamepadUser( gamepads[i], user2 );
342 if( user == user2 )
343 return gamepads[i];
344 }
345 return -1;
346 }
347
348 bool IsInactiveGamepadOrUserSelected( int gamepad = -1 )
349 {
350 if (!g_Game)
351 return false;
352
353 #ifdef PLATFORM_CONSOLE
354 if (!GetGame().GetUserManager())
355 return false;
356 #ifdef PLATFORM_XBOX
357 return !IsActiveGamepadSelected();
358 #endif
359 #ifdef PLATFORM_PS4
360 BiosUser user;
361 GetGamepadUser( gamepad, user );
362 return (user == GetGame().GetUserManager().GetSelectedUser());
363 #endif
364 #endif
365 return false;
366 }
367
371 {
372 if (!g_Game)
373 return;
374
376 if (!g_Game.IsLoading() && GetGame().GetMission())
377 {
378 DayZLoadState state = g_Game.GetLoadState();
379 if (state != DayZLoadState.MAIN_MENU_START && state != DayZLoadState.MAIN_MENU_USER_SELECT)
380 {
381 GetGame().GetMission().GetOnInputDeviceConnected().Invoke(EUAINPUT_DEVICE_MOUSE);
382 }
383 }
384 }
385
389 {
390 if (!g_Game)
391 return;
392
394 if (!g_Game.IsLoading() && GetGame().GetMission())
395 {
396 DayZLoadState state = g_Game.GetLoadState();
397 if (state != DayZLoadState.MAIN_MENU_START && state != DayZLoadState.MAIN_MENU_USER_SELECT)
398 {
399 GetGame().GetMission().GetOnInputDeviceDisconnected().Invoke(EUAINPUT_DEVICE_MOUSE);
400 }
401 }
402 }
403
407 {
408 if (!g_Game)
409 return;
410
412 if (!g_Game.IsLoading() && GetGame().GetMission())
413 {
414 DayZLoadState state = g_Game.GetLoadState();
415 if (state != DayZLoadState.MAIN_MENU_START && state != DayZLoadState.MAIN_MENU_USER_SELECT)
416 {
417 GetGame().GetMission().GetOnInputDeviceConnected().Invoke(EUAINPUT_DEVICE_KEYBOARD);
418 }
419 }
420 }
421
425 {
426 if (!g_Game)
427 return;
428
430 if (!g_Game.IsLoading() && GetGame().GetMission())
431 {
432 DayZLoadState state = g_Game.GetLoadState();
433 if (state != DayZLoadState.MAIN_MENU_START && state != DayZLoadState.MAIN_MENU_USER_SELECT)
434 {
435 GetGame().GetMission().GetOnInputDeviceDisconnected().Invoke(EUAINPUT_DEVICE_KEYBOARD);
436 }
437 }
438 }
439
442 {
443 if (!g_Game)
444 return;
445
446 if (GetGame().GetMission())
447 {
449 }
450 }
451};
452
@ 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:3868
@ CONTROLLER
Определения RadialMenu.c:4
Определения BiosUserManager.c:9
proto native Mission GetMission()
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:348
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:288
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:334
void OnLastInputDeviceChanged(EInputDeviceType inputDevice)
called from code on different input device use
Определения input.c:441
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:424
proto native void IdentifyGamepad(GamepadButton button)
the on OnGamepadIdentification callback will return the first gamepad where the button was pressed
void OnKeyboardConnected()
Определения input.c:406
proto native bool IsEnabledMouseAndKeyboard()
proto native bool IsEnabledMouseAndKeyboardEvenOnServer()
proto native int GetCurrentProfile()
gets currently selected profile
void OnMouseConnected()
Определения input.c:370
proto native bool LocalRelease(string action, bool check_focus=true)
void OnMouseDisconnected()
Определения input.c:388
void OnGamepadIdentification(int gamepad)
callback that is fired when identification was requested
Определения input.c:310
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
ScriptInvoker GetOnInputDeviceChanged()
Определения gameplay.c:851
void Reset()
Определения gameplay.c:717
ScriptInvoker GetOnInputDeviceDisconnected()
Определения gameplay.c:875
ScriptInvoker GetOnInputDeviceConnected()
Определения gameplay.c:867
proto void Invoke(void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
invoke call on all inserted methods with given arguments
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
array< int > TIntArray
Определения EnScript.c:711
GamepadButton
Определения EnSystem.c:341
EInputDeviceType
Определения input.c:3
@ MOUSE_AND_KEYBOARD
Определения input.c:5