Skip to content

feat(macos): implement Unicode text input#4980

Open
boomyao wants to merge 1 commit intoLizardByte:masterfrom
boomyao:feat/macos-unicode-input
Open

feat(macos): implement Unicode text input#4980
boomyao wants to merge 1 commit intoLizardByte:masterfrom
boomyao:feat/macos-unicode-input

Conversation

@boomyao
Copy link
Copy Markdown

@boomyao boomyao commented Apr 12, 2026

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 a CGEvent keyboard event using CGEventKeyboardSetUnicodeString(). 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 because platf::unicode() was unimplemented.

Screenshot

Issues Fixed or Closed

Roadmap Issues

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Unit tests have been added or updated for any new or modified functionality

AI Usage

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

@ReenigneArcher ReenigneArcher added the ai PR has signs of heavy ai usage (either indicated by user or assumed) label Apr 12, 2026
@ReenigneArcher

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).
@ReenigneArcher ReenigneArcher force-pushed the feat/macos-unicode-input branch from b998390 to 71781b8 Compare April 17, 2026 20:27
@ReenigneArcher
Copy link
Copy Markdown
Member

There are clang format issues in this PR. Don't worry, it's easy to fix.

  1. Create and activate a python venv in your workspace (optional) - https://docs.python.org/3/library/venv.html#creating-virtual-environments

  2. Install dependencies with the following command:

    python -m pip install ".[lint]"
  3. Run the following command to fix lint issues:

    python scripts\update_clang_format.py

@sonarqubecloud
Copy link
Copy Markdown

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Bundle Report

Bundle size has no change ✅

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

❌ Patch coverage is 0% with 25 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@5ffa66e). Learn more about missing BASE report.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/platform/macos/input.cpp 0.00% 25 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #4980   +/-   ##
=========================================
  Coverage          ?   17.99%           
=========================================
  Files             ?      109           
  Lines             ?    23524           
  Branches          ?    10388           
=========================================
  Hits              ?     4232           
  Misses            ?    14988           
  Partials          ?     4304           
Flag Coverage Δ
Archlinux 11.59% <ø> (?)
FreeBSD-14.3-amd64 13.58% <ø> (?)
Homebrew-ubuntu-22.04 13.97% <ø> (?)
Linux-AppImage 12.26% <ø> (?)
Windows-AMD64 14.89% <ø> (?)
Windows-ARM64 13.23% <ø> (?)
macOS-arm64 18.99% <0.00%> (?)
macOS-x86_64 18.33% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/platform/macos/input.cpp 34.68% <0.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5ffa66e...71781b8. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai PR has signs of heavy ai usage (either indicated by user or assumed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants