mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 23:36:04 +00:00
feat(input): a pen moves the pointer while hovering, clicks with its tip and right-clicks with its side button (#2625)
* feat(compositor): pen samples drive the pointer like a mouse Input record 13 carries the pen's state (in proximity, tip, right and middle button) and its position in input space as 24.8 fixed point. Hover moves the pointer, the tip holds the left button, and a record without the in-proximity bit releases every button. Under a pointer lock only the buttons pass. A button pressed or released mid-stroke keeps the implicit grab on the window the stroke started in, unless that window closed. * feat(input): a pen moves the pointer while hovering, clicks with its tip and right-clicks with its side button In Mouse mode (the default) a pen's hover moves the pointer, the tip holds the left button and the side button right-clicks; Touch keeps it a finger. The side button can send a middle click or nothing instead, and a Bluetooth pen key counts as the side button while the pen is near. With glasses or a program's pointer lock the pen drives the touchpad. A hover exit followed within 50 ms by more hover or a touch keeps the pen near, so a pen at the edge of its hover range does not flicker out, and a hover that sends nothing for 2 s leaves proximity. On the desktop a pen that comes near releases KWin's grab of a hardware mouse, so the pen moves KWin's pointer. Whatever cancels touches also ends the pen, and stylus devices no longer count as hardware mice. * feat(input): pen mode and side button settings in the Controls tab and the session drawer A Pen group follows the touch settings once the phone has a stylus device or a pen event was seen, which is remembered as penSeen and kept by a settings reset. It holds Pen (Mouse, Touch) and Side button (Right click, Middle click, Off); Side button is hidden in Touch. Before Android 14 a touchscreen reports the stylus source without a pen, so there it counts only with its first pen event. The strings are translated into all 32 languages. * docs: describe pen input and its limits --------- Co-authored-by: alien2003 <11610652+alien2003@users.noreply.github.com>
This commit is contained in:
1 parent
de70e37f30
commit
decab6ea90
63 files changed
+2352
-38
No files matched your search
@@ -19,6 +19,7 @@ class BottomGameScreen(
|
||||
display: Display,
|
||||
private val callback: SurfaceHolder.Callback,
|
||||
private val onTouch: (MotionEvent) -> Boolean,
|
||||
private val onHover: (MotionEvent) -> Boolean,
|
||||
) : Presentation(activity, display) {
|
||||
val surfaceView = SurfaceView(getContext())
|
||||
val holder: SurfaceHolder get() = surfaceView.holder
|
||||
@@ -51,7 +52,7 @@ class BottomGameScreen(
|
||||
activity.dispatchKeyEvent(event) || super.dispatchKeyEvent(event)
|
||||
|
||||
override fun dispatchGenericMotionEvent(event: MotionEvent): Boolean =
|
||||
activity.dispatchGenericMotionEvent(event) || super.dispatchGenericMotionEvent(event)
|
||||
onHover(event) || activity.dispatchGenericMotionEvent(event) || super.dispatchGenericMotionEvent(event)
|
||||
}
|
||||
|
||||
object GameScreenSwap {
|
||||
|
||||
@@ -63,6 +63,7 @@ class ModeSettings(
|
||||
val upscaler: Int = 0,
|
||||
val upscaleSharpness: Int = 75,
|
||||
val touchMode: String,
|
||||
val pen: SessionPrefs.Pen? = null,
|
||||
val suspendPolicy: String,
|
||||
val steamDownloadsInBackground: Boolean = false,
|
||||
val pipSupported: Boolean = false,
|
||||
@@ -116,6 +117,7 @@ class ModeSettingsActions(
|
||||
val onUpscaler: (Int) -> Unit = {},
|
||||
val onUpscaleSharpness: (Int) -> Unit = {},
|
||||
val onTouch: (String) -> Unit,
|
||||
val onPen: (key: String, value: String) -> Unit = { _, _ -> },
|
||||
val onSuspendPolicy: (String) -> Unit,
|
||||
val onSteamDownloadsInBackground: (Boolean) -> Unit = {},
|
||||
val onPipAutoEnter: (Boolean) -> Unit = {},
|
||||
@@ -321,6 +323,7 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
|
||||
}
|
||||
PhysicalShortcutRows()
|
||||
}
|
||||
s.pen?.let { PenSettingsGroup(host, it, onPick = a.onPen) }
|
||||
}
|
||||
if (tab == SheetTab.AUDIO && steam) {
|
||||
if (s.directAudio != null && s.mic != null) SettingsGroup(stringResource(R.string.mode_audio)) {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
|
||||
@Composable
|
||||
internal fun PenSettingsGroup(
|
||||
host: MenuHost, pen: SessionPrefs.Pen, track: (String) -> Modifier = { Modifier },
|
||||
onPick: (key: String, value: String) -> Unit,
|
||||
) {
|
||||
SettingsGroup(stringResource(R.string.mode_pen)) {
|
||||
ChoiceRow(host, "pen", stringResource(R.string.mode_pen), null,
|
||||
listOf(SessionPrefs.PEN_MOUSE to stringResource(R.string.mode_pen_mouse),
|
||||
SessionPrefs.PEN_TOUCH to stringResource(R.string.mode_pen_touch)),
|
||||
pen.mode, chipModifier = track("pen")) { onPick("pen", it) }
|
||||
if (pen.mode != SessionPrefs.PEN_TOUCH) ChoiceRow(host, "pen-button", stringResource(R.string.mode_pen_button), null,
|
||||
listOf(SessionPrefs.PEN_BUTTON_RIGHT to stringResource(R.string.gesture_right_click),
|
||||
SessionPrefs.PEN_BUTTON_MIDDLE to stringResource(R.string.gesture_middle_click),
|
||||
SessionPrefs.PEN_BUTTON_OFF to stringResource(R.string.widgets_off)),
|
||||
pen.button, chipModifier = track("pen-button")) { onPick("penButton", it) }
|
||||
}
|
||||
}
|
||||
@@ -239,6 +239,8 @@ class DrawerActions(
|
||||
val onPadType: (String) -> Unit = {},
|
||||
val touchMode: String,
|
||||
val touchAuto: String,
|
||||
val pen: SessionPrefs.Pen? = null,
|
||||
val onPen: (key: String, value: String) -> Unit = { _, _ -> },
|
||||
val fexPreset: String,
|
||||
val upscaler: Int = 0,
|
||||
val upscaleSharpness: Int = 75,
|
||||
@@ -672,6 +674,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
onPick = a.onDirectHoldBehavior)
|
||||
}
|
||||
}
|
||||
a.pen?.let { PenSettingsGroup(host, it, track = { key -> focus.track(page, key) }, onPick = a.onPen) }
|
||||
SettingsGroup(stringResource(R.string.input_screen_visibility)) {
|
||||
ChoiceRow(host, "osc", stringResource(R.string.mode_osc), null,
|
||||
if (a.steam) listOf(SessionPrefs.OSC_AUTO to stringResource(R.string.common_auto), SessionPrefs.OSC_ALWAYS to stringResource(R.string.common_always), SessionPrefs.OSC_STEAM_TOUCH to stringResource(R.string.osc_steam_touch), SessionPrefs.OSC_STEAM_QAM to stringResource(R.string.mode_osc_qam), SessionPrefs.OSC_NEVER to stringResource(R.string.common_never))
|
||||
|
||||
Reference in new issue
Block a user