[squeak-dev] Oddities with #keyDown and Sensor
Lawson English
lenglish5 at cox.net
Thu Sep 29 11:52:11 UTC 2011
So, based on guesswork and what little I understood of various comments
that John Mcintosh and others have said in previous threads about the
keydown/keyup issue I've been having with Mac OS X 10.6.8, I managed to
patch a Cog VM to workaround the issue.
I just modified the calls to enterKeystroke() for keydown and keyup to
use the same parameters as for a keystroke event, when called from
within the function recordKeyboardEventCarbon().
Now, keydown events report the same keyvalue as the keystroke event.
Keyup events report what appears to be the raw keyscan code. Why it
works as it does, precisely, I'm not sure, but it is enough for me to
track when a spaceship is accelerated by the arrow keys and gives
sufficient info in the keyup event for me to figure out how long a given
key has been pressed when multiple keys are held down (I think). [My
first VM patch -wheeee!]
The test code below now generates: :
#(2 100501 2 2 0 0 0 1)
#(2 102403 28 1 0 0 0 1) "keydown"
#(2 102403 28 0 0 28 0 1) "keystroke"
#(2 102500 123 2 0 0 0 1) "keyup"
#(2 103139 30 1 0 0 0 1)
#(2 103139 30 0 0 30 0 1)
#(2 103220 126 2 0 0 0 1)
#(2 103779 29 1 0 0 0 1)
#(2 103779 29 0 0 29 0 1)
#(2 103868 124 2 0 0 0 1)
#(2 104683 31 1 0 0 0 1)
#(2 104683 31 0 0 31 0 1)
#(2 104756 125 2 0 0 0 1)
#(2 105771 32 1 0 0 0 1)
#(2 105771 32 0 0 32 0 1)
#(2 105884 49 2 0 0 0 1)
#(2 111772 120 1 0 0 0 1)
On 9/23/11 8:05 PM, Lawson English wrote:
> Simpler code:
>
> http://paste.lisp.org/display/124831
>
> evoke via the following in a workspace
>
> a := (MyNewMorph new) openInWorld.
> a doit.
>
> typing 'x' stops the loop
>
> a eventBuffer do: [:each| each ifNotNil: [Transcript show: each;cr]].
>
> Partial results. Note that the keyDown and KeyUp events have no valid
> data associated with them. At this point, I would say its definitely a
> VM issue (either that, or Mac OS X doesn't include the data, period,
> which seems odd).
>
> #(1 11688796 358 202 0 0 0 1)
> #(2 11688821 2 2 0 0 0 1)
> #(2 11689589 2 1 0 0 0 1)
> #(2 11689589 100 0 0 100 0 1)
> #(2 11690028 2 2 0 0 0 1)
> #(2 11690381 2 1 0 0 0 1)
> #(2 11690381 100 0 0 100 0 1)
> #(2 11690604 2 2 0 0 0 1)
> #(2 11690907 2 1 0 0 0 1)
> #(2 11690907 100 0 0 100 0 1)
> #(2 11691092 2 2 0 0 0 1)
> #(2 11691284 2 1 0 0 0 1)
> #(2 11691284 100 0 0 100 0 1)
>
>
>
>
> Lawson
>
>
More information about the Squeak-dev
mailing list
|