Reply – Re: NEWT KeyListener on Android
Your Name
Subject
Message
or Cancel
In Reply To
Re: NEWT KeyListener on Android
— by Pedro 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.