Issue 4872 in pharo: keyboard handling

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

Issue 4872 in pharo: keyboard handling

pharo
Status: Accepted
Owner: [hidden email]

New issue 4872 by [hidden email]: keyboard handling
http://code.google.com/p/pharo/issues/detail?id=4872

If you fill an issue for the first time, please read "How to report bugs"
at http://www.pharo-project.org/community/issue-tracking

Pharo image: <core, dev or web>
Pharo core version: <copy from World/System/About>
Virtual machine used: <ex: pharo-vm-0.15.2f-linux>
Class browser used if applicable: <ex: O2PackageBrowserAdaptor. If you
don't
know, print "SystemBrowser default">

Steps to reproduce:
1.
2.
3.


Paste or attach stack trace if applicable (look at the file PharoDebug.log
located in the same directory as your image):



_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4872 in pharo: keyboard handling

pharo

Comment #1 on issue 4872 by [hidden email]: keyboard handling
http://code.google.com/p/pharo/issues/detail?id=4872

bert said the following

The keycodes in down and up events really should match. And they should  
refer to raw keys. E.g., you should get the same keycode for X and Shift-X  
(though for Shift-A you would get additional Shift-Down and Shift-Up  
events).

I am sure this was working at some point. So we just need to find out where  
along the way it got broken.

I just took a look using a 4.2 Mac VM. And lo and behold, the VM *does*  
work, it produces the expected key down/up codes. Which btw are  
Apple's "Virtual Keycodes", see e.g.  
http://boredzo.org/blog/archives/2007-05-22/virtual-key-codes

However, Morphic event handling was broken when the keyboard interpreter  
was added. That must be used only for stroke events, not for up/down  
events. I just fixed that in trunk. And it works! Not bad for a two-line  
fix.

And trying that Morphic fix on a Cog VM works fine. So, no VM change  
needed. All is good. (Well, could be better, like reporting shift-up/down  
too, but at least most keys are working)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4872 in pharo: keyboard handling

pharo

Comment #2 on issue 4872 by [hidden email]: keyboard handling
http://code.google.com/p/pharo/issues/detail?id=4872

He changed on squeak


generateKeyboardEvent: evtBuf
        "Generate the appropriate mouse event for the given raw event buffer"

        | buttons modifiers type pressType stamp char |
        stamp := evtBuf second.
        stamp = 0 ifTrue: [stamp := Time millisecondClockValue].
        pressType := evtBuf fourth.
        pressType = EventKeyDown ifTrue: [type := #keyDown].
        pressType = EventKeyUp ifTrue: [type := #keyUp].
        pressType = EventKeyChar ifTrue: [type := #keystroke].
        modifiers := evtBuf fifth.
        buttons := (modifiers bitShift: 3) bitOr: (lastMouseEvent buttons bitAnd:  
7).
        char := self keyboardInterpreter nextCharFrom: Sensor firstEvt: evtBuf.
        ^ KeyboardEvent new
                setType: type
                buttons: buttons
                position: self position
                keyValue: char asciiValue
                hand: self
                stamp: stamp.


into


generateKeyboardEvent: evtBuf
        "Generate the appropriate mouse event for the given raw event buffer"

        | buttons modifiers type pressType stamp keyValue |
        stamp := evtBuf second.
        stamp = 0 ifTrue: [stamp := Time millisecondClockValue].
        pressType := evtBuf fourth.
        pressType = EventKeyDown ifTrue: [type := #keyDown].
        pressType = EventKeyUp ifTrue: [type := #keyUp].
        pressType = EventKeyChar ifTrue: [type := #keystroke].
        modifiers := evtBuf fifth.
        buttons := (modifiers bitShift: 3) bitOr: (lastMouseEvent buttons bitAnd:  
7).
        type = #keystroke
                ifTrue: [keyValue := (self keyboardInterpreter nextCharFrom: Sensor  
firstEvt: evtBuf) asInteger]
                ifFalse: [keyValue := evtBuf third].
        ^ KeyboardEvent new
                setType: type
                buttons: buttons
                position: self position
                keyValue: keyValue
                hand: self
                stamp: stamp.


Now in pharo we get


generateKeyboardEvent: evtBuf
        "Generate the appropriate mouse event for the given raw event buffer"

        | buttons modifiers type pressType stamp charCode keyValue keyEvent |
        stamp := evtBuf second.
        stamp = 0 ifTrue: [stamp := Time millisecondClockValue].
        pressType := evtBuf fourth.
        pressType = EventKeyDown
                ifTrue: [
                        type := #keyDown.
                        lastKeyScanCode := evtBuf third].
        pressType = EventKeyUp ifTrue: [type := #keyUp].
        pressType = EventKeyChar ifTrue: [
                type := #keystroke].
        modifiers := evtBuf fifth.
        buttons := modifiers bitShift: 3.
        keyValue := evtBuf third.
        charCode := evtBuf sixth.
       
        "Adjustments to provide consistent key value data for different VM's:
        - charCode always contains unicode code point.
         - keyValue contains 0 if input is outside legacy range"
        "If there is no unicode data in the event, assume keyValue contains a  
correct (<256) Unicode codepoint, and use that"
        (charCode isNil
                or: [charCode = 0])
                ifTrue: [charCode := keyValue].
        "If charCode is not single-byte, we definately have Unicode input. Nil  
keyValue to avoid garbage values from som VMs."
        charCode > 255 ifTrue: [keyValue := 0].

        type = #keystroke
                ifTrue: [combinedChar
                        ifNil: [
                                | peekedEvent |
                                peekedEvent := Sensor peekEvent.
                                (peekedEvent notNil
                                        and: [peekedEvent fourth = EventKeyDown])
                                        ifTrue: [
                                                (CombinedChar isCompositionCharacter: charCode)
                                                        ifTrue: [
                                                                combinedChar := CombinedChar new.
                                                                combinedChar simpleAdd: charCode asCharacter.
                                                                (combinedChar combinesWith: peekedEvent third asCharacter)
                                                                        ifTrue: [^nil].
                                                                ]]]
                        ifNotNil: [
                                (combinedChar simpleAdd: charCode asCharacter)
                                        ifTrue: [charCode := combinedChar combined charCode].
                                combinedChar := nil]].

        (type = #keystroke and: [(buttons anyMask: 16)
                        and: [charCode = 30 or: [charCode = 31]]])
                ifTrue: [^MouseWheelEvent new
                                        setType: #mouseWheel
                                        position: lastMouseEvent cursorPoint
                                        direction: (charCode = 30 ifTrue: [#up] ifFalse: [#down])
                                        buttons: buttons
                                        hand: self
                                        stamp: stamp].
        keyEvent := KeyboardEvent new
                setType: type
                buttons: buttons
                position: self position
                keyValue: keyValue
                charCode: charCode
                hand: self
                stamp: stamp.
        keyEvent scanCode: lastKeyScanCode.
        ^keyEvent


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4872 in pharo: keyboard handling

pharo

Comment #3 on issue 4872 by [hidden email]: keyboard handling
http://code.google.com/p/pharo/issues/detail?id=4872

Issue 4871 has been merged into this issue.


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4872 in pharo: keyboard handling

pharo
Updates:
        Status: Closed

Comment #4 on issue 4872 by [hidden email]: keyboard handling
http://code.google.com/p/pharo/issues/detail?id=4872

With Pharo 2.0 now beta, time has come to review bug reports that have not  
seen any activity in 2012.
To keep the amount of issues managable, we close reports that have not  
drawn any attention for over one
year.

The reporter (and thus owner) of the issue should:

  -> check the issue in 2.0. Is it still relevant?
  -> If yes, just add a note to the report and we will be opened again.


As your issue has not seen any attention for over a year, please consider  
to give more information.
A good idea can be to send a mail to the mailinglist to get other people to  
help fixing the bug or
implementing an improvement.



_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4872 in pharo: keyboard handling

pharo

Comment #5 on issue 4872 by [hidden email]: keyboard handling
http://code.google.com/p/pharo/issues/detail?id=4872

With Pharo 2.0 now beta, time has come to review bug reports that have not  
seen any activity in 2012.
To keep the amount of issues managable, we close reports that have not  
drawn any attention for over one
year.

The reporter (and thus owner) of the issue should:

  -> check the issue in 2.0. Is it still relevant?
  -> If yes, just add a note to the report and we will be opened again.


As your issue has not seen any attention for over a year, please consider  
to give more information.
A good idea can be to send a mail to the mailinglist to get other people to  
help fixing the bug or
implementing an improvement.



_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4872 in pharo: keyboard handling

pharo
Updates:
        Labels: MigratedToFogBugz

Comment #6 on issue 4872 by [hidden email]: keyboard handling
http://code.google.com/p/pharo/issues/detail?id=4872#c6

Issue migrated to https://pharo.fogbugz.com/f/cases/4915

--
You received this message because this project is configured to send all  
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker