Skip to content

amiibo Part C: When a game looks for an amiibo, yours is two presses away - #713

Open
davdxpx wants to merge 40 commits into
igawa6:dev-0.1.9from
davdxpx:amiibo-in-game
Open

davdxpx wants to merge 40 commits into
igawa6:dev-0.1.9from
davdxpx:amiibo-in-game

Conversation

@davdxpx

@davdxpx davdxpx commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

A game that looks for an amiibo today waits for a figure that never comes. With this PR, in a game the player turned amiibo on for, Peanuts notices the search and offers the player's own amiibo in a small card over the game: A places it. The moment it lands gets a short show: the peanut cracks on the stand and the amiibo's card rises. The quick menu gets an amiibo tab for everything else.

Builds on the in-game menus' Part C (#680, the quick menu and its tabs) and on Part B (#712, the game page's amiibo area, which builds on Part A #711, the stand), on dev-0.1.9.

Fixes #582.

Since the review: the show has no title beside amiibo any more, and the stand is read only while the game has amiibo open (and never in a game amiibo is off for). Pictures show once the player has turned them on (Part B's row under Settings › Users); until then Peanuts' own card.

What players get

  • Only where amiibo is on, only while the game has it open. In a game amiibo is off for, nothing of this starts. In one it is on for, a thread sleeps in the host until the game opens or closes its amiibo library, and only in between is the stand read, every 150 ms while the game is in front.
  • A card over the game, never a menu. After the game has looked for about 0.4 s, a small card slides in at the bottom, once per search. It shows one of the player's own amiibo (the last placed in this game first), with A Place and B Not now. When several fit, it shows a short row, moved with left and right. With none of the player's own, it shows Choose an amiibo, which opens the quick menu on the amiibo tab with every amiibo that fits. The quick menu never opens unasked. While the card shows it takes the controller's buttons, and B closes it while the game goes on looking.
  • A short show, about 2.3 s, and any button skips it.
    • The game dims softly, eased in and out, never at once.
    • The stand's banana ring pulses, and the About peanut drops onto it with one firm haptic tick.
    • It cracks, and the amiibo rises out of the kernel's light, with the line "On the stand" and the amiibo's name below. No title names the app beside amiibo.
    • The figure's base stands on the ring's centre (found in the picture: AmiiboAPI's pictures are not centred on it), and it stays there with its name for a good second.
    • The game gets the amiibo at the crack. At the end the figure goes first, then the dim lifts.
    • Without the system's animations, the amiibo is placed at once.
  • The quick menu's amiibo tab sits between Mods and Controls, with a new solid stand icon, in a game amiibo is on for. While the game looks, its icon on the rail lights up with a slowly breathing ring.
    • The tab shows the stand's state, a search over all amiibo, the player's own that fit, and every one that fits.
    • With a controller, the tab starts on the first amiibo. The search is one press up, so the keyboard opens only when the player goes there.
    • X Take off lifts the amiibo from the stand, with the controller's X or a tap.
    • One placed while the game does not look is ready for its next search.
    • One picked from the list becomes the player's own copy, so each game keeps its data on it.
  • When a game looks for an amiibo, a setting in the tab: Suggest one of mine (the card, by default), Only light up this tab, or Place my last one at once.

On the AYN Thor

Mario Kart 8 Deluxe 4.0.1 on its Mii racing suits screen, amiibo on, the pictures off. The amiibo signs on the game's screen are the game's own; the card, the tab and the show are Peanuts' (its stand icon, plain text).

The card while the game looks Choose: the quick menu's tab
03-mk8d-card 04-mk8d-quick-menu-tab
The show: on the stand The game read it
05-mk8d-show-on-the-stand 06-mk8d-suit-received

The same on the system driver, with the pictures turned on:

The tab with pictures The show with the figure
02-tab-pictures 03-show-picture

Pictures

From before the review (emulator, a made-up game screen, the stand made up for the emulator). The video of the show is gone: it still had the title beside amiibo.

One of yours Several of yours None of yours
01-card-one 02-card-row 03-card-choose
The tab while the game looks When a game looks for an amiibo
04-tab-looking 05-tab-setting

How it is built

  • dev.peanuts.amiibo.AmiiboWatch decides on the card, the lit tab or placing at once.
    • It starts only in a game amiibo is on for (AmiiboSwitch). A thread of its own waits in the host (Bridge.amiiboWaitLib, peanuts_amiibo.c's condition variable, which nfp::Initialize and Finalize wake), and the 150 ms reads run only while the game has nfp open and is in front.
    • The card is AmiiboCard and the tab is AmiiboTab, shown in a game amiibo is on for that uses amiibo or has the library open.
    • The show is dev.peanuts.ui.AmiiboShow, drawn with the About peanut (PeanutArt): "On the stand" and the amiibo's name.
  • In the in-game menus:
    • InGamePanel attaches the watch and hands it the controller first while the card or the show is up.
    • ModsPanel gets the tab: four marked lines and a helper, one of them in padKey for the controller's X.
    • Rail.lit lights the tab's icon.
  • PeanutsPrefs.amiiboWhen keeps the setting in the game's own prefs file.
  • The new solid icon pis_amiibo follows the in-game set's style.
  • PEANUTS.md and peanuts/UPSTREAM-EDITS.md list the hooks.

Tested

  • On the AYN Thor (Android 13, the test app, Turnip T30): Mario Kart 8 Deluxe, amiibo on. Its Mii racing suits screen opens nfp and looks; the card comes after 0.4 s, Choose opens the tab, 8-Bit Mario Classic Color placed from it plays the show, and the game reads it and gives the Mario racing suit. Leaving the screen closes nfp, and the stand's reads stop. In a game amiibo is off for, the watch starts nothing (its log says so). The run was on the build before the pictures setting and the move of the switches to Users.
  • A second run on dev-0.1.9, on the system driver (Adreno 740) with the pictures turned on: the card, Choose into the tab, its pictures, the show with 8-Bit Mario Classic Color's picture on the ring, and the suit; leaving the screen closed nfp.
  • Emulator (Android 13) with the in-game menus' test screen and a made-up stand, before the review:
    • the card with one, several and none of the player's own, left and right, A, B, and Choose into the tab;
    • the show with its skip, and with the system's animations off;
    • the tab: opened with the controller, search, pick, Take off with X and by tap, and the setting's three choices.
  • peanuts/tests/test_amiibo_host.py: the wait in C (off, before the modules load, open, closed, its time). peanuts/tests/test_amiibo.py (InGame): the watch only while the library is open, no title beside amiibo.
  • upstream-update.sh --check, check-publish.sh, and check-min-api.py on the APK.
  • A run on the Thor with Breath of the Wild follows.

github-actions Bot and others added 10 commits November 25, 2026 13:13
Written by .github/workflows/catalog.yml after 4ae5c26.
Upstream's one in-game panel with five text tabs becomes two menus, as on a
console: everything about this session at the left, everything that tunes the
running game at the right. The game keeps running behind both.

- The game menu: the game's cover, name, version and this session's time;
  Back to the game, Pause the game, Quick menu, Back up the save (copied while
  the game runs, checked before and after the copy), Button mapping, Share log,
  and Stop the game set apart at the bottom, asked once inline.
- The quick menu: the panel's tabs on a rail of solid icons at the left
  (Performance, Display, Cheats, Mods, Controls, the menu's own settings at the
  bottom). Cheats and Mods are two tabs now. A header with Back and the tab's
  name, section heads in capitals, a slider's value at its right.
- Home pressed, - and + held, Back and a swipe in from the left edge open the
  game menu; Home held opens the quick menu, as do a swipe in from the right
  edge and a long press on the on-screen controls' button.
- Calm motion: in 240 ms decelerating, out 180 ms, on hardware layers.
…eded

Games that read amiibo (Breath of the Wild's daily rewards, Super Mario
Odyssey's costumes, Smash's fighters) now find one: a virtual stand in
the host that the app places the player's amiibo on. GitHub issue igawa6#582.

- dm/peanuts/peanuts_amiibo.c takes over nn::nfc and nn::nfp in the
  Android host in place of hle_sdk16.c's block (PN_AMIIBO, one marked
  pair of lines). It sits above the figures' encryption: TagInfo,
  ModelInfo, CommonInfo, RegisterInfo and the application areas are
  plain, so no amiibo keys are asked for, read or shipped.
- The activate and deactivate events are signalled; mount, read,
  write, flush and create or recreate of an area answer as the SDK's;
  each game keeps an area of its own on an amiibo; a second after the
  game unmounts it the amiibo leaves the stand on its own. One placed
  in advance is found at the game's next search.
- The owner is the player's Mii, the nickname the character's name.
- dev.peanuts.amiibo: AmiiboAPI's table offline (MIT,
  peanuts/scripts/amiibo-db.py), the player's own amiibo, imports of
  .bin files, folders and ZIP packs (ID and UID only), pictures loaded
  on demand, and the adb control's game do=amiibo.

Tests: test_amiibo_host.py (the stand in C, made-up IDs),
test_amiibo.py (AmiiboJvmTest), test_ctl.py. Round 65.
…s yours

A game that uses amiibo now has an amiibo area on its page, so a player
sees which figures do something in it before playing, brings in their
own and resets what a game saved on one.

- The tile (after Controls) only for games AmiiboAPI lists or that were
  seen looking for an amiibo; its line counts yours and all that fit.
- The area: your own that fit first (the last placed first), then every
  amiibo that fits the game, as square pictures with names; a search
  over all of them; Import of .bin files, ZIP packs or a folder.
- An amiibo's page: picture, series, type, what it does in this game,
  the game's data on it with Reset game data (that game only), where it
  came from, the other games that use it, Remove from yours.
- Pictures load when the area shows them; Peanuts' own card (the new
  stand icon, pi_amiibo) stands in offline. B goes back to the pictures.

