, "Character", InputEvent.
: AKeyEvent_getKeyCode KeyCode , "unicode/latin", . @Shammi @eozgonul, KeyEvent, Java, .
, InputQueue ++/Native , (t) > t23 > . , KEYDOWN/KEYUP , Java . ( ).
- Java, dispatchKeyEvent Queue<Integer> queueLastInputCharacter = new ConcurrentLinkedQueue<Integer>();
@Override
public boolean dispatchKeyEvent (KeyEvent event)
{
int metaState = event.getMetaState();
int unichar = event.getUnicodeChar(metaState);
if(event.getAction()==KeyEvent.ACTION_DOWN){
if(unichar != 0){
queueLastInputCharacter.offer(Integer.valueOf(unichar));
}
else{
unichar = event.getUnicodeChar();
if(unichar != 0){
queueLastInputCharacter.offer(Integer.valueOf(unichar));
}
else if (event.getDisplayLabel() != 0){
String aText = new String();
aText = "";
aText += event.getDisplayLabel();
queueLastInputCharacter.offer(Integer.valueOf(Character.codePointAt(aText, 0)));
}
else
queueLastInputCharacter.offer(Integer.valueOf(0));
}
}
else if(event.getAction()==KeyEvent.ACTION_MULTIPLE){
unichar = (Character.codePointAt(event.getCharacters(), 0));
queueLastInputCharacter.offer(Integer.valueOf(unichar));
}
return super.dispatchKeyEvent(event);
}
.
Java, :
public int getLastUnicodeChar(){
if(!queueLastInputCharacter.isEmpty())
return queueLastInputCharacter.poll().intValue();
return 0;
}
, , - :
int ident;
int events;
struct android_poll_source* source;
while ((ident = ALooper_pollAll(((nv_app_status_focused(_lpApp)) ? 1 : 250),
NULL,
&events,
(void**)&source)) >= 0)
{
if (source != NULL)
source->process(_lpApp, source);
if (!nv_app_status_running(_lpApp))
return;
}
static int modtime = 10;
if(--modtime == 0) {
long uniChar = androidUnicodeCharFromKeyEvent();
while (uniChar != 0) {
KEvent kCharEvent;
kCharEvent.ptkKey = K_VK_ERROR;
kCharEvent.unicodeChar = uniChar;
kCharEvent.character = uniChar;
kCharEvent.type = K_EVENT_UNICHAR;
_lpPortableHandler(&kCharEvent);
if (kCharEvent.character < 127) {
kCharEvent.type = K_EVENT_CHAR;
_lpPortableHandler(&kCharEvent);
}
uniChar = androidUnicodeCharFromKeyEvent();
}
modtime = 10;
}
androidUnicodeCharFromKeyEvent @Shammi GetStringFromAInputEvent, CallIntMethod, jint.
Key. Android - , AKEYCODE_BACK AKEYCODE_ENTER, ( ).
Editboxes, console .. , , , . , .