-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent_queue.go
More file actions
81 lines (65 loc) · 2.73 KB
/
event_queue.go
File metadata and controls
81 lines (65 loc) · 2.73 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
// Code generated by idiomgen. DO NOT EDIT.
package sensor
import (
"unsafe"
capi "github.com/AndroidGoLab/ndk/capi/sensor"
)
// EventQueue wraps the NDK ASensorEventQueue handle.
type EventQueue struct {
ptr *capi.ASensorEventQueue
}
// cptr returns the underlying C pointer, or nil if h is nil.
// This allows passing optional (nullable) handle parameters to capi functions.
func (h *EventQueue) cptr() *capi.ASensorEventQueue {
if h == nil {
return nil
}
return h.ptr
}
// NewEventQueueFromPointer wraps a raw ASensorEventQueue pointer.
func NewEventQueueFromPointer(ptr unsafe.Pointer) *EventQueue {
return &EventQueue{ptr: (*capi.ASensorEventQueue)(ptr)}
}
// Pointer returns the underlying pointer as unsafe.Pointer.
func (h *EventQueue) 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 *EventQueue) UintPtr() uintptr {
return uintptr(unsafe.Pointer(h.ptr))
}
// NewEventQueueFromUintPtr wraps a uintptr as a EventQueue.
// The caller must ensure ptr points to a valid ASensorEventQueue.
func NewEventQueueFromUintPtr(ptr uintptr) *EventQueue {
return &EventQueue{ptr: (*capi.ASensorEventQueue)(unsafe.Pointer(ptr))}
}
// DisableSensor calls the underlying NDK function.
func (h *EventQueue) DisableSensor(sensor *Sensor) error {
return result(capi.ASensorEventQueue_disableSensor(h.ptr, sensor.cptr()))
}
// EnableSensor calls the underlying NDK function.
func (h *EventQueue) EnableSensor(sensor *Sensor) error {
return result(capi.ASensorEventQueue_enableSensor(h.ptr, sensor.cptr()))
}
// GetEvents returns the value directly.
func (h *EventQueue) GetEvents(events *SensorEvent, count uint64) int64 {
return (int64)(capi.ASensorEventQueue_getEvents(h.ptr, events.cptr(), count))
}
// HasEvents returns the value directly.
func (h *EventQueue) HasEvents() int32 {
return (int32)(capi.ASensorEventQueue_hasEvents(h.ptr))
}
// RegisterSensor calls the underlying NDK function.
func (h *EventQueue) RegisterSensor(sensor *Sensor, samplingPeriodUs int32, maxBatchReportLatencyUs int64) error {
return result(capi.ASensorEventQueue_registerSensor(h.ptr, sensor.cptr(), samplingPeriodUs, maxBatchReportLatencyUs))
}
// RequestAdditionalInfoEvents calls the underlying NDK function.
func (h *EventQueue) RequestAdditionalInfoEvents(enable bool) error {
return result(capi.ASensorEventQueue_requestAdditionalInfoEvents(h.ptr, enable))
}
// SetEventRate calls the underlying NDK function.
func (h *EventQueue) SetEventRate(sensor *Sensor, usec int32) error {
return result(capi.ASensorEventQueue_setEventRate(h.ptr, sensor.cptr(), usec))
}