No need to block input if there is delay between actual typing and event consuming by the native thread
This commit is contained in:
parent
50db699dec
commit
a15aa70c32
1 changed files with 21 additions and 27 deletions
|
@ -112,7 +112,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
|
||||||
mSurfaceHolder = getHolder();
|
mSurfaceHolder = getHolder();
|
||||||
mSurfaceHolder.addCallback(this);
|
mSurfaceHolder.addCallback(this);
|
||||||
mainScreen = Bitmap.createBitmap(262, 14+128, Bitmap.Config.RGB_565);
|
mainScreen = Bitmap.createBitmap(262, 14+128, Bitmap.Config.RGB_565);
|
||||||
queuedCodes = new Vector<Integer>();
|
queuedCodes = new ArrayList<Integer>();
|
||||||
ann = new boolean [6];
|
ann = new boolean [6];
|
||||||
buf = new short [(14+128)*262];
|
buf = new short [(14+128)*262];
|
||||||
audiobuf = new short [44100]; // 1s worth
|
audiobuf = new short [44100]; // 1s worth
|
||||||
|
@ -993,6 +993,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code > -1) {
|
if (code > -1) {
|
||||||
|
systemOptionDisplayed = false;
|
||||||
key(code, actionCode == MotionEvent.ACTION_DOWN || actionCode == MotionEvent.ACTION_POINTER_DOWN, pointerID);
|
key(code, actionCode == MotionEvent.ACTION_DOWN || actionCode == MotionEvent.ACTION_POINTER_DOWN, pointerID);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1026,47 +1027,40 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
|
||||||
key(code, down, 255); // Use pointerID 255 for keyboard
|
key(code, down, 255); // Use pointerID 255 for keyboard
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void key(int code, boolean down, int pointerID) {
|
public void key(int code, boolean down, int pointerID) {
|
||||||
//Log.i("x48", "code: " + code + " / " + down);
|
synchronized(this) {
|
||||||
if (code < MAX_TOUCHES) {
|
if (code < MAX_TOUCHES) {
|
||||||
if (down) {
|
if (down) {
|
||||||
Integer cI = code + 1;
|
Integer cI = code + 1;
|
||||||
if (!queuedCodes.contains(cI)) {
|
|
||||||
queuedCodes.add(cI);
|
queuedCodes.add(cI);
|
||||||
touches[code] = pointerID;
|
touches[code] = pointerID;
|
||||||
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
|
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
|
||||||
HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
|
HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
|
||||||
} else {
|
} else {
|
||||||
Log.i("x48", "rejected down");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Integer cI = code + 100;
|
Integer cI = code + 100;
|
||||||
if (!queuedCodes.contains(cI) && touches [code] != 0) {
|
|
||||||
queuedCodes.add(cI);
|
queuedCodes.add(cI);
|
||||||
touches[code] = 0;
|
touches[code] = 0;
|
||||||
} else {
|
|
||||||
Log.i("x48", "rejected up");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
x48.flipScreen();
|
x48.flipScreen();
|
||||||
unpauseEvent();
|
unpauseEvent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void unpauseEvent() {
|
public void unpauseEvent() {
|
||||||
x48.openConditionVariable();
|
x48.openConditionVariable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized int waitEvent() {
|
public int waitEvent() {
|
||||||
|
synchronized(this) {
|
||||||
if (queuedCodes.size() == 0) {
|
if (queuedCodes.size() == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
int c = queuedCodes.remove(0);
|
int c = queuedCodes.remove(0);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected int width;
|
protected int width;
|
||||||
protected int height;
|
protected int height;
|
||||||
|
|
Loading…
Reference in a new issue