-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsensor.go
More file actions
111 lines (89 loc) · 3.12 KB
/
sensor.go
File metadata and controls
111 lines (89 loc) · 3.12 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Code generated by idiomgen. DO NOT EDIT.
package sensor
import (
"unsafe"
capi "github.com/AndroidGoLab/ndk/capi/sensor"
)
// Sensor wraps the NDK ASensor handle.
type Sensor struct {
ptr *capi.ASensor
}
// cptr returns the underlying C pointer, or nil if h is nil.
// This allows passing optional (nullable) handle parameters to capi functions.
func (h *Sensor) cptr() *capi.ASensor {
if h == nil {
return nil
}
return h.ptr
}
// NewSensorFromPointer wraps a raw ASensor pointer.
func NewSensorFromPointer(ptr unsafe.Pointer) *Sensor {
return &Sensor{ptr: (*capi.ASensor)(ptr)}
}
// Pointer returns the underlying pointer as unsafe.Pointer.
func (h *Sensor) Pointer() unsafe.Pointer {
return unsafe.Pointer(h.ptr)
}
// UintPtr returns the underlying pointer as a uintptr.
// This is useful for interop with gomobile bind, golang.org/x/mobile,
// gioui.org, and other packages that represent native handles as uintptr.
func (h *Sensor) UintPtr() uintptr {
return uintptr(unsafe.Pointer(h.ptr))
}
// NewSensorFromUintPtr wraps a uintptr as a Sensor.
// The caller must ensure ptr points to a valid ASensor.
func NewSensorFromUintPtr(ptr uintptr) *Sensor {
return &Sensor{ptr: (*capi.ASensor)(unsafe.Pointer(ptr))}
}
// GetFifoMaxEventCount calls the underlying NDK function.
func (h *Sensor) GetFifoMaxEventCount() error {
return result(capi.ASensor_getFifoMaxEventCount(h.ptr))
}
// GetFifoReservedEventCount calls the underlying NDK function.
func (h *Sensor) GetFifoReservedEventCount() error {
return result(capi.ASensor_getFifoReservedEventCount(h.ptr))
}
// GetHandle calls the underlying NDK function.
func (h *Sensor) GetHandle() error {
return result(capi.ASensor_getHandle(h.ptr))
}
// GetHighestDirectReportRateLevel calls the underlying NDK function.
func (h *Sensor) GetHighestDirectReportRateLevel() error {
return result(capi.ASensor_getHighestDirectReportRateLevel(h.ptr))
}
// MinDelay returns the value directly.
func (h *Sensor) MinDelay() int32 {
return (int32)(capi.ASensor_getMinDelay(h.ptr))
}
// Name returns the value directly.
func (h *Sensor) Name() string {
return (string)(capi.ASensor_getName(h.ptr))
}
// GetReportingMode calls the underlying NDK function.
func (h *Sensor) GetReportingMode() error {
return result(capi.ASensor_getReportingMode(h.ptr))
}
// Resolution returns the value directly.
func (h *Sensor) Resolution() float32 {
return (float32)(capi.ASensor_getResolution(h.ptr))
}
// GetStringType returns the value directly.
func (h *Sensor) GetStringType() string {
return (string)(capi.ASensor_getStringType(h.ptr))
}
// Type returns the value directly.
func (h *Sensor) Type() int32 {
return (int32)(capi.ASensor_getType(h.ptr))
}
// Vendor returns the value directly.
func (h *Sensor) Vendor() string {
return (string)(capi.ASensor_getVendor(h.ptr))
}
// IsDirectChannelTypeSupported returns the value directly.
func (h *Sensor) IsDirectChannelTypeSupported(channelType int32) bool {
return (bool)(capi.ASensor_isDirectChannelTypeSupported(h.ptr, channelType))
}
// IsWakeUpSensor returns the value directly.
func (h *Sensor) IsWakeUpSensor() bool {
return (bool)(capi.ASensor_isWakeUpSensor(h.ptr))
}