mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 13:55:58 +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
@@ -516,6 +516,38 @@ object SessionPrefs {
|
||||
prefs(context).edit().putString("touch", mode).apply()
|
||||
}
|
||||
|
||||
const val PEN_MOUSE = "mouse"
|
||||
const val PEN_TOUCH = "touch"
|
||||
const val PEN_BUTTON_RIGHT = "right"
|
||||
const val PEN_BUTTON_MIDDLE = "middle"
|
||||
const val PEN_BUTTON_OFF = "off"
|
||||
|
||||
data class Pen(val mode: String = PEN_MOUSE, val button: String = PEN_BUTTON_RIGHT)
|
||||
|
||||
private val PEN_SETTINGS = mapOf(
|
||||
"pen" to setOf(PEN_MOUSE, PEN_TOUCH),
|
||||
"penButton" to setOf(PEN_BUTTON_RIGHT, PEN_BUTTON_MIDDLE, PEN_BUTTON_OFF),
|
||||
)
|
||||
|
||||
private fun penSetting(context: Context, key: String, default: String): String =
|
||||
prefs(context).getString(key, default)?.takeIf { it in PEN_SETTINGS.getValue(key) } ?: default
|
||||
|
||||
fun setPenSetting(context: Context, key: String, value: String) {
|
||||
require(value in PEN_SETTINGS.getValue(key))
|
||||
prefs(context).edit().putString(key, value).apply()
|
||||
}
|
||||
|
||||
fun penMode(context: Context): String = penSetting(context, "pen", PEN_MOUSE)
|
||||
fun penButton(context: Context): String = penSetting(context, "penButton", PEN_BUTTON_RIGHT)
|
||||
|
||||
fun pen(context: Context): Pen = Pen(penMode(context), penButton(context))
|
||||
|
||||
fun penSeen(context: Context): Boolean = prefs(context).getBoolean("penSeen", false)
|
||||
|
||||
fun setPenSeen(context: Context) {
|
||||
if (!penSeen(context)) prefs(context).edit().putBoolean("penSeen", true).apply()
|
||||
}
|
||||
|
||||
const val SHAPE_AUTO = "auto"
|
||||
const val SHAPE_WIDE = "16:9"
|
||||
const val SHAPE_EXACT = "exact"
|
||||
|
||||
@@ -16,7 +16,7 @@ object SettingsReset {
|
||||
"dualScreenMode", "dualScreenSessionMode", "dualScreenLauncher", "dualScreenSessionControls", "androidTextFieldKeyboard",
|
||||
"gameStoresEnabled", "soundtracksEnabled", "soundtracksIngame", "gameStoresSpeedTier", "gameStoresParallel", "storesOpenTab", "storesShowMature",
|
||||
"storesInstallLanguage",
|
||||
"hud", "hudDeck", "hudFps", "hudBattery", "hudGraph", "hudColor", "hudOpacity", "__KEEP_droidDeckHud__", "__KEEP_droidDeckHudPos__", "backHold", "backActionsInverted", "backDoubleTapMs", "touch", "osc", "shape", "steamController",
|
||||
"hud", "hudDeck", "hudFps", "hudBattery", "hudGraph", "hudColor", "hudOpacity", "__KEEP_droidDeckHud__", "__KEEP_droidDeckHudPos__", "backHold", "backActionsInverted", "backDoubleTapMs", "touch", "pen", "penButton", "osc", "shape", "steamController",
|
||||
"gamepadLeft", "gamepadRight", "pipAutoEnter", "unfoldedControls", "unfoldedControlsWithController",
|
||||
"stretch16x9", "picturePosition", "railLabels", "agentTab", "navTabOrder", "navTabShelved", "navTabHidden", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys",
|
||||
"gpuDriverMode", "androidDriver", "linuxDriver", "linuxDriver.steam", "linuxDriver.desktop",
|
||||
|
||||
Reference in new issue
Block a user