Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 50 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ rough edges, and expect performance to vary a lot between devices - see
compatibility layer, running on Vulkan through Google's Dawn.

**An OpenGL ES fallback.** Some phones ship a Vulkan driver too broken to start
the game at all. The launcher's **Graphics...** screen can switch the renderer
the game at all. The launcher's **Settings > Graphics** can switch the renderer
to OpenGL ES for those devices. It is slower than Vulkan by nature - OpenGL only
lets one thread talk to the GPU, so shaders compile on the render thread and the
multithreaded graphics path is unavailable - so leave it on Automatic unless
Expand Down Expand Up @@ -75,10 +75,40 @@ restart, which the menu does for you.

**Vertical mode (experimental).** Play upright like Mario Kart Tour: the race
fills the tall screen, the race HUD moves to the corners and the touch controls
get their own layout. Launcher > Graphics > Vertical mode.
get their own layout. Launcher > Settings > Graphics > Vertical mode.

**Save import and export.** Bring your profile over from a Wii NAND backup or
Dolphin (`rksys.dat`), or copy it out, from the launcher's **Save data**.
Dolphin (`rksys.dat`), or copy it out, from the launcher's **Settings > Save data**.

**A launcher built around the game.** Home, Mods, Rooms, Ranks, Profile and
Settings pages, upright with a tab bar on a phone and sideways with a navigation
rail on tablets and handhelds. **Settings > Launcher orientation** picks Automatic,
Portrait or Landscape. Long jobs (installing Retro Rewind, downloading a mod,
importing a game pack) show their progress in a task bar that follows you from
page to page.

**Mods from inside the app.** Browse GameBanana's Mario Kart Wii mods and install
one with a tap (`.zip`, `.7z` and `.rar`, including RAR5), or import an archive you
already have. Turn mods on and off and drag them into priority order: the higher
mod wins when two change the same file. Turned-on mods load when you press Play (a
game that's already running restarts so the change takes) and apply to both Mario
Kart Wii and Retro Rewind. For Retro Rewind they're also laid out in its own
`Patches` folder the way the Wheel Wizard PC tool does it, so mods built on its
loose archive overrides (files like `Name.race.szs`) work too.

**Rooms and Ranks.** Every public Retro WFC room, live: the track being raced,
who's in it with their Miis and VR, the room's average VR and whether it's open.
Ranks has the top 100 players by VR, and each player has a page with their rank and
a 7-day VR chart. Tap anyone to copy their friend code or add them as a friend.
Joining a room still happens inside the game.

**Profile and Mii editor.** Licenses from your saves (Mii, friend code, VR and BR,
races and wins, friends), and an editor for every part of every Mii where each shape
is picked from pictures of your own Mii wearing it. Make, duplicate and delete Miis,
and import or export single Miis (`.rcd`) or the whole Mii file. Every change is
checked, written with the correct checksum, and the previous file is kept next to it
as a `.bak`. The pictures come from Nintendo's online Mii renderer; **Settings > Mii
pictures** turns that off and draws simple offline ones instead.

**Picture settings.** Brightness, contrast and saturation in the Display
settings.
Expand Down Expand Up @@ -158,7 +188,7 @@ a phone, and the honest summary is:
- **Android 10 (API 29) or newer**, on a 64-bit ARM (`arm64-v8a`) chip. There is no 32-bit or
x86 build.
- A working Vulkan driver for the best experience. Devices without one can fall back to OpenGL ES
from the launcher's **Graphics...** screen.
from the launcher's **Settings > Graphics**.
- Enough free storage for the extracted game data (a few GB) plus headroom during the one-time
extraction step.
- A clean, unmodified **PAL `RMCP01`** disc image of Mario Kart Wii (.iso or .wbfs), dumped by you.
Expand Down Expand Up @@ -186,7 +216,7 @@ all stay.
**Optional: a game pack.** On your PC, unpack DriftDroid Builder, open `DriftDroidBuilder.exe`
(Linux: `DriftDroidBuilder`), choose your disc image, pick Android and press **Start**. It takes 30
minutes to a couple of hours and makes `output/DriftDroid-GamePack-<version>.zip`. Copy it to the
phone and tap **Import Game Pack...**: the app then uses that game code, for example a newer Retro
phone and open **Settings > Import game pack**: the app then uses that game code, for example a newer Retro
Rewind. A game pack fits one app version, so make a new one with the matching builder.

DriftDroid Builder also makes the **Switch** version (`DriftDroid.nro` and `RetroRewind.nro`); that
Expand Down Expand Up @@ -336,8 +366,8 @@ No - this is an active, personal work-in-progress fork. It's playable start to f
performance work, device compatibility and bug fixing are ongoing.

**It won't start / the screen stays black.**
Most often a Vulkan driver the device can't actually deliver on. Open the launcher, tap
**Graphics...**, choose **OpenGL ES**, and try again. Report it either way - which renderer worked
Most often a Vulkan driver the device can't actually deliver on. Open the launcher, go to
**Settings > Graphics**, choose **OpenGL ES**, and try again. Report it either way - which renderer worked
is exactly the information that's useful.

**It runs at 60 fps and then gets slower.**
Expand All @@ -351,7 +381,7 @@ the frames. It applies from the next race.

**Retro Rewind crashes when I open Retro WFC or a menu after updating.**
Most likely a mod that replaces Retro Rewind's own files and was made for an older Retro Rewind.
Turn your mods off in **Mods...** and try again; if that fixes it, the mod needs a version made
Turn your mods off on the **Mods** page and try again; if that fixes it, the mod needs a version made
for the Retro Rewind you have now.

**Characters or menu icons are stretched across the screen.**
Expand All @@ -360,7 +390,7 @@ GPUs; if you still see it, set **Fix stretched graphics (Snapdragon)** in the se
**Everything**, or try a different GPU driver (next question).

**Can I use a different GPU driver?**
On Snapdragon phones, yes: **Graphics...** -> **GPU driver...** installs an AdrenoTools driver
On Snapdragon phones, yes: **Settings > Graphics** -> **GPU driver...** installs an AdrenoTools driver
package such as Turnip. DriftDroid does not ship drivers; where to get them and how to check which
one is active is in [`docs/android-gpu-compatibility.md`](docs/android-gpu-compatibility.md).

Expand Down Expand Up @@ -421,6 +451,17 @@ position-tracked).
steering calibration curve were directly modeled on, and the source of several GX command
processor fixes, the in-app updater, and the phone vibration fallback and vibration strength
setting this fork carries.
- **[Wheel Wizard](https://github.com/TeamWheelWizard/WheelWizard)** by Team Wheel Wizard - the PC
tool whose features the launcher brings to Android, and the reference for its Retro WFC and
GameBanana API use, the Mii renderer encoding, the save-file and Mii-file layouts, and friend-code
math.
- **Retro WFC**, whose public API powers Rooms and Ranks, and
**[GameBanana](https://gamebanana.com/games/5896)** and the mod authors whose work the Mods page
lists.
- **[libarchive](https://www.libarchive.org/)** (BSD) through
**[libarchive-android](https://github.com/zhanghai/libarchive-android)** (Apache 2.0) - unpacking
`.7z` and `.rar` mods.
- **Material Design icons** by Google (Apache 2.0) in the launcher.
- **App icon**: a 3D render made for this project in Blender. The kart is
**"Kart" by [absence_art](https://sketchfab.com/absence_art)** on Sketchfab
(<https://sketchfab.com/3d-models/kart-1eef98f88e804e3481d8b1bfb311ee06>), licensed
Expand Down
16 changes: 16 additions & 0 deletions THIRD-PARTY-NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,22 @@ load time, at `android/app/src/main/java/org/libsdl/app/`. Taken unmodified from
source tree pinned below (`android-project/app/src/main/java/org/libsdl/app/`).
Source: <https://github.com/libsdl-org/SDL>.

### Material Design icons - Apache-2.0

The launcher's icons (`android/app/src/main/kotlin/com/driftdroid/android/ui/Icons.kt`) are path data
from Google's Material Design icons, Copyright Google LLC, licensed under the Apache License 2.0.
Source: <https://github.com/google/material-design-icons>.

### libarchive-android 1.1.4 - Apache-2.0, with libarchive - BSD

The Android app's mod installer unpacks `.7z` and `.rar` archives with libarchive, through the
`me.zhanghai.android.libarchive:library:1.1.4` JNI wrapper (fetched from Maven Central by Gradle and
packaged into the APK as `libarchive-jni.so`). The wrapper is Copyright 2023 Google LLC, licensed
under the Apache License 2.0. libarchive is Copyright Tim Kientzle and the libarchive contributors,
licensed under the 2-clause BSD license; the native library also contains the compression libraries
it is built with, each under its own license as listed by the wrapper project.
Sources: <https://github.com/zhanghai/libarchive-android>, <https://github.com/libarchive/libarchive>.

---

## Fetched at build time and redistributed in release builds
Expand Down
7 changes: 7 additions & 0 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,11 @@ dependencies {
implementation("androidx.documentfile:documentfile:1.0.1")
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.recyclerview:recyclerview:1.3.2")
// libarchive for mod downloads: GameBanana's Mario Kart Wii mods come as .zip, .7z and RAR5 .rar,
// and RAR5 has no pure-Java reader. BSD-licensed libarchive behind an Apache-2.0 JNI wrapper.
implementation("me.zhanghai.android.libarchive:library:1.1.4")

testImplementation("junit:junit:4.13.2")
// Android's org.json is a stub in local unit tests; this is the real implementation.
testImplementation("org.json:json:20240303")
}
5 changes: 3 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
<!-- The Original/Retro Rewind choice must happen before any product .so loads (Android
cannot swap which native library is loaded within a process), so it's now the actual
launcher - MainActivity is started explicitly from here with the resolved choice. -->
<!-- No fixed orientation: LauncherOrientation stands it upright on phones and sideways
on tablets and handhelds (or as the player picks in Settings). -->
<activity
android:name=".ModePickerActivity"
android:exported="true"
android:screenOrientation="sensorLandscape">
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package com.driftdroid.android

import android.app.Activity
import android.content.Context
import android.content.pm.ActivityInfo
import android.graphics.Point
import android.os.Build
import android.view.Surface
import com.driftdroid.android.ui.DriftSheet
import kotlin.math.max
import kotlin.math.min

/**
* Which way up the launcher stands. Automatic puts phones in portrait - held in one hand, the
* pages are lists - and tablets and gaming handhelds in landscape, where the screen is held that
* way anyway and a rail beside the content uses the width. The game itself is always landscape.
*/
internal object LauncherOrientation {
enum class Mode(val label: String) { AUTO("Automatic"), PORTRAIT("Portrait"), LANDSCAPE("Landscape") }

private const val PREFS = "launcher"
private const val KEY = "orientation"

fun mode(context: Context): Mode =
context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).getString(KEY, null)
?.let { name -> Mode.values().firstOrNull { it.name == name } } ?: Mode.AUTO

fun setMode(context: Context, mode: Mode) {
context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putString(KEY, mode.name).apply()
}

/** The requestedOrientation for [activity] under the saved mode. */
fun requested(activity: Activity): Int {
val landscape =
when (mode(activity)) {
Mode.PORTRAIT -> false
Mode.LANDSCAPE -> true
Mode.AUTO -> deviceWantsLandscape(activity)
}
return if (landscape) ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE else ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}

/**
* A tablet or a handheld: its screen is wider than tall when held the natural way (handhelds
* and most tablets), it is tablet-sized (600dp+ on its short side), or it is too square for a
* portrait column to pay off (4:3 and 1:1 handhelds, an unfolded foldable). A phone is none
* of these: tall, narrow and portrait by nature.
*/
fun deviceWantsLandscape(activity: Activity): Boolean {
val (w, h) = displaySize(activity)
@Suppress("DEPRECATION")
val rotation = activity.windowManager.defaultDisplay.rotation
val sideways = rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270
val naturalWidth = if (sideways) h else w
val naturalHeight = if (sideways) w else h
if (naturalWidth > naturalHeight) return true
if (activity.resources.configuration.smallestScreenWidthDp >= 600) return true
val ratio = max(w, h).toFloat() / min(w, h).coerceAtLeast(1)
return ratio < 1.6f
}

private fun displaySize(activity: Activity): Pair<Int, Int> =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val bounds = activity.windowManager.maximumWindowMetrics.bounds
bounds.width() to bounds.height()
} else {
val size = Point()
@Suppress("DEPRECATION")
activity.windowManager.defaultDisplay.getRealSize(size)
size.x to size.y
}

/** The Settings sheet: three choices, applied at once. */
fun show(activity: Activity, onChanged: () -> Unit = {}) {
val current = mode(activity)
val sheet = DriftSheet(activity, T("Launcher orientation"), T("The game itself always plays in landscape"))
val auto = if (deviceWantsLandscape(activity)) T("landscape") else T("portrait")
for (option in Mode.values()) {
val detail =
when (option) {
Mode.AUTO -> T("Portrait on phones, landscape on tablets and handhelds. This device: %s").format(auto)
Mode.PORTRAIT -> T("Always upright")
Mode.LANDSCAPE -> T("Always sideways, like the game")
}
sheet.radio(option.label, detail, option == current) {
sheet.dismiss()
if (option != current) {
setMode(activity, option)
onChanged()
activity.requestedOrientation = requested(activity)
}
}
}
sheet.show()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,25 @@ class MainActivity : SDLActivity() {
restartIntoProduct(resolvedProduct)
return
}
// Same for mods: the running game read its overlay roots once, at DVD init, and never
// looks again. A mod installed, switched on or off, or reordered in the launcher since
// then would silently not apply when Play just resumed this session - restart clean so
// the new set is the one the game starts with.
ModManager.prepareEnabledPacks(this)
val overlayRoots = ModManager.enabledOverlayRoots(this)
if (sLoadedProduct != null && sLoadedOverlayRoots != overlayRoots) {
restartIntoProduct(resolvedProduct)
return
}
val freshStart = sLoadedProduct == null
sLoadedProduct = resolvedProduct
sLoadedOverlayRoots = overlayRoots
// Retro Rewind also takes mods through its own Patches folder (loose archive overrides
// and all) - laid out now, before the game reads anything, and only on a fresh start: a
// session that is merely resumed already has its files open.
if (freshStart && resolvedProduct == PRODUCT_RETRO_REWIND) {
runCatching { ModManager.syncRetroRewindPatches(this, File(filesDir, RETRO_REWIND_STAGING_SUBDIR)) }
}
// Vertical mode: upright screen, read by aurora's window setup (SDL_HINT_ORIENTATIONS) from
// this variable, so it has to be set before the native side starts.
val vertical = VerticalMode.isEnabled(this)
Expand Down Expand Up @@ -206,7 +224,7 @@ class MainActivity : SDLActivity() {
if (resolvedProduct == PRODUCT_RETRO_REWIND) {
nativeSetRetroRewindRoot(File(filesDir, RETRO_REWIND_STAGING_SUBDIR).absolutePath)
}
for (root in ModManager.enabledOverlayRoots(this)) {
for (root in overlayRoots) {
nativeAddOverlayRoot(root)
}
// Only ever used as a FIRST-RUN default (native side only writes it when no explicit
Expand Down Expand Up @@ -663,6 +681,17 @@ class MainActivity : SDLActivity() {
// instances within the same still-alive process.
private var sLoadedProduct: String? = null

/** True once a game has started in this process; the launcher warns before editing saves
* or Miis then, since the still-loaded game may write its own copy back over them. */
val isGameLoaded: Boolean get() = sLoadedProduct != null

// The mod folders (in priority order) the loaded game started with.
private var sLoadedOverlayRoots: List<String>? = null

/** The game is loaded but the launcher's mods have changed since: Play restarts it. */
fun modsChangedSinceLoad(context: android.content.Context): Boolean =
sLoadedProduct != null && sLoadedOverlayRoots != ModManager.enabledOverlayRoots(context)

// Staging path for the Retro Rewind asset pack (tracks/textures - distinct from Code.pul,
// which only carries the mod's patched game LOGIC and is already compiled into
// libGameCombined.so). Populated by ModePickerActivity's folder-import flow, mirroring how
Expand Down
Loading