Wrong keyCodes with NEWT on Linux.

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

Wrong keyCodes with NEWT on Linux.

lex
Hello.

I am trying to build an application with JOGL and NEWT. However I have ran into an unexpected problem. They keyCodes returned by the NEWT KeyboardListener do no match the codes in KeyEvenet constants.

I have tried to work around the problem, however the key codes are also different when changing the keyboard layout to another language.

Is this the expected behavior. Are there any work-arounds?
Reply | Threaded
Open this post in threaded view
|

Re: Wrong keyCodes with NEWT on Linux.

gouessej
Administrator
Hi

Which kind of keyboard do you use? QWERTY? QWERTZ? AZERTY?
Julien Gouesse | Personal blog | Website
lex
Reply | Threaded
Open this post in threaded view
|

Re: Wrong keyCodes with NEWT on Linux.

lex
I use a pretty standard Logitech QWERTY keyboard.


More strange results:

It seems that all the letters are offset by 32, unless they are used in conjunction with Shift. So when pressing Q, i get the key code equal to (KeyEvent.VK_Q + 32). And when pressing Shift + Q, the key code will be equal to KeyEvent.VK_Q.

Numbers 0 - 9 match their key codes, unless used with Shift, then I get key codes which are not even in the KeyEvent constants.

Braces, colon, and quote keys resolve to strange key codes not found in KeyEventCosntants.

Numpad keys, including the numpad enter key, resolve to completely strange keycodes (over 60 000) with or without numlock. Though the key codes are different depending on the numlock state.


I have done a quick test on Windows (another machine) and everything worked fine. My guess is that linux support is lacking and the native lib is sending raw keycodes.
I am using jogl version: 2.0.rc2 (Released on 03-Mar-2011)
lex
Reply | Threaded
Open this post in threaded view
|

Re: Wrong keyCodes with NEWT on Linux.

lex
Another issue i found is that mouse scroll generates mouse button events instead of mouse wheel events: button4 for wheel up and button5 for wheel down.

Another unrelated problem is setting the full screen is buggy: the taskbar remains on top, and window.requestFocus() does nothing.

The Linux support seems to be so bad that it's not possible to use NEWT in production. Are there plans to improve it or is it best to simply stick with AWT/Swing JOGL integration?
Reply | Threaded
Open this post in threaded view
|

Re: Wrong keyCodes with NEWT on Linux.

Sven Gothel
Administrator
On Tuesday, August 16, 2011 02:15:42 PM lex [via jogamp] wrote:

>
> Another issue i found is that mouse scroll generates mouse button events
> instead of mouse wheel events: button4 for wheel up and button5 for wheel
> down.
>
> Another unrelated problem is setting the full screen is buggy: the taskbar
> remains on top, and window.requestFocus() does nothing.
>
> The Linux support seems to be so bad that it's not possible to use NEWT in
> production. Are there plans to improve it or is it best to simply stick with
> AWT/Swing JOGL integration?
>

That sentence catched my eye .. ofc :)

- I assume you use the latest JOGL version ?

- Can you provide qualifying information (FAQ -> Bug Report),
  incl. your window manager setup etc ?

- Can you provide a simple test case, so we can reproduce your case
  and understand the issue better ?

Until now, both worked pretty well under Linux (mind bug 502 though),
keyboard codes and fullscreen.

Actually Linux/X11 is the 1st dev platform :)

Sorry that you have those issues, please provide above information.

~Sven
Reply | Threaded
Open this post in threaded view
|

Re: Wrong keyCodes with NEWT on Linux.

gouessej
Administrator
In reply to this post by lex
lex, fullscreen is broken with AWT/Swing on Linux in KDE 4, I wrote a bug report about that, fullscreen support of NEWT on Linux is better than Oracle fullscreen support in AWT/Swing. The task bar remains on top on KDE 4 and AWT, not on NEWT or you did something wrong. Can you tell me which window manager you use please?

