Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

PabstMirror
Copy link
Contributor

ref https://community.bistudio.com/wiki/actionKeysEx

e.g. "teamSwitch" key is (ctrl + U)
actionKeys "TeamSwitch" = [4.87784e+008]
won't match the input from keyDown EH

not sure if there is an easier way?
addUserActionEventHandler wasn't firing on the display

@johnb432
Copy link
Contributor

I was working on something to add keycombo support some time ago which include support for double tap keys, I'll bring it up to date and post it.

_mainKeyArray params ["_mainDik", "_mainDevice"];
if (
(_mainDik == _key)
&& {_mainDevice == "KEYBOARD"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
&& {_mainDevice == "KEYBOARD"}
&& _mainDevice isEqualTo "KEYBOARD"

If the correct casing is always returns.

And surely the lazy eval doesn't save anything with such a cheap check.

(_mainDik == _key)
&& {_mainDevice == "KEYBOARD"}
&& (if (_comboKeyArray isEqualTo []) then {
(!_shift) && {!_ctrl} && {!_alt}
Copy link
Contributor

Choose a reason for hiding this comment

The 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
(!_shift) && {!_ctrl} && {!_alt}
!_shift && !_ctrl && !_alt

(!_shift) && {!_ctrl} && {!_alt}
} else {
_comboKeyArray params ["_comboDik", "_comboDevice"];
(_comboDevice == "KEYBOARD")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(_comboDevice == "KEYBOARD")
(_comboDevice isEqualTo "KEYBOARD")

If the correct casing is always returned.

&& {(_ctrl) isEqualTo (_comboDik in [DIK_LCONTROL,DIK_RCONTROL])}
&& {(_alt) isEqualTo (_comboDik in [DIK_LALT, DIK_RALT])}
})
&& {!_isDoubleTap}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
&& {!_isDoubleTap}
&& !_isDoubleTap

And surely the lazy eval doesn't save anything with such a cheap check.

@johnb432
Copy link
Contributor

@PabstMirror I brought my old version up to date.

https://github.com/acemod/ACE3/blob/086b8821d37efc78bf34142142e5a324cc826502/addons/common/functions/fnc_disableUserInput.sqf

It can handle close to all if not all possible keycombos. I have tested various keybinds and actions, but not all.
The downside of my suggested version is that it can't handle the Escape key, as the KeyUp EH does not trigger for the Escape key (at least it doesn't in my tests).
I tried to make my suggestion more modular, as in make a different function with separate EH. However, that did not work, as, despite adding the KeyDown EH later in FUNC(disableUserInput), the EH added in the different function did not trigger.


I also did several drive-by changes, such as taking 3DEN context into the button texts and replacing the string-codes with toString and code.

@johnb432
Copy link
Contributor

johnb432 commented Jan 7, 2024

Closed in favor of #9659, can be reopened if necessary.

@johnb432 johnb432 closed this Jan 7, 2024
@PabstMirror PabstMirror deleted the actionKeySex branch January 7, 2024 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants