NEWT KeyListener on Android

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

NEWT KeyListener on Android

Pedro
Hello,

I've got a hardware USB keyboard plugged into an Android device running a NEWT backed application.
I've noticed that some keys don't seem to work the same when running a Linux desktop version of the same app, namely the following keys which are of interest to me:

Insert
Delete
Home
End
Arrow Keys
Comma Key
Tilda Key

Are you able to shed any light on this? Is it to do with what Android OS supports itself in terms of KeyEvent?
(https://developer.android.com/reference/android/view/KeyEvent)

Thanks for your time,

Pedro
Reply | Threaded
Open this post in threaded view
|

Re: NEWT KeyListener on Android

gouessej
Administrator
Hello

What do you mean by "some keys don't seem to work the same"?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: NEWT KeyListener on Android

Pedro
Sorry, what I mean is the Keys I listed don't fire any KeyListener interface callbacks for keyPressed or keyReleased when running on Android, but they do on Linux.

This morning I had a go at using the same USB keyboard to edit things in the Android OS Settings App and the Home, End, Delete and directional Arrow Keys were all working there.

I'm running JOGL v2.3.1.
Reply | Threaded
Open this post in threaded view
|

Re: NEWT KeyListener on Android

gouessej
Administrator
By the way, we only maintain the very latest version. Therefore, please use JOGL 2.3.2.

I have no such hardware, I can't use an USB keyboard on my smartphone and I use an old version of Android. Which version of Android do you use?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: NEWT KeyListener on Android

Pedro
Ok, I'll look to update the latest now & try again.

I'm running Android version 5.1.1 Lollipop - its a TV box so I have the usual peripheral slots ( USB, HDMI, Ethernet ).

The keyboard is a bog-standard Logitech wireless USB keyboard. Not sure if a paired bluetooth keyboard would work with a phone / tablet?
Reply | Threaded
Open this post in threaded view
|

Re: NEWT KeyListener on Android

Pedro
Couldn't test with 2.3.2 as my android app wouldn't work at all anymore, it couldn't find the libglugen native libraries anymore, has the build process changed for building an Android JOGL app in 2.3.2 vs 2.3.1?
Reply | Threaded
Open this post in threaded view
|

Re: NEWT KeyListener on Android

gouessej
Administrator
No, the build process didn't change. JOGL 2.3.2 has been tested under Android and some contributors use it on this platform.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: NEWT KeyListener on Android

Pedro
Hi,

I've had chance to have a proper dig around with regards to my original question, the KeyEvents:

In short, it looks like there are a few android.view.KeyEvent constants that aren't converted into a corresponding com.jogamp.newt.event.KeyEvent constant & the event appears to be being dropped before it makes it to the com.jogamp.newt.event.KeyListener interface implementation as I don't receive a callback for the affect key codes below.

I've had a look at the jogamp.newt.driver.android.event.AndroidNewtEventFactory at master and spotted the aKeyCode2NewtKeyCode method which appears to convert from the android KeyEvent type to the newt KeyEvent type but there isn't any mention of a few keys & these are the ones we've had issues with - which are, when using a hardware keyboard:

KEYCODE_MOVE_HOME -  'Home' key
KEYCODE_MOVE_END - 'End' key
KEYCODE_INSERT - 'Insert' key
KEYCODE_FORWARD_DEL 'Delete' key
KEYCODE_DPAD_UP - up arrow key
KEYCODE_DPAD_DOWN - down arrow key
KEYCODE_DPAD_LEFT - left arrow key
KEYCODE_DPAD_RIGHT - right arrow key
KEYCODE_GRAVE - the ` key
KEYCODE_NUMLOCK - 'Num Lock' key
KEYCODE_NUMPAD_DIVIDE - the num-pad / key
KEYCODE_NUMPAD_MULTIPLY - the num-pad * key
KEYCODE_NUMPAD_SUBSTRACT - the num-pad - key
KEYCODE_NUMPAD_ADD - the num-pad + key
KEYCODE_NUMPAD_DOT - the num-pad 'Del' or '.' key

There may be more as these are just the ones I'm trying to use.

Also at line 148 of AndroidNewtEventFactory the aKeyCode2NewtKeyCode  method attempts to convert KEYCODE_HOME to VK_HOME but this should be KEYCODE_MOVE_HOME to VK_HOME as the prior looks to be linked to firing the 'home itent':

https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_HOME
https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_MOVE_HOME

I've written a converter similar to that in AndroidNewtEventFactory for the key code list above for my use case so I'm happy but thought it best to report back in case any of this was of interest to yourselves - also in-case I may have gotten things wrong and done something I needn't have... XD

Pedro.
Reply | Threaded
Open this post in threaded view
|

Re: NEWT KeyListener on Android

gouessej
Administrator
Thank you for the precious pieces of information. I miss the bug tracker... :( We should prepare a patch.
Julien Gouesse | Personal blog | Website