feat(macos): implement Unicode text input#4980
feat(macos): implement Unicode text input#4980boomyao wants to merge 1 commit intoLizardByte:masterfrom
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Implement the `platf::unicode()` function for macOS, which was previously a stub that only logged a "not yet implemented" message. The implementation converts incoming UTF-8 text to UTF-16 via CFString, then injects each character as a CGEvent keyboard event using `CGEventKeyboardSetUnicodeString()`. Surrogate pairs are handled correctly for characters outside the Basic Multilingual Plane. This enables Moonlight clients to send composed text (e.g., CJK characters from mobile IME) directly to the macOS host, matching the existing functionality on Windows (`SendInput` + `KEYEVENTF_UNICODE`) and Linux (`Ctrl+Shift+U` + hex code).
b998390 to
71781b8
Compare
|
There are clang format issues in this PR. Don't worry, it's easy to fix.
|
|
Bundle ReportBundle size has no change ✅ |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4980 +/- ##
=========================================
Coverage ? 17.99%
=========================================
Files ? 109
Lines ? 23524
Branches ? 10388
=========================================
Hits ? 4232
Misses ? 14988
Partials ? 4304
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
|



Description
Implement the
platf::unicode()function for macOS, which was previously a stub that only logged "Unicode input not yet implemented for MacOS".The implementation converts incoming UTF-8 text to UTF-16 via
CFString, then injects each character as aCGEventkeyboard event usingCGEventKeyboardSetUnicodeString(). Surrogate pairs are handled correctly for characters outside the Basic Multilingual Plane (e.g., emoji).This enables Moonlight clients to send composed text (e.g., CJK characters from mobile IME) directly to the macOS host, matching the existing functionality on Windows (
SendInput+KEYEVENTF_UNICODE) and Linux (Ctrl+Shift+U+ hex code).Context: When using Moonlight on Android/iOS with a Chinese/Japanese/Korean input method, the IME completes text composition locally and sends the final text via
LiSendUtf8TextEvent(). On Windows and Linux hosts, this text is correctly injected into the active application. On macOS, it was silently dropped becauseplatf::unicode()was unimplemented.Screenshot
Issues Fixed or Closed
Roadmap Issues
Type of Change
Checklist
AI Usage