Newt KeyEvent "typed" only produced on release and auto-repeat

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

Newt KeyEvent "typed" only produced on release and auto-repeat

GiGurra
While developing a small OpenGL/OpenCL game using JOGL and JOCL, we've run into a problem with newt KeyEvents.

As we target Windows (and other platforms), and want to support chat, we need to be able
to get correct key characters for different keyboard events.

(These tests are on oracle's java7 64 bit jvm on windows 7 using jogl 2.0-rc11)

Jogl NEWT KeyEvent typed events deliver the correct characters, HOWEVER:
The first typed event arrives with a significant delay, since the event is only
produced when the key is released (or when the first autorepeat kicks in).


This is problematic as it makes text input seem very sluggish.

Pressed-events are delivered instantly, however as documented, these do not give full character information.

Is there any known way to solve or work around this?
Is there any jogl beta where typed events get delivered faster on windows or where Pressed events contain character info?
Reply | Threaded
Open this post in threaded view
|

Re: Newt KeyEvent "typed" only produced on release and auto-repeat

gouessej
Administrator
Don't look for a "beta", we will try to find a clean solution. Wouldn't you have a similar problem with AWT?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Newt KeyEvent "typed" only produced on key-up and auto-repeat

Sven Gothel
Administrator
In reply to this post by GiGurra
On 01/28/2013 11:21 PM, GiGurra [via jogamp] wrote:

>
>
> While developing a small OpenGL/OpenCL game using JOGL and JOCL, we've run
> into a problem with newt KeyEvents.
>
> As we target Windows, and want to support chat, we need to be able
> to get correct key characters for different keyboard events.
>
> (These tests are on oracle's java7 64 bit jvm on windows 7 using jogl 2.0-rc11)
>
> Jogl KeyEvent typed events deliver the correct characters, HOWEVER:
> The first typed event arrives with a significant delay, since it is only
> produces when the key is released (or when the first autorepeat kicks in).
>
> This is problematic as it makes text input seem very sluggish.
>
> Pressed-events are delivered instantly, however as documented, these do not
> give any character information.
>
> Is there any known way to solve or work around this?
You could use the key-code, which ofc would be a PIA for you - hmm.

> Is there any jogl beta where typed events get delivered faster on windows or
> where Pressed events contain character info?

But I see your point .. and I will look into this again and reply here
in a while ..

~Sven



signature.asc (911 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Newt KeyEvent "typed" only produced on release and auto-repeat

GiGurra
In reply to this post by gouessej
No AWT produces the typed event as soon as you hit the key - not on release.

I just tested it using:

package test;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;

public class AwtTest {

        public static void main(String[] args) {
                final JFrame x = new JFrame();
                x.setSize(400, 300);
                x.setVisible(true);

                x.addWindowListener(new WindowAdapter() {
                        @Override
                        public void windowClosing(WindowEvent e) {
                                x.dispose();
                        }
                });

                x.addKeyListener(new KeyAdapter() {
                        @Override
                        public void keyTyped(KeyEvent e) {
                                System.out.print(e.getKeyChar());
                        }
                });
        }

}
Reply | Threaded
Open this post in threaded view
|

Re: Newt KeyEvent "typed" only produced on key-up and auto-repeat

GiGurra
This post was updated on .
In reply to this post by Sven Gothel
Ok, 2 threads? :). Should I write here or in the other thread?
In the meantime I think I'll just lazy in a JNA keyboard hook.
Reply | Threaded
Open this post in threaded view
|

Re: Newt KeyEvent "typed" only produced on release and auto-repeat

gouessej
Administrator
In reply to this post by GiGurra
I read that in the documentation:
Key releases are not usually necessary to generate a key typed event, but there are some cases where the key typed event is not generated until a key is released
It seems to be possible to do the same.

GiGurra wrote
Ok, 2 threads? :). Should I write here or in the other thread?
In the meantime I think I'll just lazy in a JNA keyboard hook.
There is only one thread now :) Please tell us which native functions you will call, it might be helpful.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Newt KeyEvent "typed" only produced on key-up and auto-repeat

Sven Gothel
Administrator
In reply to this post by GiGurra
On 01/29/2013 05:16 AM, Sven Gothel wrote:

> On 01/28/2013 11:21 PM, GiGurra [via jogamp] wrote:
>>
>>
>> While developing a small OpenGL/OpenCL game using JOGL and JOCL, we've run
>> into a problem with newt KeyEvents.
>>
>> As we target Windows, and want to support chat, we need to be able
>> to get correct key characters for different keyboard events.
>>
>> (These tests are on oracle's java7 64 bit jvm on windows 7 using jogl 2.0-rc11)
>>
>> Jogl KeyEvent typed events deliver the correct characters, HOWEVER:
>> The first typed event arrives with a significant delay, since it is only
>> produces when the key is released (or when the first autorepeat kicks in).
>>
>> This is problematic as it makes text input seem very sluggish.
>>
>> Pressed-events are delivered instantly, however as documented, these do not
>> give any character information.
>>
>> Is there any known way to solve or work around this?
> You could use the key-code, which ofc would be a PIA for you - hmm.
>
>> Is there any jogl beta where typed events get delivered faster on windows or
>> where Pressed events contain character info?
>
> But I see your point .. and I will look into this again and reply here
> in a while ..
Good NEWS:
  https://jogamp.org/bugzilla/show_bug.cgi?id=678

I will implement this change now .. and notify you.

~Sven



signature.asc (911 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Newt KeyEvent "typed" only produced on key-up and auto-repeat

GiGurra
I see it is marked as "Fixed" here https://jogamp.org/bugzilla/show_bug.cgi?id=678 .

Which version is it implemented in? Where can I get it :). I'm currently in 2.0 rc-11 but if you point me to the beta with the fix I'll grab that ASAP.

Can get it as a beta release jar? I'd rather not have to build the native jogl on windows and package it in a jar..

BTW thanks a lot for the quick fix!
Reply | Threaded
Open this post in threaded view
|

Re: Newt KeyEvent "typed" only produced on key-up and auto-repeat

gouessej
Administrator
Sven, please can you make another autobuild? The latest one doesn't contain this fix.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Newt KeyEvent "typed" only produced on key-up and auto-repeat

Sven Gothel
Administrator
On 01/30/2013 06:14 PM, gouessej [via jogamp] wrote:
> Sven, please can you make another autobuild? The latest one doesn't contain
> this fix.

Yup .. in progress.
I currently fix a OSX/Java7 node to our Jenkins, then I kick off the 'machine'
- incl. JOAL merge.

~Sven



signature.asc (911 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Newt KeyEvent "typed" only produced on key-up and auto-repeat

GiGurra
Any news yet on that build? ;)

Sorry for being impatient hehe. Thanks for your work!
Reply | Threaded
Open this post in threaded view
|

Re: Newt KeyEvent "typed" only produced on key-up and auto-repeat

GiGurra
I saw a new release at http://jogamp.org/deployment/archive/master/gluegen_629-joal_396-jogl_903-jocl_741-signed/

But this did NOT fix the issue. Waiting for word from you when a new version will be out :).
Reply | Threaded
Open this post in threaded view
|

Re: Newt KeyEvent "typed" only produced on key-up and auto-repeat

GiGurra
In reply to this post by Sven Gothel
The build I tried above gives the following results:

"typed" is still sent on key release,
however "pressed" now contains the same information as typed, so that is good.

BUT:
Both have many incorrect mappings. They procude the same values, but don't seem to match my keyboard layout properly.

For example Alt Gr + 'the button left of z' (Swedish keyboard) should produce | , the button itself should be < and with shift it should be >. However the events all give me  < .

Reply | Threaded
Open this post in threaded view
|

Re: Newt KeyEvent "typed" only produced on key-up and auto-repeat

gouessej
Administrator
GiGurra wrote
"typed" is still sent on key release,
Reopen the former bug report or write a new one. Maybe consider writing another unit test to exhibit the problematic behaviour.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Newt KeyEvent "typed" only produced on key-up and auto-repeat

Sven Gothel
Administrator
On 02/04/2013 10:11 AM, gouessej [via jogamp] wrote:
>     GiGurra wrote
>     "typed" is still sent on key release,
>
> Reopen the former bug report or write a new one. Maybe consider writing
> another unit test to exhibit the problematic behaviour.

Bug 678 https://jogamp.org/bugzilla/show_bug.cgi?id=678
is fixed - the remaining issue reported,
key-code depends key layout, matches existing bug 668
https://jogamp.org/bugzilla/show_bug.cgi?id=668

~Sven



signature.asc (911 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Newt KeyEvent "typed" only produced on key-up and auto-repeat

Sven Gothel
Administrator
In reply to this post by GiGurra
On 02/02/2013 06:47 PM, GiGurra [via jogamp] wrote:
> The Beta version I tried above gives the following results:
>
> "typed" is still sent on key release,
> however "pressed" now contains the same information as type.

types shall be sent after key release (NEWT KeyEvent spec)
and this is validated in fix of bug 678
  https://jogamp.org/bugzilla/show_bug.cgi?id=678

http://jogamp.org/git/?p=jogl.git;a=commit;h=90e136b65a10d8daf8c3a2df6cc193e55a63722c

>
> BUT:
> Both have many incorrect mappings. They procude the same values, but don't
> seem to match my keyboard layout properly.
>
> For example Alt Gr + 'the button left of z' (Swedish keyboard) should produce
> | , the button itself should be < and with shift it should be >. However the
> events all give me  < .

Key-code or key-char ?

Probably related to bug 668 ?
https://jogamp.org/bugzilla/show_bug.cgi?id=668

How can we have a reliable unit test ?

~Sven



signature.asc (911 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Newt KeyEvent "typed" only produced on key-up and auto-repeat

GiGurra
Ok let me make it clearer:

Pressed and Typed now produce the same key chars: GOOD!, thx!

However the keyChars for several combinations are incorrect.

For example on a swedish keyboard (with the layout in the image posted above),
ALT gr + "<" (< being the button left of z) should proce a "|"

Most combinations using Alt GR are incorrect (but not all)

It seems like a layout issue.

Reply | Threaded
Open this post in threaded view
|

Re: Newt KeyEvent "typed" only produced on key-up and auto-repeat

Sven Gothel
Administrator
On 02/04/2013 08:02 PM, GiGurra [via jogamp] wrote:

> Ok let me make it clearer:
>
> Pressed and Typed now produce the same key chars: GOOD!, thx!
>
> However the keyChars for several combinations are incorrect.
>
> For example on a swedish keyboard (with the layout in the image posted above),
> ALT gr + "<" (< being the button left of z) should proce a "|"
>
> Most combinations using Alt GR are incorrect (but not all)
>
> It seems like a layout issue.
Thx .. I will tackle this again soon w/ bug 668,
trying to use such a keyboard layout.

Maybe you can add your findings w/ keyboard layout picture to bug 668.

Thank you, Sven



signature.asc (911 bytes) Download Attachment