Opened 3 years ago

Last modified 2 years ago

#6064 new defect

Clean up control group hotkeys

Reported by: wraitii Owned by:
Priority: Should Have Milestone: Backlog
Component: Core engine Keywords:
Cc: Patch:

Description

Control group hotkeys are a bit weird: instead of "shift" just modifying what the control group hotkey does, "shift+#" is the whole hotkey.

This leads, in A24, to the issue reported here: https://wildfiregames.com/forum/topic/36639-a24-feedback/page/2/?tab=comments#comment-417787

If instead, the "add to selection " behaviour was just Shift and then also pressing the control group hotkey, this would go away.

Reported by: Player Of 0AD

Change History (7)

comment:1 by Imarok, 3 years ago

I don't think I agree with your proposed solution.

If I understood it correctly the issue is following:

  1. You press e.g. Shift + 4 this triggers the add-to-control-group hotkey.
  2. You release Shift and because 4 is still pressed it triggers the control-group hotkey.

Is this correct? In that case I don't see how that should be the desired way our hotkey system should work.

comment:2 by wraitii, 3 years ago

See discussion on IRC today.

Imarok argues that it should go:

  • 4 : 'CtrlGrp pressed' is sent
  • Shift+4: "add to CtrlGrp is pressed" is sent, 'CtrlGrp' is silently un-pressed (no release sent)
  • Shift release: "add to CtrGrp is released" is sent, 'CtrlGrp' is silently re-pressed (no 'Pressed' event sent)
  • 4 release: 'CtrlGrp' is released.

Wheres right now hotkeys are retriggered on key release, so 'pressed' and 'release' will be sent twice for only one human input.

I do agree , need to look into that, doesn't invalidate the ticket.

in reply to:  2 comment:3 by Imarok, 3 years ago

Replying to wraitii:

See discussion on IRC today.

Imarok argues that it should go:

  • 4 : 'CtrlGrp pressed' is sent
  • Shift+4: "add to CtrlGrp is pressed" is sent, 'CtrlGrp' is silently un-pressed (no release sent)
  • Shift release: "add to CtrGrp is released" is sent, 'CtrlGrp' is silently re-pressed (no 'Pressed' event sent)
  • 4 release: 'CtrlGrp' is released.

Wheres right now hotkeys are retriggered on key release, so 'pressed' and 'release' will be sent twice for only one human input.

I do agree , need to look into that, doesn't invalidate the ticket.

Yes, but also (as that is the more reasonable scenario):

  • Shift : nothing happens
  • Shift+4: "add to CtrlGrp is pressed" is sent
  • Shift release: "add to CtrGrp is released" is sent, 'CtrlGrp' is silently pressed (no 'Pressed' event sent)
  • 4 release: 'CtrlGrp' is silently released (no 'Released' event sent)

comment:4 by Imarok, 3 years ago

Seems like this underlying issue also might have caused #6092.

comment:5 by wraitii, 3 years ago

In 25169:

Do not trigger "HotkeyPress" events when releasing a key.

Follows rP24675.
Because only the most specific hotkeys can be active at any time, releasing a key may require re-activating less specific hotkeys.
There were two issues with this behaviour:

  • It was buggy, as it only checked one active key, when any still active key can trigger hotkeys.
  • "HotkeyPress" and "HotkeyDown" events where sent, as if the hotkey was pressed, which was unexpected for most code/users (it is unusual to have a "Press" event on key release).

This fixes these issues by "silently" re-triggering the hotkeys in such a case. It also makes it easier for JS code to use "hotkeyPress" instead of "hotkeyDown" for non-continuous behaviour.

Accepted By: nani

Fixes #6123
Refs #6064 (fixes the problem, but not the code weirdness)

Differential Revision: https://code.wildfiregames.com/D3766

comment:6 by wraitii, 3 years ago

Milestone: Alpha 25Alpha 26

comment:7 by Freagarach, 2 years ago

Milestone: Alpha 26Backlog
Note: See TracTickets for help on using tickets.