Skip to content

input/osk: add Chinese keyboard pages (pinyin initial index) - #19735

Open
metahubaifeel wants to merge 1 commit into
libretro:masterfrom
metahubaifeel:chinese-osk-pages
Open

metahubaifeel wants to merge 1 commit into
libretro:masterfrom
metahubaifeel:chinese-osk-pages

Conversation

@metahubaifeel

Copy link
Copy Markdown

What this does

Adds a Chinese key page set to the on-screen keyboard used by menu text
entries (load-content search, playlist search, file browser filters, ...).

The OSK already has pages for Japanese kana and Korean (added with the
extended-IME work), and those work because their inventories are small —
24 jamo, 92 kana. Chinese is not: 3500+ common characters cannot be laid
out as a 4x11 grid the way those can.

So instead of trying to, this adds a two-level layout:

  • an index page holding a–z, and
  • 63 character pages, one per pinyin initial (a, b1–b3, c1–c3, …),
    each holding 30 of the most common characters for that initial.

Tapping an initial on the index jumps to that initial's first page.
Tapping a character appends it to the line. The house key returns to the index.

Why the character set is what it is

Rather than a hand-picked "top 1000 hanzi" list, the table is counted from
game titles that actually occur in playlists:

8171 titles
1515 distinct hanzi
21521 occurrences

Characters are grouped by pinyin initial, sorted by frequency within each
group, and cut into pages of 30. So the first page of each initial carries
the characters people are most likely to be looking for, and later pages
carry the long tail.

The generator that produces input/chinese_osk_pages.h is included in the
commit that adds the table — the table is generated, not maintained by hand.

Notes

  • Gated behind HAVE_LANGEXTRA with the other extra pages, so builds without
    it are byte-for-byte unaffected (OSK_TYPE_LAST stays where it was).
  • Characters are whole UTF-8 codepoints, so unlike Korean there is no
    composition step — input_keyboard_line_append() takes them directly.
  • Every page array is exactly 44 entries; the commit includes the reasoning
    for the 30-per-page figure (11 columns, 4 rows, one row of functions and
    one key reserved on the last three rows).

Testing

  • Compiles for arm64-v8a (Android).
  • All 1515 characters verified present in the produced
    libretroarch-activity.so by byte comparison, against the source table.
  • OSK_TYPE_LAST and the enum/switch/table three-way consistency asserted
    by a script.

No on-device run. The test device is a vendor ROM that blocks adb input
injection (INJECT_EVENTS), so tapping through the keyboard could not be
automated. Reviewing the page layout on a device is welcome if you want it
before merge.

Related

If a platform already has a working system IME, that path is preferable and
still wins — this is for when there is none, or when the user is driving the
menu with a gamepad. On Android, input_android_system_keyboard (1.22+)
already covers the IME case, so this is complementary rather than a
replacement: a native panel takes priority when it is available, and these
pages cover the rest.

The on-screen keyboard behind the menu's text entries has pages for
Japanese kana and Korean since the extended-IME work, but nothing for
Chinese - which needs a different shape, since 3500+ common characters
cannot fit a 4x11 grid the way 24 jamo or 92 kana can.

Rather than a pinyin IME, this adds a two-level layout:

  * an index page holding a-z, and
  * 63 character pages, one per pinyin initial (a, b1-b3, c1-c3, ...),
    each holding 30 of the most common characters for that initial

The character set is not guesswork: it is counted from the game titles
that appear in playlists (8171 titles, 1515 distinct hanzi, 21521
occurrences), ordered by frequency, so the first page of each initial
holds the characters people look for most.

Tapping an initial on the index jumps to that initial's first page,
tapping a character appends it to the line, and the house key returns
to the index. Characters are whole UTF-8 codepoints, so unlike Korean
no composition step is needed.

Gated behind HAVE_LANGEXTRA like the other extra pages, so builds
without it are unaffected.

Verified: compiles, and all 1515 characters are present in the
resulting library by byte comparison. No on-device run - the test
device's ROM blocks adb input injection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant