-
Notifications
You must be signed in to change notification settings - Fork 737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Common - Add function to check if action with modifier being pressed #9594
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,48 @@ | ||||||
#include "..\script_component.hpp" | ||||||
#include "\a3\ui_f\hpp\defineDIKCodes.inc" | ||||||
/* | ||||||
* Author: PabstMirror | ||||||
* Checks if actionName is being pressed (from ui "KeyDown" event data) | ||||||
* Limitations: Does not check joysticks, different left/right modifier keys, double tap binds | ||||||
* | ||||||
* Arguments: | ||||||
* 0: Action Name <STRING> | ||||||
* 1: Key <NUMBER> | ||||||
* 2: Shift <BOOL> | ||||||
* 3: Ctrl <BOOL> | ||||||
* 4: Alt <BOOL> | ||||||
* | ||||||
* Return Value: | ||||||
* <BOOL> | ||||||
* | ||||||
* Example: | ||||||
* ["Watch", 24, false, false, false] call ace_common_fnc_actionKeyPressed | ||||||
* ["TeamSwitch", 22, false, true, false] call ace_common_fnc_actionKeyPressed | ||||||
* | ||||||
* Public: No | ||||||
*/ | ||||||
|
||||||
params [["_actionName", "", [""]], ["_key", -1, [0]], ["_shift", false, [false]], ["_ctrl", false, [false]], ["_alt", false, [false]]]; | ||||||
|
||||||
private _return = false; | ||||||
private _actionKeys = actionKeysEx _actionName; | ||||||
{ | ||||||
_x params [["_mainKeyArray", []], ["_comboKeyArray", []], ["_isDoubleTap", false]]; | ||||||
_mainKeyArray params ["_mainDik", "_mainDevice"]; | ||||||
if ( | ||||||
(_mainDik == _key) | ||||||
&& {_mainDevice == "KEYBOARD"} | ||||||
&& (if (_comboKeyArray isEqualTo []) then { | ||||||
(!_shift) && {!_ctrl} && {!_alt} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And surely the lazy eval doesn't save anything with such a cheap check.
Suggested change
|
||||||
} else { | ||||||
_comboKeyArray params ["_comboDik", "_comboDevice"]; | ||||||
(_comboDevice == "KEYBOARD") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
If the correct casing is always returned. |
||||||
&& {(_shift) isEqualTo (_comboDik in [DIK_LSHIFT,DIK_RSHIFT])} | ||||||
&& {(_ctrl) isEqualTo (_comboDik in [DIK_LCONTROL,DIK_RCONTROL])} | ||||||
&& {(_alt) isEqualTo (_comboDik in [DIK_LALT, DIK_RALT])} | ||||||
}) | ||||||
&& {!_isDoubleTap} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
And surely the lazy eval doesn't save anything with such a cheap check. |
||||||
) exitWith { _return = true }; | ||||||
} forEach _actionKeys; | ||||||
|
||||||
_return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the correct casing is always returns.
And surely the lazy eval doesn't save anything with such a cheap check.