-
-
Notifications
You must be signed in to change notification settings - Fork 50
/
keyboard_arm64.go
51 lines (45 loc) · 1.59 KB
/
keyboard_arm64.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//go:build darwin && arm64
// +build darwin,arm64
package vz
/*
#cgo darwin CFLAGS: -mmacosx-version-min=11 -x objective-c -fno-objc-arc
#cgo darwin LDFLAGS: -lobjc -framework Foundation -framework Virtualization
# include "virtualization_14_arm64.h"
*/
import "C"
import (
"github.com/Code-Hex/vz/v3/internal/objc"
)
// MacKeyboardConfiguration is a struct that defines the configuration
// for a Mac keyboard.
//
// This device is only recognized by virtual machines running macOS 14.0 and later.
// In order to support both macOS 13.0 and earlier guests, VirtualMachineConfiguration.keyboards
// can be set to an array containing both a MacKeyboardConfiguration and
// a USBKeyboardConfiguration object. macOS 14.0 and later guests will use the Mac keyboard device,
// while earlier versions of macOS will use the USB keyboard device.
//
// see: https://developer.apple.com/documentation/virtualization/vzmackeyboardconfiguration?language=objc
type MacKeyboardConfiguration struct {
*pointer
*baseKeyboardConfiguration
}
var _ KeyboardConfiguration = (*MacKeyboardConfiguration)(nil)
// NewMacKeyboardConfiguration creates a new MacKeyboardConfiguration.
//
// This is only supported on macOS 14 and newer, error will
// be returned on older versions.
func NewMacKeyboardConfiguration() (*MacKeyboardConfiguration, error) {
if err := macOSAvailable(14); err != nil {
return nil, err
}
config := &MacKeyboardConfiguration{
pointer: objc.NewPointer(
C.newVZMacKeyboardConfiguration(),
),
}
objc.SetFinalizer(config, func(self *MacKeyboardConfiguration) {
objc.Release(self)
})
return config, nil
}