mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 22:05:59 +00:00
Merge upstream main and preserve routed Home input
Integrate upstream 213c2da5, keeping Home/Guide player-slot handling compatible with remapped controls and disabled routing. Preserve the input-settings overlay gate for Home and Steam volume keys.
Validation: 2,707 JVM tests across 389 suites pass. Device validation and latency measurements were not repeated.
This commit is contained in:
commit
b245017593
121 files changed
+7170
-348
No files matched your search
@@ -38,7 +38,7 @@ object HomeButtonShortcuts {
|
||||
|
||||
fun onKeyEvent(context: Context, event: KeyEvent): Boolean {
|
||||
// AYN maps its system-assistant key (gpio-keys KEY_F24) to HOME too; only the pad's Home is Guide.
|
||||
if (event.keyCode != KeyEvent.KEYCODE_HOME || !PadBridge.isControllerKeyEvent(event)) return false
|
||||
if (!HomeGuideInput.isHome(event.keyCode) || !PadBridge.isControllerKeyEvent(event)) return false
|
||||
return input.onKeyEvent(event, enabled() && HomeApp.isDefault(context))
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ class HomeGuideInput(private val setPressed: (Boolean) -> Unit, private val onCa
|
||||
private val cancelled = mutableSetOf<Int>()
|
||||
|
||||
fun onKeyEvent(event: KeyEvent, enabled: Boolean): Boolean {
|
||||
if (event.keyCode != KeyEvent.KEYCODE_HOME) return false
|
||||
if (!isHome(event.keyCode)) return false
|
||||
if (!enabled) cancel()
|
||||
val device = event.deviceId
|
||||
return when (event.action) {
|
||||
@@ -39,4 +39,9 @@ class HomeGuideInput(private val setPressed: (Boolean) -> Unit, private val onCa
|
||||
cancelled.remove(device)
|
||||
if (presses.remove(device) && presses.isEmpty()) { onCancel(); setPressed(false) }
|
||||
}
|
||||
|
||||
companion object {
|
||||
// The Retroid Nova pad falls back to Generic.kl, which maps its Home scan code to MOVE_HOME.
|
||||
fun isHome(keyCode: Int) = keyCode == KeyEvent.KEYCODE_HOME || keyCode == KeyEvent.KEYCODE_MOVE_HOME
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,7 @@ public final class PadBridge {
|
||||
private final FakeInputWriter[] playerWriters = new FakeInputWriter[SLOTS];
|
||||
private final PadState[] playerStates = new PadState[SLOTS];
|
||||
private final PadState effectiveState = new PadState();
|
||||
private final PadState homeGuideReport = new PadState();
|
||||
private final PadState combinedState = new PadState();
|
||||
private InputRouter inputRouter;
|
||||
private final InputRouter.PadSource[] physicalRoutes = new InputRouter.PadSource[SLOTS];
|
||||
@@ -76,6 +77,7 @@ public final class PadBridge {
|
||||
private boolean systemQamPressed;
|
||||
private boolean backQamPressed;
|
||||
private boolean homeGuidePressed;
|
||||
private int homeGuideSlot = -1;
|
||||
private final PadState lastBackQamReport = new PadState();
|
||||
private final PadState lastWrittenReport = new PadState();
|
||||
private final PadState liveReport = new PadState();
|
||||
@@ -225,6 +227,7 @@ public final class PadBridge {
|
||||
Arrays.fill(physicalRoutes, null);
|
||||
inputRouter = null;
|
||||
homeGuidePressed = false;
|
||||
homeGuideSlot = -1;
|
||||
clearBackQamWrites();
|
||||
releaseBackPaddles();
|
||||
activeControllerId = NO_CONTROLLER;
|
||||
@@ -292,6 +295,7 @@ public final class PadBridge {
|
||||
case KeyEvent.KEYCODE_BACK:
|
||||
case KeyEvent.KEYCODE_MENU:
|
||||
case KeyEvent.KEYCODE_HOME:
|
||||
case KeyEvent.KEYCODE_MOVE_HOME:
|
||||
if (!isFromController(device)) return false;
|
||||
return device.supportsSource(InputDevice.SOURCE_GAMEPAD)
|
||||
|| device.getKeyboardType() != InputDevice.KEYBOARD_TYPE_ALPHABETIC
|
||||
@@ -390,7 +394,8 @@ public final class PadBridge {
|
||||
case KeyEvent.KEYCODE_BUTTON_THUMBL: pad.press(8, pressed); break;
|
||||
case KeyEvent.KEYCODE_BUTTON_THUMBR: pad.press(9, pressed); break;
|
||||
case KeyEvent.KEYCODE_BUTTON_MODE:
|
||||
case KeyEvent.KEYCODE_HOME: pad.press(PadState.GUIDE, pressed); break;
|
||||
case KeyEvent.KEYCODE_HOME:
|
||||
case KeyEvent.KEYCODE_MOVE_HOME: pad.press(PadState.GUIDE, pressed); break;
|
||||
case KeyEvent.KEYCODE_BUTTON_Z:
|
||||
if (isPrimary(event)) DeckControls.INSTANCE.setGrip(isNovaController(event.getDevice()) ? DeckControls.R4 : DeckControls.L4, pressed);
|
||||
break;
|
||||
@@ -568,6 +573,7 @@ public final class PadBridge {
|
||||
DeckControls.INSTANCE.suspend();
|
||||
if (inputRouter == null) state.clear();
|
||||
homeGuidePressed = false;
|
||||
homeGuideSlot = -1;
|
||||
clearBackQamWrites();
|
||||
backQamPressed = false;
|
||||
if (inputRouter == null) releaseBackPaddles();
|
||||
@@ -593,18 +599,24 @@ public final class PadBridge {
|
||||
return builtinPad && nativeQam();
|
||||
}
|
||||
|
||||
public boolean canHoldGuide() {
|
||||
return builtinPad;
|
||||
}
|
||||
|
||||
public synchronized void setHomeGuidePressed(boolean pressed) {
|
||||
if (pressed && !canHoldGuide()) return;
|
||||
int slot = pressed ? firstPlayerSlot() : homeGuideSlot;
|
||||
if (slot > 0) {
|
||||
homeGuideSlot = pressed ? slot : -1;
|
||||
publish(slot);
|
||||
return;
|
||||
}
|
||||
if (homeGuidePressed == pressed) return;
|
||||
homeGuidePressed = pressed;
|
||||
updateHeldModifier(PadState.GUIDE, pressed);
|
||||
}
|
||||
|
||||
public synchronized void cancelHomeGuide() {
|
||||
int slot = homeGuideSlot;
|
||||
if (slot > 0) {
|
||||
homeGuideSlot = -1;
|
||||
publish(slot);
|
||||
}
|
||||
if (!homeGuidePressed) return;
|
||||
clearBackQamWrites();
|
||||
homeGuidePressed = false;
|
||||
@@ -903,6 +915,7 @@ public final class PadBridge {
|
||||
partners[slot] = NO_CONTROLLER;
|
||||
clearJoyCons(slot);
|
||||
slotControllers.set(slot, NO_CONTROLLER);
|
||||
if (slot == homeGuideSlot) homeGuideSlot = -1;
|
||||
if (slot == firstPlayerSlot()) releaseBackPaddles();
|
||||
if (slot == 0) {
|
||||
state.clear();
|
||||
@@ -960,6 +973,11 @@ public final class PadBridge {
|
||||
}
|
||||
playerWriters[slot] = player;
|
||||
}
|
||||
if (slot == homeGuideSlot) {
|
||||
homeGuideReport.copyFrom(output);
|
||||
homeGuideReport.press(PadState.GUIDE, true);
|
||||
output = homeGuideReport;
|
||||
}
|
||||
player.writePad(output);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.droiddeck.launcher.input
|
||||
|
||||
import android.media.AudioManager
|
||||
import android.view.KeyEvent
|
||||
|
||||
/** Use Steam's PulseAudio bridge for feedback instead of requesting Android's volume UI. */
|
||||
internal object SteamVolumeKeys {
|
||||
fun dispatch(event: KeyEvent, enabled: Boolean, adjust: (Int) -> Unit): Boolean {
|
||||
val direction = when (event.keyCode) {
|
||||
KeyEvent.KEYCODE_VOLUME_UP -> AudioManager.ADJUST_RAISE
|
||||
KeyEvent.KEYCODE_VOLUME_DOWN -> AudioManager.ADJUST_LOWER
|
||||
KeyEvent.KEYCODE_VOLUME_MUTE -> AudioManager.ADJUST_TOGGLE_MUTE
|
||||
else -> return false
|
||||
}
|
||||
if (!enabled) return false
|
||||
if (event.action == KeyEvent.ACTION_DOWN &&
|
||||
(event.keyCode != KeyEvent.KEYCODE_VOLUME_MUTE || event.repeatCount == 0)) {
|
||||
adjust(direction)
|
||||
}
|
||||
return event.action == KeyEvent.ACTION_DOWN || event.action == KeyEvent.ACTION_UP
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user