keyUp event modifier bitmap of is shifted by 3 on OSX

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

keyUp event modifier bitmap of is shifted by 3 on OSX

Kruck, Bastian
 
Hello Folks,

when looking for how Cog passes keystrokes to the image, we found that the modifier bitmap of the keyUp events is left shifted by 3 bits on OS X. This seems to be a bug in Mac OS specific event handling. sqMacUIEvents.c usually unshifts the mouse buttons away before passing it to the image, but it doesn’t do that for keyup events. Something that I oversee here? This could be a fix:

Index: platforms/Mac OS/vm/sqMacUIEvents.c
===================================================================
--- platforms/Mac OS/vm/sqMacUIEvents.c (revision 3312)
+++ platforms/Mac OS/vm/sqMacUIEvents.c (working copy)
@@ -1717,7 +1717,7 @@
                        //fprintf(stdout,"\nrawkey up %i",ioMSecs());
                        key = findInKeyMap(keyCode);
                        if (key != -1) {
- enterKeystroke ( EventTypeKeyboard,keyCode, EventKeyUp, 0, ModifierStateCarbon(event,0));
+ enterKeystroke ( EventTypeKeyboard,keyCode, EventKeyUp, 0, ModifierStateCarbon(event,0) >> 3);
                        }
                        removeFromKeyMap(keyCode);
           result = eventNotHandledErr;

Unfortunately, I couldn’t verify the fix as I am running Yosemite which seems to not be supported yet for building from source.

I appended the changeset which we used to find that issue. Steps to reproduce:
1) install our changeset into a Squeak4.5 image on OS X
2) run `TempSettings printEvents: true.`
3) open a Transcript
4) Press cmd+a
5) The fifth item of that Array should be 8 on the third time (but is 8<<3 instead)
        #(2 15512120 0 1 8 0 0 1)
        #(2 15512120 97 0 8 97 0 1)
        #(2 15512198 0 2 64 0 0 1)


Tobias commented that this bug could be duplicated to some other places (which we didn’t verify yet).
I am not sure, how many projects already rely on this behavior and how to go on with that.

BR,
Bastian Kruck



KeyboardEventSpy.1.cs (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: keyUp event modifier bitmap of is shifted by 3 on OSX

Eliot Miranda-2
 
Hi Bastian,

   this seems like a serious bug!  I'm at your service when you determine whether the change should be made or not; I'm happy to integrate it for you.  Can you please verify that it doesn't break a current Squeak trunk image?  If it does break older projects I guess we'll have to introduce a VM flag to control whether the fix should operate or not.

On Wed, Apr 22, 2015 at 11:39 AM, Kruck, Bastian <[hidden email]> wrote:
 
Hello Folks,

when looking for how Cog passes keystrokes to the image, we found that the modifier bitmap of the keyUp events is left shifted by 3 bits on OS X. This seems to be a bug in Mac OS specific event handling. sqMacUIEvents.c usually unshifts the mouse buttons away before passing it to the image, but it doesn’t do that for keyup events. Something that I oversee here? This could be a fix:

Index: platforms/Mac OS/vm/sqMacUIEvents.c
===================================================================
--- platforms/Mac OS/vm/sqMacUIEvents.c (revision 3312)
+++ platforms/Mac OS/vm/sqMacUIEvents.c (working copy)
@@ -1717,7 +1717,7 @@
                        //fprintf(stdout,"\nrawkey up %i",ioMSecs());
                        key = findInKeyMap(keyCode);
                        if (key != -1) {
-                               enterKeystroke ( EventTypeKeyboard,keyCode, EventKeyUp, 0, ModifierStateCarbon(event,0));
+                               enterKeystroke ( EventTypeKeyboard,keyCode, EventKeyUp, 0, ModifierStateCarbon(event,0) >> 3);
                        }
                        removeFromKeyMap(keyCode);
           result = eventNotHandledErr;

Unfortunately, I couldn’t verify the fix as I am running Yosemite which seems to not be supported yet for building from source.

I appended the changeset which we used to find that issue. Steps to reproduce:
1) install our changeset into a Squeak4.5 image on OS X
2) run `TempSettings printEvents: true.`
3) open a Transcript
4) Press cmd+a
5) The fifth item of that Array should be 8 on the third time (but is 8<<3 instead)
        #(2 15512120 0 1 8 0 0 1)
        #(2 15512120 97 0 8 97 0 1)
        #(2 15512198 0 2 64 0 0 1)


