OSX VM doesn't generate events for modifier keypresses (shift, ctrl, etc)

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

OSX VM doesn't generate events for modifier keypresses (shift, ctrl, etc)

Ben Coman
 
AliakseiSyrel reported that the OSX VM doesn't generate events on
shift/ctrl/command/options/capslock keypress, but Win32 and Linux do.
(https://pharo.fogbugz.com/default.asp?14521)

I've submitted a fix to pharo-vm, but thought it might also be useful to
others, and was hoping for some review and discussion here...
A diff can be seen here...
https://github.com/pharo-project/pharo-vm/pull/67/files

I discovered "recordCharEvent:fromView:" and "keyDown:" do not receive
modifier keypresses, however "flagsChanged:" does - as described by the
AppKit Reference "flagsChanged: informs the receiver that the user has
pressed or released a modifier key (Shift, Control, and so on)."

Just above "flagsChanged:" I noticed...
     -(void)keyUp:(NSEvent*)theEvent {
         [(sqSqueakOSXApplication *) gDelegateApp.squeakApplication
             recordKeyUpEvent: theEvent fromView: self];
     }

So I duplicated recordKeyUpEvent:fromView:
as recordKeyDownEvent:fromView:
changing only...
         evt.pressCode = EventKeyUp;
to...
         evt.pressCode = EventKeyDown;

and called it from the bottom of flagsChanged:

============
Now in a test image, adding a debug Transcript after primGetNextEvent:
     InputEventFetcher>>eventLoop
         ...
     [true] whileTrue: [
         self waitForInput.
         [self primGetNextEvent: eventBuffer.
             Transcript crShow: Time now ; tab ; show: eventBuffer.

shows...

11:41:18.9594 pm    #(2 182714 56 1 1 0 0 1) Shift down
11:41:18.959581 pm    #(0 0 0 0 0 0 0 0)
11:41:19.19321 pm    #(2 182948 56 1 0 0 0 1) Shift up
11:41:19.193543 pm    #(0 0 0 0 0 0 0 0)
11:41:21.04326 pm    #(2 184798 59 1 2 0 0 1) Control down
11:41:21.043494 pm    #(0 0 0 0 0 0 0 0)
11:41:21.346713 pm    #(2 185102 59 1 0 0 0 1) Control up
11:41:21.346934 pm    #(0 0 0 0 0 0 0 0)
11:41:21.814845 pm    #(2 185569 58 1 4 0 0 1) Option down
11:41:21.815136 pm    #(0 0 0 0 0 0 0 0)
11:41:22.137117 pm    #(2 185892 58 1 0 0 0 1) Option up
11:41:22.137374 pm    #(0 0 0 0 0 0 0 0)
11:43:28.593666 pm    #(2 312348 55 1 8 0 0 1) Cmd down
11:43:28.593854 pm    #(0 0 0 0 0 0 0 0)
11:43:29.014829 pm    #(2 312770 55 1 0 0 0 1) Cmd up
11:43:29.015011 pm    #(0 0 0 0 0 0 0 0)
11:41:43.762799 pm    #(2 207517 57 1 0 0 0 1) CapsLock down

CapsLock does not get a up-event per...
https://bugzilla.mozilla.org/show_bug.cgi?id=259059

It perhaps can be simulated like...
https://developer.apple.com/library/mac/qa/qa1519/_index.html

Thoughts?
Reply | Threaded
Open this post in threaded view
|

Re: OSX VM doesn't generate events for modifier keypresses (shift, ctrl, etc)

Ben Coman
 
I celebrate my first VM contribution :) :) :) with integration of [1]
into pharo-vm on github.  Now how do I submit this for consideration for
the SVN tree, to help keep things in syncd.
cheers -ben

