Page MenuHomeFeedback Tracker

[Feature request] Way to detect currenty pressed actions
New, NormalPublic

Description

Currently there is no way to detect which input actions were pressed. We have only inputAction command but here you need to know the name of the action you wish to check. Having command to return currently running input actions would make editing a bit easier.
Name suggestions:
currentActions,inputActions,pressedActions,activeActions

Syntax:
currentActions;//returns array of strings like ["watch"] ,when pressing 2xO ["watchToggle"] and so on. When having mods binded to the same action ["watch","moddedAction1"]

Thank you for consideration.

Details

Severity
Feature
Resolution
Open
Reproducibility
Unable To Reproduce
Operating System
Windows 10 x64
Category
Scripting
Additional Information

Here is the simple code i'm using now to restrict player actions which works fine.

private _allowedActions = ["ingamePause","lookAround","personView","nightVision","toggleRaiseWeapon"];
private _display = findDisplay 46;
soldierXXXX_RestrictMovement_allowedKeys = [];
{soldierXXXX_RestrictMovement_allowedKeys append (actionKeys _x);} forEach _allowedActions;
private _displayKeyDown = _display displayAddEventhandler["KeyDown",{
params ["_displayOrControl", "_key", "_shift", "_ctrl", "_alt"];
private _rewriteKey = TRUE;
if (_key == 1) then {_rewriteKey = FALSE;};//pressed ESC key always allowed !
if (_key in soldierXXXX_RestrictMovement_allowedKeys) then {_rewriteKey = FALSE;};
if (_alt) then {
_rewriteKey = TRUE;
if (_key in soldierXXXX_RestrictMovement_allowedKeys) then {_rewriteKey = FALSE;};//makes sure action cannot be allowed when alt is pressed
};
if (inputAction "toggleRaiseWeapon" > 0 AND {(actionKeys "toggleRaiseWeapon" arrayIntersect soldierXXXX_RestrictMovement_allowedKeys) isNotEqualTo []}) then {_rewriteKey = FALSE;};//allow player to rise/lower weapon double clicks are not allowed otherwise
_rewriteKey
}];

How i would imagine the code with new command

private _display = findDisplay 46;
soldierXXXX_RestrictMovement_allowedKeys = ["ingamePause","lookAround","personView","nightVision","toggleRaiseWeapon"];
private _displayKeyDown = _display displayAddEventhandler["KeyDown",{
params ["_displayOrControl", "_key", "_shift", "_ctrl", "_alt"];
private _rewriteKey = TRUE;
if (_key == 1) then {_rewriteKey = FALSE;};//pressed ESC key always allowed !
if (currentActions isNotEqualTo [] AND {(count (currentActions arrayIntersect soldierXXXX_RestrictMovement_allowedKeys)) > 0}) then {_rewriteKey = FALSE;};//no need to check for alt pressed or double clicks because command detects which actions are running automatically
_rewriteKey
}];

Event Timeline