mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 21:35:59 +00:00
fix(input): restore Steam and Quick Access shortcuts (#2948)
This commit is contained in:
1 parent
3c0d25d83b
commit
cb8e70b940
17 files changed
+145
-37
No files matched your search
@@ -1751,7 +1751,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
onLayout = ::chooseLayout,
|
||||
onDeleteLayout = ::deleteLayout,
|
||||
oscRearButtons = oscRearButtons.takeIf {
|
||||
unfoldedPanel == null && !usesSteamTouchLayout() && com.droiddeck.launcher.input.PadKit.current(this).steam &&
|
||||
unfoldedPanel == null && oscMode != SessionPrefs.OSC_STEAM_QAM &&
|
||||
!usesSteamTouchLayout() && com.droiddeck.launcher.input.PadKit.current(this).steam &&
|
||||
primaryInputLayout?.let(com.droiddeck.launcher.input.OnScreenLayout::hasBuiltInKit) == true
|
||||
},
|
||||
oscTrackpads = oscTrackpads,
|
||||
@@ -4542,7 +4543,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
|
||||
private fun controlsBelowWanted(): Boolean {
|
||||
if (!::sessionRoot.isInitialized || glassesScreen != null || bottomGame != null || cardboard.enabled) return false
|
||||
if (sessionOscMode() == SessionPrefs.OSC_NEVER || usesSteamTouchLayout()) return false
|
||||
val mode = sessionOscMode()
|
||||
if (mode == SessionPrefs.OSC_NEVER || mode == SessionPrefs.OSC_STEAM_QAM || usesSteamTouchLayout()) return false
|
||||
return SessionPrefs.controlsBelowWanted(this, SessionState.mode, sessionRoot.width, sessionRoot.height,
|
||||
pipUi || isInPictureInPictureMode)
|
||||
}
|
||||
@@ -5407,6 +5409,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
val c = onScreenControls
|
||||
glassesSlot = when {
|
||||
c == null || c.visibility != View.VISIBLE || c.hidden != null -> 0
|
||||
c.shortcutsOnly -> -1
|
||||
c.inputSurface.shownElements.any { it.id == com.droiddeck.launcher.input.KitLayout.KEYBOARD_ID } -> 2
|
||||
else -> 1
|
||||
}
|
||||
@@ -5439,7 +5442,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
fun hideBottomControls() { bottomInputControls?.takeIf { it.visibility == View.VISIBLE }?.let { it.releaseAll(); it.visibility = View.GONE } }
|
||||
fun hideSteam() {
|
||||
steamTouchControls?.let { it.cancelEditing(); it.releaseAll(); it.visibility = View.GONE }
|
||||
val keyboardOver = controlsCovered() && usesSteamTouchLayout()
|
||||
val keyboardOver = controlsCovered() && usesSteamTouchLayout() && sessionOscMode() != SessionPrefs.OSC_STEAM_QAM
|
||||
if (!keyboardOver) com.droiddeck.launcher.input.SteamTouchDevice.current?.plugged = false
|
||||
}
|
||||
val plan = controlsPlan()
|
||||
@@ -5479,13 +5482,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
bottomInputControls = bottom
|
||||
}
|
||||
bottom.updateLayout(primaryInputLayout)
|
||||
bottom.setHidden(plan.hidden)
|
||||
bottom.setPresentation(plan.hidden, plan.shortcutsOnly)
|
||||
bottom.visibility = View.VISIBLE
|
||||
}
|
||||
com.droiddeck.launcher.input.ControlsPresenter.Place.MAIN,
|
||||
com.droiddeck.launcher.input.ControlsPresenter.Place.STEAM -> {
|
||||
hideBottomControls()
|
||||
controls.setHidden(plan.hidden)
|
||||
controls.setPresentation(plan.hidden, plan.shortcutsOnly)
|
||||
controls.visibility = View.VISIBLE
|
||||
}
|
||||
else -> {
|
||||
|
||||
@@ -17,7 +17,7 @@ object ControlsPresenter {
|
||||
val bottomScreen: Boolean,
|
||||
)
|
||||
|
||||
data class Plan(val place: Place, val hidden: OnScreenControls.Hidden? = null) {
|
||||
data class Plan(val place: Place, val hidden: OnScreenControls.Hidden? = null, val shortcutsOnly: Boolean = false) {
|
||||
val shown get() = place != Place.NONE && hidden == null
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ object ControlsPresenter {
|
||||
else -> Plan(
|
||||
when {
|
||||
state.bottomScreen -> Place.BOTTOM
|
||||
state.steamLayout -> Place.STEAM
|
||||
state.steamLayout && state.mode != SessionPrefs.OSC_STEAM_QAM -> Place.STEAM
|
||||
else -> Place.MAIN
|
||||
},
|
||||
when {
|
||||
@@ -35,6 +35,7 @@ object ControlsPresenter {
|
||||
state.mode == SessionPrefs.OSC_AUTO && state.controllerInUse -> OnScreenControls.Hidden.BY_CONTROLLER
|
||||
else -> null
|
||||
},
|
||||
shortcutsOnly = state.mode == SessionPrefs.OSC_STEAM_QAM,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -120,5 +120,7 @@ internal fun InputAction.validFor(control: InputControl): Boolean = when (this)
|
||||
internal fun defaultElementAction(id: String): InputAction = when (id) {
|
||||
KitLayout.DPAD_ID -> InputAction.Native()
|
||||
KitLayout.KEYBOARD_ID -> InputAction.Command(InputCommand.KEYBOARD)
|
||||
OnScreenLayout.STEAM_SHORTCUT_ID -> InputAction.Command(InputCommand.STEAM)
|
||||
OnScreenLayout.QAM_SHORTCUT_ID -> InputAction.Command(InputCommand.QUICK_ACCESS)
|
||||
else -> InputAction.Disabled
|
||||
}
|
||||
@@ -32,6 +32,8 @@ class OnScreenControls(context: Context, pad: PadBridge?, val dock: OnScreenLayo
|
||||
private val corner = CornerButton(context)
|
||||
var hidden: Hidden? = null
|
||||
private set
|
||||
var shortcutsOnly = false
|
||||
private set
|
||||
/** Holding the corner button opens DroidDeck's controller menu. */
|
||||
var onCornerHold: (() -> Unit)? = null
|
||||
/** The player tapped the corner button. */
|
||||
@@ -56,18 +58,24 @@ class OnScreenControls(context: Context, pad: PadBridge?, val dock: OnScreenLayo
|
||||
render()
|
||||
}
|
||||
|
||||
fun setHidden(value: Hidden?) {
|
||||
if (hidden == value) return
|
||||
fun setPresentation(value: Hidden?, shortcuts: Boolean = false) {
|
||||
if (hidden == value && shortcutsOnly == shortcuts) return
|
||||
releaseAll()
|
||||
hidden = value
|
||||
shortcutsOnly = shortcuts
|
||||
render()
|
||||
}
|
||||
|
||||
private fun render() {
|
||||
val placed = OnScreenLayout.elements(context, layout, viewWidth, viewHeight, safe, dock, cutouts,
|
||||
rearButtons = SessionPrefs.oscRearButtons(context), trackpads = SessionPrefs.oscTrackpads(context))
|
||||
surface.updateCustomLayout(if (hidden != null) placed.filter { it.alwaysShown } else placed)
|
||||
surface.updateStyle(layout?.style ?: InputSurfaceStyle())
|
||||
val style = layout?.style ?: InputSurfaceStyle()
|
||||
val visible = if (hidden == null && !shortcutsOnly) placed else {
|
||||
val pinned = placed.filter { it.alwaysShown && !style.hides(it) }
|
||||
if (hidden != null) pinned else pinned + OnScreenLayout.steamShortcuts(viewWidth, viewHeight, safe, resources.displayMetrics.density, pinned)
|
||||
}
|
||||
surface.updateCustomLayout(visible)
|
||||
surface.updateStyle(style)
|
||||
corner.visibility = if (layout == null || dock != null) GONE else VISIBLE
|
||||
corner.alpha = (layout?.style?.opacity ?: 100) / 100f
|
||||
val density = resources.displayMetrics.density
|
||||
@@ -148,7 +156,7 @@ class OnScreenControls(context: Context, pad: PadBridge?, val dock: OnScreenLayo
|
||||
else if (armed && event.x in 0f..width.toFloat() && event.y in 0f..height.toFloat()) {
|
||||
performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
|
||||
val next = if (hidden == null) Hidden.BY_TAP else null
|
||||
setHidden(next)
|
||||
setPresentation(next, shortcutsOnly)
|
||||
onCornerTap?.invoke(next)
|
||||
}
|
||||
armed = false
|
||||
|
||||
@@ -44,6 +44,43 @@ object OnScreenLayout {
|
||||
return fit(elements, aspect(context, layout), 1f, width, height, safe)
|
||||
}
|
||||
|
||||
internal const val STEAM_SHORTCUT_ID = "shortcut:steam"
|
||||
internal const val QAM_SHORTCUT_ID = "shortcut:qam"
|
||||
|
||||
internal fun steamShortcuts(width: Int, height: Int, safe: Rect, density: Float,
|
||||
pinned: List<InputSurfaceElement> = emptyList()): List<InputSurfaceElement> {
|
||||
if (width <= 0 || height <= 0) return emptyList()
|
||||
val size = min(48f * density, (width - safe.left - safe.right - 64f * density) / 2f)
|
||||
if (size <= 0f || height - safe.bottom - safe.top < size) return emptyList()
|
||||
val gap = 4f * density
|
||||
val left = safe.left + 56f * density
|
||||
val right = width - safe.right - size - gap
|
||||
val middle = (left + right) / 2f
|
||||
val pinnedFromBottom = pinned.sortedByDescending { it.y }
|
||||
fun button(control: InputControl, id: String, leftSide: Boolean): InputSurfaceElement? {
|
||||
val edge = if (leftSide) left else right
|
||||
val range = if (leftSide) left..(middle - size / 2f) else (middle + size / 2f)..right
|
||||
val candidates = listOf(edge) + pinned.map {
|
||||
if (leftSide) (it.x + it.width) * width + gap else it.x * width - size - gap
|
||||
}.filter { it in range }.sortedBy { kotlin.math.abs(it - edge) }
|
||||
for (x in candidates) {
|
||||
var y = max(safe.top.toFloat(), height - safe.bottom - size - gap)
|
||||
for (element in pinnedFromBottom) {
|
||||
if (x >= (element.x + element.width) * width || x + size <= element.x * width) continue
|
||||
if (y >= (element.y + element.height) * height || y + size <= element.y * height) continue
|
||||
y = element.y * height - size - gap
|
||||
}
|
||||
if (y >= safe.top) return InputSurfaceElement(control, x / width, y / height, size / width, size / height,
|
||||
id, buttonShape = InputButtonShape.PILL).bounded()
|
||||
}
|
||||
return null
|
||||
}
|
||||
return listOfNotNull(
|
||||
button(InputControl.GUIDE, STEAM_SHORTCUT_ID, leftSide = true),
|
||||
button(InputControl.QAM, QAM_SHORTCUT_ID, leftSide = false),
|
||||
)
|
||||
}
|
||||
|
||||
fun editorElements(context: Context, layout: SavedInputLayout, width: Int, height: Int, edited: Boolean = false): List<InputSurfaceElement> =
|
||||
elements(context, if (edited && width > 0 && height > 0) layout.copy(aspect = width.toFloat() / height) else layout, width, height, Rect())
|
||||
|
||||
|
||||
@@ -664,11 +664,11 @@ object SessionPrefs {
|
||||
prefs(context).getString("shape", null)
|
||||
?: if (context.packageManager.hasSystemFeature("android.hardware.sensor.hinge_angle")) SHAPE_WIDE else SHAPE_AUTO
|
||||
|
||||
/** Auto, Always or Never. Older builds also stored the Steam layout and a buttons-only mode here. */
|
||||
fun oscMode(context: Context, steamSession: Boolean = false): String = when (val mode = prefs(context).getString("osc", OSC_AUTO)) {
|
||||
/** Overlay visibility. Older builds also stored the Steam layout here. */
|
||||
fun oscMode(context: Context, steamSession: Boolean? = null): String = when (val mode = prefs(context).getString("osc", OSC_AUTO)) {
|
||||
OSC_ALWAYS, OSC_NEVER -> mode
|
||||
OSC_STEAM_QAM -> OSC_ALWAYS
|
||||
OSC_STEAM_TOUCH -> if (steamSession) OSC_ALWAYS else OSC_AUTO
|
||||
OSC_STEAM_QAM -> if (steamSession == false) OSC_AUTO else OSC_STEAM_QAM
|
||||
OSC_STEAM_TOUCH -> if (steamSession == true) OSC_ALWAYS else OSC_AUTO
|
||||
else -> OSC_AUTO
|
||||
}
|
||||
|
||||
|
||||
@@ -206,10 +206,10 @@ private fun DefaultControlsGroup(host: MenuHost, revision: Int, onEdit: (Triple<
|
||||
host.open = null
|
||||
ControlsChoice.editTarget(context, null, desktop = false)?.let(onEdit)
|
||||
}, modifier = Modifier.testTag("osc-edit"))
|
||||
SettingsRow(stringResource(R.string.osc_show), null) {
|
||||
SegmentedTabs(listOf(SessionPrefs.OSC_AUTO to stringResource(R.string.common_auto), SessionPrefs.OSC_ALWAYS to stringResource(R.string.common_always),
|
||||
SessionPrefs.OSC_NEVER to stringResource(R.string.common_never)), oscMode,
|
||||
tabModifier = { Modifier.testTag("osc-$it") }) { SessionPrefs.setOscMode(context, it); oscMode = it; onChanged() }
|
||||
ControlsVisibilityRow(host, oscMode, steam = true) {
|
||||
SessionPrefs.setOscMode(context, it)
|
||||
oscMode = it
|
||||
onChanged()
|
||||
}
|
||||
ChoiceRow(host, "touch", stringResource(R.string.input_touches), null,
|
||||
listOf(SessionPrefs.TOUCH_AUTO to stringResource(R.string.common_auto), SessionPrefs.TOUCH_DIRECT to stringResource(R.string.mode_touch_mouse),
|
||||
@@ -240,6 +240,19 @@ private fun InputControlGrid(preset: SavedInputBindings, available: List<InputCo
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun ControlsVisibilityRow(host: MenuHost, mode: String, steam: Boolean, modifier: Modifier = Modifier, onPick: (String) -> Unit) {
|
||||
ChoiceRow(host, "osc-show", stringResource(R.string.osc_show), null, controlsVisibilityOptions(steam), mode, chipModifier = modifier, onPick = onPick)
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun controlsVisibilityOptions(steam: Boolean): List<Pair<String, String>> = buildList {
|
||||
add(SessionPrefs.OSC_AUTO to stringResource(R.string.common_auto))
|
||||
add(SessionPrefs.OSC_ALWAYS to stringResource(R.string.common_always))
|
||||
if (steam) add(SessionPrefs.OSC_STEAM_QAM to stringResource(R.string.osc_steam_shortcuts_only))
|
||||
add(SessionPrefs.OSC_NEVER to stringResource(R.string.common_never))
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun InputNavigationRow(title: String, detail: String?, modifier: Modifier = Modifier, onClick: () -> Unit) {
|
||||
Row(modifier.fillMaxWidth().focusRow(RoundedCornerShape(0.dp), onClick = onClick).heightIn(min = 64.dp).padding(14.dp),
|
||||
|
||||
@@ -322,6 +322,8 @@ class InputSurfaceView(
|
||||
(element.name == c.label || element.name == kit.name(c)) && (c !in FACE || element.buttonShape == InputButtonShape.CIRCLE)
|
||||
when {
|
||||
element.id == KitLayout.KEYBOARD_ID && element.icon == InputButtonIcons.KEYBOARD -> art.system(canvas, w, h, PadArt.Shape.ROUND, PadArt.Icon.KEYBOARD, lit)
|
||||
element.id == OnScreenLayout.STEAM_SHORTCUT_ID -> art.system(canvas, w, h, PadArt.Shape.PILL, PadArt.Icon.STEAM, lit)
|
||||
element.id == OnScreenLayout.QAM_SHORTCUT_ID -> art.system(canvas, w, h, PadArt.Shape.PILL, PadArt.Icon.QAM, lit)
|
||||
native && c in FACE -> art.face(canvas, w / 2f, h / 2f, min(w, h) / 2f - art.dp(2f), c, kit, lit)
|
||||
native && c in SHOULDERS -> art.shoulder(canvas, w, h, c, kit, lit)
|
||||
native && c in GRIPS -> art.grip(canvas, w, h, c.label, lit)
|
||||
|
||||
@@ -298,11 +298,7 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
|
||||
)
|
||||
if (steam && s.oscMode != null) ChoiceRow(
|
||||
host, "osc", stringResource(R.string.mode_osc), null,
|
||||
listOf(
|
||||
SessionPrefs.OSC_AUTO to stringResource(R.string.common_auto),
|
||||
SessionPrefs.OSC_ALWAYS to stringResource(R.string.common_always),
|
||||
SessionPrefs.OSC_NEVER to stringResource(R.string.common_never),
|
||||
), s.oscMode,
|
||||
controlsVisibilityOptions(steam = true), s.oscMode,
|
||||
note = stringResource(R.string.mode_osc_note), onPick = a.onOsc,
|
||||
)
|
||||
if (steam && s.steamController != null) ChoiceRow(
|
||||
|
||||
@@ -677,11 +677,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
ActionRow(stringResource(R.string.osc_edit_layout), null, stringResource(R.string.ctrl_edit), { host.open = null; edit() },
|
||||
modifier = focus.track(page, "osc-edit"))
|
||||
}
|
||||
SettingsRow(stringResource(R.string.osc_show), null) {
|
||||
SegmentedTabs(listOf(SessionPrefs.OSC_AUTO to stringResource(R.string.common_auto), SessionPrefs.OSC_ALWAYS to stringResource(R.string.common_always),
|
||||
SessionPrefs.OSC_NEVER to stringResource(R.string.common_never)), a.oscMode,
|
||||
tabModifier = { focus.track(page, "osc-$it") }, onPick = a.onOsc)
|
||||
}
|
||||
ControlsVisibilityRow(host, a.oscMode, a.steam, focus.track(page, "osc-show"), a.onOsc)
|
||||
a.oscRearButtons?.let { rearButtons ->
|
||||
ToggleRow(host, "osc-rear-buttons", stringResource(R.string.osc_rear_buttons), null, rearButtons,
|
||||
chipModifier = focus.track(page, "osc-rear-buttons"), onChange = a.onOscRearButtons)
|
||||
|
||||
@@ -335,6 +335,7 @@
|
||||
<string name="osc_delete_layout">Delete layout</string>
|
||||
<string name="osc_edit_layout">Edit layout</string>
|
||||
<string name="osc_show">Show</string>
|
||||
<string name="osc_steam_shortcuts_only">Steam and Quick Access only</string>
|
||||
<string name="osc_rear_buttons">Rear buttons</string>
|
||||
<string name="osc_trackpads">Trackpads</string>
|
||||
<string name="osc_more">More controller settings</string>
|
||||
|
||||
@@ -58,6 +58,15 @@ class ControlsPresenterTest {
|
||||
assertEquals(Place.MAIN, ControlsPresenter.plan(playing.copy(desktop = true, mode = SessionPrefs.OSC_ALWAYS)).place)
|
||||
}
|
||||
|
||||
@Test fun steamShortcutsOverrideTheSteamLayoutAndFollowTheGameDisplay() {
|
||||
val state = playing.copy(mode = SessionPrefs.OSC_STEAM_QAM, steamLayout = true, controllerInUse = true)
|
||||
assertEquals(ControlsPresenter.Plan(Place.MAIN, shortcutsOnly = true), ControlsPresenter.plan(state))
|
||||
assertEquals(ControlsPresenter.Plan(Place.BOTTOM, shortcutsOnly = true), ControlsPresenter.plan(state.copy(bottomScreen = true)))
|
||||
assertEquals(ControlsPresenter.Plan(Place.MAIN, Hidden.BY_TAP, shortcutsOnly = true),
|
||||
ControlsPresenter.plan(state.copy(hiddenByTap = true)))
|
||||
assertEquals(ControlsPresenter.Plan(Place.NONE), ControlsPresenter.plan(state.copy(covered = true)))
|
||||
}
|
||||
|
||||
@Test fun aCoveringPanelOrNoVirtualPadRemovesTheControls() {
|
||||
assertEquals(Place.NONE, ControlsPresenter.plan(playing.copy(covered = true)).place)
|
||||
assertEquals(Place.NONE, ControlsPresenter.plan(playing.copy(virtualPad = false, mode = SessionPrefs.OSC_ALWAYS)).place)
|
||||
|
||||
@@ -22,14 +22,17 @@ class OnScreenControlPrefsTest {
|
||||
for (name in listOf("session", "game-controls", "input-profiles", "input-surfaces", "controller")) context.getSharedPreferences(name, Context.MODE_PRIVATE).edit().clear().commit()
|
||||
}
|
||||
|
||||
@Test fun oldShowModesMapOntoAutoAlwaysAndNever() {
|
||||
@Test fun oldShowModesKeepTheirMeaning() {
|
||||
assertEquals(SessionPrefs.OSC_AUTO, SessionPrefs.oscMode(context))
|
||||
for ((saved, mode) in listOf(SessionPrefs.OSC_AUTO to SessionPrefs.OSC_AUTO, SessionPrefs.OSC_ALWAYS to SessionPrefs.OSC_ALWAYS,
|
||||
SessionPrefs.OSC_NEVER to SessionPrefs.OSC_NEVER, SessionPrefs.OSC_STEAM_QAM to SessionPrefs.OSC_ALWAYS,
|
||||
SessionPrefs.OSC_NEVER to SessionPrefs.OSC_NEVER, SessionPrefs.OSC_STEAM_QAM to SessionPrefs.OSC_STEAM_QAM,
|
||||
SessionPrefs.OSC_STEAM_TOUCH to SessionPrefs.OSC_AUTO, "buttons" to SessionPrefs.OSC_AUTO)) {
|
||||
session.edit().putString("osc", saved).commit()
|
||||
assertEquals(saved, mode, SessionPrefs.oscMode(context))
|
||||
}
|
||||
session.edit().putString("osc", SessionPrefs.OSC_STEAM_QAM).commit()
|
||||
assertEquals(SessionPrefs.OSC_STEAM_QAM, SessionPrefs.oscMode(context, steamSession = true))
|
||||
assertEquals(SessionPrefs.OSC_AUTO, SessionPrefs.oscMode(context, steamSession = false))
|
||||
session.edit().putString("osc", SessionPrefs.OSC_STEAM_TOUCH).commit()
|
||||
assertEquals(SessionPrefs.OSC_ALWAYS, SessionPrefs.oscMode(context, steamSession = true))
|
||||
SessionPrefs.setOscMode(context, SessionPrefs.OSC_AUTO)
|
||||
|
||||
@@ -231,7 +231,7 @@ class OnScreenControlsTest {
|
||||
|
||||
@Test fun aControllerHideReleasesHeldControlsAndATapBringsThemBack() {
|
||||
touch(MotionEvent.ACTION_DOWN, 4 to (800f to 250f))
|
||||
view.setHidden(OnScreenControls.Hidden.BY_CONTROLLER)
|
||||
view.setPresentation(OnScreenControls.Hidden.BY_CONTROLLER)
|
||||
measure(view)
|
||||
assertFalse(state().isDown(PadState.A))
|
||||
assertFalse(view.takesTouchAt(800f, 250f))
|
||||
@@ -241,6 +241,18 @@ class OnScreenControlsTest {
|
||||
assertTrue(view.takesTouchAt(800f, 250f))
|
||||
}
|
||||
|
||||
@Test fun tappingTheCornerKeepsTheShortcutsMode() {
|
||||
fun shownIds() = view.inputSurface.shownElements.map { it.id }
|
||||
view.setPresentation(null, shortcuts = true)
|
||||
measure(view)
|
||||
val shortcuts = listOf(OnScreenLayout.STEAM_SHORTCUT_ID, OnScreenLayout.QAM_SHORTCUT_ID)
|
||||
assertEquals(shortcuts, shownIds())
|
||||
tapCorner()
|
||||
assertTrue(shownIds().isEmpty())
|
||||
tapCorner()
|
||||
assertEquals(shortcuts, shownIds())
|
||||
}
|
||||
|
||||
@Test fun theCornerIsGoneWithoutALayoutAndOnTheDockedStrip() {
|
||||
val (x, y) = corner
|
||||
view.updateLayout(null)
|
||||
|
||||
@@ -39,6 +39,27 @@ class OnScreenLayoutTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun steamShortcutsClearPinnedControlsAndStayInsideTheSafeArea() {
|
||||
val safe = Rect(20, 10, 30, 25)
|
||||
val pin = InputSurfaceElement(InputControl.A, .05f, .8f, .2f, .15f, "pin")
|
||||
val shortcuts = OnScreenLayout.steamShortcuts(1000, 600, safe, 2f, listOf(pin))
|
||||
val (steam, qam) = shortcuts
|
||||
assertEquals(OnScreenLayout.STEAM_SHORTCUT_ID, steam.id)
|
||||
assertEquals(OnScreenLayout.QAM_SHORTCUT_ID, qam.id)
|
||||
assertTrue(steam.y + steam.height < pin.y)
|
||||
assertEquals(OnScreenLayout.steamShortcuts(1000, 600, safe, 2f).last().y, qam.y)
|
||||
assertInside(shortcuts, 1000, 600, safe)
|
||||
|
||||
val tall = pin.copy(y = .1f, height = .85f)
|
||||
val beside = OnScreenLayout.steamShortcuts(1000, 600, safe, 2f, listOf(tall))
|
||||
assertEquals(2, beside.size)
|
||||
assertTrue(beside.first().x > tall.x + tall.width)
|
||||
assertInside(beside, 1000, 600, safe)
|
||||
|
||||
val cover = pin.copy(x = 0f, y = 0f, width = 1f, height = 1f)
|
||||
assertTrue(OnScreenLayout.steamShortcuts(1000, 600, safe, 2f, listOf(cover)).isEmpty())
|
||||
}
|
||||
|
||||
@Test fun savingTheEditorFrameKeepsEveryControlWhereTheEditorShowsIt() {
|
||||
val w = 2608
|
||||
val h = 1200
|
||||
|
||||
@@ -152,7 +152,11 @@ class InputSettingsTest {
|
||||
for (removed in listOf(R.string.input_default_profiles, R.string.input_profiles, R.string.input_new_profile))
|
||||
compose.onNodeWithText(context.getString(removed)).assertDoesNotExist()
|
||||
compose.onNodeWithTag("input-profile-game").assertDoesNotExist()
|
||||
compose.onNodeWithTag("osc-${SessionPrefs.OSC_NEVER}").performScrollTo().performClick()
|
||||
compose.onNodeWithTag("setting-osc-show").performScrollTo().performClick()
|
||||
compose.onNodeWithText(context.getString(R.string.osc_steam_shortcuts_only)).performClick()
|
||||
compose.runOnIdle { assertEquals(SessionPrefs.OSC_STEAM_QAM, SessionPrefs.oscMode(context)) }
|
||||
compose.onNodeWithTag("setting-osc-show").performClick()
|
||||
compose.onNodeWithText(context.getString(R.string.common_never)).performClick()
|
||||
compose.runOnIdle { assertEquals(SessionPrefs.OSC_NEVER, SessionPrefs.oscMode(context)) }
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ class InputSurfaceTouchTest {
|
||||
touch(MotionEvent.ACTION_UP, 1 to (600f to 510f))
|
||||
assertTrue(events.isEmpty())
|
||||
show(a, b, stick)
|
||||
view.setHidden(OnScreenControls.Hidden.BY_TAP)
|
||||
view.setPresentation(OnScreenControls.Hidden.BY_TAP)
|
||||
measure(view)
|
||||
assertFalse(view.takesTouchAt(450f, 510f))
|
||||
assertFalse(touch(MotionEvent.ACTION_DOWN, 1 to (450f to 510f)))
|
||||
@@ -155,11 +155,11 @@ class InputSurfaceTouchTest {
|
||||
}
|
||||
|
||||
@Test fun hiddenControlsHideTheKeyboardShortcutUntilShownAgain() {
|
||||
view.setHidden(OnScreenControls.Hidden.BY_CONTROLLER)
|
||||
view.setPresentation(OnScreenControls.Hidden.BY_CONTROLLER)
|
||||
measure(view)
|
||||
assertFalse(view.takesTouchAt(800f, 240f))
|
||||
assertFalse(view.takesTouchAt(450f, 510f))
|
||||
view.setHidden(null)
|
||||
view.setPresentation(null)
|
||||
measure(view)
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (450f to 510f))
|
||||
touch(MotionEvent.ACTION_UP, 1 to (450f to 510f))
|
||||
|
||||
Reference in new issue
Block a user