Tests: test_amiibo.py (Page), test_game_page.py (the ten areas).
A game that looks for an amiibo now gets one from the player in two
presses, without a menu in the way, and the moment it lands has a
small show of its own: "Peanuts Native x amiibo".

- The quick menu's amiibo tab (between Mods and Controls, a new solid
  icon): the stand's state, a search, your own that fit, every one that
  fits, and "When a game looks for an amiibo" (Suggest one of mine by
  default, Only light up this tab, Place my last one at once). With a
  controller the tab starts on the first amiibo, so the keyboard opens
  only at the search; X Take off clears the stand.
- While the game looks, the tab's rail item lights up with a slowly
  breathing ring.
- After 0.4 s of looking, once per search, a small card slides in over
  the game: one of yours (or the last placed here) with A Place and
  B Not now, a short row when several fit, or Choose an amiibo, which
  opens the tab. The quick menu never opens unasked; B closes the card
  and the game goes on looking.
- The show (about 2.3 s, any button skips it): the game dims softly,
  the stand's ring pulses, the About peanut drops onto it, one firm
  haptic tick, it cracks and the amiibo rises out of the kernel, its
  base on the ring's centre, and stands there with its name for a good
  second; the figure goes first, then the dim lifts. The game gets the
  tag at the crack.
- One picked from the list becomes your own copy, with its data for
  each game. Placed while the game does not look, it is ready for its
  next search.

Tests: test_amiibo.py (InGame).
… what the design means

The Mods tab test checked that Controls follows Mods; the amiibo tab
now sits between them, as chosen. Three comments pointed at the design
boards instead of saying what they show.
@igawa6 igawa6 added enhancement New feature or request app Peanuts app, launcher, settings, and user interface labels Nov 26, 2026
@igawa6

igawa6 commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Thanks. This one sits on both series: in-game menus Part C (#680, and so Parts A and B) and amiibo Part B (#712, and so Part A). It waits for both. Its own part is about 1,270 lines on top of them.

For when it comes to it:

  • The show's title, "Peanuts Native × amiibo", reads like a joint product with Nintendo. Please drop the "×" title and keep the figure, its name and the line, so nothing suggests an endorsement.
  • The watcher reads the stand every 150 ms while a game is in front, in every game. Please let it run only while the game has the amiibo service open, so games without amiibo pay nothing.
  • It also conflicts with Cheats that check the game's code before they write and keep working after an update #677 (NOTICE.md, GamePage.java and the upstream lists), so whichever lands second will need a rebase.

…mmit beside the copy fails it

The game menu's Back up the save ran SaveStore's recovery on the save first. The game's start recovered that save already, so while the game runs a
marker beside it is the host's own swap at a Commit, still being written: the recovery could run a second swap beside the host's and delete from the
save what the host's stage 2 had just moved into it. The running game's save is now copied without the recovery (SaveStore.backupRunning), and the
copy is refused while a marker is beside the save, before it and after its second scan; the game menu tries again.

InGameBackupJvmTest: each state of a Commit as the copy starts (the marker written, stage 1 part way, .pend2, stage 2 part way, the device save's,
an empty marker) leaves the save, the host's .new and its markers exactly as they were; a host committing again and again beside backups gets
every swap through, and every finished backup holds one whole version.
…s › Controls sets it up

The app's start asked for a quick menu button while none was set, after the layout's question. That made up to three questions at the first start
after an update. It now asks nothing: the row in Settings › Controls › Controller sets the button up, and the game menu's Quick menu row names it
once one is set. The Never preference went with the question.
…n the run of the first start's setup

Later (or closing the question) asked again at every start. It now asks once more at the next start and then keeps the two menus; the menu's own
settings still change the layout. A new player is asked at the start after the one that ran the first start's setup, so each start has one
question at most. Nothing waits on the question any more (the quick menu button is no longer asked about at the start), so it takes no then.
@igawa6 igawa6 mentioned this pull request Nov 26, 2026
2 tasks done
igawa6's review of igawa6#711: amiibo comes in as an opt-in, not as a replacement of nfc and nfp for every game, and a new outside host only by the player's choice.

- Settings › Controls › amiibo (off by default) turns it on for every game; a game's own amiibo switch under its Controls (for a game AmiiboAPI lists, or one seen opening nfp) comes first. From the game's next start.
- A game it is on for starts with PN_AMIIBO=1. The loader's force_lookup asks peanuts_amiibo_force first (one marked block in dm/host/loader.c under PN_AMIIBO); the stand's take-overs sit in a table of their own (section pnamiibo), so hle_sdk16.c is unchanged again and every other game gets its nfc and nfp block as before. No helper thread, no reads or writes, the launcher's amiibo answers refuse (enabled=0).
- PN_AMIIBO is read at the loader's first lookup, once main.c has set the game's environment. The app's calls before that are refused and decide nothing (on the AYN Thor the game screen's first call came 0.25 s before the variable was set).
- The adb control's game do=amiibo is taken now: Request's list of the game's actions comes from GameLive.ACTIONS (amiibo was missing, found on the Thor).
- Pictures from AmiiboAPI's images only once the player turns them on (AmiiboSwitch.pictures, off by default; Part B has the row). Off, AmiiboPictures answers at once with none: nothing is fetched and Peanuts' own card stands in. NOTICE says so.
- peanuts_amiibo.c is stored with LF line ends (it had CR LF).
- Tests: the stand in C off and on (the loader's lookup finds nothing without PN_AMIIBO=1 and every take-over with it), hle_sdk16.c's block whole, the loader hook first, PN_AMIIBO only through AmiiboSwitch, pictures only when turned on.
- Settings search: "mii" finds the amiibo row as well (it has the letters).
… only when the player turns them on

On Part A's rework (amiibo only where the player turns it on), as igawa6 asked on igawa6#711 and igawa6#712:

- The amiibo area starts with the game's amiibo switch, the same setting as the one under its Controls; the tile says "Off for this game" while it is off.
- Settings › Controls › amiibo pictures (off by default) names the host: each amiibo's picture from AmiiboAPI's images on raw.githubusercontent.com, fetched when a page shows it and kept. Until it is on, offline, or for one without a picture, Peanuts' own card (the stand icon) shows, and the area's note says where to turn the pictures on.
- Tests: the switch comes first and the tile says off; the pictures' row (off, the host named); pictures only from the pages; Settings search finds both amiibo rows for "mii".
…he player turns it on, pictures too)

# Conflicts:
#	android/app/src/main/java/dev/peanuts/ui/LibrarySettings.java
#	android/app/src/main/java/dev/peanuts/ui/SettingsSections.java
#	peanuts/UPSTREAM-EDITS.md
#	peanuts/tests/test_amiibo.py
… and a show without a title beside amiibo

igawa6's review of igawa6#713, on Parts A and B's rework:

- The watcher starts nothing in a game amiibo is off for. In one it is on for, a thread sleeps in the host until nfp's Initialize or Finalize (nxhost_peanuts_amiibo_wait_lib, Bridge.amiiboWaitLib, 30 s at most; -2 while the game's modules are not loaded yet), and the 150 ms reads of the stand run only while the library is open and the game is in front. The amiibo tab shows only where amiibo is on.
- The show has no "Peanuts Native x amiibo" title any more: the peanut cracks, the amiibo rises, and it stands with the line "On the stand" and its name, so nothing reads like a joint product.
- The card, the tab and the show keep the amiibo's picture once the player has turned the pictures on (Part B's row); until then Peanuts' own card.
- Tests: the wait in C (off, before the modules load, open, closed, its time), the watch only while the library is open, no title beside amiibo.
- On the AYN Thor: Mario Kart 8 Deluxe looked for an amiibo on its Mii racing suits screen, the card came, Choose opened the tab, 8-Bit Mario Classic Color placed from it played the show, and the game gave the Mario racing suit.
Quick menu and Button mapping asked Icons for "chevron-right", which has no drawable, so their rows showed an empty space at the end and their
values ended short of the others. They take the launcher's own chevron now, as the settings rows do.
…'s choices have the question's names

Side by side, each card took the height of its own picture and name, so the bottom screen's card (two screens, a name on two lines) stood
taller than the others. The cards are now as tall as the tallest, and every picture sits in a box of one height, so the names line up.
In one menu, Game's rows that open a page show the launcher's chevron (there is no "chevron-right" icon), and the menu's Layout choices
have the question's names; the line under them says what each does.
…ions, not Controls

