forked from Code-Hex/vz
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pointing_device.go
52 lines (43 loc) · 1.6 KB
/
pointing_device.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
52
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_11.h"
# include "virtualization_12.h"
*/
import "C"
import (
"github.com/Code-Hex/vz/v3/internal/objc"
)
// PointingDeviceConfiguration is an interface for a pointing device configuration.
type PointingDeviceConfiguration interface {
objc.NSObject
pointingDeviceConfiguration()
}
type basePointingDeviceConfiguration struct{}
func (*basePointingDeviceConfiguration) pointingDeviceConfiguration() {}
// USBScreenCoordinatePointingDeviceConfiguration is a struct that defines the configuration
// for a USB pointing device that reports absolute coordinates.
type USBScreenCoordinatePointingDeviceConfiguration struct {
*pointer
*basePointingDeviceConfiguration
}
var _ PointingDeviceConfiguration = (*USBScreenCoordinatePointingDeviceConfiguration)(nil)
// NewUSBScreenCoordinatePointingDeviceConfiguration creates a new USBScreenCoordinatePointingDeviceConfiguration.
//
// This is only supported on macOS 12 and newer, error will
// be returned on older versions.
func NewUSBScreenCoordinatePointingDeviceConfiguration() (*USBScreenCoordinatePointingDeviceConfiguration, error) {
if err := macOSAvailable(12); err != nil {
return nil, err
}
config := &USBScreenCoordinatePointingDeviceConfiguration{
pointer: objc.NewPointer(
C.newVZUSBScreenCoordinatePointingDeviceConfiguration(),
),
}
objc.SetFinalizer(config, func(self *USBScreenCoordinatePointingDeviceConfiguration) {
objc.Release(self)
})
return config, nil
}