Tobias commented that this bug could be duplicated to some other places (which we didn’t verify yet).
I am not sure, how many projects already rely on this behavior and how to go on with that.

BR,
Bastian Kruck






--
best,
Eliot
Reply | Threaded
Open this post in threaded view
|

Re: keyUp event modifier bitmap of is shifted by 3 on OSX

johnmci
In reply to this post by Kruck, Bastian
 

The Cocoa based VM returns  this. 

#(2 156576 0 1 8 0 0 1)
#(2 156576 97 0 8 97 0 1)
#(2 156576 0 2 8 0 0 1)


Looks like cmd-a returns on a Squeak 4.2.5 vm does return.
#(2 267194 0 1 8 0 0 1)
#(2 267194 97 0 8 97 0 1)
#(2 267295 0 2 64 0 0 1)

Shrug,  no support for that code base now... 
At this point you should migrate to the cocoa based VM. 

Also see 


On Wed, Apr 22, 2015 at 11:39 AM, Kruck, Bastian <[hidden email]> wrote:
 
Hello Folks,

when looking for how Cog passes keystrokes to the image, we found that the modifier bitmap of the keyUp events is left shifted by 3 bits on OS X. This seems to be a bug in Mac OS specific event handling. sqMacUIEvents.c usually unshifts the mouse buttons away before passing it to the image, but it doesn’t do that for keyup events. Something that I oversee here? This could be a fix:

Index: platforms/Mac OS/vm/sqMacUIEvents.c
===================================================================
--- platforms/Mac OS/vm/sqMacUIEvents.c (revision 3312)
+++ platforms/Mac OS/vm/sqMacUIEvents.c (working copy)
@@ -1717,7 +1717,7 @@
                        //fprintf(stdout,"\nrawkey up %i",ioMSecs());
                        key = findInKeyMap(keyCode);
                        if (key != -1) {
-                               enterKeystroke ( EventTypeKeyboard,keyCode, EventKeyUp, 0, ModifierStateCarbon(event,0));
+                               enterKeystroke ( EventTypeKeyboard,keyCode, EventKeyUp, 0, ModifierStateCarbon(event,0) >> 3);
                        }
                        removeFromKeyMap(keyCode);
           result = eventNotHandledErr;

Unfortunately, I couldn’t verify the fix as I am running Yosemite which seems to not be supported yet for building from source.

I appended the changeset which we used to find that issue. Steps to reproduce:
1) install our changeset into a Squeak4.5 image on OS X
2) run `TempSettings printEvents: true.`
3) open a Transcript
4) Press cmd+a
5) The fifth item of that Array should be 8 on the third time (but is 8<<3 instead)
        #(2 15512120 0 1 8 0 0 1)
        #(2 15512120 97 0 8 97 0 1)
        #(2 15512198 0 2 64 0 0 1)


Tobias commented that this bug could be duplicated to some other places (which we didn’t verify yet).
I am not sure, how many projects already rely on this behavior and how to go on with that.

BR,
Bastian Kruck






--
===========================================================================
John M. McIntosh. Corporate Smalltalk Consulting Ltd https://www.linkedin.com/in/smalltalk
===========================================================================
Reply | Threaded
Open this post in threaded view
|

Re: keyUp event modifier bitmap of is shifted by 3 on OSX

marcel.taeumel
In reply to this post by Kruck, Bastian
There is a similar bug for keyUp events. Only keyStrokes work correct on Macs. :)

Best,
Marcel
Reply | Threaded
Open this post in threaded view
|

Re: keyUp event modifier bitmap of is shifted by 3 on OSX

marcel.taeumel
In reply to this post by Kruck, Bastian
The projects I know do not rely directly on this behavior bug offer configuration options to go with whatever events come. :) Our students did this in several games.

Best,
Marcel
Reply | Threaded
Open this post in threaded view
|

Re: keyUp event modifier bitmap of is shifted by 3 on OSX

marcel.taeumel
*bump*

Any improvements here? Bastian?

Best,
Marcel