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

Composed binds: the fix broke +toggle binds; some improvements #1827

Closed
Dune-jr opened this issue Dec 10, 2018 · 14 comments
Closed

Composed binds: the fix broke +toggle binds; some improvements #1827

Dune-jr opened this issue Dec 10, 2018 · 14 comments

Comments

@Dune-jr
Copy link
Member

Dune-jr commented Dec 10, 2018

bind shift+s +toggle cl_dynamic_camera

no longer works after c4fbceb

Also, I believe we could allow for bind shift+s +fire if nothing is bound to s, only make sure that s binds that start with + are always triggered:

for(int m = 0; m < MODIFIER_COUNT; m++)
{
if(((Mask&(1 << m)) || (m == 0 && m_aaaKeyBindings[Event.m_Key][0][0] == '+')) && m_aaaKeyBindings[Event.m_Key][m][0] != 0) // always trigger +xxx binds despite any modifier

@Dune-jr
Copy link
Member Author

Dune-jr commented Dec 10, 2018

I think we should simply return true if we find ourselves executing a + bind in there:

 for(int m = 0; m < MODIFIER_COUNT; m++) 
 { 
 	if(((Mask&(1 << m)) && m_aaaKeyBindings[Event.m_Key][m][0] != 0)	// always trigger +xxx binds despite any modifier
        {
               if(m == 0 && m_aaaKeyBindings[Event.m_Key][0][0] == '+')
                     return true;
               // ...

instead of doing

// skip modifiers for +xxx binds
if(pStr[0] == '+')
Modifier = 0;

Am I oversighting anything?

@oy
Copy link
Member

oy commented Dec 10, 2018

You're not supposed to use composed binds for +xxx binds.
What you proposed doesn't work. Wouldn't trigger the if statement cause it will always check for the correct modifier. Behaves like before the patch i added.

@Dune-jr
Copy link
Member Author

Dune-jr commented Dec 11, 2018

You're not supposed to use composed binds for +xxx binds.

Well then, I guess that closes the issue. Otherwise:

What you proposed doesn't work. Wouldn't trigger the if statement cause it will always check for the correct modifier. Behaves like before the patch i added.

My bad, it should stop after triggering a no-modifer +xxx bind, like this:

 for(int m = 0; m < MODIFIER_COUNT; m++) 
 { 
        if(m == 0 && m_aaaKeyBindings[Event.m_Key][0][0] == '+')
        {
                if(Event.m_Flags&IInput::FLAG_PRESS)
			Console()->ExecuteLineStroked(1, m_aaaKeyBindings[Event.m_Key][m]);
		if(Event.m_Flags&IInput::FLAG_RELEASE)
			Console()->ExecuteLineStroked(0, m_aaaKeyBindings[Event.m_Key][m]);
               return true; // always stop after triggering a +xxx bind
        }
  	if(((Mask&(1 << m)) && m_aaaKeyBindings[Event.m_Key][m][0] != 0)	
        {
               // ...

@Dune-jr Dune-jr closed this as completed Dec 11, 2018
@oy
Copy link
Member

oy commented Dec 12, 2018

Reopened the issue - will improve it for the next version.

@oy oy reopened this Dec 12, 2018
@oy oy added this to the 0.7.2 milestone Dec 12, 2018
@oy oy modified the milestones: 0.7.2, 0.7.3 Dec 24, 2018
@oy
Copy link
Member

oy commented Jan 10, 2019

How about removing the restriction that pressing a modifier and a bind key don't trigger a bind that isn't bound by a modifier?
F.e.: pressing shift+s would trigger "bind shift+s" and "bind s"

Cause for modifiers there currently is no such restriction:
pressing alt+shift+s triggers "bind alt+s" and "bind shift+s".

@Dune-jr
Copy link
Member Author

Dune-jr commented Jan 11, 2019

How about removing the restriction that pressing a modifier and a bind key don't trigger a bind that isn't bound by a modifier?
F.e.: pressing shift+s would trigger "bind shift+s" and "bind s"

That doesn't sound very good to me. In that case, all keys that are mapped to basic actions (chat, movements, firing, scoreboard, ...) cannot be used in composed binds.

In any game I know, binding Ctrl+X does not trigger X, that is not intuitive. What is the benefit?

pressing alt+shift+s triggers "bind alt+s" and "bind shift+s".

Yeah, that is not great. That comes from the fact that triple binds like alt+shift+s are not supported - if they were, alt+shift+s shouldn't trigger alt+s imo.

@oy
Copy link
Member

oy commented Jan 11, 2019

How about removing the restriction that pressing a modifier and a bind key don't trigger a bind that isn't bound by a modifier?
F.e.: pressing shift+s would trigger "bind shift+s" and "bind s"

That doesn't sound very good to me. In that case, all keys that are mapped to basic actions (chat, movements, firing, scoreboard, ...) cannot be used in composed binds.

You could use basic actions with composed binds. There's no restriction regarding this if it would trigger non and composed binds.
Right now you can't use composed binds for these actions - they get converted to non-composed ones automatically.

@Dune-jr
Copy link
Member Author

Dune-jr commented Jan 12, 2019

The code snippet I proposed earlier would fix this by allowing to use composed binds for these actions.

You could have some odd case such as:

bind shift+x +left
bind x say hi

and it should work properly, without breaking the "you can use composed binds on already single-bound keys" concept.

Am I missing something?

@oy
Copy link
Member

oy commented Jan 12, 2019

But composed binds wouldn't trigger, even "+" ones, when there's a non-composed "+" one for that key.
People might think that's a bug.

@Dune-jr
Copy link
Member Author

Dune-jr commented Feb 19, 2019

Note: In the controls menus, binding e.g. shift+a to "Left" briefly prints shift+a before reverting to a, it looks a bit buggy.


I have also encountered two people who believed bind shift+a +left not working to be a bug.

@oy
Copy link
Member

oy commented Feb 21, 2019

Should probably gather all possible bugs/down sides and pick the smallest problem.

@Dune-jr
Copy link
Member Author

Dune-jr commented Mar 25, 2019

If we don't restrict anything (0.7.1-rc before c4fbceb)

  • Bug: shift+k triggers k binds. This is bad but might be solvable in another way
  • Bug: if you do bind shift+k +left, and you release shift, you don't stop going left iirc. This is bad but might be solvable

The current approach (0.7.2, strictly no + for composed binds)

	// skip modifiers for +xxx binds
	if(pStr[0] == '+')
		Modifier = 0;

for(int m = 0; m < MODIFIER_COUNT; m++)
{
if(((Mask&(1 << m)) || (m == 0 && m_aaaKeyBindings[Event.m_Key][0][0] == '+')) && m_aaaKeyBindings[Event.m_Key][m][0] != 0) // always trigger +xxx binds despite any modifier
{
if(Event.m_Flags&IInput::FLAG_PRESS)
Console()->ExecuteLineStroked(1, m_aaaKeyBindings[Event.m_Key][m]);
if(Event.m_Flags&IInput::FLAG_RELEASE)
Console()->ExecuteLineStroked(0, m_aaaKeyBindings[Event.m_Key][m]);
rtn = true;
}
}

  • No bugs
  • Problem: bind shift+d +toggle cl_dynamic_camera will never work

My proposal (#1827 (comment))

 for(int m = 0; m < MODIFIER_COUNT; m++) 
 { 
        if(m == 0 && m_aaaKeyBindings[Event.m_Key][0][0] == '+')
        {
                if(Event.m_Flags&IInput::FLAG_PRESS)
			Console()->ExecuteLineStroked(1, m_aaaKeyBindings[Event.m_Key][m]);
		if(Event.m_Flags&IInput::FLAG_RELEASE)
			Console()->ExecuteLineStroked(0, m_aaaKeyBindings[Event.m_Key][m]);
                return true; // always stop after triggering a +xxx bind
        }
  	if(((Mask&(1 << m)) && m_aaaKeyBindings[Event.m_Key][m][0] != 0)	
        {
 		if(Event.m_Flags&IInput::FLAG_PRESS) 
 			Console()->ExecuteLineStroked(1, m_aaaKeyBindings[Event.m_Key][m]); 
 		if(Event.m_Flags&IInput::FLAG_RELEASE) 
 			Console()->ExecuteLineStroked(0, m_aaaKeyBindings[Event.m_Key][m]); 
 		rtn = true; 
        }
}
  • If there is a non-composed + bind, stop and execute only that.
    • bind x +left; bind shift+x say hi, then pressing shift+x will only trigger +left
    • bind x +left; bind shift+x +right, then pressing shift+x will only trigger +left
    • bind shift+d +toggle cl_dynamic_camera works
  • No bugs afaik?
    • Need to check that bind shift+x +left does not leave the tee constantly moving left after releasing shift (or x) though

Oy's proposal

How about removing the restriction that pressing a modifier and a bind key don't trigger a bind that isn't bound by a modifier?
F.e.: pressing shift+s would trigger "bind shift+s" and "bind s"

Cause for modifiers there currently is no such restriction:
pressing alt+shift+s triggers "bind alt+s" and "bind shift+s".

The issue I have with this is that composed binds currently expand the range of keys that can be bound, and this kills it. Example: I have 1 2 3 4 5 bound on weapons. I would like to use shift+1 for team 1, shift+1 for team 2, shift+3 for team -1, shift+4 for disconnect.

so

I may be missing something, need to complete.
And I'm also biased towards my proposal as I don't really see downsides to it?

@oy
Copy link
Member

oy commented Mar 25, 2019

The downside is that the composed binds won't trigger like in your examples. Feels like a bug.
To improve that (bind x +left; bind shift+x say hi, then pressing shift+x will only trigger +left), how about:

  • when pressing x check if shift-key is already down
  • and there's no non-composed bind for shift
  • then execute the composed bind

@Dune-jr
Copy link
Member Author

Dune-jr commented Mar 25, 2019

Ah, I forgot. There is a reason why non-composed + binds must always be executed regardless of modifiers:

  • if you hold down a to move left and briefly press shift/ctrl the tee should not stop.

This was an issue in 0.7.1-rc.

Another problem:

  • if shift+q is not a modifier, it would be nice to still trigger lshift (emotes by default)

The downside is that the composed binds won't trigger like in your examples. Feels like a bug.
To improve that (bind x +left; bind shift+x say hi, then pressing shift+x will only trigger +left), how about:

when pressing x check if shift-key is already down
and there's no non-composed bind for shift
then execute the composed bind

Doesn't that mean that bind lshift +emote disables ALL shift+x binds?
Edit: well I guess it's not so bad

I'm trying to make a summary/checklist:

"bind x +left" and "bind shift+x say hi": 
    x MUST DO "+left" # standard stuff

"bind x +left" and "bind shift+x say hi": 
    shift+x BETTER DO "say hi" #but must not interrupt x if x is held down!

"bind shift+q +left":
    release shift MUST NOT DO "+left"

"bind shift+k say yes" and "bind k say no": 
    shift+k MUST DO "say yes"
    shift+k MUST NOT DO "say no"

"bind shift+d +toggle cl_dynamic_camera": 
    shift+d BETTER DO "+toggle cl_dynamic_camera"

"bind q +left" and "unbind shift+q" and "bind lshift emote": 
    shift+q BETTER DO "+left; emote"

"bind lshift +emote" and "bind shift+x say hi": ?

oy added a commit that referenced this issue Mar 31, 2019
@oy oy closed this as completed Mar 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@oy @Dune-jr and others