Android input: Filter axis messages for duplicates. Assorted fixes and cleanup.
This commit is contained in:
parent
fc3f7da3af
commit
de96926d2e
3 changed files with 15 additions and 11 deletions
|
@ -1169,20 +1169,19 @@ PermissionStatus System_GetPermissionStatus(SystemPermission permission) {
|
|||
|
||||
extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_touch
|
||||
(JNIEnv *, jclass, float x, float y, int code, int pointerId) {
|
||||
|
||||
float scaledX = x * g_display.dpi_scale_x;
|
||||
float scaledY = y * g_display.dpi_scale_y;
|
||||
|
||||
if (!renderer_inited)
|
||||
return;
|
||||
TouchInput touch;
|
||||
touch.id = pointerId;
|
||||
touch.x = scaledX;
|
||||
touch.y = scaledY;
|
||||
touch.x = x * g_display.dpi_scale_x;
|
||||
touch.y = y * g_display.dpi_scale_y;
|
||||
touch.flags = code;
|
||||
|
||||
NativeTouch(touch);
|
||||
}
|
||||
|
||||
extern "C" jboolean Java_org_ppsspp_ppsspp_NativeApp_keyDown(JNIEnv *, jclass, jint deviceId, jint key, jboolean isRepeat) {
|
||||
if (!renderer_inited)
|
||||
return false;
|
||||
KeyInput keyInput;
|
||||
keyInput.deviceId = (InputDeviceID)deviceId;
|
||||
keyInput.keyCode = (InputKeyCode)key;
|
||||
|
@ -1194,6 +1193,8 @@ extern "C" jboolean Java_org_ppsspp_ppsspp_NativeApp_keyDown(JNIEnv *, jclass, j
|
|||
}
|
||||
|
||||
extern "C" jboolean Java_org_ppsspp_ppsspp_NativeApp_keyUp(JNIEnv *, jclass, jint deviceId, jint key) {
|
||||
if (!renderer_inited)
|
||||
return false;
|
||||
KeyInput keyInput;
|
||||
keyInput.deviceId = (InputDeviceID)deviceId;
|
||||
keyInput.keyCode = (InputKeyCode)key;
|
||||
|
@ -1210,7 +1211,6 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_joystickAxis(
|
|||
axis.deviceId = (InputDeviceID)deviceId;
|
||||
axis.axisId = (InputAxis)axisId;
|
||||
axis.value = value;
|
||||
|
||||
NativeAxis(axis);
|
||||
}
|
||||
|
||||
|
@ -1218,7 +1218,6 @@ extern "C" jboolean Java_org_ppsspp_ppsspp_NativeApp_mouseWheelEvent(
|
|||
JNIEnv *env, jclass, jint stick, jfloat x, jfloat y) {
|
||||
if (!renderer_inited)
|
||||
return false;
|
||||
|
||||
// TODO: Support mousewheel for android
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ public class InputDeviceState {
|
|||
|
||||
private InputDevice mDevice;
|
||||
private int[] mAxes;
|
||||
private float[] mAxisPrevValue;
|
||||
|
||||
private int sources;
|
||||
|
||||
|
@ -118,6 +119,7 @@ public class InputDeviceState {
|
|||
}
|
||||
|
||||
mAxes = new int[numAxes];
|
||||
mAxisPrevValue = new float[numAxes];
|
||||
|
||||
int i = 0;
|
||||
for (MotionRange range : device.getMotionRanges()) {
|
||||
|
@ -150,7 +152,10 @@ public class InputDeviceState {
|
|||
for (int i = 0; i < mAxes.length; i++) {
|
||||
int axisId = mAxes[i];
|
||||
float value = event.getAxisValue(axisId);
|
||||
if (value != mAxisPrevValue[i]) {
|
||||
NativeApp.joystickAxis(deviceId, axisId, value);
|
||||
mAxisPrevValue[i] = value;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1083,7 +1083,7 @@ public abstract class NativeActivity extends Activity {
|
|||
case KeyEvent.KEYCODE_DPAD_LEFT:
|
||||
case KeyEvent.KEYCODE_DPAD_RIGHT:
|
||||
// Joysticks are supported in Honeycomb MR1 and later via the onGenericMotionEvent method.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1 && event.getSource() == InputDevice.SOURCE_JOYSTICK) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1 && (event.getSource() & InputDevice.SOURCE_JOYSTICK) != 0) {
|
||||
// Pass through / ignore
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue