android: jni: Sanitize analog stick inputs.
- Fixes bug where joystick sometimes is unresponsive.
This commit is contained in:
parent
9656dedb95
commit
0451a70b6e
@ -244,8 +244,10 @@ jboolean Java_org_citra_citra_1android_NativeLibrary_onGamePadEvent(JNIEnv* env,
|
|||||||
jboolean Java_org_citra_citra_1android_NativeLibrary_onGamePadMoveEvent(JNIEnv* env, jobject obj,
|
jboolean Java_org_citra_citra_1android_NativeLibrary_onGamePadMoveEvent(JNIEnv* env, jobject obj,
|
||||||
jstring jDevice, jint Axis,
|
jstring jDevice, jint Axis,
|
||||||
jfloat x, jfloat y) {
|
jfloat x, jfloat y) {
|
||||||
|
// Clamp joystick movement to supported minimum and maximum
|
||||||
// Citra uses an inverted y axis sent by the frontend
|
// Citra uses an inverted y axis sent by the frontend
|
||||||
y = -y;
|
x = std::clamp(x, -1.f, 1.f);
|
||||||
|
y = std::clamp(-y, -1.f, 1.f);
|
||||||
InputManager::AnalogHandler()->MoveJoystick(Axis, x, y);
|
InputManager::AnalogHandler()->MoveJoystick(Axis, x, y);
|
||||||
return static_cast<jboolean>(InputManager::AnalogHandler()->MoveJoystick(Axis, x, y));
|
return static_cast<jboolean>(InputManager::AnalogHandler()->MoveJoystick(Axis, x, y));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user