DayZ 1.27
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();
112
117 proto native bool IsMouseConnected();
118 proto native bool IsKeyboardConnected();
119
121 proto native int GetCurrentProfile();
122 // gets currently selected profile keys for action
123 proto native void GetCurrentProfileActionKeys(int action_index, out TIntArray keys);
125 proto int GetProfileName(int profile_index, out string name);
127 proto native int GetProfilesCount();
129 proto native int SetProfile(int index);
130
131
132 // devices - joystick only!
133 proto native int GetDevicesCount();
134 proto int GetDeviceName(int device_index, out string name);
135 proto native int IsDeviceXInput(int device_index);
136 proto native int IsDeviceEnabled(int device_index);
137 proto native void SetDeviceEnabled(int device_index, bool enabled);
138
140 proto bool GetGamepadThumbDirection(GamepadButton thumbButton, out float angle, out float value);
141
143 proto native void ResetActiveGamepad();
144 proto native void SelectActiveGamepad(int gamepad);
145 proto native void GetGamepadList(out array<int> gamepads);
146 proto void GetGamepadUser(int gamepad, out BiosUser user);
151 proto native void IdentifyGamepad(GamepadButton button);
153 proto native bool IsActiveGamepadSelected();
154
160
165 bool AreAllAllowedInputDevicesActive(out array<int> unavailableDeviceList = null)
166 {
167 bool passed = true;
168 bool gamepad = IsActiveGamepadSelected();
169 bool mouse = IsMouseConnected();
170 bool keyboard = IsKeyboardConnected();
171 bool MnKEnabled;
172
173 if (g_Game.GetGameState() != DayZGameState.IN_GAME)
174 {
175 MnKEnabled = IsEnabledMouseAndKeyboard();
176 }
177 else if (g_Game.GetGameState() != DayZGameState.MAIN_MENU)
178 {
180 }
181 else
182 {
183 return true;
184 }
185
186 if (!MnKEnabled)
187 {
188 if (!gamepad)
189 {
190 passed = false;
191 FillUnavailableDeviceArray(EUAINPUT_DEVICE_CONTROLLER,unavailableDeviceList);
192 }
193 }
194 else
195 {
196 if (!gamepad)
197 {
198 if (!mouse)
199 {
200 passed = false;
201 FillUnavailableDeviceArray(EUAINPUT_DEVICE_MOUSE,unavailableDeviceList);
202 }
203 if (!keyboard)
204 {
205 passed = false;
206 FillUnavailableDeviceArray(EUAINPUT_DEVICE_KEYBOARD,unavailableDeviceList);
207 }
208
209 if (!passed)
210 {
211 FillUnavailableDeviceArray(EUAINPUT_DEVICE_CONTROLLER,unavailableDeviceList);
212 }
213 }
214 }
215 return passed;
216 }
217
218 void FillUnavailableDeviceArray(int device, inout array<int> filler)
219 {
220 if (filler)
221 {
222 filler.Insert(device);
223 }
224 }
225
228 {
229 g_Game.GetConnectedInputDeviceList().Clear();
230
232 g_Game.GetConnectedInputDeviceList().Insert(EUAINPUT_DEVICE_CONTROLLER);
233 if (IsMouseConnected())
234 g_Game.GetConnectedInputDeviceList().Insert(EUAINPUT_DEVICE_MOUSE);
236 g_Game.GetConnectedInputDeviceList().Insert(EUAINPUT_DEVICE_KEYBOARD);
237 }
238
244
251
253 void OnGamepadConnected(int gamepad)
254 {
255 if (!g_Game)
256 return;
257
258 #ifdef PLATFORM_PS4
259 BiosUser user;
260 GetGamepadUser( gamepad, user );
261 if (user && user == GetGame().GetUserManager().GetSelectedUser())
262 {
263 SelectActiveGamepad(gamepad);
264 if (GetGame().GetMission())
265 GetGame().GetMission().GetOnInputDeviceConnected().Invoke(EUAINPUT_DEVICE_CONTROLLER); //only for PS, xbox handles it on identification
266 }
267 #endif
268
269 #ifdef PLATFORM_XBOX
270 if (gamepad == g_Game.GetPreviousGamepad())
271 {
272 SelectActiveGamepad(g_Game.GetPreviousGamepad());
273 if (GetGame().GetMission())
274 GetGame().GetMission().GetOnInputDeviceConnected().Invoke(EUAINPUT_DEVICE_CONTROLLER); //only for PS, xbox handles it on identification
275 }
276 #endif
277 }
278
280 void OnGamepadDisconnected(int gamepad)
281 {
282 if (!g_Game)
283 return;
284
286 {
288
289 if (!g_Game.IsLoading())
290 {
291 DayZLoadState state = g_Game.GetLoadState();
292 if (state != DayZLoadState.MAIN_MENU_START && state != DayZLoadState.MAIN_MENU_USER_SELECT)
293 {
294 if (GetGame().GetMission())
295 GetGame().GetMission().GetOnInputDeviceDisconnected().Invoke(EUAINPUT_DEVICE_CONTROLLER);
296 }
297 }
298 }
299 }
300
302 void OnGamepadIdentification(int gamepad)
303 {
304 if (!g_Game)
305 return;
306
307 if (gamepad > -1)
308 {
309 DayZLoadState state = g_Game.GetLoadState();
310
312 SelectActiveGamepad(gamepad);
313 g_Game.SelectUser(gamepad);
314 g_Game.SetPreviousGamepad(gamepad);
315 if (state == DayZLoadState.MAIN_MENU_START || state == DayZLoadState.MAIN_MENU_USER_SELECT)
316 {
317 if (GetGame().GetMission())
319 }
320
321 if (GetGame() && GetGame().GetMission() && GetGame().GetMission().GetOnInputDeviceConnected())
322 GetGame().GetMission().GetOnInputDeviceConnected().Invoke(EUAINPUT_DEVICE_CONTROLLER);
323 }
324 }
325
327 {
328 array<int> gamepads = new array<int>;
329 GetGamepadList( gamepads );
330 for( int i = 0; i < gamepads.Count(); i++ )
331 {
332 BiosUser user2;
333 GetGamepadUser( gamepads[i], user2 );
334 if( user == user2 )
335 return gamepads[i];
336 }
337 return -1;
338 }
339
340 bool IsInactiveGamepadOrUserSelected( int gamepad = -1 )
341 {
342 if (!g_Game)
343 return false;
344
345 #ifdef PLATFORM_CONSOLE
346 if (!GetGame().GetUserManager())
347 return false;
348 #ifdef PLATFORM_XBOX
349 return !IsActiveGamepadSelected();
350 #endif
351 #ifdef PLATFORM_PS4
352 BiosUser user;
353 GetGamepadUser( gamepad, user );
354 return (user == GetGame().GetUserManager().GetSelectedUser());
355 #endif
356 #endif
357 return false;
358 }
359
363 {
364 if (!g_Game)
365 return;
366
368 if (!g_Game.IsLoading() && GetGame().GetMission())
369 {
370 DayZLoadState state = g_Game.GetLoadState();
371 if (state != DayZLoadState.MAIN_MENU_START && state != DayZLoadState.MAIN_MENU_USER_SELECT)
372 {
373 GetGame().GetMission().GetOnInputDeviceConnected().Invoke(EUAINPUT_DEVICE_MOUSE);
374 }
375 }
376 }
377
381 {
382 if (!g_Game)
383 return;
384
386 if (!g_Game.IsLoading() && GetGame().GetMission())
387 {
388 DayZLoadState state = g_Game.GetLoadState();
389 if (state != DayZLoadState.MAIN_MENU_START && state != DayZLoadState.MAIN_MENU_USER_SELECT)
390 {
391 GetGame().GetMission().GetOnInputDeviceDisconnected().Invoke(EUAINPUT_DEVICE_MOUSE);
392 }
393 }
394 }
395
399 {
400 if (!g_Game)
401 return;
402
404 if (!g_Game.IsLoading() && GetGame().GetMission())
405 {
406 DayZLoadState state = g_Game.GetLoadState();
407 if (state != DayZLoadState.MAIN_MENU_START && state != DayZLoadState.MAIN_MENU_USER_SELECT)
408 {
409 GetGame().GetMission().GetOnInputDeviceConnected().Invoke(EUAINPUT_DEVICE_KEYBOARD);
410 }
411 }
412 }
413
417 {
418 if (!g_Game)
419 return;
420
422 if (!g_Game.IsLoading() && GetGame().GetMission())
423 {
424 DayZLoadState state = g_Game.GetLoadState();
425 if (state != DayZLoadState.MAIN_MENU_START && state != DayZLoadState.MAIN_MENU_USER_SELECT)
426 {
427 GetGame().GetMission().GetOnInputDeviceDisconnected().Invoke(EUAINPUT_DEVICE_KEYBOARD);
428 }
429 }
430 }
431
434 {
435 if (!g_Game)
436 return;
437
438 if (GetGame().GetMission())
439 {
441 }
442 }
443};
444
@ 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:253
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:218
proto native void ChangeGameFocus(int add, int input_device=-1)
Change game focus number.
bool IsInactiveGamepadOrUserSelected(int gamepad=-1)
Определения input.c:340
void UpdateConnectedInputDeviceList()
currently lists only available Gamepad, Mouse, and Keyboard. Extendable as needed.
Определения input.c:227
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,...
Определения 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
Определения input.c:280
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:156
int GetUserGamepad(BiosUser user)
Определения input.c:326
void OnLastInputDeviceChanged(EInputDeviceType inputDevice)
called from code on different input device use
Определения input.c:433
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:416
proto native void IdentifyGamepad(GamepadButton button)
the on OnGamepadIdentification callback will return the first gamepad where the button was pressed
void OnKeyboardConnected()
Определения input.c:398
proto native bool IsEnabledMouseAndKeyboard()
proto native bool IsEnabledMouseAndKeyboardEvenOnServer()
proto native int GetCurrentProfile()
gets currently selected profile
void OnMouseConnected()
Определения input.c:362
proto native bool LocalRelease(string action, bool check_focus=true)
void OnMouseDisconnected()
Определения input.c:380
void OnGamepadIdentification(int gamepad)
callback that is fired when identification was requested
Определения input.c:302
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:687
GamepadButton
Определения EnSystem.c:341
EInputDeviceType
Определения input.c:3
@ MOUSE_AND_KEYBOARD
Определения input.c:5