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

Erratic behavior using if_eq() function in a macro #942

Open
sabudum opened this issue Aug 20, 2024 · 0 comments
Open

Erratic behavior using if_eq() function in a macro #942

sabudum opened this issue Aug 20, 2024 · 0 comments

Comments

@sabudum
Copy link

sabudum commented Aug 20, 2024

I created two mappings for my keyboard:

Shift_L -> if_eq($shift, 1, key_up(KEY_LEFTSHIFT).hold().key_down(KEY_LEFTSHIFT), key(KEY_LEFTSHIFT))
Super_L + Shift_L -> if_eq($shift, 0, set(shift, 1).key_down(KEY_LEFTSHIFT), set(shift, 0).key_up(KEY_LEFTSHIFT))

The first one inverts the functionality of the Shift key, so when it's released it acts as being pressed, and when being pressed, it acts as being released.
The second mapping toggles the functionality of the first one by using a variable.

This works to an extent but it's extremely erratic, although the variable is being set correctly, when it is enabled, the Shift key sometimes doesn't work, and when combined with other keys, it breaks the code and does not get released.

So for instance, when it is enabled, I press Shift_L + A, this will write a lowercase 'a', but when releasing Shift_L, all subsequent characters will be lowercase, where they should be uppercase, I have to press Shift_L once again to re-enable the functionality.

The inverse also happens when it's disabled.

When not using if_eq(), and just leaving the mapping like so:
Shift_L -> key_up(KEY_LEFTSHIFT).hold().key_down(KEY_LEFTSHIFT)

Then it works flawlessly without any problems, but there's no way to toggle it.

I believe the problem only happens when combining if_eq() with hold(), both functions don't get very well together.

Maybe one way to fix this issue is to add a way to enable or disable individual mappings without changing the preset, but I imagine that would be difficult.

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

No branches or pull requests

1 participant