Ben Coman wrote:
>
> AliakseiSyrel reported that the OSX VM doesn't generate events on
> shift/ctrl/command/options/capslock keypress, but Win32 and Linux do.
> (https://pharo.fogbugz.com/default.asp?14521)
>
> I've submitted a fix to pharo-vm, but thought it might also be useful to
> others, and was hoping for some review and discussion here...

> A diff can be seen here...
> [1] https://github.com/pharo-project/pharo-vm/pull/67/files
>

> I discovered "recordCharEvent:fromView:" and "keyDown:" do not receive
> modifier keypresses, however "flagsChanged:" does - as described by the
> AppKit Reference "flagsChanged: informs the receiver that the user has
> pressed or released a modifier key (Shift, Control, and so on)."
>
> Just above "flagsChanged:" I noticed...
>     -(void)keyUp:(NSEvent*)theEvent {
>         [(sqSqueakOSXApplication *) gDelegateApp.squeakApplication
>             recordKeyUpEvent: theEvent fromView: self];
>     }
>
> So I duplicated recordKeyUpEvent:fromView:
> as recordKeyDownEvent:fromView:
> changing only...
>         evt.pressCode = EventKeyUp;
> to...
>         evt.pressCode = EventKeyDown;
>
> and called it from the bottom of flagsChanged:
>
> ============
> Now in a test image, adding a debug Transcript after primGetNextEvent:
>     InputEventFetcher>>eventLoop
>         ...
>     [true] whileTrue: [
>         self waitForInput.
>         [self primGetNextEvent: eventBuffer.
>             Transcript crShow: Time now ; tab ; show: eventBuffer.
>
> shows...
>
> 11:41:18.9594 pm    #(2 182714 56 1 1 0 0 1) Shift down
> 11:41:18.959581 pm    #(0 0 0 0 0 0 0 0)
> 11:41:19.19321 pm    #(2 182948 56 1 0 0 0 1) Shift up
> 11:41:19.193543 pm    #(0 0 0 0 0 0 0 0)
> 11:41:21.04326 pm    #(2 184798 59 1 2 0 0 1) Control down
> 11:41:21.043494 pm    #(0 0 0 0 0 0 0 0)
> 11:41:21.346713 pm    #(2 185102 59 1 0 0 0 1) Control up
> 11:41:21.346934 pm    #(0 0 0 0 0 0 0 0)
> 11:41:21.814845 pm    #(2 185569 58 1 4 0 0 1) Option down
> 11:41:21.815136 pm    #(0 0 0 0 0 0 0 0)
> 11:41:22.137117 pm    #(2 185892 58 1 0 0 0 1) Option up
> 11:41:22.137374 pm    #(0 0 0 0 0 0 0 0)
> 11:43:28.593666 pm    #(2 312348 55 1 8 0 0 1) Cmd down
> 11:43:28.593854 pm    #(0 0 0 0 0 0 0 0)
> 11:43:29.014829 pm    #(2 312770 55 1 0 0 0 1) Cmd up
> 11:43:29.015011 pm    #(0 0 0 0 0 0 0 0)
> 11:41:43.762799 pm    #(2 207517 57 1 0 0 0 1) CapsLock down
>
> CapsLock does not get a up-event per...
> https://bugzilla.mozilla.org/show_bug.cgi?id=259059
>
> It perhaps can be simulated like...
> https://developer.apple.com/library/mac/qa/qa1519/_index.html
>
> Thoughts?
>

Reply | Threaded
Open this post in threaded view
|

Re: OSX VM doesn't generate events for modifier keypresses (shift, ctrl, etc)

EstebanLM

you don’t
they do not maintain a osx-cocoa version, so your changes are useless for them.

Esteban

> On 28 Nov 2014, at 18:09, Ben Coman <[hidden email]> wrote:
>
> I celebrate my first VM contribution :) :) :) with integration of [1] into pharo-vm on github.  Now how do I submit this for consideration for the SVN tree, to help keep things in syncd.
> cheers -ben
>
> Ben Coman wrote:
>> AliakseiSyrel reported that the OSX VM doesn't generate events on shift/ctrl/command/options/capslock keypress, but Win32 and Linux do.
>> (https://pharo.fogbugz.com/default.asp?14521)
>> I've submitted a fix to pharo-vm, but thought it might also be useful to others, and was hoping for some review and discussion here...
>
>> A diff can be seen here...
>> [1] https://github.com/pharo-project/pharo-vm/pull/67/files
>
>> I discovered "recordCharEvent:fromView:" and "keyDown:" do not receive modifier keypresses, however "flagsChanged:" does - as described by the AppKit Reference "flagsChanged: informs the receiver that the user has pressed or released a modifier key (Shift, Control, and so on)."
>> Just above "flagsChanged:" I noticed...
>>    -(void)keyUp:(NSEvent*)theEvent {
>>        [(sqSqueakOSXApplication *) gDelegateApp.squeakApplication
>>            recordKeyUpEvent: theEvent fromView: self];
>>    }
>> So I duplicated recordKeyUpEvent:fromView:
>> as recordKeyDownEvent:fromView:
>> changing only...
>>        evt.pressCode = EventKeyUp;
>> to...
>>        evt.pressCode = EventKeyDown;
>> and called it from the bottom of flagsChanged:
>> ============
>> Now in a test image, adding a debug Transcript after primGetNextEvent:
>>    InputEventFetcher>>eventLoop
>>        ...
>>    [true] whileTrue: [
>>        self waitForInput.
>>        [self primGetNextEvent: eventBuffer.
>>            Transcript crShow: Time now ; tab ; show: eventBuffer.
>> shows...
>> 11:41:18.9594 pm    #(2 182714 56 1 1 0 0 1) Shift down
>> 11:41:18.959581 pm    #(0 0 0 0 0 0 0 0)
>> 11:41:19.19321 pm    #(2 182948 56 1 0 0 0 1) Shift up
>> 11:41:19.193543 pm    #(0 0 0 0 0 0 0 0)
>> 11:41:21.04326 pm    #(2 184798 59 1 2 0 0 1) Control down
>> 11:41:21.043494 pm    #(0 0 0 0 0 0 0 0)
>> 11:41:21.346713 pm    #(2 185102 59 1 0 0 0 1) Control up
>> 11:41:21.346934 pm    #(0 0 0 0 0 0 0 0)
>> 11:41:21.814845 pm    #(2 185569 58 1 4 0 0 1) Option down
>> 11:41:21.815136 pm    #(0 0 0 0 0 0 0 0)
>> 11:41:22.137117 pm    #(2 185892 58 1 0 0 0 1) Option up
>> 11:41:22.137374 pm    #(0 0 0 0 0 0 0 0)
>> 11:43:28.593666 pm    #(2 312348 55 1 8 0 0 1) Cmd down
>> 11:43:28.593854 pm    #(0 0 0 0 0 0 0 0)
>> 11:43:29.014829 pm    #(2 312770 55 1 0 0 0 1) Cmd up
>> 11:43:29.015011 pm    #(0 0 0 0 0 0 0 0)
>> 11:41:43.762799 pm    #(2 207517 57 1 0 0 0 1) CapsLock down
>> CapsLock does not get a up-event per...
>> https://bugzilla.mozilla.org/show_bug.cgi?id=259059
>> It perhaps can be simulated like...
>> https://developer.apple.com/library/mac/qa/qa1519/_index.html
>> Thoughts?
>

Reply | Threaded
Open this post in threaded view
|

Re: OSX VM doesn't generate events for modifier keypresses (shift, ctrl, etc)

Eliot Miranda-2


Hi Both,

On Nov 28, 2014, at 9:19 AM, Esteban Lorenzano <[hidden email]> wrote:

>
> you don’t
> they do not maintain a osx-cocoa version, so your changes are useless for them.

On the contrary.  As soon as possible I want to upgrade to 10.10 and that means Cocoa.  Right now I'm concentrating on Spur 64 bits.  But soon time may be available.  So Ben please send a change set if you can.

IIRC John McIntosh wrote the Cocoa integration and it is in the squeak tree.  It could do with more love but it exists and soon enough I'll be building it.

>
> Esteban
>
>> On 28 Nov 2014, at 18:09, Ben Coman <[hidden email]> wrote:
>>
>> I celebrate my first VM contribution :) :) :) with integration of [1] into pharo-vm on github.  Now how do I submit this for consideration for the SVN tree, to help keep things in syncd.
>> cheers -ben
>>
>> Ben Coman wrote:
>>> AliakseiSyrel reported that the OSX VM doesn't generate events on shift/ctrl/command/options/capslock keypress, but Win32 and Linux do.
>>> (https://pharo.fogbugz.com/default.asp?14521)
>>> I've submitted a fix to pharo-vm, but thought it might also be useful to others, and was hoping for some review and discussion here...
>>
>>> A diff can be seen here...
>>> [1] https://github.com/pharo-project/pharo-vm/pull/67/files
>>
>>> I discovered "recordCharEvent:fromView:" and "keyDown:" do not receive modifier keypresses, however "flagsChanged:" does - as described by the AppKit Reference "flagsChanged: informs the receiver that the user has pressed or released a modifier key (Shift, Control, and so on)."
>>> Just above "flagsChanged:" I noticed...
>>>   -(void)keyUp:(NSEvent*)theEvent {
>>>       [(sqSqueakOSXApplication *) gDelegateApp.squeakApplication
>>>           recordKeyUpEvent: theEvent fromView: self];
>>>   }
>>> So I duplicated recordKeyUpEvent:fromView:
>>> as recordKeyDownEvent:fromView:
>>> changing only...
>>>       evt.pressCode = EventKeyUp;
>>> to...
>>>       evt.pressCode = EventKeyDown;
>>> and called it from the bottom of flagsChanged:
>>> ============
>>> Now in a test image, adding a debug Transcript after primGetNextEvent:
>>>   InputEventFetcher>>eventLoop
>>>       ...
>>>   [true] whileTrue: [
>>>       self waitForInput.
>>>       [self primGetNextEvent: eventBuffer.
>>>           Transcript crShow: Time now ; tab ; show: eventBuffer.
>>> shows...
>>> 11:41:18.9594 pm    #(2 182714 56 1 1 0 0 1) Shift down
>>> 11:41:18.959581 pm    #(0 0 0 0 0 0 0 0)
>>> 11:41:19.19321 pm    #(2 182948 56 1 0 0 0 1) Shift up
>>> 11:41:19.193543 pm    #(0 0 0 0 0 0 0 0)
>>> 11:41:21.04326 pm    #(2 184798 59 1 2 0 0 1) Control down
>>> 11:41:21.043494 pm    #(0 0 0 0 0 0 0 0)
>>> 11:41:21.346713 pm    #(2 185102 59 1 0 0 0 1) Control up
>>> 11:41:21.346934 pm    #(0 0 0 0 0 0 0 0)
>>> 11:41:21.814845 pm    #(2 185569 58 1 4 0 0 1) Option down
>>> 11:41:21.815136 pm    #(0 0 0 0 0 0 0 0)
>>> 11:41:22.137117 pm    #(2 185892 58 1 0 0 0 1) Option up
>>> 11:41:22.137374 pm    #(0 0 0 0 0 0 0 0)
>>> 11:43:28.593666 pm    #(2 312348 55 1 8 0 0 1) Cmd down
>>> 11:43:28.593854 pm    #(0 0 0 0 0 0 0 0)
>>> 11:43:29.014829 pm    #(2 312770 55 1 0 0 0 1) Cmd up
>>> 11:43:29.015011 pm    #(0 0 0 0 0 0 0 0)
>>> 11:41:43.762799 pm    #(2 207517 57 1 0 0 0 1) CapsLock down
>>> CapsLock does not get a up-event per...
>>> https://bugzilla.mozilla.org/show_bug.cgi?id=259059
>>> It perhaps can be simulated like...
>>> https://developer.apple.com/library/mac/qa/qa1519/_index.html
>>> Thoughts?
>
Reply | Threaded
Open this post in threaded view
|

Re: OSX VM doesn't generate events for modifier keypresses (shift, ctrl, etc)

EstebanLM


> On 28 Nov 2014, at 19:27, Eliot Miranda <[hidden email]> wrote:
>
>
>
> Hi Both,
>
> On Nov 28, 2014, at 9:19 AM, Esteban Lorenzano <[hidden email]> wrote:
>
>>
>> you don’t
>> they do not maintain a osx-cocoa version, so your changes are useless for them.
>
> On the contrary.  As soon as possible I want to upgrade to 10.10 and that means Cocoa.  Right now I'm concentrating on Spur 64 bits.  But soon time may be available.  So Ben please send a change set if you can.
>
> IIRC John McIntosh wrote the Cocoa integration and it is in the squeak tree.  It could do with more love but it exists and soon enough I'll be building it.


yeah, but that was like 3yr ago… sources changed quite a lot in the mean time.
Going to cocoa will mean take back the full tree, not just the changes.

Esteban

>
>>
>> Esteban
>>
>>> On 28 Nov 2014, at 18:09, Ben Coman <[hidden email]> wrote:
>>>
>>> I celebrate my first VM contribution :) :) :) with integration of [1] into pharo-vm on github.  Now how do I submit this for consideration for the SVN tree, to help keep things in syncd.
>>> cheers -ben
>>>
>>> Ben Coman wrote:
>>>> AliakseiSyrel reported that the OSX VM doesn't generate events on shift/ctrl/command/options/capslock keypress, but Win32 and Linux do.
>>>> (https://pharo.fogbugz.com/default.asp?14521)
>>>> I've submitted a fix to pharo-vm, but thought it might also be useful to others, and was hoping for some review and discussion here...
>>>
>>>> A diff can be seen here...
>>>> [1] https://github.com/pharo-project/pharo-vm/pull/67/files
>>>
>>>> I discovered "recordCharEvent:fromView:" and "keyDown:" do not receive modifier keypresses, however "flagsChanged:" does - as described by the AppKit Reference "flagsChanged: informs the receiver that the user has pressed or released a modifier key (Shift, Control, and so on)."
>>>> Just above "flagsChanged:" I noticed...
>>>>  -(void)keyUp:(NSEvent*)theEvent {
>>>>      [(sqSqueakOSXApplication *) gDelegateApp.squeakApplication
>>>>          recordKeyUpEvent: theEvent fromView: self];
>>>>  }
>>>> So I duplicated recordKeyUpEvent:fromView:
>>>> as recordKeyDownEvent:fromView:
>>>> changing only...
>>>>      evt.pressCode = EventKeyUp;
>>>> to...
>>>>      evt.pressCode = EventKeyDown;
>>>> and called it from the bottom of flagsChanged:
>>>> ============
>>>> Now in a test image, adding a debug Transcript after primGetNextEvent:
>>>>  InputEventFetcher>>eventLoop
>>>>      ...
>>>>  [true] whileTrue: [
>>>>      self waitForInput.
>>>>      [self primGetNextEvent: eventBuffer.
>>>>          Transcript crShow: Time now ; tab ; show: eventBuffer.
>>>> shows...
>>>> 11:41:18.9594 pm    #(2 182714 56 1 1 0 0 1) Shift down
>>>> 11:41:18.959581 pm    #(0 0 0 0 0 0 0 0)
>>>> 11:41:19.19321 pm    #(2 182948 56 1 0 0 0 1) Shift up
>>>> 11:41:19.193543 pm    #(0 0 0 0 0 0 0 0)
>>>> 11:41:21.04326 pm    #(2 184798 59 1 2 0 0 1) Control down
>>>> 11:41:21.043494 pm    #(0 0 0 0 0 0 0 0)
>>>> 11:41:21.346713 pm    #(2 185102 59 1 0 0 0 1) Control up
>>>> 11:41:21.346934 pm    #(0 0 0 0 0 0 0 0)
>>>> 11:41:21.814845 pm    #(2 185569 58 1 4 0 0 1) Option down
>>>> 11:41:21.815136 pm    #(0 0 0 0 0 0 0 0)
>>>> 11:41:22.137117 pm    #(2 185892 58 1 0 0 0 1) Option up
>>>> 11:41:22.137374 pm    #(0 0 0 0 0 0 0 0)
>>>> 11:43:28.593666 pm    #(2 312348 55 1 8 0 0 1) Cmd down
>>>> 11:43:28.593854 pm    #(0 0 0 0 0 0 0 0)
>>>> 11:43:29.014829 pm    #(2 312770 55 1 0 0 0 1) Cmd up
>>>> 11:43:29.015011 pm    #(0 0 0 0 0 0 0 0)
>>>> 11:41:43.762799 pm    #(2 207517 57 1 0 0 0 1) CapsLock down
>>>> CapsLock does not get a up-event per...
>>>> https://bugzilla.mozilla.org/show_bug.cgi?id=259059
>>>> It perhaps can be simulated like...
>>>> https://developer.apple.com/library/mac/qa/qa1519/_index.html
>>>> Thoughts?
>>

Reply | Threaded
Open this post in threaded view
|

Re: OSX VM doesn't generate events for modifier keypresses (shift, ctrl, etc)

EstebanLM
 

On 28 Nov 2014, at 19:29, Esteban Lorenzano <[hidden email]> wrote:


On 28 Nov 2014, at 19:27, Eliot Miranda <[hidden email]> wrote:



Hi Both,

On Nov 28, 2014, at 9:19 AM, Esteban Lorenzano <[hidden email]> wrote:


you don’t
they do not maintain a osx-cocoa version, so your changes are useless for them. 

On the contrary.  As soon as possible I want to upgrade to 10.10 and that means Cocoa.  Right now I'm concentrating on Spur 64 bits.  But soon time may be available.  So Ben please send a change set if you can.

IIRC John McIntosh wrote the Cocoa integration and it is in the squeak tree.  It could do with more love but it exists and soon enough I'll be building it.


yeah, but that was like 3yr ago… sources changed quite a lot in the mean time. 
Going to cocoa will mean take back the full tree, not just the changes. 

ah, but is super cool that you want to move to cocoa soon :)
so, let me know how can I help you in the process. 


Esteban



Esteban 

On 28 Nov 2014, at 18:09, Ben Coman <[hidden email]> wrote:

I celebrate my first VM contribution :) :) :) with integration of [1] into pharo-vm on github.  Now how do I submit this for consideration for the SVN tree, to help keep things in syncd.
cheers -ben

