Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

launcher: gamepad_passthrough, off by default

Guilherme5a1a92bc803e
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/Config.java b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
index 7fbc06a7f..6252d6d4b 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
@@ -141,6 +141,8 @@ final class Config {
/** Whether the key services request key filtering (config.xml or theme key_filter); false keeps key
* auto-repeat working on firmware whose AccessibilityInputFilter drops repeats (TCL Android 12). */
final boolean keyFilter;
+ /** With keyFilter on, the key services stop filtering while a game controller is connected (gamepad_passthrough). */
+ final boolean gamepadPassthrough;
/** Stock launcher whose home screen is sent back here if the firmware revives it (config.xml stock_home_redirect). */
final String stockHomeRedirect;
/** The Settings button opens the quick settings panel instead of the TV's Settings (settings_key_panel). */
@@ -218,7 +220,7 @@ final class Config {
List<RaceWeekend.Race> raceCalendar, boolean cinematicHome, boolean ambientGlow, boolean appGlow, boolean fadeRows, int homeIdleClockMinutes,
boolean keyFilter, boolean dockGlass, String glowStyle, boolean wallpaperCaptions,
boolean handleViewInputs, boolean tileMenu, boolean dockEvenPadding, boolean cinematicDots, boolean cinematicWhiteFocus, boolean wifiStatusColor, int cinematicScrim, int cinematicArt,
- Map<String, Set<String>> wallpaperMoods) {
+ Map<String, Set<String>> wallpaperMoods, boolean gamepadPassthrough) {
this.handleViewInputs = handleViewInputs;
this.tileMenu = tileMenu;
this.inputKeycodes = inputKeycodes;
@@ -297,6 +299,7 @@ final class Config {
this.cinematicArt = cinematicArt;
this.cinematicScrim = cinematicScrim;
this.wallpaperMoods = wallpaperMoods;
+ this.gamepadPassthrough = gamepadPassthrough;
this.glowStyle = glowStyle(glowStyle);
this.wallpaperCaptions = wallpaperCaptions;
}
@@ -374,6 +377,7 @@ final class Config {
boolean fadeRows = res.getBoolean(R.bool.fade_rows);
int idleClockMinutes = res.getInteger(R.integer.home_idle_clock_minutes);
boolean keyFilter = res.getBoolean(R.bool.key_filter);
+ boolean gamepadPassthrough = res.getBoolean(R.bool.gamepad_passthrough);
boolean dockGlass = res.getBoolean(R.bool.dock_glass);
boolean dockEvenPadding = res.getBoolean(R.bool.dock_even_padding);
boolean cinematicDots = res.getBoolean(R.bool.cinematic_dots);
@@ -452,6 +456,7 @@ final class Config {
fadeRows = bool(json, "fade_rows", fadeRows);
idleClockMinutes = integer(json, "home_idle_clock_minutes", idleClockMinutes, 0, 1440);
keyFilter = bool(json, "key_filter", keyFilter);
+ gamepadPassthrough = bool(json, "gamepad_passthrough", gamepadPassthrough);
dockGlass = bool(json, "dock_glass", dockGlass);
dockEvenPadding = bool(json, "dock_even_padding", dockEvenPadding);
cinematicDots = bool(json, "cinematic_dots", cinematicDots);
@@ -515,7 +520,7 @@ final class Config {
Math.max(0, Math.min(100, skyIntensity)), settingsKeycodes, settingsKeyPanel, restoreKeyServices, wallpaperEnabled, wallpaper,
wallpapers, rotationMinutes, wallpaperDim, dockOpacity, wallpaperOrder, applied,
festival, inputKeycodes, appKeys, stockHomeRedirect, json == null ? Collections.emptyList() : raceCalendar(json), cinematic, ambientGlow, appGlow, fadeRows,
- Math.max(0, idleClockMinutes), keyFilter, dockGlass, glowStyle, wallpaperCaptions, handleViewInputs, tileMenu, dockEvenPadding, cinematicDots, cinematicWhiteFocus, wifiStatusColor, cinematicScrim, cinematicArt, wallpaperMoods);
+ Math.max(0, idleClockMinutes), keyFilter, dockGlass, glowStyle, wallpaperCaptions, handleViewInputs, tileMenu, dockEvenPadding, cinematicDots, cinematicWhiteFocus, wifiStatusColor, cinematicScrim, cinematicArt, wallpaperMoods, gamepadPassthrough);
}
/**
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/GamepadPassthrough.java b/launcher/app/src/main/java/com/gathin/tvhome/GamepadPassthrough.java
index db69c40a7..ee34f7a4e 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/GamepadPassthrough.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/GamepadPassthrough.java
@@ -11,7 +11,8 @@ import android.view.InputDevice;
* Android routes every key through the accessibility layer and re-injects the ones the service passes on, and games
* (Steam Link with an Xbox controller, on a TCL G07) stop seeing the controller's buttons as the controller's. The
* remote buttons the services handle do nothing until the controller disconnects; filtering then comes back.
- * Started only with key_filter on: with it off the services never filter, and this must not turn filtering back on.
+ * Off by default (gamepad_passthrough). Started only with key_filter on too: with it off the services never filter,
+ * and this must not turn filtering back on.
*/
final class GamepadPassthrough implements InputManager.InputDeviceListener {
private final AccessibilityService service;
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java b/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java
index cb2de4738..071e850e3 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java
@@ -50,7 +50,7 @@ public class HomeKeyService extends AccessibilityService {
private BroadcastReceiver unlockReceiver;
/** The stock launcher's HOME activities (stock_home_redirect), disabled ones included. */
private final Set<String> stockHome = new HashSet<>();
- /** Stops key filtering while a game controller is connected; null with key_filter off or before the unlock. */
+ /** Stops key filtering while a game controller is connected; null unless gamepad_passthrough and key_filter, or before the unlock. */
private GamepadPassthrough gamepads;
@Override
@@ -120,8 +120,8 @@ public class HomeKeyService extends AccessibilityService {
}
holdAppKeys = RemoteKeys.parseHoldAppKeys(config.appKeys);
holdAppScancodes = RemoteKeys.parseHoldAppScancodes(config.appKeys);
- // key_filter off: the service never filters, so there is nothing to hand over to a game controller.
- if (config.keyFilter && gamepads == null) {
+ // gamepad_passthrough, off by default. Only with key_filter on: off, the service never filters keys.
+ if (config.gamepadPassthrough && config.keyFilter && gamepads == null) {
gamepads = new GamepadPassthrough(this);
gamepads.start();
}
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/InputKeyService.java b/launcher/app/src/main/java/com/gathin/tvhome/InputKeyService.java
index 23483cd8b..af7a7c79b 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/InputKeyService.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/InputKeyService.java
@@ -27,7 +27,7 @@ public class InputKeyService extends AccessibilityService {
private Map<Integer, String> holdAppScancodes = Collections.emptyMap();
/** restore_key_services was on when the config was read: this helper is noted for ServiceRepair. */
private boolean repairRecord;
- /** Stops key filtering while a game controller is connected; null with key_filter off. */
+ /** Stops key filtering while a game controller is connected; null unless gamepad_passthrough and key_filter. */
private GamepadPassthrough gamepads;
@Override
@@ -44,8 +44,8 @@ public class InputKeyService extends AccessibilityService {
RemoteKeys.applyKeyFilter(this, config.keyFilter);
holdAppKeys = RemoteKeys.parseHoldAppKeys(config.appKeys);
holdAppScancodes = RemoteKeys.parseHoldAppScancodes(config.appKeys);
- // key_filter off: the service never filters, so there is nothing to hand over to a game controller.
- if (config.keyFilter && gamepads == null) {
+ // gamepad_passthrough, off by default. Only with key_filter on: off, the service never filters keys.
+ if (config.gamepadPassthrough && config.keyFilter && gamepads == null) {
gamepads = new GamepadPassthrough(this);
gamepads.start();
}
diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xml
index ff50ea62b..29cec0b5a 100644
--- a/launcher/app/src/main/res/values/config.xml
+++ b/launcher/app/src/main/res/values/config.xml
@@ -97,11 +97,15 @@
<!-- Whether HomeKeyService and InputKeyService actually request key filtering (config.xml or a theme's
"key_filter"). Some firmware (TCL Google TV on Android 12) drops key auto-repeat once ANY service
filters keys, so long-pressing volume only steps once: set false and the service keeps running but
- stops filtering, which brings repeat back at the price of the remote buttons below doing nothing.
- With it true, filtering still pauses while a game controller is connected, so games see its buttons
- (Steam Link with an Xbox controller); the remote buttons below come back when it disconnects. -->
+ stops filtering, which brings repeat back at the price of the remote buttons below doing nothing. -->
<bool name="key_filter">true</bool>
+ <!-- With key_filter on, true makes HomeKeyService and InputKeyService stop filtering keys while a game
+ controller is connected, so games see its buttons (Steam Link with an Xbox controller on a TCL G07
+ did not). The price: the remote buttons below do nothing until the controller disconnects. A voice
+ remote that reports a joystick does not count. A theme can set it ("gamepad_passthrough"). -->
+ <bool name="gamepad_passthrough">false</bool>
+
<!-- Vendor source numbers for the Inputs menu, "HW<n>=<number>" by the framework input id's last part
(`tools/tv.py 'dumpsys tv_input'` lists them). A mapped input opens by sending input_action with the
number as the int extra "input"; "HW<n>=-" leaves a port the board reports but the set does not have
diff --git a/themes/README.md b/themes/README.md
index ec07d76ba..264848800 100644
--- a/themes/README.md
+++ b/themes/README.md
@@ -101,6 +101,7 @@ A new key needs one there in the same pull request.
| `input_key_keycodes` | list of keycodes | More remote buttons that open the input switcher, for `InputKeyService` (`KEYCODE_TV` and `KEYCODE_TV_INPUT` always do) |
| `app_keys` | list of strings | Remote buttons that open an app, as `"190:com.google.android.youtube.tv"` or `"KEYCODE_BUTTON_3:com.google.android.youtube.tv"`, or by scancode as `"scan:490:com.wbd.hbomax"` for remotes that share one keycode between app buttons (Sony BRAVIA), for `InputKeyService` or `HomeKeyService`. `"input:<input id>"` in place of the package switches to a TV input instead, e.g. `"scan:227:input:com.tcl.tvinput/.passthroughinput.TvPassThroughService/HW1413744640"` for an HDMI port (ids from `dumpsys tv_input`). Prefix an entry with `hold:` to make it the long-press action, e.g. `"hold:190:com.netflix.ninja"`, while the unprefixed entry still opens on a tap |
| `key_filter` | bool | `false` makes the key helpers stop filtering keys while staying enabled. Use it on firmware where any key-filtering accessibility service breaks long-press repeat (TCL Google TV on Android 12): the remote buttons above stop working, and volume repeat comes back |
+| `gamepad_passthrough` | bool | `true` makes the key helpers stop filtering keys while a game controller is connected, so games see its buttons (Steam Link with an Xbox controller); the remote buttons above do nothing until it disconnects. Needs `key_filter` on. A voice remote that reports a joystick does not count. Off by default |
| `stock_home_redirect` | string | Stock launcher package; if the firmware turns it back on (XGIMI), its home screen is sent straight back here (`HOME_KEY_SERVICE=1`) |
| `race_calendar` | list of races | F1 race-weekend mode: from 12 hours before a weekend's first session until 4 hours after the race starts, a panel under the clock shows the next session with a countdown (or the live one) and the weekend's session times in the TV's time zone. Write it with `tools/race_calendar.py <theme folder>`, which fetches the season from the free Jolpica API; the launcher itself never goes online |
| `home_idle_clock_minutes` | 0 to 1440 | Minutes Home may sit untouched before it shows the clock screensaver (a thin clock and date drifting over a slow glow, as the system "Clock" screensaver does). Any key returns to Home. It starts only from Home, never over Live TV or an app; 0 is off (default) |