[haiku-development] Re: Shortcut handling of shortcuts with shifted keys

  • From: Ryan Leavengood <leavengood@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 2 Aug 2012 18:51:41 -0400

On Thu, Aug 2, 2012 at 3:21 PM, Axel Dörfler <axeld@xxxxxxxxxxxxxxxx> wrote:
>
> I'm unsure where the problem is: what prevents us from doing it like that
> just for resolving the shortcuts? We do have the scancode of the key plus
> the current modifiers -- so we have everything needed to get the character a
> keymap would produce.

Well this is why I asked here :)

In other words, the above is something I have not considered, and it
might be a workable solution.

So first we look up in the shortcuts using what the input server gives
us, in this example Cmd-Shift-=.

If there is no shortcut for that, we can mask out Cmd, then get the
key from the keymap with the rest of the modifiers (which should give
us + in this overused example), and then see if there is a shortcut
for Cmd-<that key>. Of course we still need to know which modifiers
were used to produce that key so they can be removed from the shortcut
lookup. Fortunately the BKeymap class does track that in Offset, it
just needs to be exposed.

The main thing I don't like about this is that it makes
pre-calculation more difficult or impossible. I was hoping to just
transform the shortcut internally to match what we would get from the
input_server, rather than having to do all this translation for every
keystroke.

But when I get a chance I'll experiment a bit and see how this works.
As has been said before in my other shortcuts discussions keyboard
input should not make most computers stress too much, though that
doesn't mean we should be totally lazy and not optimize it where we
can. Especially because I also want to remove Cmd as being required
for shortcuts, which could greatly increase the number of keystrokes
which need to be examined.

-- 
Regards,
Ryan

Other related posts: