mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-19 12:25:56 +00:00
Merge pull request #235: Add Amiibo support via nfp:user IPC emulation and ImGui picker (leonelalej)
The Amiibo page reads its text from the catalog (UI_MENU_AMIIBO_*, in all four menu languages) instead of English literals, and its status line keeps an id and the file name so it follows a menu language change. Folders show as name/ in the list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
97e666ce2f
13 files changed
+1253
-27
No files matched your search
@@ -0,0 +1,377 @@
|
||||
// Amiibo dump loader and Horizon OS NFP state emulation.
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "amiibo.h"
|
||||
#include "host.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
static PlatMutex g_amiibo_lock = PLAT_MUTEX_INIT;
|
||||
|
||||
// 540-byte raw NTAG215 binary dump
|
||||
static uint8_t g_dump[AMIIBO_DUMP_SIZE];
|
||||
static bool g_has_dump = false;
|
||||
static AmiiboInfo g_info;
|
||||
|
||||
static bool g_device_present = true;
|
||||
static bool g_detecting = false;
|
||||
static bool g_tag_present = false;
|
||||
static bool g_mounted = false;
|
||||
static bool g_auto_remove = true;
|
||||
static float g_auto_remove_delay_s = 2.5f;
|
||||
|
||||
static uint64_t g_tap_timestamp_ns = 0;
|
||||
static bool g_timer_active = false;
|
||||
|
||||
static bool amiibo_validate_dump(const uint8_t *data, uint64_t size) {
|
||||
if (size != AMIIBO_DUMP_SIZE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// NTAG215 Capability Container (CC) at page 3 (offset 0x0C).
|
||||
// Byte 0x0C must be 0xE1 (NDEF Magic / Type 2 Tag CC container byte).
|
||||
if (data[0x0C] != 0xE1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// UID sanity: UID (bytes 0..2 and 4..7) cannot be all zeroes or all 0xFF.
|
||||
if ((data[0] == 0 && data[1] == 0 && data[2] == 0 && data[4] == 0 &&
|
||||
data[5] == 0 && data[6] == 0 && data[7] == 0) ||
|
||||
(data[0] == 0xFF && data[1] == 0xFF && data[2] == 0xFF && data[4] == 0xFF &&
|
||||
data[5] == 0xFF && data[6] == 0xFF && data[7] == 0xFF)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// ISO 14443-3 / NTAG215 Bit Check Character (BCC) verification.
|
||||
// Page 0 byte 3 (BCC0) = 0x88 ^ UID[0] ^ UID[1] ^ UID[2]
|
||||
// Page 2 byte 0 (BCC1) = UID[3] ^ UID[4] ^ UID[5] ^ UID[6]
|
||||
uint8_t bcc0 = (uint8_t)(0x88 ^ data[0] ^ data[1] ^ data[2]);
|
||||
uint8_t bcc1 = (uint8_t)(data[4] ^ data[5] ^ data[6] ^ data[7]);
|
||||
if (data[3] != bcc0 || data[8] != bcc1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void parse_dump_info(const char *path) {
|
||||
memset(&g_info, 0, sizeof(g_info));
|
||||
if (path) {
|
||||
snprintf(g_info.path, sizeof(g_info.path), "%s", path);
|
||||
const char *slash = strrchr(path, '\\');
|
||||
const char *fslash = strrchr(path, '/');
|
||||
const char *name = slash ? slash + 1 : (fslash ? fslash + 1 : path);
|
||||
if (slash && fslash) {
|
||||
name = (slash > fslash ? slash : fslash) + 1;
|
||||
}
|
||||
snprintf(g_info.filename, sizeof(g_info.filename), "%s", name);
|
||||
}
|
||||
|
||||
// UID: bytes 0..6 (7 bytes) or up to 9
|
||||
memcpy(g_info.uuid, g_dump, 7);
|
||||
g_info.uuid_len = 7;
|
||||
|
||||
// Amiibo ID at offset 0x54 (8 bytes)
|
||||
memcpy(g_info.character_id, g_dump + 0x54, 3);
|
||||
g_info.series_id = g_dump[0x57];
|
||||
g_info.numbering_id = ((uint16_t)g_dump[0x58] << 8) | g_dump[0x59];
|
||||
g_info.nfp_type = g_dump[0x5A];
|
||||
g_info.version = g_dump[0x5B];
|
||||
}
|
||||
|
||||
void amiibo_init(void) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
g_device_present = true;
|
||||
g_detecting = false;
|
||||
g_tag_present = false;
|
||||
g_mounted = false;
|
||||
g_has_dump = false;
|
||||
g_timer_active = false;
|
||||
memset(g_dump, 0, sizeof(g_dump));
|
||||
memset(&g_info, 0, sizeof(g_info));
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
}
|
||||
|
||||
void amiibo_set_device_present(bool present) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
g_device_present = present;
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
}
|
||||
|
||||
bool amiibo_is_device_present(void) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
bool res = g_device_present;
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
void amiibo_start_detection(void) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
g_detecting = true;
|
||||
rt_log("amiibo: start detection");
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
}
|
||||
|
||||
void amiibo_stop_detection(void) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
g_detecting = false;
|
||||
rt_log("amiibo: stop detection");
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
}
|
||||
|
||||
bool amiibo_is_detecting(void) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
bool res = g_detecting;
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
bool amiibo_mount(void) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
if (!g_device_present || !g_tag_present) {
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
return false;
|
||||
}
|
||||
g_mounted = true;
|
||||
rt_log("amiibo: mounted tag '%s'", g_info.filename[0] ? g_info.filename : "unknown");
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
return true;
|
||||
}
|
||||
|
||||
void amiibo_unmount(void) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
g_mounted = false;
|
||||
rt_log("amiibo: unmounted tag");
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
}
|
||||
|
||||
bool amiibo_is_mounted(void) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
bool res = g_mounted;
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
AmiiboDeviceState amiibo_get_device_state(void) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
if (!g_device_present) {
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
return AMIIBO_DEV_STATE_UNAVAILABLE;
|
||||
}
|
||||
if (g_mounted) {
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
return AMIIBO_DEV_STATE_TAG_MOUNTED;
|
||||
}
|
||||
if (g_tag_present) {
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
return AMIIBO_DEV_STATE_TAG_FOUND;
|
||||
}
|
||||
if (g_detecting) {
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
return AMIIBO_DEV_STATE_SEARCHING;
|
||||
}
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
return AMIIBO_DEV_STATE_INITIALIZED;
|
||||
}
|
||||
|
||||
bool amiibo_load_file(const char *path) {
|
||||
if (!path || !*path) return false;
|
||||
uint64_t size = 0;
|
||||
uint8_t *data = plat_file_read(path, &size);
|
||||
if (!data) {
|
||||
rt_log("amiibo: failed to read file: %s", path);
|
||||
return false;
|
||||
}
|
||||
if (size != AMIIBO_DUMP_SIZE) {
|
||||
rt_log("amiibo: invalid dump size (%llu bytes, expected exactly %d): %s",
|
||||
(unsigned long long)size, AMIIBO_DUMP_SIZE, path);
|
||||
free(data);
|
||||
return false;
|
||||
}
|
||||
if (!amiibo_validate_dump(data, size)) {
|
||||
rt_log("amiibo: dump failed NTAG215 structure sanity checks: %s", path);
|
||||
free(data);
|
||||
return false;
|
||||
}
|
||||
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
memcpy(g_dump, data, AMIIBO_DUMP_SIZE);
|
||||
g_has_dump = true;
|
||||
parse_dump_info(path);
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
|
||||
free(data);
|
||||
rt_log("amiibo: loaded dump '%s' (char_id: %02x%02x%02x, series: %02x, num: %04x)",
|
||||
g_info.filename, g_info.character_id[0], g_info.character_id[1], g_info.character_id[2],
|
||||
g_info.series_id, g_info.numbering_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
void amiibo_tap_tag(void) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
if (!g_has_dump) {
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
return;
|
||||
}
|
||||
g_tag_present = true;
|
||||
g_tap_timestamp_ns = plat_now_ns();
|
||||
if (g_auto_remove) {
|
||||
g_timer_active = true;
|
||||
}
|
||||
rt_log("amiibo: tag tapped on reader ('%s')", g_info.filename);
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
}
|
||||
|
||||
bool amiibo_scan_and_tap(const char *path) {
|
||||
if (!amiibo_load_file(path)) return false;
|
||||
amiibo_tap_tag();
|
||||
return true;
|
||||
}
|
||||
|
||||
void amiibo_remove_tag(void) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
if (g_tag_present || g_mounted) {
|
||||
g_tag_present = false;
|
||||
g_mounted = false;
|
||||
g_timer_active = false;
|
||||
rt_log("amiibo: tag removed from reader");
|
||||
}
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
}
|
||||
|
||||
void amiibo_tick(void) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
if (g_timer_active && g_tag_present) {
|
||||
uint64_t now = plat_now_ns();
|
||||
uint64_t diff = now > g_tap_timestamp_ns ? now - g_tap_timestamp_ns : 0;
|
||||
uint64_t limit_ns = (uint64_t)(g_auto_remove_delay_s * 1000000000.0f);
|
||||
if (diff >= limit_ns) {
|
||||
g_tag_present = false;
|
||||
g_mounted = false;
|
||||
g_timer_active = false;
|
||||
rt_log("amiibo: auto-removed tag after %.1fs timeout", (double)g_auto_remove_delay_s);
|
||||
}
|
||||
}
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
}
|
||||
|
||||
void amiibo_set_auto_remove(bool enable) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
g_auto_remove = enable;
|
||||
if (!enable) g_timer_active = false;
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
}
|
||||
|
||||
bool amiibo_get_auto_remove(void) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
bool res = g_auto_remove;
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
void amiibo_set_auto_remove_delay_s(float seconds) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
if (seconds >= 0.5f && seconds <= 10.0f) g_auto_remove_delay_s = seconds;
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
}
|
||||
|
||||
float amiibo_get_auto_remove_delay_s(void) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
float res = g_auto_remove_delay_s;
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
bool amiibo_has_tag(void) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
bool res = g_has_dump && g_tag_present;
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
const AmiiboInfo *amiibo_get_current_info(void) {
|
||||
return &g_info;
|
||||
}
|
||||
|
||||
const uint8_t *amiibo_get_raw_data(void) {
|
||||
return g_dump;
|
||||
}
|
||||
|
||||
void amiibo_get_tag_info(void *out_tag_info) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
uint8_t *out = (uint8_t *)out_tag_info;
|
||||
memset(out, 0, 0x58);
|
||||
// UUID: offset 0x00, 10 bytes max
|
||||
memcpy(out + 0x00, g_dump, 7);
|
||||
out[0x0A] = 7; // UUID length
|
||||
// Protocol at offset 0x20: TypeA = 1
|
||||
*(uint32_t *)(out + 0x20) = 1;
|
||||
// TagType at offset 0x24: Type2 / NTAG215 = 2
|
||||
*(uint32_t *)(out + 0x24) = 2;
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
}
|
||||
|
||||
void amiibo_get_model_info(void *out_model_info) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
uint8_t *out = (uint8_t *)out_model_info;
|
||||
memset(out, 0, 0x40);
|
||||
// Character ID at 0x00 (3 bytes)
|
||||
memcpy(out + 0x00, g_dump + 0x54, 3);
|
||||
// Series ID at 0x03 (1 byte)
|
||||
out[0x03] = g_dump[0x57];
|
||||
// Numbering ID at 0x04 (2 bytes, big-endian from 0x58)
|
||||
out[0x04] = g_dump[0x58];
|
||||
out[0x05] = g_dump[0x59];
|
||||
// NFP Type at 0x06 (1 byte)
|
||||
out[0x06] = g_dump[0x5A];
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
}
|
||||
|
||||
void amiibo_get_common_info(void *out_common_info) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
uint8_t *out = (uint8_t *)out_common_info;
|
||||
memset(out, 0, 0x40);
|
||||
// Last write date: 0x00..0x03
|
||||
out[0x00] = 0x07; out[0x01] = 0xE7; // 2023
|
||||
out[0x02] = 0x05; out[0x03] = 0x0C; // May 12
|
||||
// Write counter: 0x04..0x05
|
||||
out[0x04] = 0x00; out[0x05] = 0x01;
|
||||
// Version: 0x06
|
||||
out[0x06] = 0x02;
|
||||
// Application area size: 0x08..0x0B = 0xD8 (216 bytes)
|
||||
*(uint32_t *)(out + 0x08) = 0xD8;
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
}
|
||||
|
||||
void amiibo_get_register_info(void *out_register_info) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
uint8_t *out = (uint8_t *)out_register_info;
|
||||
memset(out, 0, 0x100);
|
||||
// Mii CharInfo at 0x00..0x57 (dummy valid mii)
|
||||
out[0x00] = 0x03; // version 3
|
||||
// First write date at 0x58..0x5B
|
||||
out[0x58] = 0x07; out[0x59] = 0xE7;
|
||||
out[0x5A] = 0x05; out[0x5B] = 0x0C;
|
||||
// Amiibo Name at 0x5C: copy up to 40 bytes NUL-terminated
|
||||
const char *name = g_info.filename[0] ? g_info.filename : "Amiibo";
|
||||
snprintf((char *)(out + 0x5C), 0x29, "%s", name);
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
}
|
||||
|
||||
int amiibo_get_application_area(void *out_buf, uint32_t max_size) {
|
||||
plat_mutex_lock(&g_amiibo_lock);
|
||||
if (!g_has_dump || !out_buf) {
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
return 0;
|
||||
}
|
||||
uint32_t to_copy = max_size < 0xD8 ? max_size : 0xD8;
|
||||
// Decrypted/payload application area starts at offset 0xDC (or 0x0A0..0x178 in raw dump)
|
||||
if (0xDC + to_copy <= AMIIBO_DUMP_SIZE) {
|
||||
memcpy(out_buf, g_dump + 0xDC, to_copy);
|
||||
} else {
|
||||
memset(out_buf, 0, to_copy);
|
||||
}
|
||||
plat_mutex_unlock(&g_amiibo_lock);
|
||||
return (int)to_copy;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
// Amiibo loader and state management subsystem (540-byte NTAG215 binary dumps).
|
||||
#pragma once
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define AMIIBO_DUMP_SIZE 540
|
||||
|
||||
// Device state corresponding to nn::nfp / nn::nfc DeviceState
|
||||
typedef enum {
|
||||
AMIIBO_DEV_STATE_INITIALIZED = 0,
|
||||
AMIIBO_DEV_STATE_SEARCHING = 1,
|
||||
AMIIBO_DEV_STATE_TAG_FOUND = 2,
|
||||
AMIIBO_DEV_STATE_TAG_REMOVED = 3,
|
||||
AMIIBO_DEV_STATE_TAG_MOUNTED = 4,
|
||||
AMIIBO_DEV_STATE_UNAVAILABLE = 5
|
||||
} AmiiboDeviceState;
|
||||
|
||||
// Amiibo identification info
|
||||
typedef struct {
|
||||
uint8_t uuid[10];
|
||||
uint8_t uuid_len;
|
||||
uint8_t character_id[3];
|
||||
uint8_t series_id;
|
||||
uint16_t numbering_id;
|
||||
uint8_t nfp_type;
|
||||
uint8_t version;
|
||||
char path[512];
|
||||
char filename[128];
|
||||
} AmiiboInfo;
|
||||
|
||||
// Subsystem lifecycle
|
||||
void amiibo_init(void);
|
||||
|
||||
// Hardware / device emulation status
|
||||
void amiibo_set_device_present(bool present);
|
||||
bool amiibo_is_device_present(void);
|
||||
|
||||
// Tag detection & lifecycle
|
||||
void amiibo_start_detection(void);
|
||||
void amiibo_stop_detection(void);
|
||||
bool amiibo_is_detecting(void);
|
||||
|
||||
// Tag mounting
|
||||
bool amiibo_mount(void);
|
||||
void amiibo_unmount(void);
|
||||
bool amiibo_is_mounted(void);
|
||||
|
||||
// State query
|
||||
AmiiboDeviceState amiibo_get_device_state(void);
|
||||
|
||||
// File loading & triggering actions
|
||||
bool amiibo_load_file(const char *path);
|
||||
bool amiibo_scan_and_tap(const char *path);
|
||||
void amiibo_tap_tag(void);
|
||||
void amiibo_remove_tag(void);
|
||||
|
||||
// Timer tick called during menu / frame updates
|
||||
void amiibo_tick(void);
|
||||
|
||||
// Options
|
||||
void amiibo_set_auto_remove(bool enable);
|
||||
bool amiibo_get_auto_remove(void);
|
||||
void amiibo_set_auto_remove_delay_s(float seconds);
|
||||
float amiibo_get_auto_remove_delay_s(void);
|
||||
|
||||
// Tag inspection
|
||||
bool amiibo_has_tag(void);
|
||||
const AmiiboInfo *amiibo_get_current_info(void);
|
||||
const uint8_t *amiibo_get_raw_data(void);
|
||||
|
||||
// Horizon OS buffers extraction (called by NFP IPC/override services)
|
||||
void amiibo_get_tag_info(void *out_tag_info);
|
||||
void amiibo_get_model_info(void *out_model_info);
|
||||
void amiibo_get_common_info(void *out_common_info);
|
||||
void amiibo_get_register_info(void *out_register_info);
|
||||
int amiibo_get_application_area(void *out_buf, uint32_t max_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
+2
-1
@@ -30,7 +30,7 @@ static int save_ok = 1; // the last cfg_save_to wrote (o
|
||||
// Every name the runtime reads (and the patch sets in generated/), without the prefix. A file key outside this list is
|
||||
// logged as unknown. A new variable goes here too, or its ini key logs a harmless "unknown key" line.
|
||||
static const char *const known[] = {
|
||||
"AB", "ANISO", "APP_POOL", "ASPECT", "ASPECT_PATCH", "ASSUME_FOCUS", "ASTC", "ASTC_BC", "ASTC_TIME", "ASYNC_PREEMPT", "AUDIO", "AUDIO_OFF", "AUDIO_PREFILL_MS",
|
||||
"AB", "AMIIBO_DIR", "ANISO", "APP_POOL", "ASPECT", "ASPECT_PATCH", "ASSUME_FOCUS", "ASTC", "ASTC_BC", "ASTC_TIME", "ASYNC_PREEMPT", "AUDIO", "AUDIO_OFF", "AUDIO_PREFILL_MS",
|
||||
"BACKGROUND_WINDOW", "BIND_A", "BIND_B", "BIND_DOWN", "BIND_L", "BIND_LCLICK", "BIND_LEFT", "BIND_LSTICK_DOWN", "BIND_LSTICK_LEFT",
|
||||
"BIND_LSTICK_RIGHT", "BIND_LSTICK_UP", "BIND_MINUS",
|
||||
"BIND_PLUS", "BIND_R", "BIND_RCLICK", "BIND_RIGHT", "BIND_RSTICK_DOWN", "BIND_RSTICK_LEFT", "BIND_RSTICK_RIGHT", "BIND_RSTICK_UP",
|
||||
@@ -130,6 +130,7 @@ static const CfgMeta metas[] = {
|
||||
{"MOUSE_SENS", "1", "0..10", LIVE},
|
||||
{"WALK_KEY", "none", NULL, LIVE}, {"WALK_SCALE", "0.51", "0.2..0.9", LIVE},
|
||||
{"MENU_LANG", "", "en|ru|pt-BR|zh-Hans", LIVE},
|
||||
{"AMIIBO_DIR", "", NULL, LIVE},
|
||||
// Advanced: scheduling
|
||||
{"ASYNC_PREEMPT", "1", "0|1|2", RESTART}, {"REPLAY_ASYNC", "0", "0|1", RESTART},
|
||||
{"FREE_CORES", "0", "0|1", RESTART}, {"TIMER_1MS", "1", "0|1", RESTART},
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "audren.h"
|
||||
#include "host.h"
|
||||
#include "ipc.h"
|
||||
#include "nfp.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
#define CMIF_IN_MAGIC 0x49434653u // "SFCI"
|
||||
@@ -25,6 +26,7 @@ enum { T_CLOSE = 2, T_REQUEST = 4, T_CONTROL = 5, T_REQUEST_CTX = 6, T_CONTROL_C
|
||||
// Services sm: hands out. Anything else is a named fatal.
|
||||
static const struct { const char *name; IpcHandler handler; } services[] = {
|
||||
{"audren:u", audren_manager_handler},
|
||||
{"nfp:user", nfp_user_manager_handler},
|
||||
};
|
||||
|
||||
static volatile int32_t g_live;
|
||||
|
||||
+230
@@ -0,0 +1,230 @@
|
||||
// Horizon OS nfp:user IPC service implementation (nn::nfp::detail::IUserManager & IUser).
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "amiibo.h"
|
||||
#include "host.h"
|
||||
#include "ipc.h"
|
||||
#include "kernel.h"
|
||||
#include "nfp.h"
|
||||
|
||||
// Simulated NFC device handle: ID 1
|
||||
static const uint8_t g_device_handle[8] = { 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
typedef struct {
|
||||
uint32_t activate_event; // writable handle
|
||||
uint32_t deactivate_event; // writable handle
|
||||
uint32_t avail_event; // writable handle
|
||||
} NfpUserState;
|
||||
|
||||
static void nfp_user_close(void *p) {
|
||||
NfpUserState *st = p;
|
||||
if (st) {
|
||||
if (st->activate_event) kern_handle_close(st->activate_event);
|
||||
if (st->deactivate_event) kern_handle_close(st->deactivate_event);
|
||||
if (st->avail_event) kern_handle_close(st->avail_event);
|
||||
free(st);
|
||||
}
|
||||
rt_log("nfp: IUser session closed");
|
||||
}
|
||||
|
||||
// Handler for nn::nfp::detail::IUser
|
||||
static void nfp_user_handler(IpcSession *s, const IpcRequest *rq, IpcResponse *rs) {
|
||||
NfpUserState *st = (NfpUserState *)s->state;
|
||||
|
||||
switch (rq->cmd) {
|
||||
case 0: { // InitializeNfp(u64 aruid, u64 m_pid, pid, buffer<unknown, 5>)
|
||||
rt_log("nfp: Initialize");
|
||||
rs->result = 0;
|
||||
return;
|
||||
}
|
||||
case 1: { // FinalizeNfp()
|
||||
rt_log("nfp: Finalize");
|
||||
amiibo_stop_detection();
|
||||
amiibo_unmount();
|
||||
rs->result = 0;
|
||||
return;
|
||||
}
|
||||
case 2: { // ListDevicesNfp() -> (s32 total_out, buffer<DeviceHandle, 0xa>)
|
||||
int32_t count = amiibo_is_device_present() ? 1 : 0;
|
||||
IPC_OUT(rs, count);
|
||||
if (count > 0 && rq->nb > 0 && rq->b[0].size >= sizeof(g_device_handle)) {
|
||||
void *dst = ipc_guest(rq->b[0].addr, sizeof(g_device_handle));
|
||||
memcpy(dst, g_device_handle, sizeof(g_device_handle));
|
||||
}
|
||||
rs->result = 0;
|
||||
return;
|
||||
}
|
||||
case 3: { // StartDetectionNfp(DeviceHandle)
|
||||
amiibo_start_detection();
|
||||
if (amiibo_has_tag() && st && st->activate_event) {
|
||||
kern_event_signal(st->activate_event);
|
||||
}
|
||||
rs->result = 0;
|
||||
return;
|
||||
}
|
||||
case 4: { // StopDetectionNfp(DeviceHandle)
|
||||
amiibo_stop_detection();
|
||||
rs->result = 0;
|
||||
return;
|
||||
}
|
||||
case 5: { // MountNfp(DeviceHandle, u32 ModelType, u32 MountTarget)
|
||||
if (!amiibo_has_tag()) {
|
||||
rs->result = 0x8073u; // Device/Tag not found
|
||||
return;
|
||||
}
|
||||
amiibo_mount();
|
||||
rs->result = 0;
|
||||
return;
|
||||
}
|
||||
case 6: { // UnmountNfp(DeviceHandle)
|
||||
amiibo_unmount();
|
||||
if (st && st->deactivate_event) {
|
||||
kern_event_signal(st->deactivate_event);
|
||||
}
|
||||
rs->result = 0;
|
||||
return;
|
||||
}
|
||||
case 7: { // OpenApplicationAreaNfp(DeviceHandle, u32 access_id)
|
||||
if (!amiibo_is_mounted()) {
|
||||
rs->result = 0x927Fu; // not mounted
|
||||
return;
|
||||
}
|
||||
rs->result = 0;
|
||||
return;
|
||||
}
|
||||
case 8: { // GetApplicationAreaNfp(DeviceHandle) -> (u32 size, buffer<data, 0x6>)
|
||||
if (!amiibo_is_mounted()) {
|
||||
rs->result = 0x927Fu;
|
||||
return;
|
||||
}
|
||||
uint32_t area_size = 0xD8;
|
||||
if (rq->nb > 0 && rq->b[0].size > 0) {
|
||||
void *dst = ipc_guest(rq->b[0].addr, rq->b[0].size);
|
||||
area_size = (uint32_t)amiibo_get_application_area(dst, (uint32_t)rq->b[0].size);
|
||||
}
|
||||
IPC_OUT(rs, area_size);
|
||||
rs->result = 0;
|
||||
return;
|
||||
}
|
||||
case 13: { // GetTagInfoNfp(DeviceHandle) -> buffer<TagInfo, 0x1a>
|
||||
if (!amiibo_has_tag() && !amiibo_is_mounted()) {
|
||||
rs->result = 0x8073u;
|
||||
return;
|
||||
}
|
||||
if (rq->nb > 0 && rq->b[0].size >= 0x58) {
|
||||
void *dst = ipc_guest(rq->b[0].addr, 0x58);
|
||||
amiibo_get_tag_info(dst);
|
||||
}
|
||||
rs->result = 0;
|
||||
return;
|
||||
}
|
||||
case 14: { // GetRegisterInfoNfp(DeviceHandle) -> buffer<RegisterInfo, 0x1a>
|
||||
if (!amiibo_is_mounted()) {
|
||||
rs->result = 0x927Fu;
|
||||
return;
|
||||
}
|
||||
if (rq->nb > 0 && rq->b[0].size >= 0x100) {
|
||||
void *dst = ipc_guest(rq->b[0].addr, 0x100);
|
||||
amiibo_get_register_info(dst);
|
||||
}
|
||||
rs->result = 0;
|
||||
return;
|
||||
}
|
||||
case 15: { // GetCommonInfoNfp(DeviceHandle) -> buffer<CommonInfo, 0x1a>
|
||||
if (!amiibo_is_mounted()) {
|
||||
rs->result = 0x927Fu;
|
||||
return;
|
||||
}
|
||||
if (rq->nb > 0 && rq->b[0].size >= 0x40) {
|
||||
void *dst = ipc_guest(rq->b[0].addr, 0x40);
|
||||
amiibo_get_common_info(dst);
|
||||
}
|
||||
rs->result = 0;
|
||||
return;
|
||||
}
|
||||
case 16: { // GetModelInfoNfp(DeviceHandle) -> buffer<ModelInfo, 0x1a>
|
||||
if (!amiibo_is_mounted()) {
|
||||
rs->result = 0x927Fu;
|
||||
return;
|
||||
}
|
||||
if (rq->nb > 0 && rq->b[0].size >= 0x40) {
|
||||
void *dst = ipc_guest(rq->b[0].addr, 0x40);
|
||||
amiibo_get_model_info(dst);
|
||||
}
|
||||
rs->result = 0;
|
||||
return;
|
||||
}
|
||||
case 17: { // GetActivateEventHandleNfp(DeviceHandle) -> handle<copy>
|
||||
if (st && st->activate_event) {
|
||||
rs->copy[rs->ncopy++] = kern_event_readable(st->activate_event);
|
||||
}
|
||||
rs->result = 0;
|
||||
return;
|
||||
}
|
||||
case 18: { // GetDeactivateEventHandleNfp(DeviceHandle) -> handle<copy>
|
||||
if (st && st->deactivate_event) {
|
||||
rs->copy[rs->ncopy++] = kern_event_readable(st->deactivate_event);
|
||||
}
|
||||
rs->result = 0;
|
||||
return;
|
||||
}
|
||||
case 19: { // GetStateNfp() -> u32 state
|
||||
uint32_t state = 1; // Initialized
|
||||
IPC_OUT(rs, state);
|
||||
rs->result = 0;
|
||||
return;
|
||||
}
|
||||
case 20: { // GetDeviceStateNfp(DeviceHandle) -> u32 device_state
|
||||
uint32_t dev_state = (uint32_t)amiibo_get_device_state();
|
||||
IPC_OUT(rs, dev_state);
|
||||
rs->result = 0;
|
||||
return;
|
||||
}
|
||||
case 21: { // GetNpadIdNfp(DeviceHandle) -> u32 npad_id
|
||||
uint32_t npad_id = 0; // Handheld / Player 1
|
||||
IPC_OUT(rs, npad_id);
|
||||
rs->result = 0;
|
||||
return;
|
||||
}
|
||||
case 22: { // GetApplicationAreaSizeNfp(DeviceHandle) -> u32 size
|
||||
uint32_t size = 0xD8;
|
||||
IPC_OUT(rs, size);
|
||||
rs->result = 0;
|
||||
return;
|
||||
}
|
||||
case 23: { // GetAvailabilityChangeEventHandleNfp() -> handle<copy>
|
||||
if (st && st->avail_event) {
|
||||
rs->copy[rs->ncopy++] = kern_event_readable(st->avail_event);
|
||||
}
|
||||
rs->result = 0;
|
||||
return;
|
||||
}
|
||||
default:
|
||||
ipc_unimplemented(s, rq);
|
||||
}
|
||||
}
|
||||
|
||||
// Handler for nn::nfp::detail::IUserManager (nfp:user)
|
||||
void nfp_user_manager_handler(IpcSession *s, const IpcRequest *rq, IpcResponse *rs) {
|
||||
switch (rq->cmd) {
|
||||
case 0: { // CreateUserInterface() -> move handle to IUser
|
||||
NfpUserState *st = calloc(1, sizeof(*st));
|
||||
if (!st) rt_fatal("nfp: failed to allocate user state");
|
||||
st->activate_event = kern_event_new();
|
||||
st->deactivate_event = kern_event_new();
|
||||
st->avail_event = kern_event_new();
|
||||
// Signal availability immediately so game detects reader
|
||||
kern_event_signal(st->avail_event);
|
||||
|
||||
uint32_t user_session = ipc_session_new("nfp:IUser", nfp_user_handler, st, nfp_user_close);
|
||||
rs->move[rs->nmove++] = user_session;
|
||||
rs->result = 0;
|
||||
rt_log("nfp: created IUser session handle %#x", user_session);
|
||||
return;
|
||||
}
|
||||
default:
|
||||
ipc_unimplemented(s, rq);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// Nintendo Figurine Platform (nfp:user) Horizon OS IPC service emulation.
|
||||
#pragma once
|
||||
#include "ipc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// sm: handler for "nfp:user" (nn::nfp::detail::IUserManager)
|
||||
void nfp_user_manager_handler(IpcSession *s, const IpcRequest *rq, IpcResponse *rs);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
+7
-5
@@ -357,21 +357,23 @@ static void probe_applet(void) {
|
||||
"AddInternetConnectionStatus");
|
||||
CHECK(CALL("nfp.Initialize", 0) == 0 && (uint32_t)CALL("nfp.GetState", 0) == 1, "nfp initialize");
|
||||
uint8_t handles[64];
|
||||
int32_t count = 7;
|
||||
CHECK((uint32_t)CALL("nfp.ListDevices", U(handles), U(&count), 4) == 0x8073 && count == 0, "nfp ListDevices");
|
||||
int32_t count = 0;
|
||||
CHECK((uint32_t)CALL("nfp.ListDevices", U(handles), U(&count), 4) == 0 && count == 1, "nfp ListDevices");
|
||||
uint64_t ev = U(guest_alloc(0x100));
|
||||
CHECK(CALL("nfp.AttachAvailabilityChangeEvent", ev) == 0, "AttachAvailabilityChangeEvent");
|
||||
int nfp_event = event_works(ev, 0);
|
||||
CHECK(nfp_event, "the nfp availability event does not work as a manual-clear system event");
|
||||
CHECK((uint32_t)CALL("nfp.GetDeviceState", U(handles)) == 0, "nfp device state");
|
||||
static const char *const none[] = {"nfp.Mount", "nfp.GetNpadId", "nfp.AttachActivateEvent", "nfp.AttachDeactivateEvent",
|
||||
"nfp.StartDetection", "nfp.StopDetection", "nfp.GetTagInfo", "nfp.GetModelInfo"};
|
||||
static const char *const none[] = {"nfp.Mount", "nfp.GetTagInfo", "nfp.GetModelInfo"};
|
||||
uint8_t out[0x100];
|
||||
for (size_t i = 0; i < sizeof none / sizeof *none; i++) {
|
||||
int first_is_handle = !strcmp(none[i], "nfp.Mount") || strstr(none[i], "Detection");
|
||||
int first_is_handle = !strcmp(none[i], "nfp.Mount");
|
||||
uint64_t r = first_is_handle ? CALL(none[i], U(handles), 0, 0) : CALL(none[i], U(out), U(handles));
|
||||
CHECK((uint32_t)r == 0x8073, "%s: %#x, not device-not-found", none[i], (uint32_t)r);
|
||||
}
|
||||
CHECK((uint32_t)CALL("nfp.GetNpadId", U(out), U(handles)) == 0, "nfp GetNpadId");
|
||||
CHECK((uint32_t)CALL("nfp.StartDetection", U(handles)) == 0, "nfp StartDetection");
|
||||
CHECK((uint32_t)CALL("nfp.StopDetection", U(handles)) == 0, "nfp StopDetection");
|
||||
CHECK(CALL("nfp.Finalize", 0) == 0 && (uint32_t)CALL("nfp.GetState", 0) == 0, "nfp finalize");
|
||||
CALL("err.ShowError", 0x2a8);
|
||||
CALL("nndiagStartup", 0);
|
||||
|
||||
+112
-13
@@ -19,6 +19,7 @@
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "amiibo.h"
|
||||
#include "cfg.h"
|
||||
#include "fs.h"
|
||||
#include "host.h"
|
||||
@@ -266,26 +267,124 @@ static void ov_report_save(Cpu *c) { // Result PlayReport::Save() and Save(con
|
||||
}
|
||||
static void ov_result_ok(Cpu *c) { ret_x(c, 0); } // RequestImmediateTransmission, AddInternetConnectionStatus
|
||||
|
||||
// nn::nfp: no NFC reader
|
||||
// nn::nfp: NFC reader & amiibo support
|
||||
static volatile int32_t nfp_state;
|
||||
static void ov_nfp_initialize(Cpu *c) { plat_xchg32(&nfp_state, 1); ret_x(c, 0); }
|
||||
static void ov_nfp_finalize(Cpu *c) { plat_xchg32(&nfp_state, 0); ret_x(c, 0); }
|
||||
static void ov_nfp_finalize(Cpu *c) {
|
||||
plat_xchg32(&nfp_state, 0);
|
||||
amiibo_stop_detection();
|
||||
amiibo_unmount();
|
||||
ret_x(c, 0);
|
||||
}
|
||||
static void ov_nfp_state(Cpu *c) { ret_x(c, (uint64_t)nfp_state); }
|
||||
|
||||
// Result ListDevices(DeviceHandle *out, int *count, int max)
|
||||
static void ov_nfp_list(Cpu *c) {
|
||||
void *out = arg_p(c, 0);
|
||||
int32_t *count = arg_p(c, 1);
|
||||
if (count) *count = 0;
|
||||
ret_x(c, NFP_R_DEVICE_NOT_FOUND);
|
||||
int32_t max = (int32_t)arg_x(c, 2);
|
||||
if (!amiibo_is_device_present()) {
|
||||
if (count) *count = 0;
|
||||
ret_x(c, NFP_R_DEVICE_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
if (out && max > 0) {
|
||||
static const uint8_t dev[8] = { 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
memcpy(out, dev, sizeof dev);
|
||||
}
|
||||
if (count) *count = 1;
|
||||
ret_x(c, 0);
|
||||
}
|
||||
|
||||
// Result AttachAvailabilityChangeEvent(os::SystemEventType *event)
|
||||
static void ov_nfp_availability(Cpu *c) {
|
||||
uint64_t ev = arg_x(c, 0);
|
||||
if (!ev) rt_fatal("nn::nfp::AttachAvailabilityChangeEvent: null event");
|
||||
kern_bind_system_event(c, ev, 0);
|
||||
kern_signal_system_event(ev);
|
||||
ret_x(c, 0);
|
||||
}
|
||||
|
||||
// DeviceState GetDeviceState(const DeviceHandle &)
|
||||
static void ov_nfp_device_state(Cpu *c) {
|
||||
(void)c;
|
||||
ret_x(c, (uint64_t)amiibo_get_device_state());
|
||||
}
|
||||
|
||||
// Result Mount(const DeviceHandle &, ModelType, MountTarget)
|
||||
static void ov_nfp_mount(Cpu *c) {
|
||||
(void)c;
|
||||
if (!amiibo_has_tag()) {
|
||||
ret_x(c, NFP_R_DEVICE_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
amiibo_mount();
|
||||
ret_x(c, 0);
|
||||
}
|
||||
|
||||
// Result GetNpadId(u32 *npad_id, const DeviceHandle &)
|
||||
static void ov_nfp_get_npad_id(Cpu *c) {
|
||||
uint32_t *npad = arg_p(c, 0);
|
||||
if (npad) *npad = 0; // Handheld / Player 1
|
||||
ret_x(c, 0);
|
||||
}
|
||||
|
||||
// Result AttachActivateEvent(os::SystemEventType *event, const DeviceHandle &)
|
||||
static void ov_nfp_attach_activate(Cpu *c) {
|
||||
uint64_t ev = arg_x(c, 0);
|
||||
if (ev) {
|
||||
kern_bind_system_event(c, ev, 0);
|
||||
if (amiibo_has_tag()) kern_signal_system_event(ev);
|
||||
}
|
||||
ret_x(c, 0);
|
||||
}
|
||||
|
||||
// Result AttachDeactivateEvent(os::SystemEventType *event, const DeviceHandle &)
|
||||
static void ov_nfp_attach_deactivate(Cpu *c) {
|
||||
uint64_t ev = arg_x(c, 0);
|
||||
if (ev) {
|
||||
kern_bind_system_event(c, ev, 0);
|
||||
}
|
||||
ret_x(c, 0);
|
||||
}
|
||||
|
||||
// Result StartDetection(const DeviceHandle &)
|
||||
static void ov_nfp_start_detection(Cpu *c) {
|
||||
(void)c;
|
||||
amiibo_start_detection();
|
||||
ret_x(c, 0);
|
||||
}
|
||||
|
||||
// Result StopDetection(const DeviceHandle &)
|
||||
static void ov_nfp_stop_detection(Cpu *c) {
|
||||
(void)c;
|
||||
amiibo_stop_detection();
|
||||
ret_x(c, 0);
|
||||
}
|
||||
|
||||
// Result GetTagInfo(TagInfo *out, const DeviceHandle &)
|
||||
static void ov_nfp_get_tag_info(Cpu *c) {
|
||||
void *out = arg_p(c, 0);
|
||||
if (!amiibo_has_tag() && !amiibo_is_mounted()) {
|
||||
ret_x(c, NFP_R_DEVICE_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
if (out) amiibo_get_tag_info(out);
|
||||
ret_x(c, 0);
|
||||
}
|
||||
|
||||
// Result GetModelInfo(ModelInfo *out, const DeviceHandle &)
|
||||
static void ov_nfp_get_model_info(Cpu *c) {
|
||||
void *out = arg_p(c, 0);
|
||||
if (!amiibo_is_mounted() && !amiibo_has_tag()) {
|
||||
ret_x(c, NFP_R_DEVICE_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
if (out) amiibo_get_model_info(out);
|
||||
ret_x(c, 0);
|
||||
}
|
||||
|
||||
static void ov_nfp_no_device(Cpu *c) { ret_x(c, NFP_R_DEVICE_NOT_FOUND); }
|
||||
static void ov_nfp_device_state(Cpu *c) { ret_x(c, 0); } // DeviceState GetDeviceState(const DeviceHandle &): none
|
||||
|
||||
// void err::ShowError(Result): the game's error dialog, logged
|
||||
static void ov_show_error(Cpu *c) {
|
||||
@@ -795,14 +894,14 @@ HOST_OVERRIDE("_ZN2nn3nfp8GetStateEv", ov_nfp_state);
|
||||
HOST_OVERRIDE("_ZN2nn3nfp11ListDevicesEPNS0_12DeviceHandleEPii", ov_nfp_list);
|
||||
HOST_OVERRIDE("_ZN2nn3nfp29AttachAvailabilityChangeEventEPNS_2os15SystemEventTypeE", ov_nfp_availability);
|
||||
HOST_OVERRIDE("_ZN2nn3nfp14GetDeviceStateERKNS0_12DeviceHandleE", ov_nfp_device_state);
|
||||
HOST_OVERRIDE("_ZN2nn3nfp5MountERKNS0_12DeviceHandleENS0_9ModelTypeENS0_11MountTargetE", ov_nfp_no_device);
|
||||
HOST_OVERRIDE("_ZN2nn3nfp9GetNpadIdEPjRKNS0_12DeviceHandleE", ov_nfp_no_device);
|
||||
HOST_OVERRIDE("_ZN2nn3nfp19AttachActivateEventEPNS_2os15SystemEventTypeERKNS0_12DeviceHandleE", ov_nfp_no_device);
|
||||
HOST_OVERRIDE("_ZN2nn3nfp21AttachDeactivateEventEPNS_2os15SystemEventTypeERKNS0_12DeviceHandleE", ov_nfp_no_device);
|
||||
HOST_OVERRIDE("_ZN2nn3nfp14StartDetectionERKNS0_12DeviceHandleE", ov_nfp_no_device);
|
||||
HOST_OVERRIDE("_ZN2nn3nfp13StopDetectionERKNS0_12DeviceHandleE", ov_nfp_no_device);
|
||||
HOST_OVERRIDE("_ZN2nn3nfp10GetTagInfoEPNS0_7TagInfoERKNS0_12DeviceHandleE", ov_nfp_no_device);
|
||||
HOST_OVERRIDE("_ZN2nn3nfp12GetModelInfoEPNS0_9ModelInfoERKNS0_12DeviceHandleE", ov_nfp_no_device);
|
||||
HOST_OVERRIDE("_ZN2nn3nfp5MountERKNS0_12DeviceHandleENS0_9ModelTypeENS0_11MountTargetE", ov_nfp_mount);
|
||||
HOST_OVERRIDE("_ZN2nn3nfp9GetNpadIdEPjRKNS0_12DeviceHandleE", ov_nfp_get_npad_id);
|
||||
HOST_OVERRIDE("_ZN2nn3nfp19AttachActivateEventEPNS_2os15SystemEventTypeERKNS0_12DeviceHandleE", ov_nfp_attach_activate);
|
||||
HOST_OVERRIDE("_ZN2nn3nfp21AttachDeactivateEventEPNS_2os15SystemEventTypeERKNS0_12DeviceHandleE", ov_nfp_attach_deactivate);
|
||||
HOST_OVERRIDE("_ZN2nn3nfp14StartDetectionERKNS0_12DeviceHandleE", ov_nfp_start_detection);
|
||||
HOST_OVERRIDE("_ZN2nn3nfp13StopDetectionERKNS0_12DeviceHandleE", ov_nfp_stop_detection);
|
||||
HOST_OVERRIDE("_ZN2nn3nfp10GetTagInfoEPNS0_7TagInfoERKNS0_12DeviceHandleE", ov_nfp_get_tag_info);
|
||||
HOST_OVERRIDE("_ZN2nn3nfp12GetModelInfoEPNS0_9ModelInfoERKNS0_12DeviceHandleE", ov_nfp_get_model_info);
|
||||
HOST_OVERRIDE("_ZN2nn3err9ShowErrorENS_6ResultE", ov_show_error);
|
||||
|
||||
HOST_OVERRIDE("nndiagStartup", ov_diag_startup);
|
||||
|
||||
@@ -0,0 +1,276 @@
|
||||
// Amiibo / NFC menu page (Dear ImGui): browser and scan controls.
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <filesystem>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "imgui.h"
|
||||
#include "ui/amiibo_page.h"
|
||||
|
||||
extern "C" {
|
||||
#include "amiibo.h"
|
||||
#include "cfg.h"
|
||||
#include "platform/platform.h"
|
||||
#include "ui_text.h"
|
||||
}
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
struct FileEntry {
|
||||
std::string name;
|
||||
bool is_dir;
|
||||
};
|
||||
|
||||
static const char kDefaultAmiiboDir[] = "./amiibo";
|
||||
static std::string g_current_dir = kDefaultAmiiboDir;
|
||||
static char g_dir_input[512] = "./amiibo";
|
||||
static std::vector<FileEntry> g_entries;
|
||||
static int g_selected_entry = -1;
|
||||
// The last action: a catalog id and the file or folder it names, formatted when drawn (the menu language can change)
|
||||
static UiTextId g_status_id = UI_MENU_AMIIBO_READY;
|
||||
static std::string g_status_arg;
|
||||
|
||||
static void set_status(UiTextId id, const std::string &arg = std::string()) {
|
||||
g_status_id = id;
|
||||
g_status_arg = arg;
|
||||
}
|
||||
|
||||
// Loads a dump and puts it on the reader; the status names the file.
|
||||
static void tap(const std::string &dir, const std::string &name) {
|
||||
std::string full_path = (fs::path(dir) / name).string();
|
||||
set_status(amiibo_scan_and_tap(full_path.c_str()) ? UI_MENU_AMIIBO_TAPPED : UI_MENU_AMIIBO_LOAD_FAILED, name);
|
||||
}
|
||||
|
||||
static bool iequals(std::string_view a, std::string_view b) {
|
||||
if (a.size() != b.size()) return false;
|
||||
for (size_t i = 0; i < a.size(); ++i) {
|
||||
if (std::tolower(static_cast<unsigned char>(a[i])) !=
|
||||
std::tolower(static_cast<unsigned char>(b[i]))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void set_current_dir(const std::string &path) {
|
||||
g_current_dir = path;
|
||||
snprintf(g_dir_input, sizeof(g_dir_input), "%s", g_current_dir.c_str());
|
||||
cfg_set("TOTK_AMIIBO_DIR", g_current_dir.c_str());
|
||||
}
|
||||
|
||||
static void refresh_dir(void) {
|
||||
g_entries.clear();
|
||||
g_selected_entry = -1;
|
||||
|
||||
std::error_code ec;
|
||||
fs::path dir_path(g_current_dir);
|
||||
|
||||
// Fall back to "." if directory does not exist or is not a directory
|
||||
if (!fs::exists(dir_path, ec) || !fs::is_directory(dir_path, ec)) {
|
||||
if (g_current_dir != ".") {
|
||||
set_current_dir(".");
|
||||
dir_path = fs::path(g_current_dir);
|
||||
}
|
||||
}
|
||||
|
||||
if (!fs::exists(dir_path, ec) || !fs::is_directory(dir_path, ec)) {
|
||||
set_status(UI_MENU_AMIIBO_NO_DIR, g_current_dir);
|
||||
return;
|
||||
}
|
||||
|
||||
// Add parent navigation if not at root
|
||||
if (dir_path.has_parent_path() && dir_path != dir_path.parent_path()) {
|
||||
g_entries.push_back({"..", true});
|
||||
}
|
||||
|
||||
for (const auto &entry : fs::directory_iterator(dir_path, fs::directory_options::skip_permission_denied, ec)) {
|
||||
if (ec) break;
|
||||
std::error_code status_ec;
|
||||
bool is_dir = entry.is_directory(status_ec);
|
||||
if (status_ec) continue;
|
||||
|
||||
std::string filename = entry.path().filename().string();
|
||||
if (filename.empty() || filename == "." || filename == "..") continue;
|
||||
|
||||
if (!is_dir) {
|
||||
std::string ext = entry.path().extension().string();
|
||||
if (!iequals(ext, ".bin") && !iequals(ext, ".nfc")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
g_entries.push_back({std::move(filename), is_dir});
|
||||
}
|
||||
|
||||
std::sort(g_entries.begin(), g_entries.end(), [](const FileEntry &a, const FileEntry &b) {
|
||||
if (a.name == "..") return true;
|
||||
if (b.name == "..") return false;
|
||||
if (a.is_dir != b.is_dir) return a.is_dir;
|
||||
return a.name < b.name;
|
||||
});
|
||||
}
|
||||
|
||||
void tab_amiibo(float scale) {
|
||||
static bool s_inited = false;
|
||||
if (!s_inited) {
|
||||
const char *cfg_dir = cfg_get("TOTK_AMIIBO_DIR");
|
||||
if (cfg_dir && *cfg_dir) {
|
||||
g_current_dir = cfg_dir;
|
||||
} else {
|
||||
g_current_dir = kDefaultAmiiboDir;
|
||||
}
|
||||
snprintf(g_dir_input, sizeof(g_dir_input), "%s", g_current_dir.c_str());
|
||||
refresh_dir();
|
||||
s_inited = true;
|
||||
}
|
||||
|
||||
// Two panes: Left (Directory Browser & Tag List), Right (Amiibo Tag Details & Controls)
|
||||
const float content_h = ImGui::GetContentRegionAvail().y - 20.0f;
|
||||
const float left_w = ImGui::GetContentRegionAvail().x * 0.58f;
|
||||
const float right_w = ImGui::GetContentRegionAvail().x - left_w - ImGui::GetStyle().ItemSpacing.x;
|
||||
|
||||
// ---- Left Pane: Explorer & List ----
|
||||
ImGui::BeginChild("##amiibo_explorer", ImVec2(left_w, content_h), true);
|
||||
ImGui::TextColored(ImVec4(0.93f, 0.76f, 0.33f, 1.0f), menu_text(UI_MENU_AMIIBO_DIR));
|
||||
|
||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
||||
if (ImGui::InputText("##amiibo_dir_input", g_dir_input, sizeof(g_dir_input), ImGuiInputTextFlags_EnterReturnsTrue)) {
|
||||
set_current_dir(g_dir_input);
|
||||
refresh_dir();
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
if (ImGui::Button(menu_text(UI_MENU_AMIIBO_OPEN))) {
|
||||
set_current_dir(g_dir_input);
|
||||
refresh_dir();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button(menu_text(UI_MENU_AMIIBO_DEFAULT_DIR))) {
|
||||
set_current_dir(kDefaultAmiiboDir);
|
||||
refresh_dir();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button(menu_text(UI_MENU_AMIIBO_REFRESH))) {
|
||||
refresh_dir();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
ImGui::TextDisabled("%s", menu_text(UI_MENU_AMIIBO_PICK));
|
||||
|
||||
ImGui::BeginChild("##file_list", ImVec2(0, 0), true);
|
||||
for (size_t i = 0; i < g_entries.size(); i++) {
|
||||
const auto &e = g_entries[i];
|
||||
std::string label = e.is_dir ? e.name + "/" : e.name;
|
||||
bool selected = ((int)i == g_selected_entry);
|
||||
|
||||
if (ImGui::Selectable(label.c_str(), selected, ImGuiSelectableFlags_AllowDoubleClick)) {
|
||||
g_selected_entry = (int)i;
|
||||
if (e.is_dir) {
|
||||
if (ImGui::IsMouseDoubleClicked(0) || ImGui::IsKeyPressed(ImGuiKey_GamepadFaceDown)) {
|
||||
if (e.name == "..") {
|
||||
fs::path cur(g_current_dir);
|
||||
if (cur.has_parent_path() && cur != cur.parent_path()) {
|
||||
set_current_dir(cur.parent_path().string());
|
||||
} else {
|
||||
set_current_dir(".");
|
||||
}
|
||||
} else {
|
||||
set_current_dir((fs::path(g_current_dir) / e.name).string());
|
||||
}
|
||||
refresh_dir();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (ImGui::IsMouseDoubleClicked(0)) tap(g_current_dir, e.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::EndChild();
|
||||
ImGui::EndChild();
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
// ---- Right Pane: Controls & Status ----
|
||||
ImGui::BeginChild("##amiibo_controls", ImVec2(right_w, content_h), true);
|
||||
ImGui::TextColored(ImVec4(0.93f, 0.76f, 0.33f, 1.0f), menu_text(UI_MENU_AMIIBO_READER));
|
||||
ImGui::Separator();
|
||||
|
||||
AmiiboDeviceState state = amiibo_get_device_state();
|
||||
UiTextId state_id = UI_MENU_AMIIBO_STATE_IDLE;
|
||||
ImVec4 state_col = ImVec4(0.8f, 0.8f, 0.8f, 1.0f);
|
||||
switch (state) {
|
||||
case AMIIBO_DEV_STATE_INITIALIZED: state_id = UI_MENU_AMIIBO_STATE_IDLE; break;
|
||||
case AMIIBO_DEV_STATE_SEARCHING: state_id = UI_MENU_AMIIBO_STATE_SEARCHING; state_col = ImVec4(1.0f, 0.8f, 0.2f, 1.0f); break;
|
||||
case AMIIBO_DEV_STATE_TAG_FOUND: state_id = UI_MENU_AMIIBO_STATE_FOUND; state_col = ImVec4(0.3f, 0.9f, 0.3f, 1.0f); break;
|
||||
case AMIIBO_DEV_STATE_TAG_MOUNTED: state_id = UI_MENU_AMIIBO_STATE_MOUNTED; state_col = ImVec4(0.2f, 0.9f, 1.0f, 1.0f); break;
|
||||
case AMIIBO_DEV_STATE_UNAVAILABLE: state_id = UI_MENU_AMIIBO_STATE_OFF; state_col = ImVec4(0.9f, 0.3f, 0.3f, 1.0f); break;
|
||||
default: break;
|
||||
}
|
||||
ImGui::TextUnformatted(menu_text(UI_MENU_AMIIBO_STATE));
|
||||
ImGui::SameLine();
|
||||
ImGui::TextColored(state_col, "%s", menu_text(state_id));
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
ImGui::TextUnformatted(menu_text(UI_MENU_AMIIBO_FILE));
|
||||
if (g_selected_entry >= 0 && g_selected_entry < (int)g_entries.size() && !g_entries[g_selected_entry].is_dir) {
|
||||
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.4f, 1.0f), "%s", g_entries[g_selected_entry].name.c_str());
|
||||
|
||||
if (ImGui::Button(menu_text(UI_MENU_AMIIBO_TAP), ImVec2(ImGui::GetContentRegionAvail().x, 32 * scale)))
|
||||
tap(g_current_dir, g_entries[g_selected_entry].name);
|
||||
} else {
|
||||
ImGui::TextDisabled("%s", menu_text(UI_MENU_AMIIBO_NO_FILE));
|
||||
ImGui::BeginDisabled();
|
||||
ImGui::Button(menu_text(UI_MENU_AMIIBO_TAP), ImVec2(ImGui::GetContentRegionAvail().x, 32 * scale));
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
if (ImGui::Button(menu_text(UI_MENU_AMIIBO_REMOVE), ImVec2(ImGui::GetContentRegionAvail().x, 28 * scale))) {
|
||||
amiibo_remove_tag();
|
||||
set_status(UI_MENU_AMIIBO_REMOVED);
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
bool auto_remove = amiibo_get_auto_remove();
|
||||
if (ImGui::Checkbox(menu_text(UI_MENU_AMIIBO_AUTO_REMOVE), &auto_remove)) {
|
||||
amiibo_set_auto_remove(auto_remove);
|
||||
}
|
||||
if (auto_remove) {
|
||||
float delay = amiibo_get_auto_remove_delay_s();
|
||||
if (ImGui::SliderFloat(menu_text(UI_MENU_AMIIBO_HOLD), &delay, 1.0f, 6.0f, menu_text(UI_MENU_AMIIBO_SECONDS))) {
|
||||
amiibo_set_auto_remove_delay_s(delay);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
ImGui::TextUnformatted(menu_text(UI_MENU_AMIIBO_TAG));
|
||||
if (amiibo_has_tag()) {
|
||||
const AmiiboInfo *info = amiibo_get_current_info();
|
||||
char character[8], uid[24];
|
||||
snprintf(character, sizeof character, "%02x%02x%02x", info->character_id[0], info->character_id[1],
|
||||
info->character_id[2]);
|
||||
snprintf(uid, sizeof uid, "%02x:%02x:%02x:%02x:%02x:%02x:%02x", info->uuid[0], info->uuid[1], info->uuid[2],
|
||||
info->uuid[3], info->uuid[4], info->uuid[5], info->uuid[6]);
|
||||
ImGui::Text(menu_text(UI_MENU_AMIIBO_TAG_FILE), info->filename);
|
||||
ImGui::Text(menu_text(UI_MENU_AMIIBO_TAG_ID), character, info->series_id, info->numbering_id, info->nfp_type);
|
||||
ImGui::Text(menu_text(UI_MENU_AMIIBO_TAG_UID), uid);
|
||||
} else {
|
||||
ImGui::TextDisabled("%s", menu_text(UI_MENU_AMIIBO_NO_TAG));
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
char status[512];
|
||||
snprintf(status, sizeof status, menu_text(g_status_id), g_status_arg.c_str());
|
||||
ImGui::TextDisabled(menu_text(UI_MENU_AMIIBO_STATUS), status);
|
||||
|
||||
ImGui::EndChild();
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// Amiibo / NFC menu page (ui/amiibo_page.cpp).
|
||||
#pragma once
|
||||
|
||||
void tab_amiibo(float scale);
|
||||
+8
-3
@@ -30,10 +30,12 @@ static int g_font_bad;
|
||||
#pragma clang diagnostic ignored "-Wunused-function"
|
||||
#include "imstb_truetype.h"
|
||||
#pragma clang diagnostic pop
|
||||
#include "ui/amiibo_page.h"
|
||||
#include "ui/binds_page.h"
|
||||
#include "ui/option_rows.h"
|
||||
|
||||
extern "C" {
|
||||
#include "amiibo.h"
|
||||
#include "cfg.h"
|
||||
#include "fs.h"
|
||||
#include "input.h"
|
||||
@@ -368,7 +370,7 @@ extern "C" void menu_vk_release(void) {
|
||||
// TOTK_MENU_TEST_SET=<frame>:<key>=<value>[,<key>=<value>...][;<frame>:...]: cfg_set of each key (TOTK_ prefix
|
||||
// optional) at that presented frame; changes live settings with no input, menu open or not. totk.ini is written only by
|
||||
// the pseudo-key SAVE=1 (cfg_save, as a row change does; a failed write shows the menu's save note).
|
||||
enum { TAB_SCREEN, TAB_GAME, TAB_SOUND, TAB_CONTROLS, TAB_MENU, TAB_ADVANCED, TAB_COUNT };
|
||||
enum { TAB_SCREEN, TAB_GAME, TAB_SOUND, TAB_CONTROLS, TAB_AMIIBO, TAB_MENU, TAB_ADVANCED, TAB_COUNT };
|
||||
enum { TEST_PAGE_FRAMES = 30, TEST_SETS = 16 };
|
||||
struct TestSet { uint64_t frame; char key[64], value[64]; };
|
||||
static struct {
|
||||
@@ -978,8 +980,9 @@ static void tab_advanced(float scale) {
|
||||
}
|
||||
}
|
||||
|
||||
static const UiTextId kTabNames[TAB_COUNT] = {UI_MENU_TAB_SCREEN, UI_MENU_TAB_GAME, UI_MENU_TAB_SOUND,
|
||||
UI_MENU_TAB_CONTROLS, UI_MENU_TAB_MENU, UI_MENU_TAB_ADVANCED};
|
||||
static const UiTextId kTabNames[TAB_COUNT] = {UI_MENU_TAB_SCREEN, UI_MENU_TAB_GAME, UI_MENU_TAB_SOUND,
|
||||
UI_MENU_TAB_CONTROLS, UI_MENU_TAB_AMIIBO, UI_MENU_TAB_MENU,
|
||||
UI_MENU_TAB_ADVANCED};
|
||||
static int g_tab; // the tab shown
|
||||
static int g_tab_request = -1; // select this tab at the next layout; -1 none
|
||||
static int g_focus_page = -1; // this tab's first row takes the cursor once it is shown; -1 none
|
||||
@@ -1030,6 +1033,7 @@ static void layout_menu(uint32_t w, uint32_t h, float scale) {
|
||||
case TAB_GAME: tab_game(scale); break;
|
||||
case TAB_SOUND: tab_sound(scale); break;
|
||||
case TAB_CONTROLS: tab_controls(scale); break;
|
||||
case TAB_AMIIBO: tab_amiibo(scale); break;
|
||||
case TAB_MENU: tab_menu(scale); break;
|
||||
case TAB_ADVANCED: tab_advanced(scale); break;
|
||||
}
|
||||
@@ -1315,6 +1319,7 @@ extern "C" int menu_overlay_frame(uint64_t frame, const MenuTarget *t, const cha
|
||||
if (g_test.next_set < g_test.n_sets && frame >= g_test.sets[g_test.next_set].frame) test_apply_sets(frame);
|
||||
if (g_perf_save.exchange(0)) cfg_save();
|
||||
perf_tick(plat_now_ns(), t);
|
||||
amiibo_tick();
|
||||
bool open = g_open.load(std::memory_order_relaxed);
|
||||
if (!open) {
|
||||
if (g_save_pending) g_save_pending = opt_save_tick(1); // closed: the last change goes to totk.ini now
|
||||
|
||||
+124
-3
@@ -30,7 +30,7 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
||||
|
||||
[UI_MENU_TITLE] = "Settings",
|
||||
[UI_MENU_TAB_SCREEN] = "Screen", [UI_MENU_TAB_GAME] = "Game", [UI_MENU_TAB_SOUND] = "Sound",
|
||||
[UI_MENU_TAB_CONTROLS] = "Controls", [UI_MENU_TAB_MENU] = "Menu", [UI_MENU_TAB_ADVANCED] = "Advanced",
|
||||
[UI_MENU_TAB_CONTROLS] = "Controls", [UI_MENU_TAB_AMIIBO] = "Amiibo", [UI_MENU_TAB_MENU] = "Menu", [UI_MENU_TAB_ADVANCED] = "Advanced",
|
||||
[UI_MENU_CONTINUE] = "Continue", [UI_MENU_QUIT] = "Quit game",
|
||||
[UI_MENU_ON] = "On", [UI_MENU_OFF] = "Off", [UI_MENU_AUTO] = "Automatic", [UI_MENU_DEFAULT_MARK] = "default",
|
||||
[UI_MENU_AFTER_RESTART] = "after restart", [UI_MENU_SET_BY_ENV] = "set by environment variable",
|
||||
@@ -232,6 +232,36 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
||||
[UI_PAD_LPADDLE2] = "Left back button 2", [UI_PAD_RPADDLE2] = "Right back button 2",
|
||||
[UI_PAD_CROSS] = "Cross", [UI_PAD_CIRCLE] = "Circle", [UI_PAD_SQUARE] = "Square", [UI_PAD_TRIANGLE] = "Triangle",
|
||||
|
||||
[UI_MENU_AMIIBO_DIR] = "Amiibo folder",
|
||||
[UI_MENU_AMIIBO_OPEN] = "Open",
|
||||
[UI_MENU_AMIIBO_DEFAULT_DIR] = "Default folder",
|
||||
[UI_MENU_AMIIBO_REFRESH] = "Refresh",
|
||||
[UI_MENU_AMIIBO_PICK] = "Amiibo dumps (540-byte .bin or .nfc files):",
|
||||
[UI_MENU_AMIIBO_NO_DIR] = "Cannot open the folder %s",
|
||||
[UI_MENU_AMIIBO_READER] = "NFC reader",
|
||||
[UI_MENU_AMIIBO_STATE] = "Reader:",
|
||||
[UI_MENU_AMIIBO_STATE_IDLE] = "ready",
|
||||
[UI_MENU_AMIIBO_STATE_SEARCHING] = "the game is waiting for an amiibo",
|
||||
[UI_MENU_AMIIBO_STATE_FOUND] = "amiibo on the reader",
|
||||
[UI_MENU_AMIIBO_STATE_MOUNTED] = "the game is reading the amiibo",
|
||||
[UI_MENU_AMIIBO_STATE_OFF] = "off",
|
||||
[UI_MENU_AMIIBO_FILE] = "Selected file:",
|
||||
[UI_MENU_AMIIBO_NO_FILE] = "(no file selected)",
|
||||
[UI_MENU_AMIIBO_TAP] = "Tap the amiibo",
|
||||
[UI_MENU_AMIIBO_REMOVE] = "Lift the amiibo",
|
||||
[UI_MENU_AMIIBO_AUTO_REMOVE] = "Lift the amiibo by itself after a tap",
|
||||
[UI_MENU_AMIIBO_HOLD] = "Time on the reader",
|
||||
[UI_MENU_AMIIBO_SECONDS] = "%.1f s",
|
||||
[UI_MENU_AMIIBO_TAG] = "Amiibo on the reader:",
|
||||
[UI_MENU_AMIIBO_NO_TAG] = "No amiibo on the reader.",
|
||||
[UI_MENU_AMIIBO_TAG_FILE] = "File: %s",
|
||||
[UI_MENU_AMIIBO_TAG_ID] = "Character %s, series %02x, number %04x, type %02x",
|
||||
[UI_MENU_AMIIBO_TAG_UID] = "UID: %s",
|
||||
[UI_MENU_AMIIBO_READY] = "Ready",
|
||||
[UI_MENU_AMIIBO_TAPPED] = "Tapped: %s",
|
||||
[UI_MENU_AMIIBO_LOAD_FAILED] = "Not an amiibo dump (540-byte NTAG215): %s",
|
||||
[UI_MENU_AMIIBO_REMOVED] = "Amiibo lifted",
|
||||
[UI_MENU_AMIIBO_STATUS] = "Status: %s",
|
||||
[UI_MENU_MENU_LANG] = "Menu language", [UI_MENU_MENU_LANG_DESC] = "Language of this menu and the overlay.",
|
||||
[UI_MENU_MENU_LANG_AUTO] = "Automatic (from Windows)",
|
||||
|
||||
@@ -336,7 +366,7 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
||||
|
||||
[UI_MENU_TITLE] = "Настройки",
|
||||
[UI_MENU_TAB_SCREEN] = "Экран", [UI_MENU_TAB_GAME] = "Игра", [UI_MENU_TAB_SOUND] = "Звук",
|
||||
[UI_MENU_TAB_CONTROLS] = "Управление", [UI_MENU_TAB_MENU] = "Меню", [UI_MENU_TAB_ADVANCED] = "Дополнительно",
|
||||
[UI_MENU_TAB_CONTROLS] = "Управление", [UI_MENU_TAB_AMIIBO] = "Amiibo", [UI_MENU_TAB_MENU] = "Меню", [UI_MENU_TAB_ADVANCED] = "Дополнительно",
|
||||
[UI_MENU_CONTINUE] = "Продолжить", [UI_MENU_QUIT] = "Выйти из игры",
|
||||
[UI_MENU_ON] = "Вкл.", [UI_MENU_OFF] = "Выкл.", [UI_MENU_AUTO] = "Автоматически",
|
||||
[UI_MENU_DEFAULT_MARK] = "по умолчанию",
|
||||
@@ -544,6 +574,36 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
||||
[UI_PAD_LPADDLE2] = "Левая задняя кнопка 2", [UI_PAD_RPADDLE2] = "Правая задняя кнопка 2",
|
||||
[UI_PAD_CROSS] = "Крест", [UI_PAD_CIRCLE] = "Круг", [UI_PAD_SQUARE] = "Квадрат", [UI_PAD_TRIANGLE] = "Треугольник",
|
||||
|
||||
[UI_MENU_AMIIBO_DIR] = "Папка amiibo",
|
||||
[UI_MENU_AMIIBO_OPEN] = "Открыть",
|
||||
[UI_MENU_AMIIBO_DEFAULT_DIR] = "Папка по умолчанию",
|
||||
[UI_MENU_AMIIBO_REFRESH] = "Обновить",
|
||||
[UI_MENU_AMIIBO_PICK] = "Дампы amiibo (файлы .bin или .nfc по 540 байт):",
|
||||
[UI_MENU_AMIIBO_NO_DIR] = "Не удаётся открыть папку %s",
|
||||
[UI_MENU_AMIIBO_READER] = "NFC-считыватель",
|
||||
[UI_MENU_AMIIBO_STATE] = "Считыватель:",
|
||||
[UI_MENU_AMIIBO_STATE_IDLE] = "готов",
|
||||
[UI_MENU_AMIIBO_STATE_SEARCHING] = "игра ждёт amiibo",
|
||||
[UI_MENU_AMIIBO_STATE_FOUND] = "amiibo на считывателе",
|
||||
[UI_MENU_AMIIBO_STATE_MOUNTED] = "игра читает amiibo",
|
||||
[UI_MENU_AMIIBO_STATE_OFF] = "выключен",
|
||||
[UI_MENU_AMIIBO_FILE] = "Выбранный файл:",
|
||||
[UI_MENU_AMIIBO_NO_FILE] = "(файл не выбран)",
|
||||
[UI_MENU_AMIIBO_TAP] = "Приложить amiibo",
|
||||
[UI_MENU_AMIIBO_REMOVE] = "Убрать amiibo",
|
||||
[UI_MENU_AMIIBO_AUTO_REMOVE] = "Убирать amiibo само после касания",
|
||||
[UI_MENU_AMIIBO_HOLD] = "Время на считывателе",
|
||||
[UI_MENU_AMIIBO_SECONDS] = "%.1f с",
|
||||
[UI_MENU_AMIIBO_TAG] = "Amiibo на считывателе:",
|
||||
[UI_MENU_AMIIBO_NO_TAG] = "На считывателе нет amiibo.",
|
||||
[UI_MENU_AMIIBO_TAG_FILE] = "Файл: %s",
|
||||
[UI_MENU_AMIIBO_TAG_ID] = "Персонаж %s, серия %02x, номер %04x, тип %02x",
|
||||
[UI_MENU_AMIIBO_TAG_UID] = "UID: %s",
|
||||
[UI_MENU_AMIIBO_READY] = "Готово",
|
||||
[UI_MENU_AMIIBO_TAPPED] = "Приложен: %s",
|
||||
[UI_MENU_AMIIBO_LOAD_FAILED] = "Не дамп amiibo (NTAG215, 540 байт): %s",
|
||||
[UI_MENU_AMIIBO_REMOVED] = "Amiibo убран",
|
||||
[UI_MENU_AMIIBO_STATUS] = "Состояние: %s",
|
||||
[UI_MENU_MENU_LANG] = "Язык меню", [UI_MENU_MENU_LANG_DESC] = "Язык этого меню и индикатора.",
|
||||
[UI_MENU_MENU_LANG_AUTO] = "Автоматически (из Windows)",
|
||||
|
||||
@@ -650,7 +710,7 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
|
||||
|
||||
[UI_MENU_TITLE] = "Configurações",
|
||||
[UI_MENU_TAB_SCREEN] = "Tela", [UI_MENU_TAB_GAME] = "Jogo", [UI_MENU_TAB_SOUND] = "Som",
|
||||
[UI_MENU_TAB_CONTROLS] = "Controles", [UI_MENU_TAB_MENU] = "Menu", [UI_MENU_TAB_ADVANCED] = "Avançado",
|
||||
[UI_MENU_TAB_CONTROLS] = "Controles", [UI_MENU_TAB_AMIIBO] = "Amiibo", [UI_MENU_TAB_MENU] = "Menu", [UI_MENU_TAB_ADVANCED] = "Avançado",
|
||||
[UI_MENU_CONTINUE] = "Continuar", [UI_MENU_QUIT] = "Sair do jogo",
|
||||
[UI_MENU_ON] = "Ligado", [UI_MENU_OFF] = "Desligado", [UI_MENU_AUTO] = "Automático",
|
||||
[UI_MENU_DEFAULT_MARK] = "padrão",
|
||||
@@ -799,6 +859,36 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
|
||||
[UI_PAD_LPADDLE2] = "Botão traseiro esquerdo 2", [UI_PAD_RPADDLE2] = "Botão traseiro direito 2",
|
||||
[UI_PAD_CROSS] = "Cruz", [UI_PAD_CIRCLE] = "Círculo", [UI_PAD_SQUARE] = "Quadrado", [UI_PAD_TRIANGLE] = "Triângulo",
|
||||
|
||||
[UI_MENU_AMIIBO_DIR] = "Pasta de amiibo",
|
||||
[UI_MENU_AMIIBO_OPEN] = "Abrir",
|
||||
[UI_MENU_AMIIBO_DEFAULT_DIR] = "Pasta padrão",
|
||||
[UI_MENU_AMIIBO_REFRESH] = "Atualizar",
|
||||
[UI_MENU_AMIIBO_PICK] = "Dumps de amiibo (arquivos .bin ou .nfc de 540 bytes):",
|
||||
[UI_MENU_AMIIBO_NO_DIR] = "Não foi possível abrir a pasta %s",
|
||||
[UI_MENU_AMIIBO_READER] = "Leitor NFC",
|
||||
[UI_MENU_AMIIBO_STATE] = "Leitor:",
|
||||
[UI_MENU_AMIIBO_STATE_IDLE] = "pronto",
|
||||
[UI_MENU_AMIIBO_STATE_SEARCHING] = "o jogo está esperando um amiibo",
|
||||
[UI_MENU_AMIIBO_STATE_FOUND] = "amiibo no leitor",
|
||||
[UI_MENU_AMIIBO_STATE_MOUNTED] = "o jogo está lendo o amiibo",
|
||||
[UI_MENU_AMIIBO_STATE_OFF] = "desligado",
|
||||
[UI_MENU_AMIIBO_FILE] = "Arquivo selecionado:",
|
||||
[UI_MENU_AMIIBO_NO_FILE] = "(nenhum arquivo selecionado)",
|
||||
[UI_MENU_AMIIBO_TAP] = "Encostar o amiibo",
|
||||
[UI_MENU_AMIIBO_REMOVE] = "Afastar o amiibo",
|
||||
[UI_MENU_AMIIBO_AUTO_REMOVE] = "Afastar o amiibo sozinho depois de encostar",
|
||||
[UI_MENU_AMIIBO_HOLD] = "Tempo no leitor",
|
||||
[UI_MENU_AMIIBO_SECONDS] = "%.1f s",
|
||||
[UI_MENU_AMIIBO_TAG] = "Amiibo no leitor:",
|
||||
[UI_MENU_AMIIBO_NO_TAG] = "Nenhum amiibo no leitor.",
|
||||
[UI_MENU_AMIIBO_TAG_FILE] = "Arquivo: %s",
|
||||
[UI_MENU_AMIIBO_TAG_ID] = "Personagem %s, série %02x, número %04x, tipo %02x",
|
||||
[UI_MENU_AMIIBO_TAG_UID] = "UID: %s",
|
||||
[UI_MENU_AMIIBO_READY] = "Pronto",
|
||||
[UI_MENU_AMIIBO_TAPPED] = "Encostado: %s",
|
||||
[UI_MENU_AMIIBO_LOAD_FAILED] = "Não é um dump de amiibo (NTAG215, 540 bytes): %s",
|
||||
[UI_MENU_AMIIBO_REMOVED] = "Amiibo afastado",
|
||||
[UI_MENU_AMIIBO_STATUS] = "Estado: %s",
|
||||
[UI_MENU_MENU_LANG] = "Idioma do menu", [UI_MENU_MENU_LANG_DESC] = "Idioma deste menu e do indicador.",
|
||||
[UI_MENU_MENU_LANG_AUTO] = "Automático (do Windows)",
|
||||
|
||||
@@ -991,6 +1081,7 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_TAB_GAME] = "游戏",
|
||||
[UI_MENU_TAB_SOUND] = "声音",
|
||||
[UI_MENU_TAB_CONTROLS] = "操作",
|
||||
[UI_MENU_TAB_AMIIBO] = "amiibo",
|
||||
[UI_MENU_TAB_MENU] = "菜单",
|
||||
[UI_MENU_TAB_ADVANCED] = "高级",
|
||||
[UI_MENU_CONTINUE] = "继续",
|
||||
@@ -1236,6 +1327,36 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
|
||||
[UI_PAD_SQUARE] = "方块键",
|
||||
[UI_PAD_TRIANGLE] = "三角键",
|
||||
|
||||
[UI_MENU_AMIIBO_DIR] = "amiibo 文件夹",
|
||||
[UI_MENU_AMIIBO_OPEN] = "打开",
|
||||
[UI_MENU_AMIIBO_DEFAULT_DIR] = "默认文件夹",
|
||||
[UI_MENU_AMIIBO_REFRESH] = "刷新",
|
||||
[UI_MENU_AMIIBO_PICK] = "amiibo 转储(540 字节的 .bin 或 .nfc 文件):",
|
||||
[UI_MENU_AMIIBO_NO_DIR] = "无法打开文件夹 %s",
|
||||
[UI_MENU_AMIIBO_READER] = "NFC 读取器",
|
||||
[UI_MENU_AMIIBO_STATE] = "读取器:",
|
||||
[UI_MENU_AMIIBO_STATE_IDLE] = "就绪",
|
||||
[UI_MENU_AMIIBO_STATE_SEARCHING] = "游戏正在等待 amiibo",
|
||||
[UI_MENU_AMIIBO_STATE_FOUND] = "amiibo 已放在读取器上",
|
||||
[UI_MENU_AMIIBO_STATE_MOUNTED] = "游戏正在读取 amiibo",
|
||||
[UI_MENU_AMIIBO_STATE_OFF] = "已关闭",
|
||||
[UI_MENU_AMIIBO_FILE] = "已选文件:",
|
||||
[UI_MENU_AMIIBO_NO_FILE] = "(未选择文件)",
|
||||
[UI_MENU_AMIIBO_TAP] = "放上 amiibo",
|
||||
[UI_MENU_AMIIBO_REMOVE] = "拿开 amiibo",
|
||||
[UI_MENU_AMIIBO_AUTO_REMOVE] = "放上后自动拿开 amiibo",
|
||||
[UI_MENU_AMIIBO_HOLD] = "停留时间",
|
||||
[UI_MENU_AMIIBO_SECONDS] = "%.1f 秒",
|
||||
[UI_MENU_AMIIBO_TAG] = "读取器上的 amiibo:",
|
||||
[UI_MENU_AMIIBO_NO_TAG] = "读取器上没有 amiibo。",
|
||||
[UI_MENU_AMIIBO_TAG_FILE] = "文件:%s",
|
||||
[UI_MENU_AMIIBO_TAG_ID] = "角色 %s,系列 %02x,编号 %04x,类型 %02x",
|
||||
[UI_MENU_AMIIBO_TAG_UID] = "UID:%s",
|
||||
[UI_MENU_AMIIBO_READY] = "就绪",
|
||||
[UI_MENU_AMIIBO_TAPPED] = "已放上:%s",
|
||||
[UI_MENU_AMIIBO_LOAD_FAILED] = "不是 amiibo 转储(NTAG215,540 字节):%s",
|
||||
[UI_MENU_AMIIBO_REMOVED] = "已拿开 amiibo",
|
||||
[UI_MENU_AMIIBO_STATUS] = "状态:%s",
|
||||
[UI_MENU_MENU_LANG] = "菜单语言",
|
||||
[UI_MENU_MENU_LANG_DESC] = "本菜单和性能浮层的语言。",
|
||||
[UI_MENU_MENU_LANG_AUTO] = "自动(跟随 Windows)",
|
||||
|
||||
+13
-2
@@ -15,8 +15,8 @@ typedef enum {
|
||||
// Simplified Chinese texts.
|
||||
UI_MENU_FIRST,
|
||||
UI_MENU_TITLE = UI_MENU_FIRST,
|
||||
UI_MENU_TAB_SCREEN, UI_MENU_TAB_GAME, UI_MENU_TAB_SOUND, UI_MENU_TAB_CONTROLS, UI_MENU_TAB_MENU,
|
||||
UI_MENU_TAB_ADVANCED,
|
||||
UI_MENU_TAB_SCREEN, UI_MENU_TAB_GAME, UI_MENU_TAB_SOUND, UI_MENU_TAB_CONTROLS, UI_MENU_TAB_AMIIBO,
|
||||
UI_MENU_TAB_MENU, UI_MENU_TAB_ADVANCED,
|
||||
UI_MENU_CONTINUE, UI_MENU_QUIT,
|
||||
UI_MENU_ON, UI_MENU_OFF, UI_MENU_AUTO, UI_MENU_DEFAULT_MARK, // "default" beside the default value
|
||||
UI_MENU_AFTER_RESTART, // note on a setting that is read at start
|
||||
@@ -112,6 +112,17 @@ typedef enum {
|
||||
UI_PAD_ZR, UI_PAD_LPADDLE1, UI_PAD_RPADDLE1, UI_PAD_LPADDLE2, UI_PAD_RPADDLE2,
|
||||
UI_PAD_CROSS, UI_PAD_CIRCLE, UI_PAD_SQUARE, UI_PAD_TRIANGLE,
|
||||
|
||||
// Amiibo tab (ui/amiibo_page.cpp): the dump folder and its files, the emulated NFC reader and its state, the
|
||||
// amiibo on it and the last action
|
||||
UI_MENU_AMIIBO_DIR, UI_MENU_AMIIBO_OPEN, UI_MENU_AMIIBO_DEFAULT_DIR, UI_MENU_AMIIBO_REFRESH, UI_MENU_AMIIBO_PICK,
|
||||
UI_MENU_AMIIBO_NO_DIR, UI_MENU_AMIIBO_READER, UI_MENU_AMIIBO_STATE, UI_MENU_AMIIBO_STATE_IDLE,
|
||||
UI_MENU_AMIIBO_STATE_SEARCHING, UI_MENU_AMIIBO_STATE_FOUND, UI_MENU_AMIIBO_STATE_MOUNTED,
|
||||
UI_MENU_AMIIBO_STATE_OFF, UI_MENU_AMIIBO_FILE, UI_MENU_AMIIBO_NO_FILE, UI_MENU_AMIIBO_TAP, UI_MENU_AMIIBO_REMOVE,
|
||||
UI_MENU_AMIIBO_AUTO_REMOVE, UI_MENU_AMIIBO_HOLD, UI_MENU_AMIIBO_SECONDS, UI_MENU_AMIIBO_TAG,
|
||||
UI_MENU_AMIIBO_NO_TAG, UI_MENU_AMIIBO_TAG_FILE, UI_MENU_AMIIBO_TAG_ID, UI_MENU_AMIIBO_TAG_UID,
|
||||
UI_MENU_AMIIBO_READY, UI_MENU_AMIIBO_TAPPED, UI_MENU_AMIIBO_LOAD_FAILED, UI_MENU_AMIIBO_REMOVED,
|
||||
UI_MENU_AMIIBO_STATUS,
|
||||
|
||||
// Menu tab
|
||||
UI_MENU_MENU_LANG, UI_MENU_MENU_LANG_DESC, UI_MENU_MENU_LANG_AUTO,
|
||||
|
||||
|
||||
Reference in new issue
Block a user