diff --git a/NeuralNetworks.odin b/NeuralNetworks.odin index 35732cc..3c5d3a9 100644 --- a/NeuralNetworks.odin +++ b/NeuralNetworks.odin @@ -18,14 +18,14 @@ foreign android { * is no longer needed. * * Available since NNAPI feature level 4. - * Available since API feature level 30. + * Available since API level 30. * * @param desc The {@link ANeuralNetworksMemoryDesc} to be created. * Set to NULL if unsuccessful. * * @return ANEURALNETWORKS_NO_ERROR if successful. */ - int ANeuralNetworksMemoryDesc_create :: proc(desc: ^^ANeuralNetworksMemoryDesc) + ANeuralNetworksMemoryDesc_create :: proc(desc: ^^ANeuralNetworksMemoryDesc) -> NNResultCode --- /** * Destroy a memory descriptor. @@ -36,11 +36,12 @@ foreign android { * See {@link ANeuralNetworksMemoryDesc} for information on multithreaded usage. * * Available since NNAPI feature level 4. + * Available since API level 30. * * @param desc The memory descriptor to be destroyed. Passing NULL is acceptable and * results in no operation. */ - void ANeuralNetworksMemoryDesc_free(ANeuralNetworksMemoryDesc* desc) __NNAPI_INTRODUCED_IN(30); + ANeuralNetworksMemoryDesc_free :: proc(desc: ^ANeuralNetworksMemoryDesc) --- /** * Specify that a memory object will be playing the role of an input to an execution created from a @@ -68,6 +69,7 @@ foreign android { * See {@link ANeuralNetworksMemoryDesc} for information on multithreaded usage. * * Available since NNAPI feature level 4. + * Available since API level 30. * * @param desc The memory descriptor to be modified. * @param compilation The compilation object. It must already have been finished by calling @@ -84,10 +86,7 @@ foreign android { * * @return ANEURALNETWORKS_NO_ERROR if successful. */ - int ANeuralNetworksMemoryDesc_addInputRole(ANeuralNetworksMemoryDesc* desc, - const ANeuralNetworksCompilation* compilation, - uint32_t index, float frequency) - __NNAPI_INTRODUCED_IN(30); + ANeuralNetworksMemoryDesc_addInputRole :: proc(desc: ^ANeuralNetworksMemoryDesc, compilation: ^ANeuralNetworksCompilation, index: u32, frequency: f32) -> NNResultCode --- /** * Specify that a memory object will be playing the role of an output to an execution created from a @@ -115,6 +114,7 @@ foreign android { * See {@link ANeuralNetworksMemoryDesc} for information on multithreaded usage. * * Available since NNAPI feature level 4. + * Available since API level 30. * * @param desc The memory descriptor to be modified. * @param compilation The compilation object. It must already have been finished by calling @@ -131,10 +131,7 @@ foreign android { * * @return ANEURALNETWORKS_NO_ERROR if successful. */ - int ANeuralNetworksMemoryDesc_addOutputRole(ANeuralNetworksMemoryDesc* desc, - const ANeuralNetworksCompilation* compilation, - uint32_t index, float frequency) - __NNAPI_INTRODUCED_IN(30); + ANeuralNetworksMemoryDesc_addOutputRole :: proc(desc: ^ANeuralNetworksMemoryDesc, compilation: ^ANeuralNetworksCompilation, index: u32, frequency: f32) -> NNResultCode --- /** * Set the dimensional information of the memory descriptor. @@ -151,6 +148,7 @@ foreign android { * See {@link ANeuralNetworksMemoryDesc} for information on multithreaded usage. * * Available since NNAPI feature level 4. + * Available since API level 30. * * @param desc The memory descriptor to be modified. * @param rank The number of dimensions. Must be 0 for scalars. @@ -159,8 +157,7 @@ foreign android { * * @return ANEURALNETWORKS_NO_ERROR if successful. */ - int ANeuralNetworksMemoryDesc_setDimensions(ANeuralNetworksMemoryDesc* desc, uint32_t rank, - const uint32_t* dimensions) __NNAPI_INTRODUCED_IN(30); + ANeuralNetworksMemoryDesc_setDimensions :: proc(desc: ^ANeuralNetworksMemoryDesc, rank: u32, dimensions: [^]u32) -> NNResultCode --- /** * Indicate that we have finished modifying a memory descriptor. Required before calling @@ -171,12 +168,13 @@ foreign android { * See {@link ANeuralNetworksMemoryDesc} for information on multithreaded usage. * * Available since NNAPI feature level 4. + * Available since API level 30. * * @param desc The memory descriptor to be finished. * * @return ANEURALNETWORKS_NO_ERROR if successful. */ - int ANeuralNetworksMemoryDesc_finish(ANeuralNetworksMemoryDesc* desc) __NNAPI_INTRODUCED_IN(30); + ANeuralNetworksMemoryDesc_finish :: proc(desc: ^ANeuralNetworksMemoryDesc) -> NNResultCode --- /** * Creates a memory object from a memory descriptor. @@ -222,17 +220,17 @@ foreign android { * object. * * Available since NNAPI feature level 4. + * Available since API level 30. * * @param desc The memory descriptor. * @param memory The memory object to be created. * Set to NULL if unsuccessful. * - * @return ANEURALNETWORKS_NO_ERROR if successful; ANEURALNETWORKS_OP_FAILED if the memory is + * @return ANEURALNETWORKS_NO_ERROR if successful ANEURALNETWORKS_OP_FAILED if the memory is * created with unspecified dimensions or rank and it is not supported for this set of * roles. */ - int ANeuralNetworksMemory_createFromDesc(const ANeuralNetworksMemoryDesc* desc, - ANeuralNetworksMemory** memory) __NNAPI_INTRODUCED_IN(30); + ANeuralNetworksMemory_createFromDesc :: proc(desc: ^ANeuralNetworksMemoryDesc, memory: ^^ANeuralNetworksMemory) -> NNResultCode --- /** * Copies data from one memory object to another. @@ -264,14 +262,14 @@ foreign android { * logically with data layout transformation. * * Available since NNAPI feature level 4. + * Available since API level 30. * * @param src The source memory object. * @param dst The destination memory object. * * @return ANEURALNETWORKS_NO_ERROR if successful. */ - int ANeuralNetworksMemory_copy(const ANeuralNetworksMemory* src, const ANeuralNetworksMemory* dst) - __NNAPI_INTRODUCED_IN(30); + ANeuralNetworksMemory_copy :: proc(src: ^ANeuralNetworksMemory, dst: ^ANeuralNetworksMemory) -> NNResultCode --- /** * Get the number of available devices. @@ -281,8 +279,9 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if successful. * * Available since NNAPI feature level 3. + * Available since API level 29. */ - int ANeuralNetworks_getDeviceCount(uint32_t* numDevices) __NNAPI_INTRODUCED_IN(29); + ANeuralNetworks_getDeviceCount :: proc(numDevices: ^u32) -> NNResultCode --- /** * Get the representation of the specified device. @@ -296,9 +295,9 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if successful. * * Available since NNAPI feature level 3. + * Available since API level 29. */ - int ANeuralNetworks_getDevice(uint32_t devIndex, ANeuralNetworksDevice** device) - __NNAPI_INTRODUCED_IN(29); + ANeuralNetworks_getDevice :: proc(devIndex: u32, device: ^^ANeuralNetworksDevice) -> NNResultCode --- /** * Get the name of the specified device. @@ -316,9 +315,9 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if successful. * * Available since NNAPI feature level 3. + * Available since API level 29. */ - int ANeuralNetworksDevice_getName(const ANeuralNetworksDevice* device, const char** name) - __NNAPI_INTRODUCED_IN(29); + ANeuralNetworksDevice_getName :: proc(device: ^ANeuralNetworksDevice, name: ^cstring) -> NNResultCode --- /** * Get the type of a given device. @@ -335,9 +334,9 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if successful. * * Available since NNAPI feature level 3. + * Available since API level 29. */ - int ANeuralNetworksDevice_getType(const ANeuralNetworksDevice* device, int32_t* type) - __NNAPI_INTRODUCED_IN(29); + ANeuralNetworksDevice_getType :: proc(device: ^ANeuralNetworksDevice, type: ^DeviceTypeCode) -> NNResultCode --- /** * Get the version of the driver implementation of the specified device. @@ -365,9 +364,9 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if successful. * * Available since NNAPI feature level 3. + * Available since API level 29. */ - int ANeuralNetworksDevice_getVersion(const ANeuralNetworksDevice* device, const char** version) - __NNAPI_INTRODUCED_IN(29); + ANeuralNetworksDevice_getVersion :: proc(device: ^ANeuralNetworksDevice, version: ^cstring) -> NNResultCode --- /** * Get the NNAPI feature level of the specified NNAPI device. @@ -392,9 +391,9 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if successful. * * Available since NNAPI feature level 3. + * Available since API level 29. */ - int ANeuralNetworksDevice_getFeatureLevel(const ANeuralNetworksDevice* device, - int64_t* featureLevel) __NNAPI_INTRODUCED_IN(29); + ANeuralNetworksDevice_getFeatureLevel :: proc(device: ^ANeuralNetworksDevice, featureLevel: ^FeatureLevelCode) -> NNResultCode --- /** * Wait until the device is in a live state. @@ -409,8 +408,9 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if successful. * * Available since NNAPI feature level 4. + * Available since API level 30. */ - int ANeuralNetworksDevice_wait(const ANeuralNetworksDevice* device) __NNAPI_INTRODUCED_IN(30); + ANeuralNetworksDevice_wait :: proc(device: ^ANeuralNetworksDevice) -> NNResultCode --- /** * Get the supported operations for a specified set of devices. If multiple devices @@ -428,10 +428,9 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if successful. * * Available since NNAPI feature level 3. + * Available since API level 29. */ - int ANeuralNetworksModel_getSupportedOperationsForDevices( - const ANeuralNetworksModel* model, const ANeuralNetworksDevice* const* devices, - uint32_t numDevices, bool* supportedOps) __NNAPI_INTRODUCED_IN(29); + ANeuralNetworksModel_getSupportedOperationsForDevices :: proc(model: ^ANeuralNetworksModel, devices: [^]^ANeuralNetworksDevice, numDevices: u32, supportedOps: [^]bool) -> NNResultCode --- /** * Create a {@link ANeuralNetworksCompilation} to compile the given model for a specified set @@ -459,12 +458,9 @@ foreign android { * if the model is invalid. * * Available since NNAPI feature level 3. + * Available since API level 29. */ - int ANeuralNetworksCompilation_createForDevices(ANeuralNetworksModel* model, - const ANeuralNetworksDevice* const* devices, - uint32_t numDevices, - ANeuralNetworksCompilation** compilation) - __NNAPI_INTRODUCED_IN(29); + ANeuralNetworksCompilation_createForDevices :: proc(model: ^ANeuralNetworksModel, devices: [^]^ANeuralNetworksDevice, numDevices: u32, compilation: ^^ANeuralNetworksCompilation) -> NNResultCode --- /** * Sets the compilation caching signature and the cache directory. @@ -483,17 +479,16 @@ foreign android { * @param token The token provided by the user to specify a model must be of length * ANEURALNETWORKS_BYTE_SIZE_OF_CACHE_TOKEN. The user should ensure that * the token is unique to a model within the application. The NNAPI - * runtime cannot detect token collisions; a collision will result in a + * runtime cannot detect token collisions a collision will result in a * failed execution or in a successful execution that produces incorrect * output values. * * @return ANEURALNETWORKS_NO_ERROR if successful. * * Available since NNAPI feature level 3. + * Available since API level 29. */ - int ANeuralNetworksCompilation_setCaching(ANeuralNetworksCompilation* compilation, - const char* cacheDir, const uint8_t* token) - __NNAPI_INTRODUCED_IN(29); + ANeuralNetworksCompilation_setCaching :: proc(compilation: ^ANeuralNetworksCompilation, cacheDir: cstring, token: [^]byte) -> NNResultCode --- /** * Schedule synchronous evaluation of the execution. @@ -527,6 +522,7 @@ foreign android { * asynchronous execution with dependencies. * * Available since NNAPI feature level 3. + * Available since API level 29. * * @param execution The execution to be scheduled and executed. * @@ -534,7 +530,7 @@ foreign android { * ANEURALNETWORKS_UNMAPPABLE if the execution input or output memory cannot * be properly mapped. */ - int ANeuralNetworksExecution_compute(ANeuralNetworksExecution* execution) __NNAPI_INTRODUCED_IN(29); + ANeuralNetworksExecution_compute :: proc(execution: ^ANeuralNetworksExecution) -> NNResultCode --- /** * Get the dimensional information of the specified output operand of the model of the @@ -556,10 +552,9 @@ foreign android { * ANEURALNETWORKS_BAD_DATA if the index is invalid. * * Available since NNAPI feature level 3. + * Available since API level 29. */ - int ANeuralNetworksExecution_getOutputOperandRank(ANeuralNetworksExecution* execution, - int32_t index, uint32_t* rank) - __NNAPI_INTRODUCED_IN(29); + ANeuralNetworksExecution_getOutputOperandRank :: proc(execution: ^ANeuralNetworksExecution, index: i32, rank: ^u32) -> NNResultCode --- /** * Get the dimensional information of the specified output operand of the model of the @@ -582,10 +577,9 @@ foreign android { * ANEURALNETWORKS_BAD_DATA if the index is invalid or if the target is a scalar. * * Available since NNAPI feature level 3. + * Available since API level 29. */ - int ANeuralNetworksExecution_getOutputOperandDimensions(ANeuralNetworksExecution* execution, - int32_t index, uint32_t* dimensions) - __NNAPI_INTRODUCED_IN(29); + ANeuralNetworksExecution_getOutputOperandDimensions :: proc(execution: ^ANeuralNetworksExecution, index: i32, dimensions: [^]u32) -> NNResultCode --- /** * Create a {@link ANeuralNetworksBurst} to apply the given compilation. @@ -596,6 +590,7 @@ foreign android { *
The provided compilation must outlive the burst object.
* * Available since NNAPI feature level 3. + * Available since API level 29. * * @param compilation The {@link ANeuralNetworksCompilation} to be evaluated. * @param burst The newly created object or NULL if unsuccessful. @@ -603,18 +598,18 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if successful, ANEURALNETWORKS_BAD_DATA * if the compilation is invalid. */ - int ANeuralNetworksBurst_create(ANeuralNetworksCompilation* compilation, - ANeuralNetworksBurst** burst) __NNAPI_INTRODUCED_IN(29); + ANeuralNetworksBurst_create :: proc(compilation: ^ANeuralNetworksCompilation, burst: ^^ANeuralNetworksBurst) -> NNResultCode --- /** * Destroys the burst object. * * Available since NNAPI feature level 3. + * Available since API level 29. * * @param burst The burst object to be destroyed. Passing NULL is acceptable and * results in no operation. */ - void ANeuralNetworksBurst_free(ANeuralNetworksBurst* burst) __NNAPI_INTRODUCED_IN(29); + ANeuralNetworksBurst_free :: proc(burst: ^ANeuralNetworksBurst) --- /** * Schedule synchronous evaluation of the execution on a burst object. @@ -652,6 +647,7 @@ foreign android { * asynchronous execution with dependencies. * * Available since NNAPI feature level 3. + * Available since API level 29. * * @param burst The burst object to execute on. * @param execution The execution to be scheduled and executed. The execution @@ -660,8 +656,7 @@ foreign android { * * @return ANEURALNETWORKS_NO_ERROR if the execution completed normally. */ - int ANeuralNetworksExecution_burstCompute(ANeuralNetworksExecution* execution, - ANeuralNetworksBurst* burst) __NNAPI_INTRODUCED_IN(29); + ANeuralNetworksExecution_burstCompute :: proc(execution: ^ANeuralNetworksExecution, burst: ^ANeuralNetworksBurst) -> NNResultCode --- /** * Creates a shared memory object from an AHardwareBuffer handle. @@ -687,6 +682,7 @@ foreign android { * The provided AHardwareBuffer must outlive the ANeuralNetworksMemory object. * * Available since NNAPI feature level 3. + * Available since API level 29. * * @param ahwb The AHardwareBuffer handle. * @param memory The memory object to be created. @@ -696,11 +692,7 @@ foreign android { * * @see AHardwareBuffer */ - #ifdef __ANDROID__ - int ANeuralNetworksMemory_createFromAHardwareBuffer(const AHardwareBuffer* ahwb, - ANeuralNetworksMemory** memory) - __NNAPI_INTRODUCED_IN(29); - #endif // __ANDROID__ + ANeuralNetworksMemory_createFromAHardwareBuffer :: proc(ahwb: ^AHardwareBuffer, memory: ^^ANeuralNetworksMemory) -> NNResultCode --- /** @@ -721,14 +713,14 @@ foreign android { * See {@link ANeuralNetworksExecution} for information on execution states and multithreaded usage. * * Available since NNAPI feature level 3. + * Available since API level 29. * * @param execution The execution to be modified. * @param measure 'true' if duration is to be measured, 'false' if not. * * @return ANEURALNETWORKS_NO_ERROR if successful. */ - int ANeuralNetworksExecution_setMeasureTiming(ANeuralNetworksExecution* execution, bool measure) - __NNAPI_INTRODUCED_IN(29); + ANeuralNetworksExecution_setMeasureTiming :: proc(execution: ^ANeuralNetworksExecution, measure: bool) -> NNResultCode --- /** * Get the time spent in the latest computation evaluated on the specified @@ -751,10 +743,9 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if successful. * * Available since NNAPI feature level 3. + * Available since API level 29. */ - int ANeuralNetworksExecution_getDuration(const ANeuralNetworksExecution* execution, - int32_t durationCode, uint64_t* duration) - __NNAPI_INTRODUCED_IN(29); + ANeuralNetworksExecution_getDuration :: proc(execution: ^ANeuralNetworksExecution, durationCode: DurationCode, duration: ^u64) -> NNResultCode --- /** * Creates a shared memory object from a file descriptor. @@ -764,6 +755,7 @@ foreign android { * this shared memory. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param size The requested size in bytes. * Must not be larger than the file size. @@ -780,8 +772,7 @@ foreign android { * * @return ANEURALNETWORKS_NO_ERROR if the request completed normally. */ - int ANeuralNetworksMemory_createFromFd(size_t size, int protect, int fd, size_t offset, - ANeuralNetworksMemory** memory) __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksMemory_createFromFd :: proc(size: uint, protect: i32, fd: i32, offset: uint, memory: ^^ANeuralNetworksMemory) -> NNResultCode --- /** * Delete a memory object. @@ -791,11 +782,12 @@ foreign android { * handles to this memory. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param memory The memory object to be freed. Passing NULL is acceptable and * results in no operation. */ - void ANeuralNetworksMemory_free(ANeuralNetworksMemory* memory) __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksMemory_free :: proc(memory: ^ANeuralNetworksMemory) --- /** * Create an empty {@link ANeuralNetworksModel}. @@ -817,13 +809,14 @@ foreign android { * is no longer needed. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param model The {@link ANeuralNetworksModel} to be created. * Set to NULL if unsuccessful. * * @return ANEURALNETWORKS_NO_ERROR if successful. */ - int ANeuralNetworksModel_create(ANeuralNetworksModel** model) __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksModel_create :: proc(model: ^^ANeuralNetworksModel) -> NNResultCode --- /** * Destroy a model. @@ -834,11 +827,12 @@ foreign android { * See {@link ANeuralNetworksModel} for information on multithreaded usage. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param model The model to be destroyed. Passing NULL is acceptable and * results in no operation. */ - void ANeuralNetworksModel_free(ANeuralNetworksModel* model) __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksModel_free :: proc(model: ^ANeuralNetworksModel) --- /** * Indicate that we have finished modifying a model. Required before @@ -853,12 +847,13 @@ foreign android { * See {@link ANeuralNetworksModel} for information on multithreaded usage. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param model The model to be finished. * * @return ANEURALNETWORKS_NO_ERROR if successful. */ - int ANeuralNetworksModel_finish(ANeuralNetworksModel* model) __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksModel_finish :: proc(model: ^ANeuralNetworksModel) -> NNResultCode --- /** * Add an operand to a model. @@ -901,6 +896,7 @@ foreign android { * See {@link ANeuralNetworksModel} for information on multithreaded usage. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param model The model to be modified. * @param type The {@link ANeuralNetworksOperandType} that describes the shape @@ -910,9 +906,7 @@ foreign android { * * @return ANEURALNETWORKS_NO_ERROR if successful. */ - int ANeuralNetworksModel_addOperand(ANeuralNetworksModel* model, - const ANeuralNetworksOperandType* type) - __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksModel_addOperand :: proc(model: ^ANeuralNetworksModel, type: ^ANeuralNetworksOperandType) -> NNResultCode --- /** * Sets an operand to a constant value. @@ -941,6 +935,7 @@ foreign android { * See {@link ANeuralNetworksModel} for information on multithreaded usage. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param model The model to be modified. * @param index The index of the model operand we're setting. @@ -949,9 +944,7 @@ foreign android { * * @return ANEURALNETWORKS_NO_ERROR if successful. */ - int ANeuralNetworksModel_setOperandValue(ANeuralNetworksModel* model, int32_t index, - const void* buffer, size_t length) - __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksModel_setOperandValue :: proc(model: ^ANeuralNetworksModel, index: i32, buffer: rawptr, length: uint) -> NNResultCode --- /** * Sets an operand's per channel quantization parameters. @@ -963,6 +956,7 @@ foreign android { * calling {@link ANeuralNetworksModel_finish}. * * Available since NNAPI feature level 3. + * Available since API level 29. * * @param model The model to be modified. * @param index The index of the model operand we're setting. @@ -972,9 +966,7 @@ foreign android { * * @return ANEURALNETWORKS_NO_ERROR if successful. */ - int ANeuralNetworksModel_setOperandSymmPerChannelQuantParams( - ANeuralNetworksModel* model, int32_t index, - const ANeuralNetworksSymmPerChannelQuantParams* channelQuant) __NNAPI_INTRODUCED_IN(29); + ANeuralNetworksModel_setOperandSymmPerChannelQuantParams :: proc(model: ^ANeuralNetworksModel, index: i32, channelQuant: ^ANeuralNetworksSymmPerChannelQuantParams) -> NNResultCode --- /** * Sets an operand to a value stored in a memory object. @@ -1004,6 +996,7 @@ foreign android { * AHardwareBuffer usage. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param model The model to be modified. * @param index The index of the model operand we're setting. @@ -1014,10 +1007,7 @@ foreign android { * * @return ANEURALNETWORKS_NO_ERROR if successful. */ - int ANeuralNetworksModel_setOperandValueFromMemory(ANeuralNetworksModel* model, int32_t index, - const ANeuralNetworksMemory* memory, - size_t offset, size_t length) - __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksModel_setOperandValueFromMemory :: proc(model: ^ANeuralNetworksModel, index: i32, memory: ^ANeuralNetworksMemory, offset: uint, length: uint) -> NNResultCode --- /** * Sets an operand to a value that is a reference to another NNAPI model. @@ -1037,6 +1027,7 @@ foreign android { * See {@link ANeuralNetworksModel} for information on multithreaded usage. * * Available since NNAPI feature level 4. + * Available since API level 30. * * @param model The model to be modified. * @param index The index of the model operand we're setting. @@ -1044,9 +1035,7 @@ foreign android { * * @return ANEURALNETWORKS_NO_ERROR if successful. */ - int ANeuralNetworksModel_setOperandValueFromModel(ANeuralNetworksModel* model, int32_t index, - const ANeuralNetworksModel* value) - __NNAPI_INTRODUCED_IN(30); + ANeuralNetworksModel_setOperandValueFromModel :: proc(model: ^ANeuralNetworksModel, index: i32, value: ^ANeuralNetworksModel) -> NNResultCode --- /** * Add an operation to a model. @@ -1067,13 +1056,11 @@ foreign android { * See {@link ANeuralNetworksModel} for information on multithreaded usage. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @return ANEURALNETWORKS_NO_ERROR if successful. */ - int ANeuralNetworksModel_addOperation(ANeuralNetworksModel* model, - ANeuralNetworksOperationType type, uint32_t inputCount, - const uint32_t* inputs, uint32_t outputCount, - const uint32_t* outputs) __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksModel_addOperation :: proc(model: ^ANeuralNetworksModel, type: ANeuralNetworksOperationType, inputCount: u32, inputs: [^]u32, outputCount: u32, outputs: [^]u32) -> NNResultCode --- /** * Specifies which operands will be the model's inputs and @@ -1097,12 +1084,10 @@ foreign android { * See {@link ANeuralNetworksModel} for information on multithreaded usage. * * Available since NNAPI feature level 1. + * Available since API level 27. * */ - int ANeuralNetworksModel_identifyInputsAndOutputs(ANeuralNetworksModel* model, uint32_t inputCount, - const uint32_t* inputs, uint32_t outputCount, - const uint32_t* outputs) - __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksModel_identifyInputsAndOutputs :: proc(model: ^ANeuralNetworksModel, inputCount: u32, inputs: [^]u32, outputCount: u32, outputs: [^]u32) -> NNResultCode --- /** * Specifies whether {@link ANEURALNETWORKS_TENSOR_FLOAT32} is allowed to be @@ -1126,11 +1111,11 @@ foreign android { * called will return an error. * * Available since NNAPI feature level 2. + * Available since API level 28. * * See {@link ANeuralNetworksModel} for information on multithreaded usage. */ - int ANeuralNetworksModel_relaxComputationFloat32toFloat16(ANeuralNetworksModel* model, bool allow) - __NNAPI_INTRODUCED_IN(28); + ANeuralNetworksModel_relaxComputationFloat32toFloat16 :: proc(model: ^ANeuralNetworksModel, allow: bool) -> NNResultCode --- /** * Create a {@link ANeuralNetworksCompilation} to compile the given model. @@ -1156,6 +1141,7 @@ foreign android { * See {@link ANeuralNetworksCompilation} for information on multithreaded usage. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param model The {@link ANeuralNetworksModel} to be compiled. * @param compilation The newly created object or NULL if unsuccessful. @@ -1163,9 +1149,7 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if successful, ANEURALNETWORKS_BAD_DATA * if the model is invalid. */ - int ANeuralNetworksCompilation_create(ANeuralNetworksModel* model, - ANeuralNetworksCompilation** compilation) - __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksCompilation_create :: proc(model: ^ANeuralNetworksModel, compilation: ^^ANeuralNetworksCompilation) -> NNResultCode --- /** * Destroy a compilation. @@ -1176,12 +1160,12 @@ foreign android { * See {@link ANeuralNetworksCompilation} for information on multithreaded usage. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param compilation The compilation to be destroyed. Passing NULL is acceptable and * results in no operation. */ - void ANeuralNetworksCompilation_free(ANeuralNetworksCompilation* compilation) - __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksCompilation_free :: proc(compilation: ^ANeuralNetworksCompilation) --- /** * Sets the execution preference. @@ -1192,6 +1176,7 @@ foreign android { * See {@link ANeuralNetworksCompilation} for information on multithreaded usage. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param compilation The compilation to be modified. * @param preference Either {@link ANEURALNETWORKS_PREFER_LOW_POWER}, @@ -1200,8 +1185,7 @@ foreign android { * * @return ANEURALNETWORKS_NO_ERROR if successful. */ - int ANeuralNetworksCompilation_setPreference(ANeuralNetworksCompilation* compilation, - int32_t preference) __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksCompilation_setPreference :: proc(compilation: ^ANeuralNetworksCompilation, preference: PreferenceCode) -> NNResultCode --- /** * Indicate that we have finished modifying a compilation. Required before @@ -1221,13 +1205,13 @@ foreign android { * See {@link ANeuralNetworksCompilation} for information on multithreaded usage. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param compilation The compilation to be finished. * * @return ANEURALNETWORKS_NO_ERROR if successful. */ - int ANeuralNetworksCompilation_finish(ANeuralNetworksCompilation* compilation) - __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksCompilation_finish :: proc(compilation: ^ANeuralNetworksCompilation) -> NNResultCode --- /** * Set the execution priority. @@ -1244,6 +1228,7 @@ foreign android { * See {@link ANeuralNetworksCompilation} for information on multithreaded usage. * * Available since NNAPI feature level 4. + * Available since API level 30. * * @param compilation The compilation to be modified. * @param priority The relative priority of the execution compared to other @@ -1252,8 +1237,7 @@ foreign android { * * @return ANEURALNETWORKS_NO_ERROR if successful. */ - int ANeuralNetworksCompilation_setPriority(ANeuralNetworksCompilation* compilation, int priority) - __NNAPI_INTRODUCED_IN(30); + ANeuralNetworksCompilation_setPriority :: proc(compilation: ^ANeuralNetworksCompilation, priority: PriorityCode) -> NNResultCode --- /** * Set the maximum expected duration for compiling the model. @@ -1294,9 +1278,9 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if successful. * * Available since NNAPI feature level 4. + * Available since API level 30. */ - int ANeuralNetworksCompilation_setTimeout(ANeuralNetworksCompilation* compilation, - uint64_t duration) __NNAPI_INTRODUCED_IN(30); + ANeuralNetworksCompilation_setTimeout :: proc(compilation: ^ANeuralNetworksCompilation, duration: u64) -> NNResultCode --- /** * Create a {@link ANeuralNetworksExecution} to apply the given compilation. @@ -1311,6 +1295,7 @@ foreign android { * See {@link ANeuralNetworksExecution} for information on multithreaded usage. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param compilation The {@link ANeuralNetworksCompilation} to be evaluated. * @param execution The newly created object or NULL if unsuccessful. @@ -1318,8 +1303,7 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if successful, ANEURALNETWORKS_BAD_DATA * if the compilation is invalid. */ - int ANeuralNetworksExecution_create(ANeuralNetworksCompilation* compilation, - ANeuralNetworksExecution** execution) __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksExecution_create :: proc(compilation: ^ANeuralNetworksCompilation, execution: ^^ANeuralNetworksExecution) -> NNResultCode --- /** * Destroy an execution. @@ -1328,7 +1312,7 @@ foreign android { * {@link ANeuralNetworksExecution_burstCompute}, * {@link ANeuralNetworksExecution_compute}, * {@link ANeuralNetworksExecution_startCompute} or - * {@link ANeuralNetworksExecution_startComputeWithDependencies}; but if it has been scheduled, + * {@link ANeuralNetworksExecution_startComputeWithDependencies} but if it has been scheduled, * then the application must not call {@link ANeuralNetworksExecution_free} * until the execution has completed (i.e., * {@link ANeuralNetworksExecution_burstCompute}, @@ -1338,11 +1322,12 @@ foreign android { * See {@link ANeuralNetworksExecution} for information on multithreaded usage. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param execution The execution to be destroyed. Passing NULL is acceptable and * results in no operation. */ - void ANeuralNetworksExecution_free(ANeuralNetworksExecution* execution) __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksExecution_free :: proc(execution: ^ANeuralNetworksExecution) --- /** * Associate a user buffer with an input of the model of the @@ -1377,6 +1362,7 @@ foreign android { * preferred buffer alignment and padding, to improve performance. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param execution The execution to be modified. * @param index The index of the input argument we are setting. It is @@ -1400,9 +1386,7 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if successful, ANEURALNETWORKS_BAD_DATA if the * name is not recognized or the buffer is too small for the input. */ - int ANeuralNetworksExecution_setInput(ANeuralNetworksExecution* execution, int32_t index, - const ANeuralNetworksOperandType* type, const void* buffer, - size_t length) __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksExecution_setInput :: proc(execution: ^ANeuralNetworksExecution, index: i32, type: ^ANeuralNetworksOperandType, buffer: rawptr, length: uint) -> NNResultCode --- /** * Associate a region of a memory object with an input of the model of the @@ -1447,6 +1431,7 @@ foreign android { * preferred memory alignment and padding, to improve performance. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param execution The execution to be modified. * @param index The index of the input argument we are setting. It is @@ -1470,10 +1455,7 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if successful, ANEURALNETWORKS_BAD_DATA if the * name is not recognized or the buffer is too small for the input. */ - int ANeuralNetworksExecution_setInputFromMemory(ANeuralNetworksExecution* execution, int32_t index, - const ANeuralNetworksOperandType* type, - const ANeuralNetworksMemory* memory, size_t offset, - size_t length) __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksExecution_setInputFromMemory :: proc(execution: ^ANeuralNetworksExecution, index: i32, type: ^ANeuralNetworksOperandType, memory: ^ANeuralNetworksMemory, offset: uint, length: uint) -> NNResultCode --- /** * Associate a user buffer with an output of the model of the @@ -1507,6 +1489,7 @@ foreign android { * preferred buffer alignment and padding, to improve performance. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param execution The execution to be modified. * @param index The index of the output argument we are setting. It is @@ -1535,9 +1518,7 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if successful, ANEURALNETWORKS_BAD_DATA if the * name is not recognized or the buffer is too small for the output. */ - int ANeuralNetworksExecution_setOutput(ANeuralNetworksExecution* execution, int32_t index, - const ANeuralNetworksOperandType* type, void* buffer, - size_t length) __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksExecution_setOutput :: proc(execution: ^ANeuralNetworksExecution, index: i32, type: ^ANeuralNetworksOperandType, buffer: rawptr, length: uint) -> NNResultCode --- /** * Associate a region of a memory object with an output of the model of the @@ -1581,6 +1562,7 @@ foreign android { * preferred memory alignment and padding, to improve performance. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param execution The execution to be modified. * @param index The index of the output argument we are setting. It is @@ -1610,10 +1592,7 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if successful, ANEURALNETWORKS_BAD_DATA if the * name is not recognized or the buffer is too small for the output. */ - int ANeuralNetworksExecution_setOutputFromMemory(ANeuralNetworksExecution* execution, int32_t index, - const ANeuralNetworksOperandType* type, - const ANeuralNetworksMemory* memory, size_t offset, - size_t length) __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksExecution_setOutputFromMemory :: proc(execution: ^ANeuralNetworksExecution, index: i32, type: ^ANeuralNetworksOperandType, memory: ^ANeuralNetworksMemory, offset: uint, length: uint) -> NNResultCode --- /** * Schedule asynchronous evaluation of the execution. @@ -1660,6 +1639,7 @@ foreign android { * asynchronous execution with dependencies. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param execution The execution to be scheduled and executed. * @param event The event that will be signaled on completion. event is set to @@ -1667,8 +1647,7 @@ foreign android { * * @return ANEURALNETWORKS_NO_ERROR if the evaluation is successfully scheduled. */ - int ANeuralNetworksExecution_startCompute(ANeuralNetworksExecution* execution, - ANeuralNetworksEvent** event) __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksExecution_startCompute :: proc(execution: ^ANeuralNetworksExecution, event: ^^ANeuralNetworksEvent) -> NNResultCode --- /** * Set the maximum expected duration of the specified execution. @@ -1715,9 +1694,9 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if successful. * * Available since NNAPI feature level 4. + * Available since API level 30. */ - int ANeuralNetworksExecution_setTimeout(ANeuralNetworksExecution* execution, uint64_t duration) - __NNAPI_INTRODUCED_IN(30); + ANeuralNetworksExecution_setTimeout :: proc(execution: ^ANeuralNetworksExecution, duration: u64) -> NNResultCode --- /** * Set the maximum duration of WHILE loops in the specified execution. @@ -1746,9 +1725,9 @@ foreign android { * ANEURALNETWORKS_UNEXPECTED_NULL if execution is NULL. * * Available since NNAPI feature level 4. + * Available since API level 30. */ - int ANeuralNetworksExecution_setLoopTimeout(ANeuralNetworksExecution* execution, uint64_t duration) - __NNAPI_INTRODUCED_IN(30); + ANeuralNetworksExecution_setLoopTimeout :: proc(execution: ^ANeuralNetworksExecution, duration: u64) -> NNResultCode --- /** * Get the default timeout value for WHILE loops. @@ -1756,8 +1735,9 @@ foreign android { * @return The default timeout value in nanoseconds. * * Available since NNAPI feature level 4. + * Available since API level 30. */ - uint64_t ANeuralNetworks_getDefaultLoopTimeout() __NNAPI_INTRODUCED_IN(30); + ANeuralNetworks_getDefaultLoopTimeout :: proc() -> u64 --- /** * Get the maximum timeout value for WHILE loops. @@ -1765,8 +1745,9 @@ foreign android { * @return The maximum timeout value in nanoseconds. * * Available since NNAPI feature level 4. + * Available since API level 30. */ - uint64_t ANeuralNetworks_getMaximumLoopTimeout() __NNAPI_INTRODUCED_IN(30); + ANeuralNetworks_getMaximumLoopTimeout :: proc() -> u64 --- /** * Waits until the execution completes. @@ -1787,13 +1768,14 @@ foreign android { * See {@link ANeuralNetworksExecution} for information on execution states and multithreaded usage. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param event The event that will be signaled on completion. * @return ANEURALNETWORKS_NO_ERROR if the execution completed normally. * ANEURALNETWORKS_UNMAPPABLE if the execution input or output memory cannot * be properly mapped. */ - int ANeuralNetworksEvent_wait(ANeuralNetworksEvent* event) __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksEvent_wait :: proc(event: ^ANeuralNetworksEvent) -> NNResultCode --- /** * Destroys the event. @@ -1801,11 +1783,12 @@ foreign android { * See {@link ANeuralNetworksExecution} for information on multithreaded usage. * * Available since NNAPI feature level 1. + * Available since API level 27. * * @param event The event object to be destroyed. Passing NULL is acceptable and * results in no operation. */ - void ANeuralNetworksEvent_free(ANeuralNetworksEvent* event) __NNAPI_INTRODUCED_IN(27); + ANeuralNetworksEvent_free :: proc(event: ^ANeuralNetworksEvent) --- /** * Create a {@link ANeuralNetworksEvent} from a sync_fence file descriptor. @@ -1819,9 +1802,9 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if successful. * * Available since NNAPI feature level 4. + * Available since API level 30. */ - int ANeuralNetworksEvent_createFromSyncFenceFd(int sync_fence_fd, ANeuralNetworksEvent** event) - __NNAPI_INTRODUCED_IN(30); + ANeuralNetworksEvent_createFromSyncFenceFd :: proc(sync_fence_fd: i32, event: ^^ANeuralNetworksEvent) -> NNResultCode --- /** * Get sync_fence file descriptor from the event. @@ -1843,9 +1826,9 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if successful. * * Available since NNAPI feature level 4. + * Available since API level 30. */ - int ANeuralNetworksEvent_getSyncFenceFd(const ANeuralNetworksEvent* event, int* sync_fence_fd) - __NNAPI_INTRODUCED_IN(30); + ANeuralNetworksEvent_getSyncFenceFd :: proc(event: ^ANeuralNetworksEvent, sync_fence_fd: ^i32) -> NNResultCode --- /** * Schedule asynchronous evaluation of the execution with dependencies. @@ -1922,11 +1905,9 @@ foreign android { * @return ANEURALNETWORKS_NO_ERROR if the evaluation is successfully scheduled. * * Available since NNAPI feature level 4. + * Available since API level 30. */ - int ANeuralNetworksExecution_startComputeWithDependencies( - ANeuralNetworksExecution* execution, const ANeuralNetworksEvent* const* dependencies, - uint32_t num_dependencies, uint64_t duration, ANeuralNetworksEvent** event) - __NNAPI_INTRODUCED_IN(30); + ANeuralNetworksExecution_startComputeWithDependencies :: proc(execution: ^ANeuralNetworksExecution, dependencies: ^^ANeuralNetworksEvent, num_dependencies: u32, duration: u64, event: ^^ANeuralNetworksEvent) -> NNResultCode --- /** * Get the NNAPI runtime feature level. @@ -1946,9 +1927,9 @@ foreign android { * after NNAPI feature level 5 and API levels after S (31). * * Example usage: - * int device_api_level = android_get_device_api_level(); + * int device_api_level = android_get_device_api_level() * int64_t runtime_feature_level = (device_api_level < __ANDROID_API_S__) ? - * device_api_level : ANeuralNetworks_getRuntimeFeatureLevel(); + * device_api_level : ANeuralNetworks_getRuntimeFeatureLevel() * * Runtime feature level is closely related to NNAPI device feature level * ({@link ANeuralNetworksDevice_getFeatureLevel}), which indicates an NNAPI device feature level @@ -1962,8 +1943,9 @@ foreign android { * It is NOT an Android API level. * * Available since NNAPI feature level 5. + * Available since API level 31. */ - int64_t ANeuralNetworks_getRuntimeFeatureLevel() __NNAPI_INTRODUCED_IN(31); + ANeuralNetworks_getRuntimeFeatureLevel :: proc() -> FeatureLevelCode --- /** * Specifies whether the {@link ANeuralNetworksExecution} is able to accept padded input and output @@ -1998,9 +1980,9 @@ foreign android { * {@link ANeuralNetworksExecution_setOutputFromMemory} has been called on the execution. * * Available since NNAPI feature level 5. + * Available since API level 31. */ - int ANeuralNetworksExecution_enableInputAndOutputPadding(ANeuralNetworksExecution* execution, - bool enable) __NNAPI_INTRODUCED_IN(31); + ANeuralNetworksExecution_enableInputAndOutputPadding :: proc(execution: ^ANeuralNetworksExecution, enable: bool) -> NNResultCode --- /** * Get the preferred buffer and memory alignment of an input to an execution created from a @@ -2029,10 +2011,9 @@ foreign android { * ANEURALNETWORKS_BAD_DATA if the index is out of range. * * Available since NNAPI feature level 5. + * Available since API level 31. */ - int ANeuralNetworksCompilation_getPreferredMemoryAlignmentForInput( - const ANeuralNetworksCompilation* compilation, uint32_t index, uint32_t* alignment) - __NNAPI_INTRODUCED_IN(31); + ANeuralNetworksCompilation_getPreferredMemoryAlignmentForInput :: proc(compilation: ^ANeuralNetworksCompilation, index: u32, alignment: ^u32) -> NNResultCode --- /** * Get the preferred buffer and memory end padding of an input to an execution created from a @@ -2067,10 +2048,9 @@ foreign android { * ANEURALNETWORKS_BAD_DATA if the index is out of range. * * Available since NNAPI feature level 5. + * Available since API level 31. */ - int ANeuralNetworksCompilation_getPreferredMemoryPaddingForInput( - const ANeuralNetworksCompilation* compilation, uint32_t index, uint32_t* padding) - __NNAPI_INTRODUCED_IN(31); + ANeuralNetworksCompilation_getPreferredMemoryPaddingForInput :: proc(compilation: ^ANeuralNetworksCompilation, index: u32, padding: ^u32) -> NNResultCode --- /** * Get the preferred buffer and memory alignment of an output to an execution created from a @@ -2099,10 +2079,9 @@ foreign android { * ANEURALNETWORKS_BAD_DATA if the index is out of range. * * Available since NNAPI feature level 5. + * Available since API level 31. */ - int ANeuralNetworksCompilation_getPreferredMemoryAlignmentForOutput( - const ANeuralNetworksCompilation* compilation, uint32_t index, uint32_t* alignment) - __NNAPI_INTRODUCED_IN(31); + ANeuralNetworksCompilation_getPreferredMemoryAlignmentForOutput :: proc(compilation: ^ANeuralNetworksCompilation, index: u32, alignment: ^u32) -> NNResultCode --- /** * Get the preferred memory end padding of an output to an execution created from a particular @@ -2137,10 +2116,9 @@ foreign android { * ANEURALNETWORKS_BAD_DATA if the index is out of range. * * Available since NNAPI feature level 5. + * Available since API level 31. */ - int ANeuralNetworksCompilation_getPreferredMemoryPaddingForOutput( - const ANeuralNetworksCompilation* compilation, uint32_t index, uint32_t* padding) - __NNAPI_INTRODUCED_IN(31); + ANeuralNetworksCompilation_getPreferredMemoryPaddingForOutput :: proc(compilation: ^ANeuralNetworksCompilation, index: u32, padding: ^u32) -> NNResultCode --- /** * Specifies whether the {@link ANeuralNetworksExecution} can be reused for multiple computations. @@ -2166,7 +2144,7 @@ foreign android { * ANEURALNETWORKS_BAD_STATE if the execution is not in the preparation state. * * Available since NNAPI feature level 5. + * Available since API level 31. */ - int ANeuralNetworksExecution_setReusable(ANeuralNetworksExecution* execution, bool reusable) - __NNAPI_INTRODUCED_IN(31); + ANeuralNetworksExecution_setReusable :: proc(execution: ^ANeuralNetworksExecution, reusable: bool) -> NNResultCode --- } diff --git a/NeuralNetworksTypes.odin b/NeuralNetworksTypes.odin index 8a16b68..42ef31b 100644 --- a/NeuralNetworksTypes.odin +++ b/NeuralNetworksTypes.odin @@ -22,7 +22,7 @@ ANEURALNETWORKS_BYTE_SIZE_OF_CACHE_TOKEN :: 32 * Aliasing to {@link OperationCode}, used in function * {@link ANeuralNetworksModel_addOperation}. */ -ANeuralNetworksOperationType :: i32 +ANeuralNetworksOperationType :: OperationCode /** * Operand types. @@ -186,7 +186,7 @@ OperandCode :: enum i32 { * * Available since NNAPI feature level 1. */ -OperationCode :: enum { +OperationCode :: enum i32 { // Operations below are available since NNAPI feature level 1. /** @@ -5871,7 +5871,7 @@ PaddingCode :: enum { * * Available since NNAPI feature level 1. */ -PreferenceCode :: enum { +PreferenceCode :: enum i32 { /** * Prefer executing in a way that minimizes battery drain. * This is desirable for compilations that will be executed often. @@ -5894,7 +5894,7 @@ PreferenceCode :: enum { * * The type of NNAPI device. */ -DeviceTypeCode :: enum { +DeviceTypeCode :: enum i32 { /** The device type cannot be provided. */ UNKNOWN = 0, /** The device does not fall into any category below. */ @@ -5923,7 +5923,7 @@ DeviceTypeCode :: enum { * {@link ANeuralNetworks_getRuntimeFeatureLevel} must be compared against * these enum values instead of the Android API level. */ -FeatureLevelCode :: enum { +FeatureLevelCode :: enum i64 { /** NNAPI specification available in Android O-MR1, Android NNAPI feature level 1 */ LEVEL_1 = 27, /** NNAPI specification available in Android P, Android NNAPI feature level 2 */ @@ -5959,7 +5959,7 @@ FeatureLevelCode :: enum { * * Available since NNAPI feature level 1. */ -NNResultCode :: enum { +NNResultCode :: enum i32 { /** * Operation was successful. */ @@ -6060,7 +6060,7 @@ NNResultCode :: enum { * * Available since NNAPI feature level 3. */ -DurationCode :: enum { +DurationCode :: enum i32 { // Execution time on hardware (not driver, which runs on host processor). DURATION_ON_HARDWARE = 0, // Execution time in driver (including time on hardware). Excludes overhead @@ -6088,7 +6088,7 @@ DurationCode :: enum { * * Available since NNAPI feature level 4. */ -PriorityCode :: enum { +PriorityCode :: enum i32 { LOW = 90, MEDIUM = 100, HIGH = 110, diff --git a/imagedecoder.odin b/imagedecoder.odin index 7c8bca4..b422f01 100644 --- a/imagedecoder.odin +++ b/imagedecoder.odin @@ -147,27 +147,6 @@ AImageDecoderBlendOp :: enum i32 { SRC_OVER = 2, } -ResultOrRepeatCount :: union { - AImageDecoderResult, - AImageDecoderRepeatCount, - i32, -} - -ResultOrFrameDuration :: union { - AImageDecoderResult, - i64, -} - -ResultOrFrameDisposalOp :: union { - AImageDecoderResult, - AImageDecoderFrameDisposalOp, -} - -ResultOrBlendOp :: union { - AImageDecoderResult, - AImageDecoderBlendOp, -} - /** * Opaque handle for decoding images. * @@ -737,7 +716,7 @@ foreign android { * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER}: The AImageDecoder * is null. */ - AImageDecoder_getRepeatCount :: proc(decoder: ^AImageDecoder) -> ResultOrRepeatCount --- + AImageDecoder_getRepeatCount :: proc(decoder: ^AImageDecoder) -> i32 --- /** * Advance to the next frame in the animation. @@ -864,7 +843,7 @@ foreign android { * Errors: * - returns {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER} if |info| is null. */ - AImageDecoderFrameInfo_getDuration :: proc(info: ^AImageDecoderFrameInfo) -> ResultOrFrameDuration --- + AImageDecoderFrameInfo_getDuration :: proc(info: ^AImageDecoderFrameInfo) -> i64 --- /** * The rectangle of the image (within 0, 0, @@ -936,7 +915,7 @@ foreign android { * Errors: * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER} if |info| is null. */ - AImageDecoderFrameInfo_getDisposeOp :: proc(info: ^AImageDecoderFrameInfo) -> ResultOrFrameDisposalOp --- + AImageDecoderFrameInfo_getDisposeOp :: proc(info: ^AImageDecoderFrameInfo) -> i32 --- /** * Return how this frame is blended with the previous frame. @@ -954,7 +933,7 @@ foreign android { * Errors: * - {@link ANDROID_IMAGE_DECODER_BAD_PARAMETER} if |info| is null. */ - AImageDecoderFrameInfo_getBlendOp :: proc(info: ^AImageDecoderFrameInfo) -> ResultOrBlendOp --- + AImageDecoderFrameInfo_getBlendOp :: proc(info: ^AImageDecoderFrameInfo) -> i32 --- /** * Whether to have AImageDecoder store the frame prior to a diff --git a/jni.odin b/jni.odin index a013a84..31b6627 100644 --- a/jni.odin +++ b/jni.odin @@ -74,7 +74,7 @@ JNIEnv :: ^JNINativeInterface * Table of interface function pointers. */ JNINativeInterface :: struct { - reserved0: rawptr, + reserved0: rawptr, reserved1: rawptr, reserved2: rawptr, reserved3: rawptr, diff --git a/keycodes.odin b/keycodes.odin index 022548c..c9b468e 100644 --- a/keycodes.odin +++ b/keycodes.odin @@ -511,7 +511,7 @@ Keycode :: enum { MANNER_MODE = 205, /** 3D Mode key. * Toggles the display between 2D and 3D mode. */ - 3D_MODE = 206, + _3D_MODE = 206, /** Contacts special function key. * Used to launch an address book application. */ CONTACTS = 207, @@ -569,9 +569,9 @@ Keycode :: enum { * Goes to the top of media menu. */ MEDIA_TOP_MENU = 226, /** '11' key. */ - 11 = 227, + KEY_11 = 227, /** '12' key. */ - 12 = 228, + KEY_12 = 228, /** Last Channel key. * Goes to the last viewed channel. */ LAST_CHANNEL = 229, diff --git a/looper.odin b/looper.odin index 1b6a70e..f7da45d 100644 --- a/looper.odin +++ b/looper.odin @@ -12,7 +12,7 @@ foreign import android "system:android" * MUST check the return from these functions to discover when * data is available on such fds and process it. */ -ALOOPER_PREPARE_ALLOW_NON_CALLBACKS = 1<<0 +ALOOPER_PREPARE_ALLOW_NON_CALLBACKS :: 1<<0 /** Result from ALooper_pollOnce() and ALooper_pollAll(). */ ALooperPollResult :: enum i32 { @@ -41,11 +41,6 @@ ALooperPollResult :: enum i32 { ERROR = -4, } -PollResultOrIdent :: union { - ALooperPollResult, - i32, -} - /** * Flags for file descriptor events that a looper can monitor. * @@ -174,14 +169,14 @@ foreign android { * This method does not return until it has finished invoking the appropriate callbacks * for all file descriptors that were signalled. */ - ALooper_pollOnce :: proc(timeoutMillis: i32, outFd: ^i32, outEvents: ^i32, outData: ^rawptr) -> PollResultOrIdent --- + ALooper_pollOnce :: proc(timeoutMillis: i32, outFd: ^i32, outEvents: ^i32, outData: ^rawptr) -> i32 --- /** * Like ALooper_pollOnce(), but performs all pending callbacks until all * data has been consumed or a file descriptor is available with no callback. * This function will never return ALOOPER_POLL_CALLBACK. */ - ALooper_pollAll :: proc(timeoutMillis: i32, outFd: ^i32, outEvents: ^i32, outData: ^rawptr) -> PollResultOrIdent --- + ALooper_pollAll :: proc(timeoutMillis: i32, outFd: ^i32, outEvents: ^i32, outData: ^rawptr) -> i32 --- /** * Wakes the poll asynchronously. diff --git a/multinetwork.odin b/multinetwork.odin index 6bde84c..6bb63cd 100644 --- a/multinetwork.odin +++ b/multinetwork.odin @@ -14,7 +14,28 @@ foreign import android "system:android" */ net_handle_t :: distinct u64 +// TODO: these should probably be put in android's libc bindings or something uid_t :: u32 +socklen_t :: u32 // See: https://android.googlesource.com/platform/bionic/+/main/docs/32-bit-abi.md +sa_family_t :: u16 + +#assert(size_of(sockaddr) == 16) +sockaddr :: struct { + sa_family: sa_family_t, + sa_data: [14]byte, +} + +addrinfo :: struct { + ai_flags: i32, /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */ + ai_family: i32, /* PF_xxx */ + ai_socktype: i32, /* SOCK_xxx */ + ai_protocol: i32, /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ + ai_addrlen: socklen_t, /* length of ai_addr */ + ai_canonname: cstring, /* canonical name for hostname */ + ai_addr: ^sockaddr, /* binary address */ + ai_next: ^addrinfo, /* next structure in linked list */ +} + /** * The value NETWORK_UNSPECIFIED indicates no specific network. diff --git a/native_acitivty.odin b/native_acitivty.odin index f24acfb..3dd5155 100644 --- a/native_acitivty.odin +++ b/native_acitivty.odin @@ -256,9 +256,7 @@ foreign android { * *any* thread it will send a message to the main thread of the process * where the Java finish call will take place. */ - // TODO: wtf is format here ?? is there an enum or constants for this proc? - // I think this might be AHardwareBuffer_Format, but annoyingly so, it's u32 while this proc requires i32. - ANativeActivity_setWindowFormat :: proc(activity: ^ANativeActivity, format: i32) --- + ANativeActivity_setWindowFormat :: proc(activity: ^ANativeActivity, format: AHardwareBuffer_Format) --- /** * Change the window flags of the given activity. Calls getWindow().setFlags() diff --git a/native_window.odin b/native_window.odin index 4153a4e..6cd90f0 100644 --- a/native_window.odin +++ b/native_window.odin @@ -5,15 +5,15 @@ package android * Legacy window pixel format names, kept for backwards compatibility. * New code and APIs should use AHARDWAREBUFFER_FORMAT_*. */ -ANativeWindow_LegacyFormat :: enum { +ANativeWindow_LegacyFormat :: enum u32 { // NOTE: these values must match the values from graphics/common/x.x/types.hal /** Red: 8 bits, Green: 8 bits, Blue: 8 bits, Alpha: 8 bits. **/ - RGBA_8888 = AHardwareBuffer_Format.R8G8B8A8_UNORM, + RGBA_8888 = u32(AHardwareBuffer_Format.R8G8B8A8_UNORM), /** Red: 8 bits, Green: 8 bits, Blue: 8 bits, Unused: 8 bits. **/ - RGBX_8888 = AHardwareBuffer_Format.R8G8B8X8_UNORM, + RGBX_8888 = u32(AHardwareBuffer_Format.R8G8B8X8_UNORM), /** Red: 5 bits, Green: 6 bits, Blue: 5 bits. **/ - RGB_565 = AHardwareBuffer_Format.R5G6B5_UNORM, + RGB_565 = u32(AHardwareBuffer_Format.R5G6B5_UNORM), } /** @@ -93,8 +93,7 @@ ANativeWindow_Buffer :: struct { stride: i32, /// The format of the buffer. One of AHardwareBuffer_Format. - // TODO: u32/i32 mismatch with the enum. - int32_t format, + format: AHardwareBuffer_Format, /// The actual bits. bits: rawptr, @@ -136,8 +135,7 @@ foreign android { * * \return a negative value on error. */ - // TODO: should return AHardwarebuffer_Format but i32/u32 mismatch - ANativeWindow_getFormat :: proc(window: ^ANativeWindow) -> i32 --- + ANativeWindow_getFormat :: proc(window: ^ANativeWindow) -> AHardwareBuffer_Format --- /** * Change the format and size of the window buffers. diff --git a/obb.odin b/obb.odin new file mode 100644 index 0000000..c401991 --- /dev/null +++ b/obb.odin @@ -0,0 +1,39 @@ +//+build android +package android + +foreign import android "system:android" + +/** Flag for an obb file, returned by AObbInfo_getFlags(). */ +ObbFlags :: enum i32 { + OVERLAY = 0x0001, +} + +/** {@link AObbInfo} is an opaque type representing information for obb storage. */ +AObbInfo :: struct{} + +foreign android { + /** + * Scan an OBB and get information about it. + */ + AObbScanner_getObbInfo :: proc(filename: cstring) -> ^AObbInfo --- + + /** + * Destroy the AObbInfo object. You must call this when finished with the object. + */ + AObbInfo_delete :: proc(obbInfo: ^AObbInfo) --- + + /** + * Get the package name for the OBB. + */ + AObbInfo_getPackageName :: proc(obbInfo: ^AObbInfo) -> cstring --- + + /** + * Get the version of an OBB file. + */ + AObbInfo_getVersion :: proc(obbInfo: ^AObbInfo) -> i32 --- + + /** + * Get the flags of an OBB file. + */ + AObbInfo_getFlags :: proc(obbInfo: ^AObbInfo) -> ObbFlags --- +} diff --git a/performance_hint.odin b/performance_hint.odin new file mode 100644 index 0000000..da1d6f3 --- /dev/null +++ b/performance_hint.odin @@ -0,0 +1,127 @@ +//+build android +package android + +foreign import android "system:android" + +/** + * An opaque type representing a handle to a performance hint manager. + * It must be released after use. + * + *To use:
Each session is expected to have a periodic workload with a target duration for each + * cycle. The cycle duration is likely greater than the target work duration to allow other + * parts of the pipeline to run within the available budget. For example, a renderer thread may + * work at 60hz in order to produce frames at the display's frame but have a target work + * duration of only 6ms.
+ * + *After each cycle of work, the client is expected to use + * {@link APerformanceHint_reportActualWorkDuration} to report the actual time taken to + * complete.
+ * + *To use:
The system will attempt to adjust the core placement of the threads within the thread + * group and/or the frequency of the core on which they are run to bring the actual duration + * close to the target duration.
+ * + * Available since API level 33. + * + * @param session The performance hint session instance to update. + * @param actualDurationNanos how long the thread group took to complete its last task in + * nanoseconds. This must be positive. + * @return 0 on success + * EINVAL if actualDurationNanos is not positive. + * EPIPE if communication with the system service has failed. + */ + APerformanceHint_reportActualWorkDuration :: proc(session: ^APerformanceHintSession, actualDurationNanos: i64) -> i32 --- + + /** + * Release the performance hint manager pointer acquired via + * {@link APerformanceHint_createSession}. + * + * Available since API level 33. + * + * @param session The performance hint session instance to release. + */ + APerformanceHint_closeSession :: proc(session: ^APerformanceHintSession) --- +} + diff --git a/permission_manager.odin b/permission_manager.odin new file mode 100644 index 0000000..8b7e69d --- /dev/null +++ b/permission_manager.odin @@ -0,0 +1,68 @@ +//+build android +package android + +foreign import android "system:android" + +// TODO: move to libc or something +pid_t :: i32 + +/** + * Permission check results. + * + * Introduced in API 31. + */ +PermissionManagerResult :: enum i32 { + /** + * This is returned by APermissionManager_checkPermission() + * if the permission has been granted to the given package. + */ + PERMISSION_GRANTED = 0, + /** + * This is returned by APermissionManager_checkPermission() + * if the permission has not been granted to the given package. + */ + PERMISSION_DENIED = -1, +} + +/** + * Permission check return status values. + * + * Introduced in API 31. +*/ +PermissionManagerStatus :: enum i32 { + /** + * This is returned if the permission check completed without errors. + * The output result is valid and contains one of {::PERMISSION_MANAGER_PERMISSION_GRANTED, + * ::PERMISSION_MANAGER_PERMISSION_DENIED}. + */ + OK = 0, + /** + * This is returned if the permission check encountered an unspecified error. + * The output result is unmodified. + */ + ERROR_UNKNOWN = -1, + /** + * This is returned if the permission check failed because the service is + * unavailable. The output result is unmodified. + */ + SERVICE_UNAVAILABLE = -2, +} + +foreign android { + /** + * Checks whether the package with the given pid/uid has been granted a permission. + * + * Note that the Java API of Context#checkPermission() is usually faster due to caching, + * thus is preferred over this API wherever possible. + * + * Available since API level 31 + * + * @param permission the permission to be checked. + * @param pid the process id of the package to be checked. + * @param uid the uid of the package to be checked. + * @param outResult output of the permission check result. + * + * @return error codes if any error happened during the check. + */ + APermissionManager_checkPermission :: proc(permission: cstring, pid: pid_t, uid: uid_t, outResult: ^PermissionManagerResult) -> PermissionManagerStatus --- +} diff --git a/sensor.odin b/sensor.odin new file mode 100644 index 0000000..a88898e --- /dev/null +++ b/sensor.odin @@ -0,0 +1,1058 @@ +//+build android +package android + +foreign import android "system:android" + +/* + * A few useful constants + */ + +/** Earth's gravity in m/s^2 */ +ASENSOR_STANDARD_GRAVITY :: (9.80665) +/** Maximum magnetic field on Earth's surface in uT */ +ASENSOR_MAGNETIC_FIELD_EARTH_MAX :: (60.0) +/** Minimum magnetic field on Earth's surface in uT*/ +ASENSOR_MAGNETIC_FIELD_EARTH_MIN :: (30.0) + + +ASENSOR_RESOLUTION_INVALID :: f32(0h7ff80000_00000001) +ASENSOR_FIFO_COUNT_INVALID :: (-1) +ASENSOR_DELAY_INVALID :: min(i32) +ASENSOR_INVALID :: (-1) + +/** + * Sensor types. + * + * See + * [android.hardware.SensorEvent#values](https://developer.android.com/reference/android/hardware/SensorEvent.html#values) + * for detailed explanations of the data returned for each of these types. + */ +SensorType :: enum i32 { + /** + * Invalid sensor type. Returned by {@link ASensor_getType} as error value. + */ + INVALID = -1, + /** + * {@link ASENSOR_TYPE_ACCELEROMETER} + * reporting-mode: continuous + * + * All values are in SI units (m/s^2) and measure the acceleration of the + * device minus the force of gravity. + */ + ACCELEROMETER = 1, + /** + * {@link ASENSOR_TYPE_MAGNETIC_FIELD} + * reporting-mode: continuous + * + * All values are in micro-Tesla (uT) and measure the geomagnetic + * field in the X, Y and Z axis. + */ + MAGNETIC_FIELD = 2, + /** + * {@link ASENSOR_TYPE_GYROSCOPE} + * reporting-mode: continuous + * + * All values are in radians/second and measure the rate of rotation + * around the X, Y and Z axis. + */ + GYROSCOPE = 4, + /** + * {@link ASENSOR_TYPE_LIGHT} + * reporting-mode: on-change + * + * The light sensor value is returned in SI lux units. + */ + LIGHT = 5, + /** + * {@link ASENSOR_TYPE_PRESSURE} + * + * The pressure sensor value is returned in hPa (millibar). + */ + PRESSURE = 6, + /** + * {@link ASENSOR_TYPE_PROXIMITY} + * reporting-mode: on-change + * + * The proximity sensor which turns the screen off and back on during calls is the + * wake-up proximity sensor. Implement wake-up proximity sensor before implementing + * a non wake-up proximity sensor. For the wake-up proximity sensor set the flag + * SENSOR_FLAG_WAKE_UP. + * The value corresponds to the distance to the nearest object in centimeters. + */ + PROXIMITY = 8, + /** + * {@link ASENSOR_TYPE_GRAVITY} + * + * All values are in SI units (m/s^2) and measure the direction and + * magnitude of gravity. When the device is at rest, the output of + * the gravity sensor should be identical to that of the accelerometer. + */ + GRAVITY = 9, + /** + * {@link ASENSOR_TYPE_LINEAR_ACCELERATION} + * reporting-mode: continuous + * + * All values are in SI units (m/s^2) and measure the acceleration of the + * device not including the force of gravity. + */ + LINEAR_ACCELERATION = 10, + /** + * {@link ASENSOR_TYPE_ROTATION_VECTOR} + */ + ROTATION_VECTOR = 11, + /** + * {@link ASENSOR_TYPE_RELATIVE_HUMIDITY} + * + * The relative humidity sensor value is returned in percent. + */ + RELATIVE_HUMIDITY = 12, + /** + * {@link ASENSOR_TYPE_AMBIENT_TEMPERATURE} + * + * The ambient temperature sensor value is returned in Celcius. + */ + AMBIENT_TEMPERATURE = 13, + /** + * {@link ASENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED} + */ + MAGNETIC_FIELD_UNCALIBRATED = 14, + /** + * {@link ASENSOR_TYPE_GAME_ROTATION_VECTOR} + */ + GAME_ROTATION_VECTOR = 15, + /** + * {@link ASENSOR_TYPE_GYROSCOPE_UNCALIBRATED} + */ + GYROSCOPE_UNCALIBRATED = 16, + /** + * {@link ASENSOR_TYPE_SIGNIFICANT_MOTION} + */ + SIGNIFICANT_MOTION = 17, + /** + * {@link ASENSOR_TYPE_STEP_DETECTOR} + */ + STEP_DETECTOR = 18, + /** + * {@link ASENSOR_TYPE_STEP_COUNTER} + */ + STEP_COUNTER = 19, + /** + * {@link ASENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR} + */ + GEOMAGNETIC_ROTATION_VECTOR = 20, + /** + * {@link ASENSOR_TYPE_HEART_RATE} + */ + HEART_RATE = 21, + /** + * {@link ASENSOR_TYPE_POSE_6DOF} + */ + POSE_6DOF = 28, + /** + * {@link ASENSOR_TYPE_STATIONARY_DETECT} + */ + STATIONARY_DETECT = 29, + /** + * {@link ASENSOR_TYPE_MOTION_DETECT} + */ + MOTION_DETECT = 30, + /** + * {@link ASENSOR_TYPE_HEART_BEAT} + */ + HEART_BEAT = 31, + /** + * A constant describing a dynamic sensor meta event sensor. + * + * A sensor event of this type is received when a dynamic sensor is added to or removed from + * the system. This sensor type should always use special trigger report mode. + */ + DYNAMIC_SENSOR_META = 32, + /** + * This sensor type is for delivering additional sensor information aside + * from sensor event data. + * + * Additional information may include: + * - {@link ASENSOR_ADDITIONAL_INFO_INTERNAL_TEMPERATURE} + * - {@link ASENSOR_ADDITIONAL_INFO_SAMPLING} + * - {@link ASENSOR_ADDITIONAL_INFO_SENSOR_PLACEMENT} + * - {@link ASENSOR_ADDITIONAL_INFO_UNTRACKED_DELAY} + * - {@link ASENSOR_ADDITIONAL_INFO_VEC3_CALIBRATION} + * + * This type will never bind to a sensor. In other words, no sensor in the + * sensor list can have the type {@link ASENSOR_TYPE_ADDITIONAL_INFO}. + * + * If a device supports the sensor additional information feature, it will + * report additional information events via {@link ASensorEvent} and will + * have the type of {@link ASensorEvent} set to + * {@link ASENSOR_TYPE_ADDITIONAL_INFO} and the sensor of {@link ASensorEvent} set + * to the handle of the reporting sensor. + * + * Additional information reports consist of multiple frames ordered by + * {@link ASensorEvent#timestamp}. The first frame in the report will have + * a {@link AAdditionalInfoEvent#type} of + * {@link ASENSOR_ADDITIONAL_INFO_BEGIN}, and the last frame in the report + * will have a {@link AAdditionalInfoEvent#type} of + * {@link ASENSOR_ADDITIONAL_INFO_END}. + * + */ + ADDITIONAL_INFO = 33, + /** + * {@link ASENSOR_TYPE_LOW_LATENCY_OFFBODY_DETECT} + */ + LOW_LATENCY_OFFBODY_DETECT = 34, + /** + * {@link ASENSOR_TYPE_ACCELEROMETER_UNCALIBRATED} + */ + ACCELEROMETER_UNCALIBRATED = 35, + /** + * {@link ASENSOR_TYPE_HINGE_ANGLE} + * reporting-mode: on-change + * + * The hinge angle sensor value is returned in degrees. + */ + HINGE_ANGLE = 36, + /** + * {@link ASENSOR_TYPE_HEAD_TRACKER} + * reporting-mode: continuous + * + * Measures the orientation and rotational velocity of a user's head. Only for internal use + * within the Android system. + */ + HEAD_TRACKER = 37, + /** + * {@link ASENSOR_TYPE_ACCELEROMETER_LIMITED_AXES} + * reporting-mode: continuous + * + * The first three values are in SI units (m/s^2) and measure the acceleration of the device + * minus the force of gravity. The last three values indicate which acceleration axes are + * supported. A value of 1.0 means supported and a value of 0 means not supported. + */ + ACCELEROMETER_LIMITED_AXES = 38, + /** + * {@link ASENSOR_TYPE_GYROSCOPE_LIMITED_AXES} + * reporting-mode: continuous + * + * The first three values are in radians/second and measure the rate of rotation around the X, + * Y and Z axis. The last three values indicate which rotation axes are supported. A value of + * 1.0 means supported and a value of 0 means not supported. + */ + GYROSCOPE_LIMITED_AXES = 39, + /** + * {@link ASENSOR_TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED} + * reporting-mode: continuous + * + * The first three values are in SI units (m/s^2) and measure the acceleration of the device + * minus the force of gravity. The middle three values represent the estimated bias for each + * axis. The last three values indicate which acceleration axes are supported. A value of 1.0 + * means supported and a value of 0 means not supported. + */ + ACCELEROMETER_LIMITED_AXES_UNCALIBRATED = 40, + /** + * {@link ASENSOR_TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED} + * reporting-mode: continuous + * + * The first three values are in radians/second and measure the rate of rotation around the X, + * Y and Z axis. The middle three values represent the estimated drift around each axis in + * rad/s. The last three values indicate which rotation axes are supported. A value of 1.0 means + * supported and a value of 0 means not supported. + */ + GYROSCOPE_LIMITED_AXES_UNCALIBRATED = 41, + /** + * {@link ASENSOR_TYPE_HEADING} + * reporting-mode: continuous + * + * A heading sensor measures the direction in which the device is pointing + * relative to true north in degrees. + */ + HEADING = 42, +} + +/** + * Sensor accuracy measure. + */ +SensorStatus :: enum i8 { + NO_CONTACT = -1, + UNRELIABLE = 0, + ACCURACY_LOW = 1, + ACCURACY_MEDIUM = 2, + ACCURACY_HIGH = 3 +} + +/** + * Sensor Reporting Modes. + */ +SensorReportingMode :: enum i32 { + INVALID = -1, + CONTINUOUS = 0, + ON_CHANGE = 1, + ONE_SHOT = 2, + SPECIAL_TRIGGER = 3 +} + +/** + * Sensor Direct Report Rates. + */ + SensorDirectReportRate :: enum i32 { + /** stopped */ + STOP = 0, + /** nominal 50Hz */ + NORMAL = 1, + /** nominal 200Hz */ + FAST = 2, + /** nominal 800Hz */ + VERY_FAST = 3 +} + +/** + * Sensor Direct Channel Type. + */ + SensorDirectChannelType :: enum i32 { + /** shared memory created by ASharedMemory_create */ + SHARED_MEMORY = 1, + /** AHardwareBuffer */ + HARDWARE_BUFFER = 2 +} + +/** + * Sensor Additional Info Types. + * + * Used to populate {@link AAdditionalInfoEvent#type}. + */ +SensorAdditionalInfo :: enum i32 { + /** Marks the beginning of additional information frames */ + BEGIN = 0, + + /** Marks the end of additional information frames */ + END = 1, + + /** + * Estimation of the delay that is not tracked by sensor timestamps. This + * includes delay introduced by sensor front-end filtering, data transport, + * etc. + * float[2]: delay in seconds, standard deviation of estimated value + */ + UNTRACKED_DELAY = 0x10000, + + /** float: Celsius temperature */ + INTERNAL_TEMPERATURE, + + /** + * First three rows of a homogeneous matrix, which represents calibration to + * a three-element vector raw sensor reading. + * float[12]: 3x4 matrix in row major order + */ + VEC3_CALIBRATION, + + /** + * Location and orientation of sensor element in the device frame: origin is + * the geometric center of the mobile device screen surface; the axis + * definition corresponds to Android sensor definitions. + * float[12]: 3x4 matrix in row major order + */ + SENSOR_PLACEMENT, + + /** + * float[2]: raw sample period in seconds, + * standard deviation of sampling period + */ + SAMPLING, +} + +/** + * A sensor event. + */ + +/* NOTE: changes to these structs have to be backward compatible */ +ASensorVector :: struct { + using _: struct #raw_union { + v: [3]f32, + using _: struct { + x: f32, + y: f32, + z: f32, + }, + using _: struct { + azimuth: f32, + pitch: f32, + roll: f32, + }, + }, + status: SensorStatus, + reserved: [3]u8, +} + +// TODO: sensor might be SensorType here, will need some code to confirm though. +// Not sure what "what" is, maybe code will confirm this too. +AMetaDataEvent :: struct { + what: i32, + sensor: i32, +} + +AUncalibratedEvent :: struct { + using _: struct #raw_union { + uncalib: [3]f32, + using _: struct { + x_uncalib: f32, + y_uncalib: f32, + z_uncalib: f32, + }, + }, + using _: struct #raw_union { + bias: [3]f32, + using _: struct { + x_bias: f32, + y_bias: f32, + z_bias: f32, + }, + }, +} + +AHeartRateEvent :: struct { + bpm: f32, + status: SensorStatus, +} + +ADynamicSensorEvent :: struct { + connected: i32, + handle: i32, +} + +AAdditionalInfoEvent :: struct { + /** + * Event type, such as ASENSOR_ADDITIONAL_INFO_BEGIN, ASENSOR_ADDITIONAL_INFO_END and others. + * Refer to {@link ASENSOR_TYPE_ADDITIONAL_INFO} for the expected reporting behavior. + */ + type: SensorAdditionalInfo, + serial: i32, + using _: struct #raw_union { + data_int32: [14]i32, + data_float: [14]f32, + }, +} + +AHeadTrackerEvent :: struct { + /** + * The fields rx, ry, rz are an Euler vector (rotation vector, i.e. a vector + * whose direction indicates the axis of rotation and magnitude indicates + * the angle to rotate around that axis) representing the transform from + * the (arbitrary, possibly slowly drifting) reference frame to the + * head frame. Expressed in radians. Magnitude of the vector must be + * in the range [0, pi], while the value of individual axes are + * in the range [-pi, pi]. + */ + rx: f32, + ry: f32, + rz: f32, + + /** + * The fields vx, vy, vz are an Euler vector (rotation vector) representing + * the angular velocity of the head (relative to itself), in radians per + * second. The direction of this vector indicates the axis of rotation, and + * the magnitude indicates the rate of rotation. + */ + vx: f32, + vy: f32, + vz: f32, + + /** + * This value changes each time the reference frame is suddenly and + * significantly changed, for example if an orientation filter algorithm + * used for determining the orientation has had its state reset. + */ + discontinuity_count: i32, +} + +ALimitedAxesImuEvent :: struct { + using _: struct #raw_union { + calib: [3]f32, + using _: struct { + x: f32, + y: f32, + z: f32, + }, + }, + using _: struct #raw_union { + supported: [3]f32, + using _: struct { + x_supported: f32, + y_supported: f32, + z_supported: f32, + }, + }, +} + +ALimitedAxesImuUncalibratedEvent :: struct { + using _: struct #raw_union { + uncalib: [3]f32, + using _: struct { + x_uncalib: f32, + y_uncalib: f32, + z_uncalib: f32, + }, + }, + using _: struct #raw_union { + bias: [3]f32, + using _: struct { + x_bias: f32, + y_bias: f32, + z_bias: f32, + }, + }, + using _: struct #raw_union { + supported: [3]f32, + using _: struct { + x_supported: f32, + y_supported: f32, + z_supported: f32, + }, + }, +} + +AHeadingEvent :: struct { + /** + * The direction in which the device is pointing relative to true north in + * degrees. The value must be between 0.0 (inclusive) and 360.0 (exclusive), + * with 0 indicating north, 90 east, 180 south, and 270 west. + */ + heading: f32, + /** + * Accuracy is defined at 68% confidence. In the case where the underlying + * distribution is assumed Gaussian normal, this would be considered one + * standard deviation. For example, if the heading returns 60 degrees, and + * accuracy returns 10 degrees, then there is a 68 percent probability of + * the true heading being between 50 degrees and 70 degrees. + */ + accuracy: f32, +} + +// LINT.IfChange +/** + * Information that describes a sensor event, refer to + * SensorEvent for additional + * documentation. + * + * NOTE: changes to this struct has to be backward compatible and reflected in + * sensors_event_t + */ +ASensorEvent :: struct { + version: i32, /* sizeof(struct ASensorEvent) */ + sensor: i32, /** The sensor that generates this event */ + type: SensorType, /** Sensor type for the event, such as {@link ASENSOR_TYPE_ACCELEROMETER} */ + reserved0: i32, /** do not use */ + /** + * The time in nanoseconds at which the event happened, and its behavior + * is identical to + * SensorEvent::timestamp in Java API. + */ + timestamp: i64, + using _: struct #raw_union { + using _: struct #raw_union { + data: [16]f32, + vector: ASensorVector, + acceleration: ASensorVector, + gyro: ASensorVector, + magnetic: ASensorVector, + temperature: f32, + distance: f32, + light: f32, + pressure: f32, + relative_humidity: f32, + uncalibrated_acceleration: AUncalibratedEvent, + uncalibrated_gyro: AUncalibratedEvent, + uncalibrated_magnetic: AUncalibratedEvent, + meta_data: AMetaDataEvent, + heart_rate: AHeartRateEvent, + dynamic_sensor_meta: ADynamicSensorEvent, + additional_info: AAdditionalInfoEvent, + head_tracker: AHeadTrackerEvent, + limited_axes_imu: ALimitedAxesImuEvent, + limited_axes_imu_uncalibrated: ALimitedAxesImuUncalibratedEvent, + heading: AHeadingEvent, + }, + u64: struct #raw_union { + data: [8]u64, + step_counter: u64, + }, + }, + + flags: u32, + reserved1: [3]i32, +} + +/** + * {@link ASensorManager} is an opaque type to manage sensors and + * events queues. + * + * {@link ASensorManager} is a singleton that can be obtained using + * ASensorManager_getInstance(). + * + * This file provides a set of functions that uses {@link + * ASensorManager} to access and list hardware sensors, and + * create and destroy event queues: + * - ASensorManager_getSensorList() + * - ASensorManager_getDefaultSensor() + * - ASensorManager_getDefaultSensorEx() + * - ASensorManager_createEventQueue() + * - ASensorManager_destroyEventQueue() + */ +ASensorManager :: struct{} + + +/** + * {@link ASensorEventQueue} is an opaque type that provides access to + * {@link ASensorEvent} from hardware sensors. + * + * A new {@link ASensorEventQueue} can be obtained using ASensorManager_createEventQueue(). + * + * This file provides a set of functions to enable and disable + * sensors, check and get events, and set event rates on a {@link + * ASensorEventQueue}. + * - ASensorEventQueue_enableSensor() + * - ASensorEventQueue_disableSensor() + * - ASensorEventQueue_hasEvents() + * - ASensorEventQueue_getEvents() + * - ASensorEventQueue_setEventRate() + * - ASensorEventQueue_requestAdditionalInfoEvents() + */ +ASensorEventQueue :: struct{} + +/** + * {@link ASensor} is an opaque type that provides information about + * an hardware sensors. + * + * A {@link ASensor} pointer can be obtained using + * ASensorManager_getDefaultSensor(), + * ASensorManager_getDefaultSensorEx() or from a {@link ASensorList}. + * + * This file provides a set of functions to access properties of a + * {@link ASensor}: + * - ASensor_getName() + * - ASensor_getVendor() + * - ASensor_getType() + * - ASensor_getResolution() + * - ASensor_getMinDelay() + * - ASensor_getFifoMaxEventCount() + * - ASensor_getFifoReservedEventCount() + * - ASensor_getStringType() + * - ASensor_getReportingMode() + * - ASensor_isWakeUpSensor() + * - ASensor_getHandle() + */ +ASensor :: struct{} +/** + * {@link ASensorRef} is a type for constant pointers to {@link ASensor}. + * + * This is used to define entry in {@link ASensorList} arrays. + */ +ASensorRef :: ^ASensor +/** + * {@link ASensorList} is an array of reference to {@link ASensor}. + * + * A {@link ASensorList} can be initialized using ASensorManager_getSensorList(). + */ +ASensorList :: [^]ASensorRef + +foreign android { + /** + * Get a reference to the sensor manager. ASensorManager is a singleton + * per package as different packages may have access to different sensors. + * + * Deprecated: Use ASensorManager_getInstanceForPackage(const char*) instead. + * Deprecated since API level 26 + * + * Example: + * + * ASensorManager* sensorManager = ASensorManager_getInstance() + * + */ + @(deprecated="Use ASensorManager_getInstanceForPackage instead. Deprecated since API level 26.") + ASensorManager_getInstance :: proc() -> ^ASensorManager --- + + /** + * Get a reference to the sensor manager. ASensorManager is a singleton + * per package as different packages may have access to different sensors. + * + * Example: + * + * ASensorManager* sensorManager = ASensorManager_getInstanceForPackage("foo.bar.baz") + * + * Available since API level 26. + */ + ASensorManager_getInstanceForPackage :: proc(packageName: cstring) -> ^ASensorManager --- + + /** + * Returns the list of available sensors. The returned list is owned by the + * sensor manager and will not change between calls to this function. + * + * \param manager the {@link ASensorManager} instance obtained from + * {@link ASensorManager_getInstanceForPackage}. + * \param list the returned list of sensors. + * \return positive number of returned sensors or negative error code. + * BAD_VALUE: manager is NULL. + */ + ASensorManager_getSensorList :: proc(manager: ^ASensorManager, list: ^ASensorList) -> i32 --- + + /** + * Returns the list of available dynamic sensors. If there are no dynamic + * sensors available, returns nullptr in list. + * + * Each time this is called, the previously returned list is deallocated and + * must no longer be used. + * + * Clients should call this if they receive a sensor update from + * {@link ASENSOR_TYPE_DYNAMIC_SENSOR_META} indicating the sensors have changed. + * If this happens, previously received lists from this method will be stale. + * + * Available since API level 33. + * + * \param manager the {@link ASensorManager} instance obtained from + * {@link ASensorManager_getInstanceForPackage}. + * \param list the returned list of dynamic sensors. + * \return positive number of returned sensors or negative error code. + * BAD_VALUE: manager is NULL. + */ + ASensorManager_getDynamicSensorList :: proc(manager: ^ASensorManager, list: ^ASensorList) -> int --- + + /** + * Returns the default sensor for the given type, or NULL if no sensor + * of that type exists. + */ + ASensorManager_getDefaultSensor :: proc(manager: ^ASensorManager, type: SensorType) -> ^ASensor --- + + /** + * Returns the default sensor with the given type and wakeUp properties or NULL if no sensor + * of this type and wakeUp properties exists. + * + * Available since API level 21. + */ + ASensorManager_getDefaultSensorEx :: proc(manager: ^ASensorManager, type: SensorType, wakeUp: bool) -> ^ASensor --- + + /** + * Creates a new sensor event queue and associate it with a looper. + * + * "ident" is a identifier for the events that will be returned when + * calling ALooper_pollOnce(). The identifier must be >= 0, or + * ALOOPER_POLL_CALLBACK if providing a non-NULL callback. + */ + ASensorManager_createEventQueue :: proc(manager: ^ASensorManager, looper: ^ALooper, ident: i32, callback: ALooper_callbackFunc, data: rawptr) -> ^ASensorEventQueue --- + + /** + * Destroys the event queue and free all resources associated to it. + */ + ASensorManager_destroyEventQueue :: proc(manager: ^ASensorManager, queue: ^ASensorEventQueue) -> i32 --- + + /** + * Create direct channel based on shared memory + * + * Create a direct channel of {@link ASENSOR_DIRECT_CHANNEL_TYPE_SHARED_MEMORY} to be used + * for configuring sensor direct report. + * + * Available since API level 26. + * + * \param manager the {@link ASensorManager} instance obtained from + * {@link ASensorManager_getInstanceForPackage}. + * \param fd file descriptor representing a shared memory created by + * {@link ASharedMemory_create} + * \param size size to be used, must be less or equal to size of shared memory. + * + * \return a positive integer as a channel id to be used in + * {@link ASensorManager_destroyDirectChannel} and + * {@link ASensorManager_configureDirectReport}, or value less or equal to 0 for failures. + */ + ASensorManager_createSharedMemoryDirectChannel :: proc(manager: ^ASensorManager, fd: i32, size: uint) -> i32 --- + + /** + * Create direct channel based on AHardwareBuffer + * + * Create a direct channel of {@link ASENSOR_DIRECT_CHANNEL_TYPE_HARDWARE_BUFFER} type to be used + * for configuring sensor direct report. + * + * Available since API level 26. + * + * \param manager the {@link ASensorManager} instance obtained from + * {@link ASensorManager_getInstanceForPackage}. + * \param buffer {@link AHardwareBuffer} instance created by {@link AHardwareBuffer_allocate}. + * \param size the intended size to be used, must be less or equal to size of buffer. + * + * \return a positive integer as a channel id to be used in + * {@link ASensorManager_destroyDirectChannel} and + * {@link ASensorManager_configureDirectReport}, or value less or equal to 0 for failures. + */ + ASensorManager_createHardwareBufferDirectChannel :: proc(manager: ^ASensorManager, buffer: ^AHardwareBuffer, size: uint) -> i32 --- + + /** + * Destroy a direct channel + * + * Destroy a direct channel previously created by using one of + * ASensorManager_create*DirectChannel() derivative functions. + * Note that the buffer used for creating the direct channel does not get destroyed with + * ASensorManager_destroyDirectChannel and has to be closed or released separately. + * + * Available since API level 26. + * + * \param manager the {@link ASensorManager} instance obtained from + * {@link ASensorManager_getInstanceForPackage}. + * \param channelId channel id (a positive integer) returned from + * {@link ASensorManager_createSharedMemoryDirectChannel} or + * {@link ASensorManager_createHardwareBufferDirectChannel}. + */ + ASensorManager_destroyDirectChannel :: proc(manager: ^ASensorManager, channelId: i32) --- + + /** + * Configure direct report on channel + * + * Configure sensor direct report on a direct channel: set rate to value other than + * {@link ASENSOR_DIRECT_RATE_STOP} so that sensor event can be directly + * written into the shared memory region used for creating the buffer. It returns a positive token + * which can be used for identify sensor events from different sensors on success. Calling with rate + * {@link ASENSOR_DIRECT_RATE_STOP} will stop direct report of the sensor specified in the channel. + * + * To stop all active sensor direct report configured to a channel, set sensor to NULL and rate to + * {@link ASENSOR_DIRECT_RATE_STOP}. + * + * In order to successfully configure a direct report, the sensor has to support the specified rate + * and the channel type, which can be checked by {@link ASensor_getHighestDirectReportRateLevel} and + * {@link ASensor_isDirectChannelTypeSupported}, respectively. + * + * Example: + * + * ASensorManager *manager = ... + * ASensor *sensor = ... + * int channelId = ... + * + * ASensorManager_configureDirectReport(manager, sensor, channel_id, ASENSOR_DIRECT_RATE_FAST) + * + * Available since API level 26. + * + * \param manager the {@link ASensorManager} instance obtained from + * {@link ASensorManager_getInstanceForPackage}. + * \param sensor a {@link ASensor} to denote which sensor to be operate. It can be NULL if rate + * is {@link ASENSOR_DIRECT_RATE_STOP}, denoting stopping of all active sensor + * direct report. + * \param channelId channel id (a positive integer) returned from + * {@link ASensorManager_createSharedMemoryDirectChannel} or + * {@link ASensorManager_createHardwareBufferDirectChannel}. + * \param rate one of predefined ASENSOR_DIRECT_RATE_... that is supported by the sensor. + * \return positive token for success or negative error code. + */ + ASensorManager_configureDirectReport :: proc(manager: ^ASensorManager, sensor: ^ASensor, channelId: i32, rate: SensorDirectReportRate) -> i32 --- + + /*****************************************************************************/ + + /** + * Enable the selected sensor with sampling and report parameters + * + * Enable the selected sensor at a specified sampling period and max batch report latency. + * To disable sensor, use {@link ASensorEventQueue_disableSensor}. + * + * \param queue {@link ASensorEventQueue} for sensor event to be report to. + * \param sensor {@link ASensor} to be enabled. + * \param samplingPeriodUs sampling period of sensor in microseconds. + * \param maxBatchReportLatencyUs maximum time interval between two batches of sensor events are + * delievered in microseconds. For sensor streaming, set to 0. + * \return 0 on success or a negative error code on failure. + */ + ASensorEventQueue_registerSensor :: proc(queue: ^ASensorEventQueue, sensor: ^ASensor, samplingPeriodUs: i32, maxBatchReportLatencyUs: i64) -> i32 --- + + /** + * Enable the selected sensor at default sampling rate. + * + * Start event reports of a sensor to specified sensor event queue at a default rate. + * + * \param queue {@link ASensorEventQueue} for sensor event to be report to. + * \param sensor {@link ASensor} to be enabled. + * + * \return 0 on success or a negative error code on failure. + */ + ASensorEventQueue_enableSensor :: proc(queue: ^ASensorEventQueue, sensor: ^ASensor) -> i32 --- + + /** + * Disable the selected sensor. + * + * Stop event reports from the sensor to specified sensor event queue. + * + * \param queue {@link ASensorEventQueue} to be changed + * \param sensor {@link ASensor} to be disabled + * \return 0 on success or a negative error code on failure. + */ + ASensorEventQueue_disableSensor :: proc(queue: ^ASensorEventQueue, sensor: ^ASensor) -> i32 --- + + /** + * Sets the delivery rate of events in microseconds for the given sensor. + * + * This function has to be called after {@link ASensorEventQueue_enableSensor}. + * Note that this is a hint only, generally event will arrive at a higher + * rate. It is an error to set a rate inferior to the value returned by + * ASensor_getMinDelay(). + * + * \param queue {@link ASensorEventQueue} to which sensor event is delivered. + * \param sensor {@link ASensor} of which sampling rate to be updated. + * \param usec sensor sampling period (1/sampling rate) in microseconds + * \return 0 on sucess or a negative error code on failure. + */ + ASensorEventQueue_setEventRate :: proc(queue: ^ASensorEventQueue, sensor: ^ASensor, usec: i32) -> i32 --- + + /** + * Determine if a sensor event queue has pending event to be processed. + * + * \param queue {@link ASensorEventQueue} to be queried + * \return 1 if the queue has events 0 if it does not have events + * or a negative value if there is an error. + */ + ASensorEventQueue_hasEvents :: proc(queue: ^ASensorEventQueue) -> i32 --- + + /** + * Retrieve pending events in sensor event queue + * + * Retrieve next available events from the queue to a specified event array. + * + * \param queue {@link ASensorEventQueue} to get events from + * \param events pointer to an array of {@link ASensorEvent}. + * \param count max number of event that can be filled into array event. + * \return number of events returned on success negative error code when + * no events are pending or an error has occurred. + * + * Examples: + * + * ASensorEvent event + * ssize_t numEvent = ASensorEventQueue_getEvents(queue, &event, 1) + * + * ASensorEvent eventBuffer[8] + * ssize_t numEvent = ASensorEventQueue_getEvents(queue, eventBuffer, 8) + * + */ + ASensorEventQueue_getEvents :: proc(queue: ^ASensorEventQueue, events: [^]ASensorEvent, count: uint) -> int --- + + /** + * Request that {@link ASENSOR_TYPE_ADDITIONAL_INFO} events to be delivered on + * the given {@link ASensorEventQueue}. + * + * Sensor data events are always delivered to the {@link ASensorEventQueue}. + * + * The {@link ASENSOR_TYPE_ADDITIONAL_INFO} events will be returned through + * {@link ASensorEventQueue_getEvents}. The client is responsible for checking + * {@link ASensorEvent#type} to determine the event type prior to handling of + * the event. + * + * The client must be tolerant of any value for + * {@link AAdditionalInfoEvent#type}, as new values may be defined in the future + * and may delivered to the client. + * + * Available since API level 29. + * + * \param queue {@link ASensorEventQueue} to configure + * \param enable true to request {@link ASENSOR_TYPE_ADDITIONAL_INFO} events, + * false to stop receiving events + * \return 0 on success or a negative error code on failure + */ + ASensorEventQueue_requestAdditionalInfoEvents :: proc(queue: ^ASensorEventQueue, enable: bool) -> i32 --- + + /*****************************************************************************/ + + /** + * Returns this sensor's name (non localized) + */ + ASensor_getName :: proc(sensor: ^ASensor) -> cstring --- + + /** + * Returns this sensor's vendor's name (non localized) + */ + ASensor_getVendor :: proc(sensor: ^ASensor) -> cstring --- + + /** + * Return this sensor's type + */ + ASensor_getType :: proc(sensor: ^ASensor) -> SensorType --- + + /** + * Returns this sensors's resolution + */ + ASensor_getResolution :: proc(sensor: ^ASensor) -> f32 --- + + /** + * Returns the minimum delay allowed between events in microseconds. + * A value of zero means that this sensor doesn't report events at a + * constant rate, but rather only when a new data is available. + */ + ASensor_getMinDelay :: proc(sensor: ^ASensor) -> i32 --- + + /** + * Returns the maximum size of batches for this sensor. Batches will often be + * smaller, as the hardware fifo might be used for other sensors. + * + * Available since API level 21. + */ + ASensor_getFifoMaxEventCount :: proc(sensor: ^ASensor) -> i32 --- + + /** + * Returns the hardware batch fifo size reserved to this sensor. + * + * Available since API level 21. + */ + ASensor_getFifoReservedEventCount :: proc(sensor: ^ASensor) -> i32 --- + + /** + * Returns this sensor's string type. + * + * Available since API level 21. + */ + ASensor_getStringType :: proc(sensor: ^ASensor) -> cstring --- + + /** + * Returns the reporting mode for this sensor. One of AREPORTING_MODE_* constants. + * + * Available since API level 21. + */ + ASensor_getReportingMode :: proc(sensor: ^ASensor) -> SensorReportingMode --- + + /** + * Returns true if this is a wake up sensor, false otherwise. + * + * Available since API level 21. + */ + ASensor_isWakeUpSensor :: proc(sensor: ^ASensor) -> bool --- + + /** + * Test if sensor supports a certain type of direct channel. + * + * Available since API level 26. + * + * \param sensor a {@link ASensor} to denote the sensor to be checked. + * \param channelType Channel type constant, either + * {@link ASENSOR_DIRECT_CHANNEL_TYPE_SHARED_MEMORY} + * or {@link ASENSOR_DIRECT_CHANNEL_TYPE_HARDWARE_BUFFER}. + * \returns true if sensor supports the specified direct channel type. + */ + ASensor_isDirectChannelTypeSupported :: proc(sensor: ^ASensor, channelType: SensorDirectChannelType) -> bool --- + + /** + * Get the highest direct rate level that a sensor supports. + * + * Available since API level 26. + * + * \param sensor a {@link ASensor} to denote the sensor to be checked. + * + * \return a ASENSOR_DIRECT_RATE_... enum denoting the highest rate level supported by the sensor. + * If return value is {@link ASENSOR_DIRECT_RATE_STOP}, it means the sensor + * does not support direct report. + */ + ASensor_getHighestDirectReportRateLevel :: proc(sensor: ^ASensor) -> SensorDirectReportRate --- + + /** + * Returns the sensor's handle. + * + * The handle identifies the sensor within the system and is included in the + * sensor field of {@link ASensorEvent}, including those sent with type + * {@link ASENSOR_TYPE_ADDITIONAL_INFO}. + * + * A sensor's handle is able to be used to map {@link ASENSOR_TYPE_ADDITIONAL_INFO} events to the + * sensor that generated the event. + * + * It is important to note that the value returned by {@link ASensor_getHandle} is not the same as + * the value returned by the Java API + * android.hardware.Sensor's getId() and no mapping exists between the values. + * + * Available since API level 29. + */ + ASensor_getHandle :: proc(sensor: ^ASensor) -> i32 --- +}