Merge remote-tracking branch 'origin/main'
# Conflicts: # app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
This commit is contained in:
1 file changed
+25
@@ -793,6 +793,21 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 手柄摇杆控制翻页
|
||||||
|
if (0 != (event.source and InputDevice.SOURCE_CLASS_JOYSTICK)) {
|
||||||
|
if (event.action == MotionEvent.ACTION_MOVE) {
|
||||||
|
// 左摇杆上下移动控制翻页
|
||||||
|
val yAxis = event.getAxisValue(MotionEvent.AXIS_Y)
|
||||||
|
if (Math.abs(yAxis) > 0.5f) { // 死区设置
|
||||||
|
if (yAxis > 0) { // 摇杆向下
|
||||||
|
handleKeyPage(PageDirection.NEXT, false)
|
||||||
|
} else { // 摇杆向上
|
||||||
|
handleKeyPage(PageDirection.PREV, false)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return super.onGenericMotionEvent(event)
|
return super.onGenericMotionEvent(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -838,6 +853,16 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
handleKeyPage(PageDirection.NEXT, longPress)
|
handleKeyPage(PageDirection.NEXT, longPress)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
// 手柄方向键控制翻页
|
||||||
|
KeyEvent.KEYCODE_DPAD_UP, KeyEvent.KEYCODE_DPAD_LEFT -> {
|
||||||
|
handleKeyPage(PageDirection.PREV, longPress)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyEvent.KEYCODE_DPAD_DOWN, KeyEvent.KEYCODE_DPAD_RIGHT -> {
|
||||||
|
handleKeyPage(PageDirection.NEXT, longPress)
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onKeyDown(keyCode, event)
|
return super.onKeyDown(keyCode, event)
|
||||||
|
|||||||
Reference in new issue
Block a user