Stick with AWT/Swing integration if NEWT does not give you any performance improvements and if you don't need to support multiple displays but GLJPanel has some limitations too. However, in the future, using an AWT peer with NEWT might become a more viable solution.
Julien Gouesse | Personal blog | Website
lex
Reply | Threaded
Open this post in threaded view
|

Re: Wrong keyCodes with NEWT on Linux.

lex
In reply to this post by Sven Gothel
> Actually Linux/X11 is the 1st dev platform :)

This is very reassuring!
I intend get to the bottom of this. So I will start working on a test case.
Reply | Threaded
Open this post in threaded view
|

Re: Wrong keyCodes with NEWT on Linux.

Sven Gothel
Administrator
On Wednesday, August 17, 2011 09:11:32 PM lex [via jogamp] wrote:
>
> > Actually Linux/X11 is the 1st dev platform :)
>
> This is very reassuring!

Thank you very much - and trust me, it really is.

Actual order of things currently is:

- Unix OS [ Linux, .. ] + [ X11, Android-Surface, .. ] @ x86, x86_64, arm7
- Windows @ x86, x86_64
- OSX @ x86_64

Adn ofc NEWT is the only toolkit which supports them all, hence it is critical.

> I intend get to the bottom of this. So I will start working on a test case.

Pls do so, this will allow us to become more stabel/mature.
even if you might think some minor information about your setup is useless
(windowmanager, 32/64 bit, java version, .. compositioning, ..) it might matter.

~Sven
lex
Reply | Threaded
Open this post in threaded view
|

Re: Wrong keyCodes with NEWT on Linux.

lex
I use Arch Linux, 64 bit version, with standard X and KDE 4.7 vanilla setup. Java version is 7. JOGL version is 2.0.rc2 (Released on 03-Mar-2011), downloaded from "http://jogamp.org/deployment/webstart/".

I have been playing with JOGL and NEWT for a while, but havent started a serious project until now. I had problems with fullScreen not functioning correctly as far back as Java 6 and JOGL 2.0.rc1. Though I don't know about the input issues with earlier versions.

My window setup is as follows (copied from one of the examples and then modified):
[code]
    NewtFactory.setUseEDT(true)

    val display = NewtFactory.createDisplay(null)
    val screen  = NewtFactory.createScreen(display, 0)
    val profile = GLProfile.get(GLProfile.GL2ES2)
    if (profile == null) throw new RuntimeException("Required GL profile is not supported.")
    val capabilities = new GLCapabilities(profile)
   
    val newtWindow = NewtFactory.createWindow(screen, capabilities)
    val window = GLWindow.create(newtWindow)

    val exitListener = new WindowAdapter with KeyListener {
      override def windowDestroyNotify(e: WindowEvent) { quit = true }

      def keyPressed(e: NKeyEvent) {}
      def keyReleased(e: NKeyEvent) { if (e.getKeyCode() == NKeyEvent.VK_ESCAPE) quit = true }
      def keyTyped(e: NKeyEvent) {}
    }
    window.addWindowListener(exitListener)
    window.addKeyListener(exitListener)
    window.addKeyListener(wrappedInput)
    window.addMouseListener(wrappedInput)

    window.addGLEventListener(glEventListener)
    window.setAutoSwapBufferMode(true)

    window.setPosition(0, 0)
    window.setSize(800, 600)
    window.setVisible(true)
    window.setFullscreen(false)
    window.enablePerfLog(false)
    window.requestFocus()
[/code]


My wild guess at the moment is that I am using outdated natives libraries. I am working on an ANT script to download all the libraries and launch a simple example. Then I will test it on my system and some live-cd versions of linux.
lex
Reply | Threaded
Open this post in threaded view
|

Re: Wrong keyCodes with NEWT on Linux.

lex
I have finished an automated ANT script to download jogl depencies and native libs, setup the classpath and native library path, and finally, compile and run an example. Here are the files:

build.xml:       http://pastebin.com/7tGXM61w
Example.java: http://pastebin.com/SaRgkGCz

To run: "ant run64". or "ant run32".

Press the key Q, you will see the correct key code as well as the received key code.
Also try Shift+Q.

You can change the fullscreen settings in Example.java by modifying the following line:
window.setFullscreen(false);

TEST RESULTS:
Wrong keycode for Arch Linux 64 bit.
Wrong keycode for Linux Mint 32 bit.

This setup is consistently buggy for me on two different machines with two different variants of Linux.
lex
Reply | Threaded
Open this post in threaded view
|

Re: Wrong keyCodes with NEWT on Linux.

lex
This post was updated on .
I forgot to mention that Linux Mint has Java 6 and uses Gnome, and Arch Linux has Java 7 and uses KDE.
lex
Reply | Threaded
Open this post in threaded view
|

Re: Wrong keyCodes with NEWT on Linux.

lex
I have also tested the atomic jogl setup with the same results. At this point all I can tell is that the files available at http://jogamp.org/deployment/webstart/ do not work for newt on linux (both 32 and 64).

If you are an on linux, please run the test and verify the results.
lex
Reply | Threaded
Open this post in threaded view
|

Re: Wrong keyCodes with NEWT on Linux.

lex
I have noticed that it is not possible to have both W and A pressed at the same time. So with WSAD camera controls it is not possible to go forward and left at the same time. Same goes for any two key combinations. This issue is persistent on both Windows and Linux (not tested on mac).

Has anyone managed to get controls working with JOGL and NEWT on any platform? Am I doing something seriously wrong to have so many problems?!
Reply | Threaded
Open this post in threaded view
|

Re: Wrong keyCodes with NEWT on Linux.

gouessej
Administrator
In reply to this post by lex
Hi

I tested this a few months ago on Mageia Linux 1, 32 bits, KDE 4, and full screen was working fine:
http://jogamp.org/deployment/webstart/jogl-demos/jogl-newt-applet-runner-angelesgl2es1.html

I'm going to give it another try tonight. I will try to use your ANT script at home during this weekend.

I'm quite surprised because even the buggy fullscreen support of AWT has reliably worked on Gnome for years (since about 2007 just after something wrong had been changed in Metacity).

Can you try older versions to see whether it is a regression? I'm sure NEWT fullscreen was working fine on Linux a few months ago, I had tested on several machines, 32 bits & 64 bits.


Sven, please, can you add a Java Web Start version of the same demo I tried several months ago (Angeles GL2ES1)? On some Linux machines I use for my tests, I don't have enough permissions to setup Java in Firefox. I would like to use this demo on 64 bits machines and at home I have only 2 computers with 32 bits microprocessors.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Wrong keyCodes with NEWT on Linux.

gouessej
Administrator
In reply to this post by lex
Full screen mode still works on KDE 4.6.3 with Mageia Linux 1, NVIDIA 7600 GT, proprietary driver, no compositing, no 3D desktop effects.
Julien Gouesse | Personal blog | Website
lex
Reply | Threaded
Open this post in threaded view
|

Re: Wrong keyCodes with NEWT on Linux.

lex
Fullscreen mode works 50% of the time for me. Please test it several times to get an accurate reading. Also, are you getting the correct keys?

Despite all the setbacks I have made some progress with my project, however now i find yet another problem: the application stops rendering randomly. Rendering resumes after the mouse is moved or there is some kind of input.
Reply | Threaded
Open this post in threaded view
|

Re: Wrong keyCodes with NEWT on Linux.

gouessej
Administrator
d, f and r work fine. I have switched to KDE 4.6.5 and I do not reproduce your bugs. I'm going to try your script tomorrow night.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Wrong keyCodes with NEWT on Linux.

gouessej
Administrator
In reply to this post by lex
:( I reproduce one of your bugs.

When I go to full screen mode, the display stays frozen until I move the mouse or I press any key. It is the same when I come back to windowed mode.
Julien Gouesse | Personal blog | Website