Ben Coman wrote:
AliakseiSyrel reported that the OSX VM doesn't generate events on shift/ctrl/command/options/capslock keypress, but Win32 and Linux do.
(https://pharo.fogbugz.com/default.asp?14521)
I've submitted a fix to pharo-vm, but thought it might also be useful to others, and was hoping for some review and discussion here...

A diff can be seen here...
[1] https://github.com/pharo-project/pharo-vm/pull/67/files

I discovered "recordCharEvent:fromView:" and "keyDown:" do not receive modifier keypresses, however "flagsChanged:" does - as described by the AppKit Reference "flagsChanged: informs the receiver that the user has pressed or released a modifier key (Shift, Control, and so on)."
Just above "flagsChanged:" I noticed...
-(void)keyUp:(NSEvent*)theEvent {
    [(sqSqueakOSXApplication *) gDelegateApp.squeakApplication
        recordKeyUpEvent: theEvent fromView: self];
}
So I duplicated recordKeyUpEvent:fromView:
as recordKeyDownEvent:fromView:
changing only...
    evt.pressCode = EventKeyUp;
to...
    evt.pressCode = EventKeyDown;
and called it from the bottom of flagsChanged:
============
Now in a test image, adding a debug Transcript after primGetNextEvent:
InputEventFetcher>>eventLoop
    ...
[true] whileTrue: [
    self waitForInput.
    [self primGetNextEvent: eventBuffer.
        Transcript crShow: Time now ; tab ; show: eventBuffer.
shows...
11:41:18.9594 pm    #(2 182714 56 1 1 0 0 1) Shift down
11:41:18.959581 pm    #(0 0 0 0 0 0 0 0)
11:41:19.19321 pm    #(2 182948 56 1 0 0 0 1) Shift up
11:41:19.193543 pm    #(0 0 0 0 0 0 0 0)
11:41:21.04326 pm    #(2 184798 59 1 2 0 0 1) Control down
11:41:21.043494 pm    #(0 0 0 0 0 0 0 0)
11:41:21.346713 pm    #(2 185102 59 1 0 0 0 1) Control up
11:41:21.346934 pm    #(0 0 0 0 0 0 0 0)
11:41:21.814845 pm    #(2 185569 58 1 4 0 0 1) Option down
11:41:21.815136 pm    #(0 0 0 0 0 0 0 0)
11:41:22.137117 pm    #(2 185892 58 1 0 0 0 1) Option up
11:41:22.137374 pm    #(0 0 0 0 0 0 0 0)
11:43:28.593666 pm    #(2 312348 55 1 8 0 0 1) Cmd down
11:43:28.593854 pm    #(0 0 0 0 0 0 0 0)
11:43:29.014829 pm    #(2 312770 55 1 0 0 0 1) Cmd up
11:43:29.015011 pm    #(0 0 0 0 0 0 0 0)
11:41:43.762799 pm    #(2 207517 57 1 0 0 0 1) CapsLock down
CapsLock does not get a up-event per...
https://bugzilla.mozilla.org/show_bug.cgi?id=259059
It perhaps can be simulated like...
https://developer.apple.com/library/mac/qa/qa1519/_index.html
Thoughts?

Reply | Threaded
Open this post in threaded view
|

Re: OSX VM doesn't generate events for modifier keypresses (shift, ctrl, etc)

David T. Lewis
In reply to this post by Ben Coman
 
On Sat, Nov 29, 2014 at 01:09:39AM +0800, Ben Coman wrote:
>
> I celebrate my first VM contribution :) :) :) with integration of [1]
> into pharo-vm on github.  Now how do I submit this for consideration for
> the SVN tree, to help keep things in syncd.
> cheers -ben