Controls keeps what the controller and touch do. amiibo belongs to the player
like their Miis: Settings › Users › amiibo turns it on for every game, and the
game's own switch sits in its Game options, above Mods & Cheats. Texts, docs
and the adb control's refusal name the new places; the wiring test checks
them.
# Conflicts:
#	android/app/src/main/java/dev/peanuts/ui/SettingsHelp.java
#	android/app/src/main/java/dev/peanuts/ui/SettingsSections.java
The pictures row joins Part A's amiibo switch in the Users section's amiibo
group, both with the stand icon; the game's switch in its Game options gets
the icon too. The area's note, the docs and the tests name the new place.
# Conflicts:
#	android/app/src/main/java/dev/peanuts/ui/LibrarySettings.java
#	android/app/src/main/java/dev/peanuts/ui/SettingsSections.java
…rd's name fits one line

In the layout question the long name wrapped to two lines, so its card's line sat lower than the other two.
Menu settings › Layout uses the same name.
Merges upstream dev-0.1.9 (54eacc9), where the next releases are made, so
the stand merges there without conflicts.

- peanuts/UPSTREAM-EDITS.md and PEANUTS.md: dev-0.1.9's new sections and
  lines first, the amiibo round and hooks after them.
- GameAreas and GameHelp: dev-0.1.9 dropped the Xbox button label swap, so
  its row and help line stay out; the game's amiibo row stays after Time of
  day.
- The game catalog (README.md, README.github.md, games.json, games.tsv,
  peanuts_games.json) is dev-0.1.9's. The branch only had main's catalog
  update of 2026-11-25 there, none of its own changes.
Part A on dev-0.1.9 brought in. GameAreas: the game's amiibo row keeps Part
B's stand icon, and the Controls line is dev-0.1.9's (no Xbox label swap).
Parts A and B on dev-0.1.9 brought in. peanuts/UPSTREAM-EDITS.md: dev-0.1.9's
new sections first, then the in-game menus' rounds and the amiibo rounds;
peanuts/upstream-unmarked.txt: dev-0.1.9's new lines, then ModsPanel's.

InGamePanel.keys: dev-0.1.9 dropped the Xbox button label swap
(Prefs.xboxButtons), so the panel's confirm and back come from the game's
Button mapping alone, as GameActivity's do there.
The Users section is a page of its own (UsersPage: the users as cards,
Who's playing? and the Miis), and SettingsPage returned right after it, so
the amiibo group SettingsSections places there was never drawn. Found on the
AYN Thor: Settings › Users showed the users and the Miis, no amiibo switch.

SettingsPage now draws the section's other groups (all but Users and Miis,
which the users' part draws itself) into a column of their own and hands it
to UsersPage, which puts it back at its end each time it draws anew (after a
rename, a picture, the editor). The other sections draw their groups as
before, through the same helper.
fill(a, col, wide, null) matched both the Sink and the View overload.
Its title names the game ("amiibo in Mario Kart 8 Deluxe"), so GameAreas'
icon by title never reached it and its tile stayed empty (AYN Thor).
@davdxpx
davdxpx changed the base branch from main to dev-0.1.9 November 26, 2026 11:55
@davdxpx
davdxpx changed the base branch from dev-0.1.9 to main November 26, 2026 11:56
@davdxpx
davdxpx changed the base branch from main to dev-0.1.9 November 26, 2026 12:31
…review) into amiibo-in-game-main

The amiibo series sat on igawa6#680 as it was before the review (ef21e02), so its
builds still asked the layout and the quick-button questions at the start.
peanuts/UPSTREAM-EDITS.md: igawa6#680's Peanuts-owned line for the Quick menu
button, then the amiibo rounds.
dev-0.1.9 now has igawa6#827 (the Mods tab switch under Settings › App), Android 12
(minSdk 31) and new games. Users keeps its amiibo group beside App's new line,
and UPSTREAM-EDITS has dev-0.1.9's new sections first, then the amiibo rounds.
Part A on dev-0.1.9 again (igawa6#827, Android 12). Users' amiibo group keeps
Part B's pictures row beside App's new line.
Parts A and B on dev-0.1.9 again (igawa6#827 landed: the Mods tab switch under
Settings › App). igawa6#680's halves of the Mods tab stay, their comment names App;
Controls keeps igawa6#680's Quick menu button without the Mods tab row. UPSTREAM-EDITS:
dev-0.1.9's new sections, then igawa6#680's, then the amiibo rounds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app Peanuts app, launcher, settings, and user interface enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Amiibo support

2 participants