moonlight-qt icon indicating copy to clipboard operation
moonlight-qt copied to clipboard

[Moonlight 5.0] Keystrokes sent from AppleScript are passed incorrectly to remote server

Open di11ard opened this issue 2 years ago • 8 comments

Describe the bug Moonlight 5.0 is not interpreting and passing keystrokes sent from AppleScript to the remote server correctly. "!@#$ QWERTY asdf 1234" is received by the remote PC as "1234 qwerty asdf 1234."

Special characters and uppercase characters are all received as though the shift key was never pressed. Furthermore, I have created/tested AppleScripts with the "using shift down" modifier, and there is no change in what is received by the remote computer. I never experienced this issue until installing Moonlight 5.0. I have confirmed that v4.3.1 does not have this issue, as I have rolled back since the functionality of sending capitalized letters and special characters is required for my environment.

Note: Typing from the client computer's keyboard (instead of using AppleScript to simulate typing) results in all characters being interpreted by the server PC correctly. This odd behavior that I believe only exists in Moonlight 5.0 is exclusively related to sending and typing text via AppleScript Keystroke or Keycode commands.

Steps to reproduce

  1. Open Notepad on a server running Sunshine or Gamestream and set the notepad application as the primary focus on the remote computer.
  2. Run the following AppleScript from the client Mac:
set output_chat_message to "!@#$ QWERTY asdf 1234"

tell application "Moonlight" to activate

tell application "System Events"
	repeat with thisChar in output_chat_message
		keystroke thisChar
		delay 0.01
	end repeat
	key code 76 #enter
end tell

Result: Screenshots CleanShot 2023-10-20 at 14 34 04@2x

Affected games This has not been tested in any specific game as I expect this will impact all programs when conditions outlined above are met.

Other Moonlight clients N/A

Moonlight settings (please complete the following information)

  • Have any settings been adjusted from defaults?
    • Unsure, as I have toggled many settings in attempts to find a solution.
  • If so, which settings have been changed? N/A
    • My current settings shown here: CleanShot 2023-10-20 at 14 43 00@2x

Client PC details (please complete the following information)

  • OS: MacOS Sonoma 14.0
  • Moonlight Version: 5.0
  • GPU: Apple Silicon M1 Max

Server PC details (please complete the following information)

  • OS: Windows 11 Pro 22H2
  • GeForce Experience version: 3.27.0.112
  • Nvidia GPU driver: 545.84

Additional context I have not encountered this issue in previous versions of Moonlight. This issue seems to be exclusive to the latest version, Moonlight 5.0.

di11ard avatar Oct 20 '23 20:10 di11ard

I suspect the breakage is caused by this change to SDL: https://github.com/libsdl-org/SDL/commit/1c2f825230d8a1d406179f80192e3421054d688b

Nothing else between v4.3.1 and v5.0.0 seems relevant.

cgutman avatar Oct 24 '23 01:10 cgutman

I greatly appreciate your input. I'd love to try and troubleshoot this, but I am way out of my depth on this subject.

di11ard avatar Oct 31 '23 18:10 di11ard

Just to update, the bug is still in version 5.01.

di11ard avatar Nov 16 '23 16:11 di11ard

I've encountered the same issue. Modifier keys are not passed to the host machine. I'm trying to trigger Moonlight shortcuts with AppleScript. For example, the following command does no longer terminate my session:

tell application "System Events" to keystroke "q" using {control down, option down, shift down}

FelixLisczyk avatar Jan 08 '24 16:01 FelixLisczyk

Here is an Applescript that types the contents of the client's clipboard into the remote PC. Sadly, this script cannot be reliably used on any version of Moonlight newer than 4.3.1:

set output_message to the clipboard as string

tell application "System Events"
	repeat with thisChar in output_message
		keystroke thisChar
		delay 0.01
	end repeat
end tell

I invoke this applescript from a streamdeck, but this could easliy be used from a hotkey or via shortcuts. I wish I understood enough about how Moonlight is built to investigate this issue or try to fix.

di11ard avatar Jan 08 '24 17:01 di11ard

This was an SDL bug and should be fixed with the latest dependency sync. Please test https://ci.appveyor.com/project/cgutman/moonlight-qt/builds/49211978/job/2exqqybbsko35tww/artifacts

cgutman avatar Feb 17 '24 23:02 cgutman

It's working again with the new version. Thank you very much! 👍

FelixLisczyk avatar Feb 18 '24 12:02 FelixLisczyk

This was an SDL bug and should be fixed with the latest dependency sync. Please test https://ci.appveyor.com/project/cgutman/moonlight-qt/builds/49211978/job/2exqqybbsko35tww/artifacts

FIXED! THANK YOU!

di11ard avatar Feb 18 '24 19:02 di11ard

Released in v6.0.0

cgutman avatar Jun 06 '24 06:06 cgutman