Hi Ben,

Bravo! Thanks for your contribution, and thank you for keeping the sources
in sync.

Conceptually we have:

  -- SVN trunk
    -- SVN oscog
      -- Pharo VM

Active development is happening in Cog/Spur ("SVN oscog"), and we are
trying to keep SVN trunk synchronized with this as well.

Eliot replied separately, and if you can post your change set to Eliot and
to vm-dev, that is the best thing. It would be good if your changes can also
be incorporated into SVN trunk, but we do not currently have a maintainer for
the trunk SVN branch for Mac, so getting your changes into Eliot's source
tree should be the priority. This should keep them synchronized with the Cog,
Spur and Pharo VMs.

Thanks!

Dave

>
> Ben Coman wrote:
> >
> >AliakseiSyrel reported that the OSX VM doesn't generate events on
> >shift/ctrl/command/options/capslock keypress, but Win32 and Linux do.
> >(https://pharo.fogbugz.com/default.asp?14521)
> >
> >I've submitted a fix to pharo-vm, but thought it might also be useful to
> >others, and was hoping for some review and discussion here...
>
> >A diff can be seen here...
> >[1] https://github.com/pharo-project/pharo-vm/pull/67/files
> >
>
> >I discovered "recordCharEvent:fromView:" and "keyDown:" do not receive
> >modifier keypresses, however "flagsChanged:" does - as described by the
> >AppKit Reference "flagsChanged: informs the receiver that the user has
> >pressed or released a modifier key (Shift, Control, and so on)."
> >
> >Just above "flagsChanged:" I noticed...
> >    -(void)keyUp:(NSEvent*)theEvent {
> >        [(sqSqueakOSXApplication *) gDelegateApp.squeakApplication
> >            recordKeyUpEvent: theEvent fromView: self];
> >    }
> >
> >So I duplicated recordKeyUpEvent:fromView:
> >as recordKeyDownEvent:fromView:
> >changing only...
> >        evt.pressCode = EventKeyUp;
> >to...
> >        evt.pressCode = EventKeyDown;
> >
> >and called it from the bottom of flagsChanged:
> >
> >============
> >Now in a test image, adding a debug Transcript after primGetNextEvent:
> >    InputEventFetcher>>eventLoop
> >        ...
> >    [true] whileTrue: [
> >        self waitForInput.
> >        [self primGetNextEvent: eventBuffer.
> >            Transcript crShow: Time now ; tab ; show: eventBuffer.
> >
> >shows...
> >
> >11:41:18.9594 pm    #(2 182714 56 1 1 0 0 1) Shift down
> >11:41:18.959581 pm    #(0 0 0 0 0 0 0 0)
> >11:41:19.19321 pm    #(2 182948 56 1 0 0 0 1) Shift up
> >11:41:19.193543 pm    #(0 0 0 0 0 0 0 0)
> >11:41:21.04326 pm    #(2 184798 59 1 2 0 0 1) Control down
> >11:41:21.043494 pm    #(0 0 0 0 0 0 0 0)
> >11:41:21.346713 pm    #(2 185102 59 1 0 0 0 1) Control up
> >11:41:21.346934 pm    #(0 0 0 0 0 0 0 0)
> >11:41:21.814845 pm    #(2 185569 58 1 4 0 0 1) Option down
> >11:41:21.815136 pm    #(0 0 0 0 0 0 0 0)
> >11:41:22.137117 pm    #(2 185892 58 1 0 0 0 1) Option up
> >11:41:22.137374 pm    #(0 0 0 0 0 0 0 0)
> >11:43:28.593666 pm    #(2 312348 55 1 8 0 0 1) Cmd down
> >11:43:28.593854 pm    #(0 0 0 0 0 0 0 0)
> >11:43:29.014829 pm    #(2 312770 55 1 0 0 0 1) Cmd up
> >11:43:29.015011 pm    #(0 0 0 0 0 0 0 0)
> >11:41:43.762799 pm    #(2 207517 57 1 0 0 0 1) CapsLock down
> >
> >CapsLock does not get a up-event per...
> >https://bugzilla.mozilla.org/show_bug.cgi?id=259059
> >
> >It perhaps can be simulated like...
> >https://developer.apple.com/library/mac/qa/qa1519/_index.html
> >
> >Thoughts?
> >
Reply | Threaded
Open this post in threaded view
|

Re: OSX VM doesn't generate events for modifier keypresses (shift, ctrl, etc)

Ben Coman
In reply to this post by Eliot Miranda-2
 
Eliot Miranda wrote:
> So Ben please send a change set if you can.

Is the attached file sufficient?
cheers -ben


diff --git a/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+events.m b/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+events.m
index ee794dd..f861db9 100644
--- a/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+events.m
+++ b/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+events.m
@@ -73,6 +73,7 @@
  ioProcessEvents();
  id event = [eventQueue returnAndRemoveOldest];
  if (event) {
+ /* NSLog(@"ioGetNextEvent:"); */
  NSAutoreleasePool * pool = [NSAutoreleasePool new];
  [self processAsOldEventOrComplexEvent: event placeIn: evt];
  [event release];
diff --git a/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.h b/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.h
index 1d2aa7c..1cbc2db 100644
--- a/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.h
+++ b/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.h
@@ -43,6 +43,7 @@
 @interface sqSqueakOSXApplication (events)
 
 - (void) recordCharEvent:(NSString *) unicodeString fromView: (NSView<sqSqueakOSXView> *) mainView;
+- (void) recordKeyDownEvent:(NSEvent *)theEvent fromView: (NSView<sqSqueakOSXView> *) aView ;
 - (void) recordKeyUpEvent:(NSEvent *)theEvent fromView: (NSView<sqSqueakOSXView> *) aView ;
 - (void) recordMouseEvent: (NSEvent*) theEvent fromView: (NSView<sqSqueakOSXView> *) aView;
 - (void) recordWheelEvent: (NSEvent*) theEvent  fromView: (NSView<sqSqueakOSXView> *) aView;
diff --git a/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.m b/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.m
index f3d6d32..b3e1580 100644
--- a/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.m
+++ b/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.m
@@ -157,6 +157,8 @@ static int buttonState=0;
 
 - (void) pushEventToQueue: (sqInputEvent *) evt {
  NSMutableArray* data = [NSMutableArray new];
+
+// NSLog(@"sqSqueakOSXApplication+events.m>>pushEventToQueue:");
  [data addObject: [NSNumber numberWithInteger: 1]];
  [data addObject: [NSData  dataWithBytes:(const void *) evt length: sizeof(sqInputEvent)]];
  [eventQueue addItem: data];
@@ -171,6 +173,7 @@ static int buttonState=0;
  NSRange picker;
  NSUInteger totaLength;
 
+// NSLog(@"sqSqueakOSXApplication+events>>recordCharEvent:fromView:");
  evt.type = EventTypeKeyboard;
  evt.timeStamp = (int) ioMSecs();
  picker.location = 0;
@@ -227,6 +230,22 @@ static int buttonState=0;
 
 }
 
+- (void) recordKeyDownEvent:(NSEvent *)theEvent fromView: (NSView<sqSqueakOSXView>*) aView {
+ sqKeyboardEvent evt;
+
+ evt.type = EventTypeKeyboard;
+ evt.timeStamp = (int) ioMSecs();
+ evt.charCode = [theEvent keyCode];
+ evt.pressCode = EventKeyDown;
+ evt.modifiers = [self translateCocoaModifiersToSqueakModifiers: [theEvent modifierFlags]];
+ evt.utf32Code = 0;
+ evt.reserved1 = 0;
+ evt.windowIndex = (int)[[aView windowLogic] windowIndex];
+ [self pushEventToQueue: (sqInputEvent *) &evt];
+
+ interpreterProxy->signalSemaphoreWithIndex(gDelegateApp.squeakApplication.inputSemaphoreIndex);
+}
+
 - (void) recordKeyUpEvent:(NSEvent *)theEvent fromView: (NSView<sqSqueakOSXView>*) aView {
  sqKeyboardEvent evt;
 
diff --git a/platforms/iOS/vm/OSX/sqSqueakOSXCGView.m b/platforms/iOS/vm/OSX/sqSqueakOSXCGView.m
index 0a1f9fe..5a9480e 100644
--- a/platforms/iOS/vm/OSX/sqSqueakOSXCGView.m
+++ b/platforms/iOS/vm/OSX/sqSqueakOSXCGView.m
@@ -339,6 +339,7 @@ lastSeenKeyBoardModifierDetails,dragInProgress,dragCount,dragItems,windowLogic,s
  NSArray *down = [[NSArray alloc] initWithObjects: theEvent,nil];
  @synchronized(self) {
  lastSeenKeyBoardStrokeDetails = aKeyBoardStrokeDetails;
+
  NSString *possibleConversion = [theEvent characters];
 
  if ([possibleConversion length] > 0) {
@@ -357,6 +358,7 @@ lastSeenKeyBoardModifierDetails,dragInProgress,dragCount,dragItems,windowLogic,s
  aKeyBoardStrokeDetails.modifierFlags = [theEvent modifierFlags];
 
  NSArray *down = [[NSArray alloc] initWithObjects: theEvent,nil];
+// NSLog(@"sqSqueakOSXCGView.m>>keyDown:");
  @synchronized(self) {
  lastSeenKeyBoardStrokeDetails = aKeyBoardStrokeDetails;
  [self interpretKeyEvents: down];
@@ -373,19 +375,24 @@ lastSeenKeyBoardModifierDetails,dragInProgress,dragCount,dragItems,windowLogic,s
 
 - (void)insertText:(id)aString
 {
+// NSLog(@"sqSqueakOSXCGView.m>>insertText:");
+
  [(sqSqueakOSXApplication *) gDelegateApp.squeakApplication recordCharEvent: aString fromView: self];
 }
 
 - (void)insertText:(id)aString replacementRange:(NSRange)replacementRange
 {
+// NSLog(@"sqSqueakOSXCGView.m>>insertText:replacementRange:");
  [(sqSqueakOSXApplication *) gDelegateApp.squeakApplication recordCharEvent: aString fromView: self];
 }
 
 - (void)flagsChanged:(NSEvent *)theEvent {
+// NSLog(@"sqSqueakOSXCGView.m>>flagsChanged -- %d, %d", [theEvent keyCode], [theEvent modifierFlags] );
  keyBoardStrokeDetails *aKeyBoardStrokeDetails = [[keyBoardStrokeDetails alloc] init];
  aKeyBoardStrokeDetails.keyCode = [theEvent keyCode];
  aKeyBoardStrokeDetails.modifierFlags = [theEvent modifierFlags];
  self.lastSeenKeyBoardModifierDetails = aKeyBoardStrokeDetails;
+ [(sqSqueakOSXApplication *) gDelegateApp.squeakApplication recordKeyDownEvent: theEvent fromView: self];
  [aKeyBoardStrokeDetails release];
 }
 
@@ -677,4 +684,4 @@ lastSeenKeyBoardModifierDetails,dragInProgress,dragCount,dragItems,windowLogic,s
  }
 }
 
-@end
\ No newline at end of file
+@end