[squeak-dev] Unix keyboard events lose track when multiple keys pressed or keys held down

David T. Lewis lewis at mail.msen.com
Sat Jan 16 23:33:14 UTC 2021

Hi Tim,

On Sat, Jan 16, 2021 at 03:17:06PM -0800, tim Rowledge wrote:
> > On 2021-01-15, at 8:51 PM, tim Rowledge <tim at rowledge.org> wrote:
> > 
> > Ah; look at static int x2sqKeyInput() {line 1720} - it carefully does some stuff to track the *single* last key pressed and if the event is a release, tells you what the last press key was and then sets the record of last-press to -1. Thus if we press a second key it destroys any evidence of the prior press and we're screwed.
> So far as I can work out this insane collection of input X code is unable to convert a key release in the same way that it converts a key press; possibly sometihng to do with use of the extra compositor things and multiple keypresses ? We can't use XmbLookupString() since that is undefined for key release events.
> What it means is that in order to provide an event saying "oh, key $b was released" based on the information provided by X events we had to use some side-effect algorithm that maps the char code produced by the last press of the key. Currently that only copes with a single key being pressed at a time. It seems faintly plausible that making a somewhat bigger array with pairs of the event keycode and the value returned last time that was pressed *might* work. The potential problem would be any case where a multiple key action had been required to compose a character; I have no idea how one might handle that.

I have to admit I'm getting a bit lost in this, but I have been looking
in the same area and I think you are on the right track. The part I
can't figure out is how it could be working on any of the VMs.

For the functions that you are looking at, the C code is almost (but not
quite) identical in the oscog git code base and the squeakvm svn code
base. The small differences that I so do not appear relevant to the
missing KeyRelease event problem. But on my PC, one VM works and the
other does not.

So far I've run the interpreter VM under gdb and I can see where it
is not working (exactly as you have explained). I have not yet tried
making a debug version of the Spur VM but it's possible that it would
show why that one *does* seem to work on my PC. I'll try to find time
to check that tomorrow.

> I think this is one of those cases where simply passing the raw OS event data into the image and handling it there might have been less painful. Obviously more platform spread stuff in the image but...

Quite possible so. I certainly would make the debugging simpler.


> Surely this can't be a unique situation?
> tim
> --
> tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
> Useful random insult:- The wheel's spinning but the hamster's dead.

More information about the Squeak-dev mailing list