feat: Add physical controller button shortcuts (#1202)

* feat(controller): add physical button shortcuts

* fix(controller): improve shortcut capture and assignment feedback

* refactor(controller): simplify menu button assignment UI

* feat(controller): save menu assignments on button release

* refactor(controller): remove obsolete shortcut UI resources

* fix(controller): place drawer remaps below Back

* refactor(controller): simplify shortcut capture wording

* fix(controller): refresh active shortcut bindings on changes

* fix(controller): preserve drawer confirmation for mapped A

* fix: preserve controller shortcut navigation and cancel

* test: align shortcut dialog assertions

---------

Co-authored-by: xXJsonDeruloXx <danielhimebauch@gmail.com>
Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-10-30 07:08:59 -04:00
1 parent f69e2d0171
commit 4770d11e39
42 files changed
+1316

No files matched your search

@@ -75,6 +75,8 @@ import com.droiddeck.launcher.input.ControllerPrefs
import com.droiddeck.launcher.input.SessionClipboard
import com.droiddeck.launcher.input.OnScreenControls
import com.droiddeck.launcher.input.PadBridge
import com.droiddeck.launcher.input.PhysicalShortcuts
import com.droiddeck.launcher.input.PhysicalShortcutRouter
import com.droiddeck.launcher.input.PadMouse
import com.droiddeck.launcher.input.PadState
import com.droiddeck.launcher.input.ScreenKeys
@@ -162,6 +164,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
private lateinit var hud: FusionHudHost
private lateinit var memoryHud: com.droiddeck.launcher.session.MemoryHud
private var padBridge: PadBridge? = null
private val physicalShortcuts = PhysicalShortcutRouter()
private var joyConVr: com.droiddeck.launcher.input.JoyConVr? = null
private var handCamera: com.droiddeck.launcher.handtracking.HandCamera? = null
private var padMotion: com.droiddeck.launcher.input.PadMotion? = null
@@ -433,6 +436,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
private val cardboardPrefListener = android.content.SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
if (key == SessionPrefs.CARDBOARD_KEY) uiHandler.post { applyCardboard(SessionPrefs.cardboard(this)) }
}
private val shortcutPrefListener = android.content.SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
if (key == null || key == PhysicalShortcuts.KEY) {
physicalShortcuts.bindings = PhysicalShortcuts.read(this)
}
}
private var textureAnisotropy by mutableStateOf(0)
private var textureLodBias by mutableStateOf(TextureFiltering.LOD_BIAS_OFF)
private var drawerTextureAnisotropy by mutableStateOf<Int?>(null)
@@ -519,6 +527,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
updateHandCamera()
}
override fun onInputDeviceRemoved(deviceId: Int) {
physicalShortcuts.onDeviceRemoved(deviceId)
Log.i(TAG, "input device $deviceId disconnected")
backQamInput.onDeviceRemoved(deviceId)
joyConVr?.refresh()
@@ -1828,6 +1837,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
steamDownloadsInBackground = SessionPrefs.steamDownloadsInBackground(this)
oscMode = SessionPrefs.oscMode(this)
backActionsInverted = SessionPrefs.backActionsInverted(this)
physicalShortcuts.bindings = PhysicalShortcuts.read(this)
backDoubleTapMs = SessionPrefs.backDoubleTapMs(this)
lowLatency = SessionPrefs.lowLatency(this)
evdevMouseOn = SessionPrefs.evdevMouse(this)
@@ -2456,6 +2466,26 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
}
if (pipUi) return true
if (screenKeyTextFocus) return super.dispatchKeyEvent(event)
if (physicalShortcuts.onKey(
event,
enabled = SessionState.running && !SessionState.suspended &&
!(drawerOpen && event.keyCode == KeyEvent.KEYCODE_BUTTON_A) &&
!(drawerOpen && PhysicalShortcuts.isDrawerNavigationKey(event)) &&
(event.deviceId to event.keyCode) !in resumeKeysDown &&
!(::loading.isInitialized && (loading.visible || loading.ended)) &&
!pcKeyboardOpen && !achievementsOpen && !gestureSettingsOpen,
steam = SessionState.mode == SessionService.MODE_STEAM,
) { action ->
pendingBackAction?.let(uiHandler::removeCallbacks)
pendingBackAction = null
drawerControllerActive = true
Log.i(TAG, "physical shortcut ${action.name} device=${event.deviceId} key=${event.keyCode} scan=${event.scanCode}")
when (action) {
PhysicalShortcuts.Action.STEAM -> sendSteamGuide()
PhysicalShortcuts.Action.QAM -> triggerSteamQam()
PhysicalShortcuts.Action.DROIDDECK -> drawerOpen = !drawerOpen
}
}) return true
val pad = com.droiddeck.launcher.input.JoyCon.normalize(event)
if (pad !== event) return dispatchKeyEvent(pad)
val fromController = PadBridge.isControllerKeyEvent(event)
@@ -3892,6 +3922,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
updatePointerCapture()
if (!pipUi) sessionClipboard.start()
updatePadMotion()
ControllerPrefs.prefs(this).registerOnSharedPreferenceChangeListener(shortcutPrefListener)
readPrefs()
refreshControls()
if (::pip.isInitialized) pip.resumed()
@@ -3902,6 +3933,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
override fun onPause() {
com.droiddeck.launcher.input.HomeButtonShortcuts.detach(this)
if (runtimeRemovalBlocked) { super.onPause(); return }
physicalShortcuts.clear()
backQamInput.cancel()
capturePausedFrame()
sessionClipboard.stop()
@@ -3925,6 +3957,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
updatePadMotion()
keyboard?.takeIf { it.shown }?.hide()
SessionPrefs.sessionPrefs(this).unregisterOnSharedPreferenceChangeListener(cardboardPrefListener)
ControllerPrefs.prefs(this).unregisterOnSharedPreferenceChangeListener(shortcutPrefListener)
updateHeadTracker()
super.onPause()
}
@@ -0,0 +1,145 @@
package com.droiddeck.launcher.input
import android.content.Context
import android.util.Log
import android.view.InputDevice
import android.view.KeyEvent
import androidx.annotation.StringRes
import com.droiddeck.launcher.R
import org.json.JSONArray
import org.json.JSONException
import org.json.JSONObject
object PhysicalShortcuts {
internal const val KEY = "physicalShortcuts"
private const val TAG = "PhysicalShortcuts"
enum class Action(@StringRes val label: Int) {
STEAM(R.string.drawer_steam_menu),
QAM(R.string.drawer_open_qam),
DROIDDECK(R.string.shortcuts_dd_menu),
}
data class Button(
val device: String,
val name: String,
val keyCode: Int,
val scanCode: Int,
) {
fun matches(event: KeyEvent): Boolean =
event.device?.let { device == identity(it) } == true &&
keyCode == event.keyCode && scanCode == event.scanCode
fun sameInput(other: Button): Boolean =
device == other.device && keyCode == other.keyCode && scanCode == other.scanCode
val label: String
get() = KeyEvent.keyCodeToString(keyCode).removePrefix("KEYCODE_").removePrefix("BUTTON_")
}
data class Binding(val button: Button, val action: Action)
private fun identity(device: InputDevice): String =
"${device.vendorId}:${device.productId}:${device.descriptor.ifBlank { device.name }}"
fun isVolumeKey(event: KeyEvent): Boolean = when (event.keyCode) {
KeyEvent.KEYCODE_VOLUME_UP, KeyEvent.KEYCODE_VOLUME_DOWN, KeyEvent.KEYCODE_VOLUME_MUTE -> true
else -> false
}
fun isDrawerNavigationKey(event: KeyEvent): Boolean = when (event.keyCode) {
KeyEvent.KEYCODE_DPAD_UP, KeyEvent.KEYCODE_DPAD_DOWN,
KeyEvent.KEYCODE_DPAD_LEFT, KeyEvent.KEYCODE_DPAD_RIGHT -> true
else -> false
}
fun button(event: KeyEvent): Button? {
val device = event.device ?: return null
if (device.isVirtual || isVolumeKey(event)) return null
when (event.keyCode) {
KeyEvent.KEYCODE_HOME, KeyEvent.KEYCODE_POWER, KeyEvent.KEYCODE_SLEEP,
KeyEvent.KEYCODE_WAKEUP, KeyEvent.KEYCODE_APP_SWITCH -> return null
}
if (event.keyCode == KeyEvent.KEYCODE_UNKNOWN && event.scanCode <= 0) return null
return Button(identity(device), device.name, event.keyCode, event.scanCode)
}
fun read(context: Context): List<Binding> {
val raw = ControllerPrefs.prefs(context).getString(KEY, null) ?: return emptyList()
return try {
val array = JSONArray(raw)
buildList {
for (i in 0 until array.length()) {
try {
val entry = array.getJSONObject(i)
val action = Action.entries.firstOrNull { it.name == entry.getString("action") }
val code = entry.getInt("keyCode")
val scan = entry.getInt("scanCode")
val device = entry.getString("device")
if (action == null || device.isBlank() || code < 0 || scan < 0) {
Log.w(TAG, "Ignoring invalid shortcut at index $i")
continue
}
val binding = Binding(Button(device, entry.getString("name"), code, scan), action)
if (none { it.button.sameInput(binding.button) }) add(binding)
} catch (e: JSONException) {
Log.w(TAG, "Ignoring malformed shortcut at index $i", e)
}
}
}
} catch (e: JSONException) {
Log.w(TAG, "Could not read physical shortcuts; reset shortcuts to restore defaults", e)
emptyList()
}
}
fun assign(context: Context, button: Button, action: Action) {
val bindings = read(context).filterNot {
it.button.sameInput(button) || (it.button.device == button.device && it.action == action)
} + Binding(button, action)
write(context, bindings)
}
fun remove(context: Context, binding: Binding) {
write(context, read(context).filterNot { it == binding })
}
private fun write(context: Context, bindings: List<Binding>) {
val array = JSONArray()
bindings.forEach {
array.put(JSONObject().put("device", it.button.device).put("name", it.button.name)
.put("keyCode", it.button.keyCode).put("scanCode", it.button.scanCode).put("action", it.action.name))
}
ControllerPrefs.prefs(context).edit().putString(KEY, array.toString()).apply()
}
}
class PhysicalShortcutRouter {
var bindings: List<PhysicalShortcuts.Binding> = emptyList()
private data class Press(val device: Int, val keyCode: Int, val scanCode: Int)
private val held = mutableSetOf<Press>()
fun onKey(event: KeyEvent, enabled: Boolean, steam: Boolean, perform: (PhysicalShortcuts.Action) -> Unit): Boolean {
val press = Press(event.deviceId, event.keyCode, event.scanCode)
if (event.action == KeyEvent.ACTION_UP) return held.remove(press)
if (event.action != KeyEvent.ACTION_DOWN) return false
if (press in held) return true
if (!enabled || bindings.isEmpty()) return false
val button = PhysicalShortcuts.button(event) ?: return false
val binding = bindings.firstOrNull { it.button.sameInput(button) } ?: return false
if (!steam && binding.action != PhysicalShortcuts.Action.DROIDDECK) return false
held.add(press)
if (event.repeatCount == 0) perform(binding.action)
return true
}
fun onDeviceRemoved(deviceId: Int) {
held.removeAll { it.device == deviceId }
}
fun clear() {
held.clear()
}
}
@@ -93,6 +93,9 @@ fun ControllerMappingPage(mapping: Map<String, String>, onPick: (String, String)
lede = stringResource(R.string.ctrl_mapping_lede),
onBack = onBack,
) {
SettingsGroup(stringResource(R.string.shortcuts_title)) {
PhysicalShortcutRows()
}
SettingsGroup(stringResource(R.string.ctrl_onscreen_buttons)) {
val targets = ControllerPrefs.targets.map { (id, label) -> id to stringResource(label) }
for ((id, name) in ControllerPrefs.mappable) {
@@ -306,6 +306,7 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
if (steam && s.steamController in listOf(SessionPrefs.CONTROLLER_DECK, SessionPrefs.CONTROLLER_STEAM)) {
Note(stringResource(R.string.back_native_qam_hint))
}
PhysicalShortcutRows()
}
}
if (tab == SheetTab.AUDIO && steam) {
@@ -0,0 +1,189 @@
package com.droiddeck.launcher.ui
import android.util.Log
import android.view.KeyEvent
import android.view.Window
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import androidx.compose.ui.window.DialogWindowProvider
import com.droiddeck.launcher.R
import com.droiddeck.launcher.input.PhysicalShortcuts
@Composable
internal fun PhysicalShortcutRows(
onChanged: () -> Unit = {},
modifierFor: (PhysicalShortcuts.Action) -> Modifier = { Modifier },
) {
val context = LocalContext.current
var bindings by remember { mutableStateOf(PhysicalShortcuts.read(context)) }
var editing by remember { mutableStateOf<PhysicalShortcuts.Action?>(null) }
Column {
for (action in PhysicalShortcuts.Action.entries) {
val assigned = bindings.filter { it.action == action }
SettingsRow(
stringResource(action.label),
assigned.joinToString { "${it.button.label} · ${it.button.name}" }.ifEmpty { null },
) {
SecondaryButton(
stringResource(if (assigned.isEmpty()) R.string.game_settings_default else R.string.ctrl_custom),
compact = true,
modifier = modifierFor(action).width(LocalChipMinWidth.current)
.testTag("shortcuts-assign-${action.name}"),
) { editing = action }
}
}
}
editing?.let { action ->
PhysicalShortcutsDialog(action, onDismiss = { editing = null }, onChanged = {
bindings = PhysicalShortcuts.read(context)
onChanged()
})
}
}
@Composable
internal fun PhysicalShortcutsDialog(
action: PhysicalShortcuts.Action,
onDismiss: () -> Unit,
onChanged: () -> Unit = {},
) {
val context = LocalContext.current
val bindings = remember { PhysicalShortcuts.read(context) }
var candidate by remember { mutableStateOf<PhysicalShortcuts.Button?>(null) }
var listening by remember { mutableStateOf(true) }
var capturedDevice by remember { mutableStateOf(-1) }
Dialog(
onDismissRequest = onDismiss,
properties = DialogProperties(dismissOnBackPress = !listening, usePlatformDefaultWidth = false),
) {
CaptureShortcutKeys { event ->
if (listening && event.action == KeyEvent.ACTION_DOWN && event.repeatCount == 0 &&
(event.keyCode == KeyEvent.KEYCODE_BACK || event.keyCode == KeyEvent.KEYCODE_BUTTON_B)) {
listening = false
onDismiss()
true
} else if (!listening || PhysicalShortcuts.isVolumeKey(event)) {
false
} else {
if (candidate == null && event.action == KeyEvent.ACTION_DOWN && event.repeatCount == 0) {
PhysicalShortcuts.button(event)?.let { button ->
candidate = button
capturedDevice = event.deviceId
Log.i("PhysicalShortcuts", "capture device=${button.name} key=${event.keyCode} " +
"scan=${event.scanCode} source=0x${event.source.toString(16)}")
}
} else if (event.action == KeyEvent.ACTION_UP && event.deviceId == capturedDevice &&
candidate?.matches(event) == true) {
listening = false
candidate?.let { button ->
if (bindings.none { it.button.sameInput(button) && it.action != action }) {
PhysicalShortcuts.assign(context, button, action)
onChanged()
onDismiss()
}
}
}
true
}
}
CompositionLocalProvider(LocalFrontFocus provides null) {
Surface(
shape = RoundedCornerShape(16.dp),
modifier = Modifier.padding(12.dp).widthIn(max = 560.dp).fillMaxWidth()
.heightIn(max = (LocalConfiguration.current.screenHeightDp - 24).dp),
) {
Column(
Modifier.verticalScroll(rememberScrollState()).padding(18.dp).controllerBack(onDismiss),
verticalArrangement = Arrangement.spacedBy(12.dp),
) {
Text(stringResource(R.string.shortcuts_capture, stringResource(action.label)),
style = MaterialTheme.typography.titleLarge)
val button = candidate
if (button == null) {
Text(stringResource(R.string.shortcuts_press))
} else {
Text(stringResource(R.string.shortcuts_detected, button.name, button.label))
if (listening) {
Text(stringResource(R.string.shortcuts_release))
} else {
val replacements = bindings.filter {
it.button.sameInput(button) || (it.button.device == button.device && it.action == action)
}
for (conflict in replacements) {
Text("${conflict.button.label} · ${conflict.button.name}")
Text(stringResource(R.string.shortcuts_conflict, stringResource(conflict.action.label)))
}
SecondaryButton(stringResource(R.string.shortcuts_save), modifier = Modifier.testTag("shortcuts-save")) {
PhysicalShortcuts.assign(context, button, action)
onChanged()
onDismiss()
}
}
SecondaryButton(stringResource(R.string.shortcuts_retry), modifier = Modifier.testTag("shortcuts-retry")) {
candidate = null
capturedDevice = -1
listening = true
}
}
Text(stringResource(R.string.shortcuts_limitations), style = MaterialTheme.typography.bodySmall)
for (binding in bindings.filter { it.action == action }) {
ActionRow(
stringResource(R.string.shortcuts_detected, binding.button.name, binding.button.label),
null, stringResource(R.string.ctrl_reset), {
PhysicalShortcuts.remove(context, binding)
onChanged()
onDismiss()
},
modifier = Modifier.testTag("shortcuts-remove"),
)
}
SecondaryButton(stringResource(R.string.common_close), modifier = Modifier.testTag("shortcuts-cancel"),
onClick = onDismiss)
}
}
}
}
}
@Composable
private fun CaptureShortcutKeys(onKey: (KeyEvent) -> Boolean) {
val currentOnKey by rememberUpdatedState(onKey)
val window = (LocalView.current.parent as DialogWindowProvider).window
DisposableEffect(window) {
val previous = window.callback
// Capture before dialog navigation so Back and gamepad buttons can be assigned.
window.callback = object : Window.Callback by previous {
override fun dispatchKeyEvent(event: KeyEvent): Boolean =
currentOnKey(event) || previous.dispatchKeyEvent(event)
}
onDispose { window.callback = previous }
}
}
@@ -635,6 +635,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
if (a.steam) ChoiceRow(host, "back-double-tap", stringResource(R.string.back_double_tap_window), null,
SessionPrefs.BACK_DOUBLE_TAP_MS_OPTIONS.map { it to stringResource(R.string.back_tap_ms, it) },
a.backDoubleTapMs, chipModifier = focus.track(page, "back-double-tap"), onPick = a.onBackDoubleTapMs)
PhysicalShortcutRows(modifierFor = { focus.track(page, "physical-shortcut-${it.name}") })
if (a.steam && a.unfoldedControls != null) ToggleRow(host, "unfolded-controls", stringResource(R.string.unfolded_controls),
stringResource(R.string.unfolded_controls_hint), a.unfoldedControls,
chipModifier = focus.track(page, "unfolded-controls"), onChange = a.onUnfoldedControls)
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">اختصارات الأزرار الفعلية</string>
<string name="shortcuts_dd_menu">قائمة DroidDeck</string>
<string name="shortcuts_capture">تعيين: %1$s</string>
<string name="shortcuts_press">اضغط على زر ثم حرره. يُحفظ التعيين تلقائيًا.</string>
<string name="shortcuts_release">أفلت الزر للمتابعة.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">هذا الزر معيّن بالفعل إلى: %1$s</string>
<string name="shortcuts_save">إعادة تعيين</string>
<string name="shortcuts_retry">تجربة زر آخر</string>
<string name="shortcuts_limitations">قد لا يتوفر زر الشاشة الرئيسية وبعض الأزرار الإضافية.</string>
</resources>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Atajos de botones físicos</string>
<string name="shortcuts_dd_menu">Menú de DroidDeck</string>
<string name="shortcuts_capture">Asignar: %1$s</string>
<string name="shortcuts_press">Presiona y suelta un botón. La asignación se guarda automáticamente.</string>
<string name="shortcuts_release">Suelta el botón para continuar.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Este botón ya está asignado a: %1$s</string>
<string name="shortcuts_save">Reasignar</string>
<string name="shortcuts_retry">Probar otro botón</string>
<string name="shortcuts_limitations">El botón Inicio y algunos botones adicionales pueden no estar disponibles.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Преки пътища с физически бутони</string>
<string name="shortcuts_dd_menu">Меню на DroidDeck</string>
<string name="shortcuts_capture">Задаване: %1$s</string>
<string name="shortcuts_press">Натиснете и отпуснете бутон. Назначението се запазва автоматично.</string>
<string name="shortcuts_release">Отпуснете бутона, за да продължите.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Този бутон вече е зададен за: %1$s</string>
<string name="shortcuts_save">Преназначаване</string>
<string name="shortcuts_retry">Опитайте друг бутон</string>
<string name="shortcuts_limitations">Бутонът Начало и някои допълнителни бутони може да не са налични.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Zkratky fyzických tlačítek</string>
<string name="shortcuts_dd_menu">Nabídka DroidDeck</string>
<string name="shortcuts_capture">Přiřadit: %1$s</string>
<string name="shortcuts_press">Stiskněte a uvolněte tlačítko. Přiřazení se uloží automaticky.</string>
<string name="shortcuts_release">Pokračujte uvolněním tlačítka.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Toto tlačítko je již přiřazeno k: %1$s</string>
<string name="shortcuts_save">Přeřadit</string>
<string name="shortcuts_retry">Zkusit jiné tlačítko</string>
<string name="shortcuts_limitations">Tlačítko Domů a některá další tlačítka nemusí být dostupná.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Genveje til fysiske knapper</string>
<string name="shortcuts_dd_menu">DroidDeck-menu</string>
<string name="shortcuts_capture">Tildel: %1$s</string>
<string name="shortcuts_press">Tryk på en knap, og slip den. Tildelingen gemmes automatisk.</string>
<string name="shortcuts_release">Slip knappen for at fortsætte.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Denne knap er allerede tildelt: %1$s</string>
<string name="shortcuts_save">Tildel igen</string>
<string name="shortcuts_retry">Prøv en anden knap</string>
<string name="shortcuts_limitations">Hjem-knappen og visse ekstra knapper er muligvis ikke tilgængelige.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Physische Tastenkürzel</string>
<string name="shortcuts_dd_menu">DroidDeck-Menü</string>
<string name="shortcuts_capture">Zuweisen: %1$s</string>
<string name="shortcuts_press">Drücke eine Taste und lasse sie los. Die Zuweisung wird automatisch gespeichert.</string>
<string name="shortcuts_release">Lasse die Taste los, um fortzufahren.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Diese Taste ist bereits zugewiesen: %1$s</string>
<string name="shortcuts_save">Neu zuweisen</string>
<string name="shortcuts_retry">Andere Taste versuchen</string>
<string name="shortcuts_limitations">Die Home-Taste und einige Zusatztasten sind möglicherweise nicht verfügbar.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Συντομεύσεις φυσικών κουμπιών</string>
<string name="shortcuts_dd_menu">Μενού DroidDeck</string>
<string name="shortcuts_capture">Αντιστοίχιση: %1$s</string>
<string name="shortcuts_press">Πατήστε και αφήστε ένα κουμπί. Η αντιστοίχιση αποθηκεύεται αυτόματα.</string>
<string name="shortcuts_release">Αφήστε το κουμπί για συνέχεια.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Αυτό το κουμπί έχει ήδη αντιστοιχιστεί σε: %1$s</string>
<string name="shortcuts_save">Επαναντιστοίχιση</string>
<string name="shortcuts_retry">Δοκιμή άλλου κουμπιού</string>
<string name="shortcuts_limitations">Το κουμπί Αρχική και ορισμένα επιπλέον κουμπιά ενδέχεται να μην είναι διαθέσιμα.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Atajos de botones físicos</string>
<string name="shortcuts_dd_menu">Menú de DroidDeck</string>
<string name="shortcuts_capture">Asignar: %1$s</string>
<string name="shortcuts_press">Pulsa y suelta un botón. La asignación se guarda automáticamente.</string>
<string name="shortcuts_release">Suelta el botón para continuar.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Este botón ya está asignado a: %1$s</string>
<string name="shortcuts_save">Reasignar</string>
<string name="shortcuts_retry">Probar otro botón</string>
<string name="shortcuts_limitations">El botón Inicio y algunos botones adicionales pueden no estar disponibles.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Fyysisten painikkeiden pikavalinnat</string>
<string name="shortcuts_dd_menu">DroidDeck-valikko</string>
<string name="shortcuts_capture">Määritä: %1$s</string>
<string name="shortcuts_press">Paina painiketta ja vapauta se. Määritys tallennetaan automaattisesti.</string>
<string name="shortcuts_release">Jatka vapauttamalla painike.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Tämä painike on jo määritetty toimintoon: %1$s</string>
<string name="shortcuts_save">Määritä uudelleen</string>
<string name="shortcuts_retry">Kokeile toista painiketta</string>
<string name="shortcuts_limitations">Koti-painike ja jotkin lisäpainikkeet eivät ehkä ole käytettävissä.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Raccourcis des boutons physiques</string>
<string name="shortcuts_dd_menu">Menu DroidDeck</string>
<string name="shortcuts_capture">Attribuer : %1$s</string>
<string name="shortcuts_press">Appuyez sur un bouton puis relâchez-le. L’affectation est enregistrée automatiquement.</string>
<string name="shortcuts_release">Relâchez le bouton pour continuer.</string>
<string name="shortcuts_detected">%1$s : %2$s</string>
<string name="shortcuts_conflict">Ce bouton est déjà attribué à : %1$s</string>
<string name="shortcuts_save">Réaffecter</string>
<string name="shortcuts_retry">Essayer un autre bouton</string>
<string name="shortcuts_limitations">Le bouton Accueil et certains boutons supplémentaires peuvent être indisponibles.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">भौतिक बटन शॉर्टकट</string>
<string name="shortcuts_dd_menu">DroidDeck मेनू</string>
<string name="shortcuts_capture">असाइन करें: %1$s</string>
<string name="shortcuts_press">कोई बटन दबाकर छोड़ें। असाइनमेंट अपने आप सहेजा जाता है।</string>
<string name="shortcuts_release">जारी रखने के लिए बटन छोड़ें।</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">यह बटन पहले से असाइन है: %1$s</string>
<string name="shortcuts_save">फिर से असाइन करें</string>
<string name="shortcuts_retry">दूसरा बटन आज़माएँ</string>
<string name="shortcuts_limitations">होम और कुछ अतिरिक्त बटन उपलब्ध नहीं हो सकते हैं।</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Fizikai gombok parancsikonjai</string>
<string name="shortcuts_dd_menu">DroidDeck-menü</string>
<string name="shortcuts_capture">Hozzárendelés: %1$s</string>
<string name="shortcuts_press">Nyomj meg és engedj fel egy gombot. A hozzárendelés automatikusan mentődik.</string>
<string name="shortcuts_release">A folytatáshoz engedje fel a gombot.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Ez a gomb már ehhez van rendelve: %1$s</string>
<string name="shortcuts_save">Új hozzárendelés</string>
<string name="shortcuts_retry">Másik gomb kipróbálása</string>
<string name="shortcuts_limitations">A Kezdőlap és egyes extra gombok nem feltétlenül érhetők el.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Pintasan tombol fisik</string>
<string name="shortcuts_dd_menu">Menu DroidDeck</string>
<string name="shortcuts_capture">Tetapkan: %1$s</string>
<string name="shortcuts_press">Tekan lalu lepaskan tombol. Penetapan disimpan otomatis.</string>
<string name="shortcuts_release">Lepaskan tombol untuk melanjutkan.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Tombol ini sudah ditetapkan untuk: %1$s</string>
<string name="shortcuts_save">Tetapkan ulang</string>
<string name="shortcuts_retry">Coba tombol lain</string>
<string name="shortcuts_limitations">Tombol Beranda dan beberapa tombol tambahan mungkin tidak tersedia.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Scorciatoie dei pulsanti fisici</string>
<string name="shortcuts_dd_menu">Menu DroidDeck</string>
<string name="shortcuts_capture">Assegna: %1$s</string>
<string name="shortcuts_press">Premi e rilascia un pulsante. L’assegnazione viene salvata automaticamente.</string>
<string name="shortcuts_release">Rilascia il pulsante per continuare.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Questo pulsante è già assegnato a: %1$s</string>
<string name="shortcuts_save">Riassegna</string>
<string name="shortcuts_retry">Prova un altro pulsante</string>
<string name="shortcuts_limitations">Il pulsante Home e alcuni pulsanti aggiuntivi potrebbero non essere disponibili.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">物理ボタンのショートカット</string>
<string name="shortcuts_dd_menu">DroidDeck メニュー</string>
<string name="shortcuts_capture">割り当て:%1$s</string>
<string name="shortcuts_press">ボタンを押して離してください。割り当ては自動的に保存されます。</string>
<string name="shortcuts_release">ボタンを離して続行してください。</string>
<string name="shortcuts_detected">%1$s:%2$s</string>
<string name="shortcuts_conflict">このボタンはすでに次の操作に割り当てられています:%1$s</string>
<string name="shortcuts_save">再割り当て</string>
<string name="shortcuts_retry">別のボタンを試す</string>
<string name="shortcuts_limitations">ホームボタンや一部の追加ボタンは使用できない場合があります。</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">물리 버튼 바로가기</string>
<string name="shortcuts_dd_menu">DroidDeck 메뉴</string>
<string name="shortcuts_capture">지정: %1$s</string>
<string name="shortcuts_press">버튼을 눌렀다 놓으세요. 할당은 자동으로 저장됩니다.</string>
<string name="shortcuts_release">계속하려면 버튼을 놓으세요.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">이 버튼은 이미 다음 동작에 지정되어 있습니다: %1$s</string>
<string name="shortcuts_save">다시 할당</string>
<string name="shortcuts_retry">다른 버튼 시도</string>
<string name="shortcuts_limitations">홈 버튼과 일부 추가 버튼은 사용할 수 없을 수 있습니다.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Pintasan butang fizikal</string>
<string name="shortcuts_dd_menu">Menu DroidDeck</string>
<string name="shortcuts_capture">Tetapkan: %1$s</string>
<string name="shortcuts_press">Tekan dan lepaskan butang. Penetapan disimpan secara automatik.</string>
<string name="shortcuts_release">Lepaskan butang untuk meneruskan.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Butang ini sudah ditetapkan kepada: %1$s</string>
<string name="shortcuts_save">Tukar penetapan</string>
<string name="shortcuts_retry">Cuba butang lain</string>
<string name="shortcuts_limitations">Butang Utama dan sesetengah butang tambahan mungkin tidak tersedia.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Snarveier for fysiske knapper</string>
<string name="shortcuts_dd_menu">DroidDeck-meny</string>
<string name="shortcuts_capture">Tilordne: %1$s</string>
<string name="shortcuts_press">Trykk på en knapp og slipp den. Tilordningen lagres automatisk.</string>
<string name="shortcuts_release">Slipp knappen for å fortsette.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Denne knappen er allerede tilordnet: %1$s</string>
<string name="shortcuts_save">Tilordne på nytt</string>
<string name="shortcuts_retry">Prøv en annen knapp</string>
<string name="shortcuts_limitations">Hjem-knappen og enkelte ekstraknapper er kanskje ikke tilgjengelige.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Snelkoppelingen voor fysieke knoppen</string>
<string name="shortcuts_dd_menu">DroidDeck-menu</string>
<string name="shortcuts_capture">Toewijzen: %1$s</string>
<string name="shortcuts_press">Druk op een knop en laat deze los. De toewijzing wordt automatisch opgeslagen.</string>
<string name="shortcuts_release">Laat de knop los om door te gaan.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Deze knop is al toegewezen aan: %1$s</string>
<string name="shortcuts_save">Opnieuw toewijzen</string>
<string name="shortcuts_retry">Andere knop proberen</string>
<string name="shortcuts_limitations">De Home-knop en sommige extra knoppen zijn mogelijk niet beschikbaar.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Skróty przycisków fizycznych</string>
<string name="shortcuts_dd_menu">Menu DroidDeck</string>
<string name="shortcuts_capture">Przypisz: %1$s</string>
<string name="shortcuts_press">Naciśnij i zwolnij przycisk. Przypisanie zostanie zapisane automatycznie.</string>
<string name="shortcuts_release">Zwolnij przycisk, aby kontynuować.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Ten przycisk jest już przypisany do: %1$s</string>
<string name="shortcuts_save">Przypisz ponownie</string>
<string name="shortcuts_retry">Wypróbuj inny przycisk</string>
<string name="shortcuts_limitations">Przycisk Home i niektóre dodatkowe przyciski mogą być niedostępne.</string>
</resources>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Atalhos de botões físicos</string>
<string name="shortcuts_dd_menu">Menu do DroidDeck</string>
<string name="shortcuts_capture">Atribuir: %1$s</string>
<string name="shortcuts_press">Prima e solte um botão. A atribuição é guardada automaticamente.</string>
<string name="shortcuts_release">Solte o botão para continuar.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Este botão já está atribuído a: %1$s</string>
<string name="shortcuts_save">Reatribuir</string>
<string name="shortcuts_retry">Experimentar outro botão</string>
<string name="shortcuts_limitations">O botão Início e alguns botões adicionais podem não estar disponíveis.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Atalhos de botões físicos</string>
<string name="shortcuts_dd_menu">Menu do DroidDeck</string>
<string name="shortcuts_capture">Atribuir: %1$s</string>
<string name="shortcuts_press">Pressione e solte um botão. A atribuição é salva automaticamente.</string>
<string name="shortcuts_release">Solte o botão para continuar.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Este botão já está atribuído a: %1$s</string>
<string name="shortcuts_save">Reatribuir</string>
<string name="shortcuts_retry">Testar outro botão</string>
<string name="shortcuts_limitations">O botão Início e alguns botões extras podem não estar disponíveis.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Scurtături pentru butoane fizice</string>
<string name="shortcuts_dd_menu">Meniul DroidDeck</string>
<string name="shortcuts_capture">Atribuie: %1$s</string>
<string name="shortcuts_press">Apasă și eliberează un buton. Atribuirea se salvează automat.</string>
<string name="shortcuts_release">Eliberează butonul pentru a continua.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Acest buton este deja atribuit pentru: %1$s</string>
<string name="shortcuts_save">Reatribuie</string>
<string name="shortcuts_retry">Încearcă alt buton</string>
<string name="shortcuts_limitations">Butonul Acasă și unele butoane suplimentare pot fi indisponibile.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Действия физических кнопок</string>
<string name="shortcuts_dd_menu">Меню DroidDeck</string>
<string name="shortcuts_capture">Назначить: %1$s</string>
<string name="shortcuts_press">Нажмите и отпустите кнопку. Назначение сохранится автоматически.</string>
<string name="shortcuts_release">Отпустите кнопку, чтобы продолжить.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Эта кнопка уже назначена для: %1$s</string>
<string name="shortcuts_save">Переназначить</string>
<string name="shortcuts_retry">Попробовать другую кнопку</string>
<string name="shortcuts_limitations">Кнопка «Домой» и некоторые дополнительные кнопки могут быть недоступны.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Genvägar för fysiska knappar</string>
<string name="shortcuts_dd_menu">DroidDeck-meny</string>
<string name="shortcuts_capture">Tilldela: %1$s</string>
<string name="shortcuts_press">Tryck på en knapp och släpp den. Tilldelningen sparas automatiskt.</string>
<string name="shortcuts_release">Släpp knappen för att fortsätta.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Den här knappen är redan tilldelad: %1$s</string>
<string name="shortcuts_save">Tilldela igen</string>
<string name="shortcuts_retry">Prova en annan knapp</string>
<string name="shortcuts_limitations">Hemknappen och vissa extraknappar kanske inte är tillgängliga.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">ทางลัดปุ่มจริง</string>
<string name="shortcuts_dd_menu">เมนู DroidDeck</string>
<string name="shortcuts_capture">กำหนด: %1$s</string>
<string name="shortcuts_press">กดปุ่มแล้วปล่อย การกำหนดปุ่มจะบันทึกโดยอัตโนมัติ</string>
<string name="shortcuts_release">ปล่อยปุ่มเพื่อดำเนินการต่อ</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">ปุ่มนี้ถูกกำหนดไว้แล้วสำหรับ: %1$s</string>
<string name="shortcuts_save">กำหนดใหม่</string>
<string name="shortcuts_retry">ลองปุ่มอื่น</string>
<string name="shortcuts_limitations">ปุ่มโฮมและปุ่มพิเศษบางปุ่มอาจไม่พร้อมใช้งาน</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Fiziksel düğme kısayolları</string>
<string name="shortcuts_dd_menu">DroidDeck menüsü</string>
<string name="shortcuts_capture">Ata: %1$s</string>
<string name="shortcuts_press">Bir düğmeye basıp bırakın. Atama otomatik olarak kaydedilir.</string>
<string name="shortcuts_release">Devam etmek için düğmeyi bırakın.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Bu düğme zaten şuna atanmış: %1$s</string>
<string name="shortcuts_save">Yeniden ata</string>
<string name="shortcuts_retry">Başka düğme dene</string>
<string name="shortcuts_limitations">Ana ekran düğmesi ve bazı ek düğmeler kullanılamayabilir.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Дії фізичних кнопок</string>
<string name="shortcuts_dd_menu">Меню DroidDeck</string>
<string name="shortcuts_capture">Призначити: %1$s</string>
<string name="shortcuts_press">Натисніть і відпустіть кнопку. Призначення збережеться автоматично.</string>
<string name="shortcuts_release">Відпустіть кнопку, щоб продовжити.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Ця кнопка вже призначена для: %1$s</string>
<string name="shortcuts_save">Перепризначити</string>
<string name="shortcuts_retry">Спробувати іншу кнопку</string>
<string name="shortcuts_limitations">Кнопка «Додому» та деякі додаткові кнопки можуть бути недоступні.</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Phím tắt nút vật lý</string>
<string name="shortcuts_dd_menu">Menu DroidDeck</string>
<string name="shortcuts_capture">Gán: %1$s</string>
<string name="shortcuts_press">Nhấn và thả một nút. Gán nút được lưu tự động.</string>
<string name="shortcuts_release">Thả nút để tiếp tục.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">Nút này đã được gán cho: %1$s</string>
<string name="shortcuts_save">Gán lại</string>
<string name="shortcuts_retry">Thử nút khác</string>
<string name="shortcuts_limitations">Nút Home và một số nút bổ sung có thể không khả dụng.</string>
</resources>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">实体按键快捷操作</string>
<string name="shortcuts_dd_menu">DroidDeck 菜单</string>
<string name="shortcuts_capture">分配:%1$s</string>
<string name="shortcuts_press">按下并松开一个按钮,分配将自动保存。</string>
<string name="shortcuts_release">松开按键以继续。</string>
<string name="shortcuts_detected">%1$s:%2$s</string>
<string name="shortcuts_conflict">此按键已分配给:%1$s</string>
<string name="shortcuts_save">重新分配</string>
<string name="shortcuts_retry">尝试其他按键</string>
<string name="shortcuts_limitations">主屏幕按钮和部分额外按钮可能无法使用。</string>
</resources>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">實體按鍵快捷操作</string>
<string name="shortcuts_dd_menu">DroidDeck 選單</string>
<string name="shortcuts_capture">指派:%1$s</string>
<string name="shortcuts_press">按下並放開一個按鈕,指派會自動儲存。</string>
<string name="shortcuts_release">放開按鍵以繼續。</string>
<string name="shortcuts_detected">%1$s:%2$s</string>
<string name="shortcuts_conflict">此按鍵已指派給:%1$s</string>
<string name="shortcuts_save">重新指派</string>
<string name="shortcuts_retry">嘗試其他按鍵</string>
<string name="shortcuts_limitations">主畫面按鈕及部分額外按鈕可能無法使用。</string>
</resources>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">實體按鍵快捷操作</string>
<string name="shortcuts_dd_menu">DroidDeck 選單</string>
<string name="shortcuts_capture">指派:%1$s</string>
<string name="shortcuts_press">按下並放開一個按鈕,指派會自動儲存。</string>
<string name="shortcuts_release">放開按鍵以繼續。</string>
<string name="shortcuts_detected">%1$s:%2$s</string>
<string name="shortcuts_conflict">此按鍵已指派給:%1$s</string>
<string name="shortcuts_save">重新指派</string>
<string name="shortcuts_retry">嘗試其他按鍵</string>
<string name="shortcuts_limitations">主畫面按鈕及部分額外按鈕可能無法使用。</string>
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shortcuts_title">Physical button shortcuts</string>
<string name="shortcuts_dd_menu">DroidDeck menu</string>
<string name="shortcuts_capture">Assign: %1$s</string>
<string name="shortcuts_press">Press and release a button. Your assignment saves automatically.</string>
<string name="shortcuts_release">Release the button to continue.</string>
<string name="shortcuts_detected">%1$s: %2$s</string>
<string name="shortcuts_conflict">This button is already assigned to: %1$s</string>
<string name="shortcuts_save">Reassign</string>
<string name="shortcuts_retry">Try another button</string>
<string name="shortcuts_limitations">Home and some extra buttons may be unavailable.</string>
</resources>
@@ -0,0 +1,254 @@
package com.droiddeck.launcher.input
import android.content.Context
import android.hardware.input.InputManager
import android.view.InputDevice
import android.view.KeyCharacterMap
import android.view.KeyEvent
import com.droiddeck.launcher.input.PhysicalShortcuts.Action
import org.json.JSONArray
import org.json.JSONObject
import org.junit.Assert.*
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.Shadows.shadowOf
import org.robolectric.annotation.Config
import org.robolectric.shadows.InputDeviceBuilder
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [34], manifest = Config.NONE, shadows = [PadBridgeRoutingTest.RegisteredKeyEvent::class])
class PhysicalShortcutsTest {
private val context: Context get() = RuntimeEnvironment.getApplication()
private val router = PhysicalShortcutRouter()
private val actions = mutableListOf<Action>()
private lateinit var pad: InputDevice
@Before fun setUp() {
ControllerPrefs.prefs(context).edit().clear().commit()
pad = device(10, "retroid")
}
@Test fun defaultsDoNotInterceptAnyButton() {
assertTrue(PhysicalShortcuts.read(context).isEmpty())
for (code in listOf(KeyEvent.KEYCODE_BACK, KeyEvent.KEYCODE_BUTTON_MODE,
KeyEvent.KEYCODE_BUTTON_SELECT, KeyEvent.KEYCODE_BUTTON_1)) {
assertFalse(route(key(code)))
assertFalse(route(key(code, KeyEvent.ACTION_UP)))
}
assertTrue(actions.isEmpty())
}
@Test fun assignmentPersistsAndConsumesTheWholePressWithoutRepeating() {
assign(key(), Action.STEAM)
assertEquals(listOf(PhysicalShortcuts.Binding(button(key()), Action.STEAM)), PhysicalShortcuts.read(context))
assertTrue(route(key()))
assertTrue(route(key(repeat = 1)))
assertTrue(route(key(repeat = 2)))
assertTrue(route(key(action = KeyEvent.ACTION_UP)))
assertEquals(listOf(Action.STEAM), actions)
assertFalse(route(key(action = KeyEvent.ACTION_UP)))
}
@Test fun releaseIsConsumedEvenIfAnActionChangedTheRoutingContextOrSettings() {
assign(key(), Action.DROIDDECK)
assertTrue(route(key()))
router.bindings = emptyList()
assertTrue(route(key(action = KeyEvent.ACTION_UP), enabled = false, steam = false))
assertEquals(listOf(Action.DROIDDECK), actions)
}
@Test fun aRepeatedDownWithoutAnInitialPressDoesNotTriggerAnAction() {
assign(key(), Action.QAM)
assertTrue(route(key(repeat = 1)))
assertTrue(route(key(action = KeyEvent.ACTION_UP)))
assertTrue(actions.isEmpty())
}
@Test fun disabledMappedConfirmLeavesTheWholePressForDrawerNavigation() {
assign(key(KeyEvent.KEYCODE_BUTTON_A), Action.DROIDDECK)
assertFalse(route(key(KeyEvent.KEYCODE_BUTTON_A), enabled = false))
assertFalse(route(key(KeyEvent.KEYCODE_BUTTON_A, repeat = 1), enabled = false))
assertFalse(route(key(KeyEvent.KEYCODE_BUTTON_A, KeyEvent.ACTION_UP), enabled = false))
assertTrue(actions.isEmpty())
}
@Test fun mappedConfirmOpeningTheDrawerConsumesItsReleaseWithoutStayingHeld() {
assign(key(KeyEvent.KEYCODE_BUTTON_A), Action.DROIDDECK)
assertTrue(route(key(KeyEvent.KEYCODE_BUTTON_A)))
assertTrue(route(key(KeyEvent.KEYCODE_BUTTON_A, repeat = 1), enabled = false))
assertTrue(route(key(KeyEvent.KEYCODE_BUTTON_A, KeyEvent.ACTION_UP), enabled = false))
assertFalse(route(key(KeyEvent.KEYCODE_BUTTON_A), enabled = false))
assertFalse(route(key(KeyEvent.KEYCODE_BUTTON_A, KeyEvent.ACTION_UP), enabled = false))
assertTrue(route(key(KeyEvent.KEYCODE_BUTTON_A)))
assertTrue(route(key(KeyEvent.KEYCODE_BUTTON_A, KeyEvent.ACTION_UP)))
assertEquals(listOf(Action.DROIDDECK, Action.DROIDDECK), actions)
}
@Test fun aResumePressKeepsItsRepeatsAndReleaseInTheResumePath() {
assign(key(), Action.STEAM)
assertFalse(route(key(), enabled = false))
assertFalse(route(key(repeat = 1), enabled = false))
assertFalse(route(key(action = KeyEvent.ACTION_UP), enabled = false))
assertTrue(actions.isEmpty())
assertTrue(route(key()))
assertEquals(listOf(Action.STEAM), actions)
}
@Test fun steamActionsAreInactiveOutsideSteamAndAllActionsRespectDisabledContexts() {
for (action in Action.entries) {
assign(key(), action)
assertFalse(route(key(), enabled = false))
assertFalse(route(key(action = KeyEvent.ACTION_UP), enabled = false))
assertEquals(action == Action.DROIDDECK, route(key(), steam = false))
route(key(action = KeyEvent.ACTION_UP), steam = false)
}
assertEquals(listOf(Action.DROIDDECK), actions)
}
@Test fun reassigningAButtonReplacesItsPreviousAction() {
assign(key(), Action.STEAM)
assign(key(), Action.QAM)
assertEquals(listOf(Action.QAM), PhysicalShortcuts.read(context).map { it.action })
assertTrue(route(key()))
assertEquals(listOf(Action.QAM), actions)
}
@Test fun reassigningAnActionOnlyReplacesThatControllersBinding() {
val second = device(11, "bluetooth")
assign(key(), Action.STEAM)
assign(key(device = second), Action.STEAM)
assign(key(KeyEvent.KEYCODE_BUTTON_2), Action.STEAM)
val saved = PhysicalShortcuts.read(context)
assertEquals(2, saved.size)
assertTrue(saved.any { it.button.sameInput(button(key(device = second))) })
assertTrue(saved.any { it.button.sameInput(button(key(KeyEvent.KEYCODE_BUTTON_2))) })
assertFalse(route(key()))
}
@Test fun deviceIdentitySurvivesReconnectionButDoesNotMatchAnUnrelatedController() {
assign(key(), Action.QAM)
assertFalse(route(key(device = device(11, "other"))))
val reconnected = device(12, "retroid")
assertTrue(route(key(device = reconnected)))
assertEquals(listOf(Action.QAM), actions)
}
@Test fun scanCodesDistinguishButtonsSharingAnAndroidKeyCode() {
assign(key(scan = 700), Action.STEAM)
assign(key(scan = 701), Action.QAM)
assertEquals(2, PhysicalShortcuts.read(context).size)
assertTrue(route(key(scan = 700)))
assertTrue(route(key(scan = 701)))
assertFalse(route(key(scan = 702)))
assertEquals(listOf(Action.STEAM, Action.QAM), actions)
}
@Test fun keyboardLikeExtraButtonsCanBeExplicitlyAssignedWithoutChangingKeyboardDefaults() {
val keyboard = device(11, "m1-keyboard", InputDevice.SOURCE_KEYBOARD, InputDevice.KEYBOARD_TYPE_ALPHABETIC)
val m1 = key(KeyEvent.KEYCODE_F1, device = keyboard)
assertFalse(PadBridge.isControllerKeyEvent(m1))
assign(m1, Action.STEAM)
assertTrue(route(m1))
assertFalse(route(key(KeyEvent.KEYCODE_F2, device = keyboard)))
assertEquals(listOf(Action.STEAM), actions)
}
@Test fun virtualAndSystemKeysCannotBeAssigned() {
val virtual = device(-1, "virtual")
assertNull(PhysicalShortcuts.button(key(device = virtual)))
for (code in listOf(KeyEvent.KEYCODE_HOME, KeyEvent.KEYCODE_POWER, KeyEvent.KEYCODE_APP_SWITCH,
KeyEvent.KEYCODE_SLEEP, KeyEvent.KEYCODE_WAKEUP, KeyEvent.KEYCODE_VOLUME_UP,
KeyEvent.KEYCODE_VOLUME_DOWN, KeyEvent.KEYCODE_VOLUME_MUTE)) {
assertNull(PhysicalShortcuts.button(key(code)))
}
assertNull(PhysicalShortcuts.button(key(KeyEvent.KEYCODE_UNKNOWN, scan = 0)))
assertNotNull(PhysicalShortcuts.button(key(KeyEvent.KEYCODE_UNKNOWN, scan = 700)))
}
@Test fun drawerDirectionalKeysRemainAvailableForNavigation() {
for (code in listOf(KeyEvent.KEYCODE_DPAD_UP, KeyEvent.KEYCODE_DPAD_DOWN,
KeyEvent.KEYCODE_DPAD_LEFT, KeyEvent.KEYCODE_DPAD_RIGHT)) {
assertTrue(PhysicalShortcuts.isDrawerNavigationKey(key(code)))
}
assertFalse(PhysicalShortcuts.isDrawerNavigationKey(key(KeyEvent.KEYCODE_BUTTON_A)))
}
@Test fun resetAndRemovalPreserveOtherControllerSettings() {
ControllerPrefs.setSelectSteam(context, true)
ControllerPrefs.setTarget(context, "a", "b")
assign(key(), Action.STEAM)
assign(key(KeyEvent.KEYCODE_BUTTON_2), Action.QAM)
PhysicalShortcuts.remove(context, PhysicalShortcuts.read(context).first())
assertEquals(listOf(Action.QAM), PhysicalShortcuts.read(context).map { it.action })
PhysicalShortcuts.remove(context, PhysicalShortcuts.read(context).single())
assertTrue(PhysicalShortcuts.read(context).isEmpty())
assertTrue(ControllerPrefs.read(context).selectSteam)
assertEquals("b", ControllerPrefs.target(context, "a"))
assign(key(), Action.STEAM)
ControllerPrefs.resetAll(context)
assertTrue(PhysicalShortcuts.read(context).isEmpty())
}
@Test fun disconnectAndPauseClearHeldButtons() {
assign(key(), Action.QAM)
assertTrue(route(key()))
router.onDeviceRemoved(pad.id)
assertFalse(route(key(action = KeyEvent.ACTION_UP)))
assertTrue(route(key()))
router.clear()
assertFalse(route(key(action = KeyEvent.ACTION_UP)))
assertTrue(route(key()))
assertEquals(listOf(Action.QAM, Action.QAM, Action.QAM), actions)
}
@Test fun malformedPreferencesDoNotCrashInputDispatch() {
ControllerPrefs.prefs(context).edit().putString("physicalShortcuts", "invalid").commit()
assertTrue(PhysicalShortcuts.read(context).isEmpty())
}
@Test fun malformedEntriesDoNotDiscardValidAssignmentsWhenSaving() {
assign(key(), Action.STEAM)
assign(key(KeyEvent.KEYCODE_BUTTON_2), Action.QAM)
val entries = JSONArray(ControllerPrefs.prefs(context).getString("physicalShortcuts", null))
val damaged = JSONArray().put(entries.getJSONObject(0)).put(JSONObject().put("action", "STEAM"))
.put("not an object").put(entries.getJSONObject(1))
ControllerPrefs.prefs(context).edit().putString("physicalShortcuts", damaged.toString()).commit()
assertEquals(listOf(Action.STEAM, Action.QAM), PhysicalShortcuts.read(context).map { it.action })
assign(key(KeyEvent.KEYCODE_BUTTON_3), Action.DROIDDECK)
assertEquals(listOf(Action.STEAM, Action.QAM, Action.DROIDDECK),
PhysicalShortcuts.read(context).map { it.action })
}
@Test fun buttonSummaryKeepsTechnicalDetailsSeparate() {
val select = button(key(KeyEvent.KEYCODE_BUTTON_SELECT, scan = 314))
val androidName = KeyEvent.keyCodeToString(KeyEvent.KEYCODE_BUTTON_SELECT)
assertEquals(androidName.removePrefix("KEYCODE_").removePrefix("BUTTON_"), select.label)
assertFalse(select.label.contains("(314)"))
}
private fun assign(event: KeyEvent, action: Action) {
PhysicalShortcuts.assign(context, button(event), action)
router.bindings = PhysicalShortcuts.read(context)
}
private fun button(event: KeyEvent) = requireNotNull(PhysicalShortcuts.button(event))
private fun route(event: KeyEvent, enabled: Boolean = true, steam: Boolean = true) =
router.onKey(event, enabled, steam) { actions.add(it) }
private fun key(code: Int = KeyEvent.KEYCODE_BUTTON_1, action: Int = KeyEvent.ACTION_DOWN,
repeat: Int = 0, scan: Int = 700, device: InputDevice = pad): KeyEvent =
KeyEvent(100L, 100L, action, code, repeat, 0, device.id, scan, 0, device.sources)
private fun device(id: Int, descriptor: String, sources: Int = InputDevice.SOURCE_GAMEPAD,
type: Int = InputDevice.KEYBOARD_TYPE_NONE): InputDevice {
val device = InputDeviceBuilder.newBuilder().setId(id).setName("Test $descriptor")
.setDescriptor(descriptor).setSources(sources).setKeyboardType(type)
.setKeyCharacterMap(KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD)).build()
shadowOf(context.getSystemService(InputManager::class.java)).addInputDevice(device)
return device
}
}
@@ -0,0 +1,253 @@
package com.droiddeck.launcher.ui
import android.app.Application
import android.content.res.Configuration
import android.hardware.input.InputManager
import android.view.InputDevice
import android.view.KeyCharacterMap
import android.view.KeyEvent
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.test.*
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.dp
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.width
import androidx.compose.ui.Modifier
import com.droiddeck.launcher.R
import com.droiddeck.launcher.input.ControllerPrefs
import com.droiddeck.launcher.input.PadBridgeRoutingTest
import com.droiddeck.launcher.input.PhysicalShortcuts
import org.junit.Assert.*
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.Shadows.shadowOf
import org.robolectric.annotation.Config
import org.robolectric.shadows.InputDeviceBuilder
import org.robolectric.shadows.ShadowDialog
import java.util.Locale
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [34], application = Application::class, qualifiers = "w960dp-h640dp-land",
shadows = [PadBridgeRoutingTest.RegisteredKeyEvent::class])
class PhysicalShortcutsDialogTest {
@get:Rule val compose = createRobolectricComposeRule()
private val context get() = RuntimeEnvironment.getApplication()
private lateinit var device: InputDevice
@Before fun setUp() {
context.getSharedPreferences("controller", 0).edit().clear().commit()
device = InputDeviceBuilder.newBuilder().setId(10).setName("Retroid extra buttons")
.setDescriptor("retroid-extra").setSources(InputDevice.SOURCE_KEYBOARD)
.setKeyboardType(InputDevice.KEYBOARD_TYPE_ALPHABETIC)
.setKeyCharacterMap(KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD)).build()
shadowOf(context.getSystemService(InputManager::class.java)).addInputDevice(device)
}
@Test fun assignmentSavesAutomaticallyOnRelease() {
var changes = 0
compose.setContent { DroidDeckTheme { PhysicalShortcutRows(onChanged = { changes++ }) } }
assign(PhysicalShortcuts.Action.STEAM)
send(KeyEvent.KEYCODE_F1, KeyEvent.ACTION_DOWN)
compose.onNodeWithText(context.getString(R.string.shortcuts_release)).assertExists()
compose.onNodeWithTag("shortcuts-save").assertDoesNotExist()
assertTrue(PhysicalShortcuts.read(context).isEmpty())
send(KeyEvent.KEYCODE_F1, KeyEvent.ACTION_UP)
compose.onNodeWithTag("shortcuts-save").assertDoesNotExist()
compose.runOnIdle {
val binding = PhysicalShortcuts.read(context).single()
assertEquals(KeyEvent.KEYCODE_F1, binding.button.keyCode)
assertEquals(PhysicalShortcuts.Action.STEAM, binding.action)
assertEquals(1, changes)
}
}
@Test fun buttonMappingPageOpensPhysicalShortcutAssignments() {
compose.setContent {
DroidDeckTheme { ControllerMappingPage(emptyMap(), { _, _ -> }, {}, {}) }
}
compose.onNodeWithTag("shortcuts-assign-STEAM").assertExists()
compose.onNodeWithTag("shortcuts-assign-QAM").assertExists()
compose.onNodeWithTag("shortcuts-assign-DROIDDECK").assertExists()
}
@Test fun backCancelsCaptureWithoutSaving() {
compose.setContent { DroidDeckTheme { PhysicalShortcutRows() } }
assign(PhysicalShortcuts.Action.QAM)
send(KeyEvent.KEYCODE_BACK, KeyEvent.ACTION_DOWN)
compose.onNodeWithTag("shortcuts-cancel").assertDoesNotExist()
compose.runOnIdle {
assertTrue(PhysicalShortcuts.read(context).isEmpty())
}
compose.onNodeWithTag("shortcuts-assign-QAM").assertExists()
}
@Test fun controllerBCancelsCaptureWithoutSaving() {
compose.setContent { DroidDeckTheme { PhysicalShortcutRows() } }
assign(PhysicalShortcuts.Action.QAM)
send(KeyEvent.KEYCODE_BUTTON_B, KeyEvent.ACTION_DOWN)
compose.onNodeWithTag("shortcuts-assign-QAM").assertExists()
assertTrue(PhysicalShortcuts.read(context).isEmpty())
}
@Test fun closingConflictKeepsBothPreviousAssignments() {
PhysicalShortcuts.assign(context, requireNotNull(PhysicalShortcuts.button(event(KeyEvent.KEYCODE_F1, KeyEvent.ACTION_DOWN))),
PhysicalShortcuts.Action.STEAM)
PhysicalShortcuts.assign(context, requireNotNull(PhysicalShortcuts.button(event(KeyEvent.KEYCODE_F2, KeyEvent.ACTION_DOWN))),
PhysicalShortcuts.Action.QAM)
val previous = PhysicalShortcuts.read(context)
compose.setContent { DroidDeckTheme { PhysicalShortcutRows() } }
assign(PhysicalShortcuts.Action.QAM)
send(KeyEvent.KEYCODE_F1, KeyEvent.ACTION_DOWN)
send(KeyEvent.KEYCODE_F1, KeyEvent.ACTION_UP)
compose.onNodeWithTag("shortcuts-save").assertExists()
compose.onNodeWithTag("shortcuts-cancel").performScrollTo().performClick()
assertEquals(previous, PhysicalShortcuts.read(context))
}
@Test fun conflictingAssignmentIsNotReplacedUntilSave() {
PhysicalShortcuts.assign(context, requireNotNull(PhysicalShortcuts.button(event(KeyEvent.KEYCODE_F1, KeyEvent.ACTION_DOWN))),
PhysicalShortcuts.Action.STEAM)
compose.setContent { DroidDeckTheme { PhysicalShortcutRows() } }
assign(PhysicalShortcuts.Action.QAM)
send(KeyEvent.KEYCODE_F1, KeyEvent.ACTION_DOWN)
send(KeyEvent.KEYCODE_F1, KeyEvent.ACTION_UP)
compose.onNodeWithText(context.getString(R.string.shortcuts_conflict,
context.getString(R.string.drawer_steam_menu))).assertExists()
val button = requireNotNull(PhysicalShortcuts.button(event(KeyEvent.KEYCODE_F1, KeyEvent.ACTION_DOWN)))
compose.onAllNodesWithText("${button.label} · ${button.name}").assertCountEquals(2)
assertEquals(PhysicalShortcuts.Action.STEAM, PhysicalShortcuts.read(context).single().action)
compose.onNodeWithTag("shortcuts-save").performScrollTo().performClick()
compose.runOnIdle { assertEquals(PhysicalShortcuts.Action.QAM, PhysicalShortcuts.read(context).single().action) }
}
@Test fun removalRestoresDefaultAndPreservesOtherAssignmentsAndControllerSettings() {
ControllerPrefs.setSelectSteam(context, true)
PhysicalShortcuts.assign(context, requireNotNull(PhysicalShortcuts.button(event(KeyEvent.KEYCODE_F1, KeyEvent.ACTION_DOWN))),
PhysicalShortcuts.Action.STEAM)
PhysicalShortcuts.assign(context, requireNotNull(PhysicalShortcuts.button(event(KeyEvent.KEYCODE_F2, KeyEvent.ACTION_DOWN))),
PhysicalShortcuts.Action.QAM)
compose.setContent { DroidDeckTheme { PhysicalShortcutRows() } }
assign(PhysicalShortcuts.Action.STEAM)
send(KeyEvent.KEYCODE_F3, KeyEvent.ACTION_DOWN)
compose.onNodeWithTag("shortcuts-remove").performScrollTo().performClick()
compose.runOnIdle {
assertEquals(PhysicalShortcuts.Action.QAM, PhysicalShortcuts.read(context).single().action)
assertTrue(ControllerPrefs.read(context).selectSteam)
}
compose.onNodeWithTag("shortcuts-assign-STEAM").assertTextContains(context.getString(R.string.game_settings_default))
}
@Test fun retryRecoversFromAMissingReleaseWithoutSavingTheOldButton() {
compose.setContent { DroidDeckTheme { PhysicalShortcutRows() } }
assign(PhysicalShortcuts.Action.STEAM)
send(KeyEvent.KEYCODE_F1, KeyEvent.ACTION_DOWN)
compose.onNodeWithTag("shortcuts-retry").performScrollTo().performClick()
send(KeyEvent.KEYCODE_F1, KeyEvent.ACTION_UP)
compose.onNodeWithTag("shortcuts-save").assertDoesNotExist()
send(KeyEvent.KEYCODE_F2, KeyEvent.ACTION_DOWN)
send(KeyEvent.KEYCODE_F1, KeyEvent.ACTION_UP)
compose.onNodeWithTag("shortcuts-save").assertDoesNotExist()
send(KeyEvent.KEYCODE_F2, KeyEvent.ACTION_UP)
compose.onNodeWithTag("shortcuts-save").assertDoesNotExist()
val button = requireNotNull(PhysicalShortcuts.button(event(KeyEvent.KEYCODE_F2, KeyEvent.ACTION_DOWN)))
compose.onNodeWithText("${button.label} · ${button.name}").assertExists()
compose.runOnIdle { assertEquals(KeyEvent.KEYCODE_F2, PhysicalShortcuts.read(context).single().button.keyCode) }
}
@Test fun longControllerNameDoesNotSqueezeTheMenuLabelInANarrowDrawer() {
val button = requireNotNull(PhysicalShortcuts.button(event(KeyEvent.KEYCODE_BUTTON_SELECT, KeyEvent.ACTION_DOWN)))
.copy(name = "Xbox Wireless Controller with a long device name")
PhysicalShortcuts.assign(context, button, PhysicalShortcuts.Action.STEAM)
compose.setContent {
DroidDeckTheme {
Box(Modifier.width(360.dp)) { PhysicalShortcutRows() }
}
}
val control = compose.onNodeWithTag("shortcuts-assign-STEAM").getUnclippedBoundsInRoot()
val label = compose.onNodeWithText(context.getString(R.string.drawer_steam_menu)).getUnclippedBoundsInRoot()
assertTrue(control.right - control.left < 200.dp)
assertTrue("Menu label must not wrap vertically: $label", label.bottom - label.top <= 48.dp)
compose.onNodeWithTag("shortcuts-assign-STEAM").assertTextContains(context.getString(R.string.ctrl_custom))
compose.onNodeWithText("${button.label} · ${button.name}").assertExists()
}
@Test fun replacingSameActionsButtonSavesWithoutConfirmation() {
val oldButton = requireNotNull(PhysicalShortcuts.button(event(KeyEvent.KEYCODE_F1, KeyEvent.ACTION_DOWN)))
PhysicalShortcuts.assign(context, oldButton, PhysicalShortcuts.Action.STEAM)
compose.setContent { DroidDeckTheme { PhysicalShortcutRows() } }
assign(PhysicalShortcuts.Action.STEAM)
send(KeyEvent.KEYCODE_F2, KeyEvent.ACTION_DOWN)
assertEquals(oldButton, PhysicalShortcuts.read(context).single().button)
send(KeyEvent.KEYCODE_F2, KeyEvent.ACTION_UP)
compose.onNodeWithTag("shortcuts-save").assertDoesNotExist()
compose.runOnIdle { assertEquals(KeyEvent.KEYCODE_F2, PhysicalShortcuts.read(context).single().button.keyCode) }
}
@Test
@Config(qualifiers = "de-rDE-w400dp-h850dp-port")
fun narrowLargeTextKeepsTranslatedCaptureReachableAndSavesOnRelease() {
compose.setContent {
val density = LocalDensity.current
CompositionLocalProvider(LocalDensity provides Density(density.density, fontScale = 1.5f)) {
DroidDeckTheme { PhysicalShortcutRows() }
}
}
assign(PhysicalShortcuts.Action.DROIDDECK)
compose.onNodeWithText(context.getString(R.string.shortcuts_capture,
context.getString(R.string.shortcuts_dd_menu))).assertExists()
send(KeyEvent.KEYCODE_F1, KeyEvent.ACTION_DOWN)
send(KeyEvent.KEYCODE_F1, KeyEvent.ACTION_UP)
compose.onNodeWithTag("shortcuts-save").assertDoesNotExist()
compose.runOnIdle { assertEquals(PhysicalShortcuts.Action.DROIDDECK, PhysicalShortcuts.read(context).single().action) }
}
@Test
@Config(qualifiers = "ar-rEG-w400dp-h850dp-port")
fun rightToLeftDialogKeepsCancelReachable() {
compose.setContent { DroidDeckTheme { PhysicalShortcutRows() } }
assign(PhysicalShortcuts.Action.QAM)
compose.onNodeWithTag("shortcuts-cancel").performScrollTo().assertIsDisplayed().performClick()
compose.onNodeWithTag("shortcuts-assign-QAM").assertExists()
}
@Test fun everySupportedLanguageHasALocalizedShortcutTitleAndValidFormatArguments() {
val languages = mutableListOf<String>()
context.resources.getXml(R.xml.locales_config).use { xml ->
while (xml.next() != org.xmlpull.v1.XmlPullParser.END_DOCUMENT) {
if (xml.eventType == org.xmlpull.v1.XmlPullParser.START_TAG && xml.name == "locale") {
languages.add(xml.getAttributeValue("http://schemas.android.com/apk/res/android", "name"))
}
}
}
val english = context.getString(R.string.shortcuts_title)
for (language in languages) {
val config = Configuration(context.resources.configuration).apply { setLocale(Locale.forLanguageTag(language)) }
val localized = context.createConfigurationContext(config)
if (language != "en") assertNotEquals(language, english, localized.getString(R.string.shortcuts_title))
assertTrue(localized.getString(R.string.shortcuts_capture, "ACTION").contains("ACTION"))
assertTrue(localized.getString(R.string.shortcuts_conflict, "ACTION").contains("ACTION"))
val detected = localized.getString(R.string.shortcuts_detected, "DEVICE", "BUTTON")
assertTrue(detected.contains("DEVICE"))
assertTrue(detected.contains("BUTTON"))
}
}
private fun assign(action: PhysicalShortcuts.Action) {
compose.onNodeWithTag("shortcuts-assign-${action.name}").performClick()
}
private fun send(code: Int, action: Int) {
compose.runOnIdle {
assertTrue(ShadowDialog.getLatestDialog().window!!.callback.dispatchKeyEvent(event(code, action)))
}
compose.waitForIdle()
}
private fun event(code: Int, action: Int) =
KeyEvent(100L, 100L, action, code, 0, 0, device.id, 700, 0, InputDevice.SOURCE_KEYBOARD)
}