wraith/internal/rdp/types.go
Vantz Stockwell 14b780c914 feat: RDP types, pixel buffer, and scancode mapping
Define the RDPBackend interface, RDPConfig, and FrameUpdate types that
abstract FreeRDP behind a pluggable backend. Add PixelBuffer for shared
RGBA frame management with partial-update support and dirty tracking.
Implement full 104-key US keyboard scancode map (JS KeyboardEvent.code
to RDP hardware scancodes) with extended-key detection helpers and
mouse event flag constants matching MS-RDPBCGR.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 07:17:12 -04:00

53 lines
1.9 KiB
Go

package rdp
// RDPConfig holds the parameters needed to establish an RDP connection.
type RDPConfig struct {
Hostname string // Remote host address
Port int // RDP port (default 3389)
Username string
Password string
Domain string // Windows domain (optional)
Width int // Desktop width in pixels
Height int // Desktop height in pixels
ColorDepth int // 16, 24, or 32
Security string // "nla", "tls", or "rdp"
}
// FrameUpdate represents a partial screen update from the RDP server.
// The data is in RGBA format (4 bytes per pixel).
type FrameUpdate struct {
X int // top-left X of the updated region
Y int // top-left Y of the updated region
Width int // width of the updated region in pixels
Height int // height of the updated region in pixels
Data []byte // RGBA pixel data, len = Width * Height * 4
}
// RDPBackend abstracts the FreeRDP implementation so that a mock can be
// used during development on platforms where FreeRDP is not available.
type RDPBackend interface {
// Connect establishes an RDP session with the given configuration.
Connect(config RDPConfig) error
// Disconnect tears down the RDP session.
Disconnect() error
// SendMouseEvent sends a mouse event with the given position and flags.
// Flags use the RDP mouse event flag constants (MouseFlag*).
SendMouseEvent(x, y int, flags uint32) error
// SendKeyEvent sends a keyboard event for the given RDP scancode.
// pressed=true for key down, false for key up.
SendKeyEvent(scancode uint32, pressed bool) error
// SendClipboard sends clipboard text to the remote session.
SendClipboard(data string) error
// GetFrame returns the current full-frame RGBA pixel buffer.
// The returned slice length is Width * Height * 4.
GetFrame() ([]byte, error)
// IsConnected reports whether the backend has an active connection.
IsConnected() bool
}