Skip to content

socket synthesize-keyboard#156

Merged
beefon merged 10 commits into
macvmio:mainfrom
beefon:dev/beefon/synthesize-keyboard
Feb 21, 2026
Merged

socket synthesize-keyboard#156
beefon merged 10 commits into
macvmio:mainfrom
beefon:dev/beefon/synthesize-keyboard

Conversation

@beefon
Copy link
Copy Markdown
Contributor

@beefon beefon commented Feb 7, 2026

This PR implements keyboard synthesis. The proposal:

  • Window makes its single content view as a first responder - currently it is implicitly assumed that it is going to be view that renders VM. Maybe we might have a different subclass for window that renders VM, so it is easier to find it in NSApp.windows, and that window could make its vm view as first responder directly. I'm happy to try to do that in further PR.
  • Synthesised NSEvents are posted into that window.
  • It is useful to use socket JSON to send complex keyboard events.

Synthesised events are key presses of US ANSII keyboard. So actual result depends on the currently selected language in the target OS.

@beefon beefon requested a review from marciniwanicki February 7, 2026 14:30
Copy link
Copy Markdown
Contributor

@marciniwanicki marciniwanicki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @beefon, the keyboard interaction works very well. Happy to rename the command to "keyboard" to make it shorter.

import Foundation

public struct KeyboardInput: Codable {
public static let defaultdelayAfterStrokes = 0.1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename to defaultDelayAfterStrokes

// limitations under the License.
//

/// Human-friendly variants of various keys, mostly to make JSON user firendly.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"firendly" to "friendly"

@@ -0,0 +1,53 @@
//
// Copyright 2024 Marcin Iwanicki, Tomasz Jarosik, and contributors
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2026?

""".trimmingCharacters(in: .whitespacesAndNewlines))
}

func testKeyboardInput_KeyContent_NoModifiers() throws {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the test has "command" modifier so the name might be misleading.

@@ -0,0 +1,148 @@
// Copyright 2026 Marcin Iwanicki, Tomasz Jarosik, and contributors
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing // (for consistency)

@beefon beefon merged commit bb372a7 into macvmio:main Feb 21, 2026
3 checks passed
@beefon beefon deleted the dev/beefon/synthesize-keyboard branch February 21, 2026 14:35
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.

2 participants