ml_input.h
Classes
Name | |
---|---|
struct | MLInputControllerTouchpadGesture |
struct | MLInputControllerCallbacksEx A structure containing callbacks for input controller events. |
struct | MLInputControllerState A structure containing information about the current state of an input controller. |
struct | MLInputControllerStateEx A structure containing information about the current state of an input controller. |
struct | MLInputConnectedDevicesList A structure containing information about the connected devices. |
struct | MLInputPreDefinedPattern A structure containing information about the Pre-Defined pattern to be played. |
struct | MLInputBuzzCommand A structure containing information about the Buzz command to be played. |
struct | MLInputCustomHaptics A structure containing information about the Buzz command and/or pre-defined pattern to be played. |
struct | MLInputCustomHapticsInfo A structure containing a list of Buzz command and/or pre-defined patterns to be played. |
union | MLInputCustomHaptics.MLInputCustomHapticsPattern |
Types
Name | |
---|---|
typedef struct MLInputControllerTouchpadGesture | MLInputControllerTouchpadGesture |
typedef struct MLInputControllerCallbacksEx | MLInputControllerCallbacksEx A structure containing callbacks for input controller events. |
typedef struct MLInputControllerState | MLInputControllerState A structure containing information about the current state of an input controller. |
typedef struct MLInputControllerStateEx | MLInputControllerStateEx A structure containing information about the current state of an input controller. |
typedef struct MLInputConnectedDevicesList | MLInputConnectedDevicesList A structure containing information about the connected devices. |
typedef struct MLInputPreDefinedPattern | MLInputPreDefinedPattern A structure containing information about the Pre-Defined pattern to be played. |
typedef struct MLInputBuzzCommand | MLInputBuzzCommand A structure containing information about the Buzz command to be played. |
typedef struct MLInputCustomHaptics | MLInputCustomHaptics A structure containing information about the Buzz command and/or pre-defined pattern to be played. |
typedef struct MLInputCustomHapticsInfo | MLInputCustomHapticsInfo A structure containing a list of Buzz command and/or pre-defined patterns to be played. |
Enums
Functions
Name | |
---|---|
void | MLInputControllerCallbacksExInit(MLInputControllerCallbacksEx * inout_callbacks) Initializes default values for MLInputControllerCallbacksEx. |
void | MLInputControllerStateExInit(MLInputControllerStateEx inout_attr[MLInput_MaxControllers]) Initializes values for MLInputControllerStateEx. |
void | MLInputConnectedDevicesListInit(MLInputConnectedDevicesList * inout_devices_list) Initializes default values for MLInputConnectedDevicesList. |
void | MLInputPreDefinedPatternInit(MLInputPreDefinedPattern * inout_pattern) Initializes default values for MLInputPreDefinedPattern. |
void | MLInputBuzzCommandInit(MLInputBuzzCommand * inout_command) Initializes default values for MLInputBuzzCommand. |
void | MLInputCustomHapticsInfoInit(MLInputCustomHapticsInfo * inout_info) Initializes an array of MLInputCustomHaptics with default values. |
const char * | MLInputGetResultString(MLResult result) Returns an ASCII string for MLInputsResult and MLResult codes. |
MLResult | MLInputCreate(MLHandle * out_handle) Creates an input tracker. |
MLResult | MLInputSetControllerCallbacksEx(MLHandle handle, const MLInputControllerCallbacksEx controller_callbacks, void user_data) Sets the callbacks for controller input events. |
MLResult | MLInputGetControllerState(MLHandle handle, struct MLInputControllerState out_state[MLInput_MaxControllers]) Returns current state of all possible input controllers. |
MLResult | MLInputGetControllerStateEx(MLHandle handle, MLInputControllerStateEx out_state[MLInput_MaxControllers]) Returns current state of all possible input controllers. |
MLResult | MLInputGetConnectedDevices(MLHandle handle, MLInputConnectedDevicesList * inout_devices) Gets the device IDs of all connected devices. |
MLResult | MLInputReleaseConnectedDevicesList(MLHandle handle, MLInputConnectedDevicesList * devices) Releases the contents of MLInputConnectedDevicesList populated by MLInputGetConnectedDevices. |
MLResult | MLInputStartControllerFeedbackPreDefinedPattern(MLHandle handle, uint8_t controller_id, MLInputPreDefinedPattern * pattern) Plays the pre-defined pattern. |
MLResult | MLInputStartControllerFeedbackBuzzCommand(MLHandle handle, uint8_t controller_id, const MLInputBuzzCommand * command) Plays controller haptic buzz command. |
MLResult | MLInputCreateCustomHapticsPattern(MLHandle handle, MLInputCustomHapticsInfo info, uint32_t inout_pattern_id) Creates a custom haptic pattern. |
MLResult | MLInputStartControllerFeedbackCustomHapticsPattern(MLHandle handle, uint8_t controller_id, uint32_t pattern_id) Plays the custom haptic pattern created by MLInputCreateCustomHapticsPattern. |
MLResult | MLInputDeleteCustomHapticsPattern(MLHandle handle, uint32_t pattern_id) Deletes the custom haptic pattern created by MLInputCreateCustomHapticsPattern. |
MLResult | MLInputStopControllerFeedback(MLHandle handle, uint8_t controller_id) Stops the currently playing haptic pattern. |
MLResult | MLInputDestroy(MLHandle handle) Destroys an input tracker. |
Enums Documentation
Anonymous Enum 13
Enumerator | Value | Description |
---|---|---|
MLResultAPIPrefix_Input | ( 0x21DC << 16) | Defines the prefix for MLInputResult codes. |
MLInputResult
Enumerator | Value | Description |
---|---|---|
MLInputResult_ServiceNotAvailable | MLResultAPIPrefix_Input | |
MLInputResult_PermissionDenied | Operation failed because a required permission has not been granted. Example: This can happen when the app is not in the foreground. | |
MLInputResult_DeviceNotFound | Operation failed because a required device was not found. | |
MLInputResult_IllegalState | Operation failed because the service was in an illegal state. Example: This can occur when the service is still initializing. | |
MLInputResult_InternalError | Operation failed because of an internal error. | |
MLInputResult_SpeechDisabled | Operation failed because a required speech feature is disabled in system settings. | |
MLInputResult_Ensure32Bits | 0x7FFFFFFF | Ensure enum is represented as 32 bits. |
Return values for Input API calls.
Anonymous Enum 14
Enumerator | Value | Description |
---|---|---|
MLInput_MaxControllers | 1 | Maximum recognized number of input controllers. |
MLInput_MaxControllerTouchpadTouches | 2 | Maximum recognized number of controller touchpad touches. |
MLInputControllerTouchpadGestureState
Enumerator | Value | Description |
---|---|---|
MLInputControllerTouchpadGestureState_End | End(Default). | |
MLInputControllerTouchpadGestureState_Continue | Continue. | |
MLInputControllerTouchpadGestureState_Start | Start. | |
MLInputControllerTouchpadGestureState_Ensure32Bits | 0x7FFFFFFF | Ensure enum is represented as 32 bits. |
Touchpad gesture state.
MLInputControllerTouchpadGestureType
Enumerator | Value | Description |
---|---|---|
MLInputControllerTouchpadGestureType_None | None. | |
MLInputControllerTouchpadGestureType_Tap | Tap. This is a discrete gesture. | |
MLInputControllerTouchpadGestureType_ForceTapDown | Force tap down. This is a discrete gesture. | |
MLInputControllerTouchpadGestureType_ForceTapUp | Force tap up. This is a discrete gesture. | |
MLInputControllerTouchpadGestureType_ForceDwell | Force dwell. This is a discrete gesture. | |
MLInputControllerTouchpadGestureType_SecondForceDown | Second force down. This is a discrete gesture. | |
MLInputControllerTouchpadGestureType_RadialScroll | Radial scroll. This is a continuous gesture. | |
MLInputControllerTouchpadGestureType_Swipe | Swipe. This is a continuous gesture. | |
MLInputControllerTouchpadGestureType_Count | Number of gesture types. | |
MLInputControllerTouchpadGestureType_Ensure32Bits | 0x7FFFFFFF | Ensure enum is represented as 32 bits. |
Recognized touchpad gesture types.
MLInputControllerTouchpadGestureDirection
Enumerator | Value | Description |
---|---|---|
MLInputControllerTouchpadGestureDirection_None | None. | |
MLInputControllerTouchpadGestureDirection_Up | Up. | |
MLInputControllerTouchpadGestureDirection_Down | Down. | |
MLInputControllerTouchpadGestureDirection_Left | Left. | |
MLInputControllerTouchpadGestureDirection_Right | Right. | |
MLInputControllerTouchpadGestureDirection_Clockwise | Clockwise. | |
MLInputControllerTouchpadGestureDirection_CounterClockwise | Counter clockwise. | |
MLInputControllerTouchpadGestureDirection_Count | Number of directions. | |
MLInputControllerTouchpadGestureDirection_Ensure32Bits | 0x7FFFFFFF | Ensure enum is represented as 32 bits. |
Direction of touchpad gesture.
MLInputControllerType
Enumerator | Value | Description |
---|---|---|
MLInputControllerType_None | None. | |
MLInputControllerType_Device | Device. | |
MLInputControllerType_Ensure32Bits | 0x7FFFFFFF | Ensure enum is represented as 32 bits. |
Types of input controllers recognized by Magic Leap platform.
MLInputControllerButton
Enumerator | Value | Description |
---|---|---|
MLInputControllerButton_None | ||
MLInputControllerButton_Bumper | Bumper. | |
MLInputControllerButton_Menu | Menu. | |
MLInputControllerButton_Count | Number of buttons. | |
MLInputControllerButton_Ensure32Bits | 0x7FFFFFFF | Ensure enum is represented as 32 bits. |
Buttons on input controllers.
MLInputControllerTriggerEvent
Enumerator | Value | Description |
---|---|---|
MLInputControllerTriggerEvent_Pull | This is used when trigger is pulled down, and the normalized value is > 0. | |
MLInputControllerTriggerEvent_Release | This is used when trigger is fully released, and the normalized value is 0. | |
MLInputControllerTriggerEvent_Click | This is used when trigger is pulled and released within a short duration. | |
MLInputControllerTriggerEvent_Hold | This is used when trigger is pulled and held for a longer duration. | |
MLInputControllerTriggerEvent_Ensure32Bits | 0x7FFFFFFF | Ensure enum is represented as 32 bits. |
Trigger events types.
MLInputPreDefinedPatternType
Enumerator | Value | Description |
---|---|---|
MLInputPreDefinedPatternType_A | 0 | Pre-defined pattern used for VKB hover. |
MLInputPreDefinedPatternType_B | 1 | Pre-Defined pattern used for VKB select. |
MLInputPreDefinedPatternType_C | 2 | Pre-Defined pattern used for homemenu hover. |
MLInputPreDefinedPatternType_Ensure32Bits | 0x7FFFFFFF | Ensure enum is represented as 32 bits. |
Custom haptics pattern types.
MLInputCustomHapticsType
Enumerator | Value | Description |
---|---|---|
MLInputCustomHapticsType_None | 0 | None. |
MLInputCustomHapticsType_Buzz | 1 | Pattern is a buzz command. |
MLInputCustomHapticsType_Predefined | 2 | Pattern is a pre-defined pattern. |
MLInputCustomHapticsType_Ensure32Bits | 0x7FFFFFFF | Ensure enum is represented as 32 bits. |
Custom haptics pattern types.
MLInputControllerHand
Enumerator | Value | Description |
---|---|---|
MLInputControllerHand_None | 0 | None. |
MLInputControllerHand_Left | 1 | Left hand. |
MLInputControllerHand_Right | 2 | Right hand. |
MLInputControllerHand_Both | 3 | Both hand. |
MLInputControllerHand_Ensure32Bits | 0x7FFFFFFF | Ensure enum is represented as 32 bits. |
Hand in which the controller is held.
API Level:
- 21
Types Documentation
MLInputControllerTouchpadGesture
typedef struct MLInputControllerTouchpadGesture MLInputControllerTouchpadGesture;
A structure containing information about recognized touchpad gesture.
MLInputControllerCallbacksEx
typedef struct MLInputControllerCallbacksEx MLInputControllerCallbacksEx;
A structure containing callbacks for input controller events.
The final parameter to all the callbacks is a void *, which will point to whatever payload data the user provides in MLInputSetControllerCallbacksEx. Individual callbacks which are not required by the client can be NULL.
This structure must be initialized by calling MLInputControllerCallbacksExInit() before use.
API Level:
- 20
MLInputControllerState
typedef struct MLInputControllerState MLInputControllerState;
A structure containing information about the current state of an input controller.
Deprecated since 1.1.0. Scheduled for removal.
MLInputControllerStateEx
typedef struct MLInputControllerStateEx MLInputControllerStateEx;
A structure containing information about the current state of an input controller.
API Level:
- 21
MLInputConnectedDevicesList
typedef struct MLInputConnectedDevicesList MLInputConnectedDevicesList;
A structure containing information about the connected devices.
API Level:
- 20
MLInputPreDefinedPattern
typedef struct MLInputPreDefinedPattern MLInputPreDefinedPattern;
A structure containing information about the Pre-Defined pattern to be played.
When playing haptic pre-defined pattern, needed information is stored in this structure.
API Level:
- 20
MLInputBuzzCommand
typedef struct MLInputBuzzCommand MLInputBuzzCommand;
A structure containing information about the Buzz command to be played.
When playing haptic buzz command, needed information is stored in this structure.
API Level:
- 20
MLInputCustomHaptics
typedef struct MLInputCustomHaptics MLInputCustomHaptics;
A structure containing information about the Buzz command and/or pre-defined pattern to be played.
A custom haptics pattern can be played by combining Buzz haptic command and/or a pre-defined pattern, this structure will hold info of a pattern to be added to the custom haptics array. A MLInputCustomHapticsType should be set while initializing the struct to indicate whether the to-be set pattern is a buzz command or a pre-defined pattern.
The #duration will set the time for which a pattern is played:
- If the inherited duration of a pre-defined pattern is greater, then it will be cut short and the next pattern will start playing.
- If the inherited duration of a pre-defined pattern is smaller, then it will not repeat itself and will wait for the #duration to complete before starting to play the next pattern.
- Buzz command's duration will supersede the #duration. Above caveat is true in case buzz command's duration is smaller.
- The last pattern of the array will continue playing even if the inherited duration is longer than #duration unless the pattern is interrupted by another pattern in the pipeline.
MLInputCustomHapticsInfo
typedef struct MLInputCustomHapticsInfo MLInputCustomHapticsInfo;
A structure containing a list of Buzz command and/or pre-defined patterns to be played.
A custom haptics pattern can be played by combining Buzz haptic command and/or a pre-defined pattern, this structure holds a list of such a combination.
API Level:
- 20
Functions Documentation
MLInputControllerCallbacksExInit
static inline void MLInputControllerCallbacksExInit(
MLInputControllerCallbacksEx * inout_callbacks
)
Initializes default values for MLInputControllerCallbacksEx.
Parameters
MLInputControllerCallbacksEx * | inout_callbacks | The object to initialize with default settings. |
API Level:
- 20
MLInputControllerStateExInit
static inline void MLInputControllerStateExInit(
MLInputControllerStateEx inout_attr[MLInput_MaxControllers]
)
Initializes values for MLInputControllerStateEx.
Parameters
MLInputControllerStateEx | inout_attr | The object to initialize. |
API Level:
- 21
MLInputConnectedDevicesListInit
static inline void MLInputConnectedDevicesListInit(
MLInputConnectedDevicesList * inout_devices_list
)
Initializes default values for MLInputConnectedDevicesList.
Parameters
MLInputConnectedDevicesList * | inout_devices_list | The object to initialize with default settings. |
API Level:
- 20
MLInputPreDefinedPatternInit
static inline void MLInputPreDefinedPatternInit(
MLInputPreDefinedPattern * inout_pattern
)
Initializes default values for MLInputPreDefinedPattern.
Parameters
MLInputPreDefinedPattern * | inout_pattern | The object to initialize with default settings. |
MLInputBuzzCommandInit
static inline void MLInputBuzzCommandInit(
MLInputBuzzCommand * inout_command
)
Initializes default values for MLInputBuzzCommand.
Parameters
MLInputBuzzCommand * | inout_command | The object to initialize with default settings. |
MLInputCustomHapticsInfoInit
static inline void MLInputCustomHapticsInfoInit(
MLInputCustomHapticsInfo * inout_info
)
Initializes an array of MLInputCustomHaptics with default values.
Parameters
MLInputCustomHapticsInfo * | inout_info | The object to MLInputCustomHapticsInfo struct to initialize the array elements with default settings. |
MLInputGetResultString
const char * MLInputGetResultString(
MLResult result
)
Returns an ASCII string for MLInputsResult and MLResult codes.
Parameters
MLResult | result | The input MLResult enum from MLInput functions. |
Required Permissions:
- None
Return: ASCII string containing readable version of result code.
API Level:
- 8
MLInputCreate
MLResult MLInputCreate(
MLHandle * out_handle
)
Creates an input tracker.
Parameters
MLHandle * | out_handle | A handle to the created input tracker. Only valid if the return value is MLResult_Ok. |
Returns
MLResult | MLResult_InvalidParam | Failed to create the input tracker to an invalid input parameter. |
MLResult | MLResult_Ok | Successfully created the input tracker. |
MLResult | MLResult_UnspecifiedFailure | Failed to create the input tracker due to an unknown error. |
MLResult | MLInputResult_IllegalState | Failed to create the input tracker due to an unexpected state. |
Required Permissions:
- None
API Level:
- 20
MLInputSetControllerCallbacksEx
MLResult MLInputSetControllerCallbacksEx(
MLHandle handle,
const MLInputControllerCallbacksEx * controller_callbacks,
void * user_data
)
Sets the callbacks for controller input events.
Parameters
MLHandle | handle | Handle to the input tracker. |
const MLInputControllerCallbacksEx * | controller_callbacks | Pointer to MLInputControllerCallbacksEx structure (can be NULL). |
void * | user_data | Pointer to user payload data; this will be the first argument passed to all the callback functions (can be NULL). |
Returns
MLResult | MLResult_InvalidParam | Failed to set the callback for controller input events due to an invalid input parameter. |
MLResult | MLResult_Ok | Successfully set the callback for controller input events. |
MLResult | MLResult_UnspecifiedFailure | Failed to set the callback for the controller input events due to an unknown error. |
Required Permissions:
- None
API Level:
- 8
MLInputGetControllerState
MLResult MLInputGetControllerState(
MLHandle handle,
struct MLInputControllerState out_state[MLInput_MaxControllers]
)
Returns current state of all possible input controllers.
Parameters
MLHandle | handle | Handle to the input tracker. |
struct MLInputControllerState | out_state | Array of MLInputControllerState structures that will be populated. The size of this array is at least the size MLInput_MaxControllers. |
Returns
MLResult | MLResult_InvalidParam | Failed to fetch the controller state due to an invalid input parameter. |
MLResult | MLResult_Ok | Successfully fetched the controller state. |
MLResult | MLResult_UnspecifiedFailure | Failed to fetch the controller state due to an unknown error. |
Required Permissions:
- None
Deprecated since 1.1.0. Scheduled for removal.
MLInputGetControllerStateEx
MLResult MLInputGetControllerStateEx(
MLHandle handle,
MLInputControllerStateEx out_state[MLInput_MaxControllers]
)
Returns current state of all possible input controllers.
Parameters
MLHandle | handle | Handle to the input tracker. |
MLInputControllerStateEx | out_state | Array of MLInputControllerStateEx structures that will be populated. The size of this array is at least the size MLInput_MaxControllers. |
Returns
MLResult | MLResult_InvalidParam | Failed to fetch the controller state due to an invalid input parameter. |
MLResult | MLResult_Ok | Successfully fetched the controller state. |
MLResult | MLResult_UnspecifiedFailure | Failed to fetch the controller state due to an unknown error. |
Required Permissions:
- None
API Level:
- 21
MLInputGetConnectedDevices
MLResult MLInputGetConnectedDevices(
MLHandle handle,
MLInputConnectedDevicesList * inout_devices
)
Gets the device IDs of all connected devices.
Parameters
MLHandle | handle | Handle to the input tracker. |
MLInputConnectedDevicesList * | inout_devices | Pointer to MLInputConnectedDevicesList structure that will be populated. The app should call MLInputReleaseConnectedDevicesList to release the contents after use. |
Returns
MLResult | MLResult_InvalidParam | Failed to get the IDs of all connected devices due to an invalid input parameter. |
MLResult | MLResult_Ok | Successfully fetched the IDs of the connected devices. |
MLResult | MLResult_UnspecifiedFailure | Failed to get the IDs of all connected devices due to an unknown error. |
Required Permissions:
- None
API Level:
- 5
MLInputReleaseConnectedDevicesList
MLResult MLInputReleaseConnectedDevicesList(
MLHandle handle,
MLInputConnectedDevicesList * devices
)
Releases the contents of MLInputConnectedDevicesList populated by MLInputGetConnectedDevices.
Parameters
MLHandle | handle | Handle to the input tracker. |
MLInputConnectedDevicesList * | devices | Pointer to MLInputConnectedDevicesList struct. Its contents will be released. |
Returns
MLResult | MLResult_Ok | Successfully released the contents of the device list. |
MLResult | MLResult_InvalidParam | Failed to release the contents of the device list due to an invalid input parameter. |
MLResult | MLResult_UnspecifiedFailure | Failed to release the contents of the device list due to an unknown error. |
Required Permissions:
- None
API Level:
- 5
MLInputStartControllerFeedbackPreDefinedPattern
MLResult MLInputStartControllerFeedbackPreDefinedPattern(
MLHandle handle,
uint8_t controller_id,
MLInputPreDefinedPattern * pattern
)
Plays the pre-defined pattern.
Parameters
MLHandle | handle | Handle to the input tracker. |
uint8_t | controller_id | Id of the input controller 0 ~ MLInput_MaxControllers. |
MLInputPreDefinedPattern * | pattern | A pointer to #MLInputPredefinedPattern structure (can be NULL). |
Returns
MLResult | MLInputResult_IllegalState | The service is either not initialized or terminated or the app is not in focus. |
MLResult | MLResult_DeviceNotFound | The haptic device could not be found. |
MLResult | MLResult_InvalidParam | Failed to start a pre-defined pattern due to an invalid input parameter. |
MLResult | MLResult_Ok | Successfully started a pre-defined pattern on the specified controller. |
MLResult | MLResult_UnspecifiedFailure | Failed to start a pre-defined pattern due to an unknown error. |
Required Permissions:
- None
API Level:
- 20
MLInputStartControllerFeedbackBuzzCommand
MLResult MLInputStartControllerFeedbackBuzzCommand(
MLHandle handle,
uint8_t controller_id,
const MLInputBuzzCommand * command
)
Plays controller haptic buzz command.
Parameters
MLHandle | handle | Handle to the input tracker. |
uint8_t | controller_id | Id of the input controller 0 ~ MLInput_MaxControllers. |
const MLInputBuzzCommand * | command | A pointer to MLInputBuzzCommand structure (can be NULL). |
Returns
MLResult | MLInputResult_IllegalState | The service is either not initialized or terminated or the app is not in focus. |
MLResult | MLResult_DeviceNotFound | The haptic device could not be found. |
MLResult | MLResult_InvalidParam | Failed to start the buzz command due to an invalid input parameter. |
MLResult | MLResult_Ok | Successfully started the buzz command on the specified controller. |
MLResult | MLResult_UnspecifiedFailure | Failed to start the buzz command due to an unknown error. |
Required Permissions:
- None
API Level:
- 20
MLInputCreateCustomHapticsPattern
MLResult MLInputCreateCustomHapticsPattern(
MLHandle handle,
MLInputCustomHapticsInfo * info,
uint32_t * inout_pattern_id
)
Creates a custom haptic pattern.
Parameters
MLHandle | handle | Handle to the input tracker. |
MLInputCustomHapticsInfo * | info | Pointer to MLInputCustomHapticsInfo struct. |
uint32_t * | inout_pattern_id | A pattern Id created by the API, to be used by MLInputStartControllerFeedbackCustomHapticsPattern. |
Returns
MLResult | MLInputResult_IllegalState | The service is either not initialized or terminated. |
MLResult | MLResult_InvalidParam | Failed to create a custom haptic pattern due to an invalid input parameter. |
MLResult | MLResult_Ok | Successfully created a custom haptic pattern. |
MLResult | MLResult_UnspecifiedFailure | Failed to create a custom haptic pattern due to an unknown error. |
Required Permissions:
- None
A custom haptics pattern is defined as a set of either buzz command and/or pre-defined patterns. Each pattern is played for a duration defined as the #duration_ms member of each element of the MLInputCustomHaptics array.
API Level:
- 20
MLInputStartControllerFeedbackCustomHapticsPattern
MLResult MLInputStartControllerFeedbackCustomHapticsPattern(
MLHandle handle,
uint8_t controller_id,
uint32_t pattern_id
)
Plays the custom haptic pattern created by MLInputCreateCustomHapticsPattern.
Parameters
MLHandle | handle | Handle to the input tracker. |
uint8_t | controller_id | Id of the input controller 0 ~ MLInput_MaxControllers. |
uint32_t | pattern_id | Custom pattern id created by MLInputCreateCustomHapticsPattern. |
Returns
MLResult | MLInputResult_IllegalState | The service is either not initialized or terminated or the app is not in focus. |
MLResult | MLResult_DeviceNotFound | The haptic device could not be found. |
MLResult | MLResult_InvalidParam | Failed to start the custom haptic pattern due to an invalid input parameter. |
MLResult | MLResult_Ok | Successfully started the custom haptic pattern on the specified controller. |
MLResult | MLResult_UnspecifiedFailure | Failed to start the custom haptic pattern due to an unknown error. |
Required Permissions:
- None
API Level:
- 20
MLInputDeleteCustomHapticsPattern
MLResult MLInputDeleteCustomHapticsPattern(
MLHandle handle,
uint32_t pattern_id
)
Deletes the custom haptic pattern created by MLInputCreateCustomHapticsPattern.
Parameters
MLHandle | handle | Handle to the input tracker. |
uint32_t | pattern_id | Custom pattern Id created by MLInputCreateCustomHapticsPattern. |
Returns
MLResult | MLInputResult_IllegalState | The service is either not initialized or terminated. |
MLResult | MLResult_InvalidParam | Failed to destroy the custom haptic pattern due to an invalid input parameter. |
MLResult | MLResult_Ok | Successfully destroyed the custom haptic pattern on the specified controller. |
MLResult | MLResult_UnspecifiedFailure | Failed to destroy the custom haptic pattern due to an unknown error. |
Required Permissions:
- None
API Level:
- 20
MLInputStopControllerFeedback
MLResult MLInputStopControllerFeedback(
MLHandle handle,
uint8_t controller_id
)
Stops the currently playing haptic pattern.
Parameters
MLHandle | handle | Handle to the input tracker. |
uint8_t | controller_id | Id of the input controller 0 ~ MLInput_MaxControllers. |
Returns
MLResult | MLInputResult_IllegalState | The service is either not initialized or terminated or the app is not in focus. |
MLResult | MLResult_DeviceNotFound | The haptic device could not be found. |
MLResult | MLResult_InvalidParam | Failed to stop the pattern due to an invalid input parameter. |
MLResult | MLResult_Ok | Successfully stopped the pattern on the specified controller. |
MLResult | MLResult_UnspecifiedFailure | Failed to stop the pattern due to an unknown error. |
Required Permissions:
- None
API Level:
- 20
MLInputDestroy
MLResult MLInputDestroy(
MLHandle handle
)
Destroys an input tracker.
Parameters
MLHandle | handle | MLHandle to the input tracker to destroy. |
Returns
MLResult | MLResult_InvalidParam | Failed to destroy the input tracker due to an invalid input parameter. |
MLResult | MLResult_Ok | Successfully destroyed the input tracker. |
MLResult | MLResult_UnspecifiedFailure | Failed to destroy the input handler due to an unknown error. |
MLResult | MLInputResult_IllegalState | Failed to destroy the input handler due to an unexpected state. |
Required Permissions:
- None
Source code
// %BANNER_BEGIN%
// ---------------------------------------------------------------------
// %COPYRIGHT_BEGIN%
// Copyright (c) 2017 Magic Leap, Inc. All Rights Reserved.
// Use of this file is governed by the Software License Agreement,
// located here: https://www.magicleap.com/software-license-agreement-ml2
// Terms and conditions applicable to third-party materials accompanying
// this distribution may also be found in the top-level NOTICE file
// appearing herein.
// %COPYRIGHT_END%
// ---------------------------------------------------------------------
// %BANNER_END%
#pragma once
#include "ml_api.h"
#include "ml_types.h"
ML_EXTERN_C_BEGIN
enum {
MLResultAPIPrefix_Input = MLRESULT_PREFIX(0x21DC)
};
typedef enum MLInputResult {
MLInputResult_ServiceNotAvailable = MLResultAPIPrefix_Input,
MLInputResult_PermissionDenied,
MLInputResult_DeviceNotFound,
MLInputResult_IllegalState,
MLInputResult_InternalError,
MLInputResult_SpeechDisabled,
MLInputResult_Ensure32Bits = 0x7FFFFFFF
} MLInputResult;
enum {
MLInput_MaxControllers = 1,
MLInput_MaxControllerTouchpadTouches = 2
};
typedef enum MLInputControllerTouchpadGestureState {
MLInputControllerTouchpadGestureState_End,
MLInputControllerTouchpadGestureState_Continue,
MLInputControllerTouchpadGestureState_Start,
MLInputControllerTouchpadGestureState_Ensure32Bits = 0x7FFFFFFF
} MLInputControllerTouchpadGestureState;
typedef enum MLInputControllerTouchpadGestureType {
MLInputControllerTouchpadGestureType_None,
MLInputControllerTouchpadGestureType_Tap,
MLInputControllerTouchpadGestureType_ForceTapDown,
MLInputControllerTouchpadGestureType_ForceTapUp,
MLInputControllerTouchpadGestureType_ForceDwell,
MLInputControllerTouchpadGestureType_SecondForceDown,
MLInputControllerTouchpadGestureType_RadialScroll,
MLInputControllerTouchpadGestureType_Swipe,
MLInputControllerTouchpadGestureType_Count,
MLInputControllerTouchpadGestureType_Ensure32Bits = 0x7FFFFFFF
} MLInputControllerTouchpadGestureType;
typedef enum MLInputControllerTouchpadGestureDirection {
MLInputControllerTouchpadGestureDirection_None,
MLInputControllerTouchpadGestureDirection_Up,
MLInputControllerTouchpadGestureDirection_Down,
MLInputControllerTouchpadGestureDirection_Left,
MLInputControllerTouchpadGestureDirection_Right,
MLInputControllerTouchpadGestureDirection_Clockwise,
MLInputControllerTouchpadGestureDirection_CounterClockwise,
MLInputControllerTouchpadGestureDirection_Count,
MLInputControllerTouchpadGestureDirection_Ensure32Bits = 0x7FFFFFFF
} MLInputControllerTouchpadGestureDirection;
typedef struct MLInputControllerTouchpadGesture {
MLVec3f pos_and_force;
MLInputControllerTouchpadGestureType type;
MLInputControllerTouchpadGestureDirection direction;
float speed;
float distance;
float radius;
float angle;
} MLInputControllerTouchpadGesture;
typedef enum MLInputControllerType {
MLInputControllerType_None,
MLInputControllerType_Device,
MLInputControllerType_Ensure32Bits = 0x7FFFFFFF
} MLInputControllerType;
typedef enum MLInputControllerButton {
MLInputControllerButton_None,
MLInputControllerButton_Bumper,
MLInputControllerButton_Menu,
MLInputControllerButton_Count,
MLInputControllerButton_Ensure32Bits = 0x7FFFFFFF
} MLInputControllerButton;
typedef enum MLInputControllerTriggerEvent {
MLInputControllerTriggerEvent_Pull,
MLInputControllerTriggerEvent_Release,
MLInputControllerTriggerEvent_Click,
MLInputControllerTriggerEvent_Hold,
MLInputControllerTriggerEvent_Ensure32Bits = 0x7FFFFFFF
} MLInputControllerTriggerEvent;
typedef enum MLInputPreDefinedPatternType {
MLInputPreDefinedPatternType_A = 0,
MLInputPreDefinedPatternType_B = 1,
MLInputPreDefinedPatternType_C = 2,
MLInputPreDefinedPatternType_Ensure32Bits = 0x7FFFFFFF
} MLInputPreDefinedPatternType;
typedef enum MLInputCustomHapticsType {
MLInputCustomHapticsType_None = 0,
MLInputCustomHapticsType_Buzz = 1,
MLInputCustomHapticsType_Predefined = 2,
MLInputCustomHapticsType_Ensure32Bits = 0x7FFFFFFF
} MLInputCustomHapticsType;
typedef enum MLInputControllerHand {
MLInputControllerHand_None = 0,
MLInputControllerHand_Left = 1,
MLInputControllerHand_Right = 2,
MLInputControllerHand_Both = 3,
MLInputControllerHand_Ensure32Bits = 0x7FFFFFFF
} MLInputControllerHand;
typedef struct MLInputControllerCallbacksEx {
uint32_t version;
void (*on_touchpad_gesture)(uint8_t controller_id, const MLInputControllerTouchpadGesture *touchpad_gesture, void *data);
void (*on_touchpad_gesture_continue)(uint8_t controller_id, const MLInputControllerTouchpadGesture *touchpad_gesture, void *data);
void (*on_touchpad_gesture_end)(uint8_t controller_id, const MLInputControllerTouchpadGesture *touchpad_gesture, void *data);
void (*on_button_down)(uint8_t controller_id, MLInputControllerButton button, void *data);
void (*on_button_up)(uint8_t controller_id, MLInputControllerButton button, void *data);
void (*on_button_click)(uint8_t controller_id, MLInputControllerButton button, void *data);
void (*on_trigger)(uint8_t controller_id, MLInputControllerTriggerEvent event, float depth, void *data);
void (*on_connect)(uint8_t controller_id, void *data);
void (*on_disconnect)(uint8_t controller_id, void *data);
} MLInputControllerCallbacksEx;
ML_STATIC_INLINE void MLInputControllerCallbacksExInit(MLInputControllerCallbacksEx *inout_callbacks) {
if (inout_callbacks) {
inout_callbacks->version = 3u;
inout_callbacks->on_touchpad_gesture = NULL;
inout_callbacks->on_touchpad_gesture_continue = NULL;
inout_callbacks->on_touchpad_gesture_end = NULL;
inout_callbacks->on_button_down = NULL;
inout_callbacks->on_button_up = NULL;
inout_callbacks->on_button_click = NULL;
inout_callbacks->on_trigger = NULL;
inout_callbacks->on_connect = NULL;
inout_callbacks->on_disconnect = NULL;
}
}
typedef ML_DEPRECATED_MSG("Replaced by MLInputControllerStateEx.") struct MLInputControllerState {
MLVec3f touch_pos_and_force[MLInput_MaxControllerTouchpadTouches];
float trigger_normalized;
bool button_state[MLInputControllerButton_Count];
bool is_touch_active[MLInput_MaxControllerTouchpadTouches];
bool is_connected;
MLInputControllerTouchpadGesture touchpad_gesture;
MLInputControllerTouchpadGestureState touchpad_gesture_state;
MLInputControllerType type;
uint8_t hardware_index;
} MLInputControllerState;
typedef struct MLInputControllerStateEx {
uint32_t version;
MLInputControllerType type;
MLInputControllerHand hand;
MLVec3f touch_pos_and_force[MLInput_MaxControllerTouchpadTouches];
float trigger_normalized;
bool button_state[MLInputControllerButton_Count];
bool is_touch_active[MLInput_MaxControllerTouchpadTouches];
bool is_connected;
MLInputControllerTouchpadGesture touchpad_gesture;
MLInputControllerTouchpadGestureState touchpad_gesture_state;
uint8_t hardware_index;
} MLInputControllerStateEx;
ML_STATIC_INLINE void MLInputControllerStateExInit(MLInputControllerStateEx inout_attr[MLInput_MaxControllers]) {
if (NULL != inout_attr) {
for (int i = 0; i < MLInput_MaxControllers; ++i) {
inout_attr[i].version = 1u;
}
}
}
typedef struct MLInputConnectedDevicesList {
uint32_t version;
uint32_t connected_controller_count;
const uint8_t *connected_controller_ids;
} MLInputConnectedDevicesList;
ML_STATIC_INLINE void MLInputConnectedDevicesListInit(MLInputConnectedDevicesList *inout_devices_list) {
if (inout_devices_list) {
inout_devices_list->version = 2u;
inout_devices_list->connected_controller_count = 0u;
inout_devices_list->connected_controller_ids = NULL;
}
}
typedef struct MLInputPreDefinedPattern {
uint32_t version;
uint32_t pattern;
} MLInputPreDefinedPattern;
ML_STATIC_INLINE void MLInputPreDefinedPatternInit(MLInputPreDefinedPattern *inout_pattern) {
if (inout_pattern) {
inout_pattern->version = 1u;
inout_pattern->pattern = (uint32_t)MLInputPreDefinedPatternType_C;
}
}
typedef struct MLInputBuzzCommand {
uint32_t version;
uint16_t start_hz;
uint16_t end_hz;
uint32_t duration_ms;
uint8_t amp;
} MLInputBuzzCommand;
ML_STATIC_INLINE void MLInputBuzzCommandInit(MLInputBuzzCommand *inout_command) {
if (inout_command) {
inout_command->version = 1u;
inout_command->start_hz = 200;
inout_command->end_hz = 800;
inout_command->duration_ms = 1000;
inout_command->amp = 20;
}
}
typedef struct MLInputCustomHaptics {
MLInputCustomHapticsType type;
union {
MLInputBuzzCommand buzz;
MLInputPreDefinedPattern pre_defined;
} MLInputCustomHapticsPattern;
uint32_t duration_ms;
} MLInputCustomHaptics;
typedef struct MLInputCustomHapticsInfo {
uint32_t version;
MLInputCustomHaptics *custom;
uint32_t size;
} MLInputCustomHapticsInfo;
ML_STATIC_INLINE void MLInputCustomHapticsInfoInit(MLInputCustomHapticsInfo *inout_info) {
if (inout_info && inout_info->custom) {
for (uint32_t it = 0; it < inout_info->size; it++) {
inout_info->version = 1u;
inout_info->custom[it].type = MLInputCustomHapticsType_None;
inout_info->custom[it].MLInputCustomHapticsPattern.pre_defined.pattern = 0;
inout_info->custom[it].duration_ms = 0;
}
}
}
ML_API const char *ML_CALL MLInputGetResultString(MLResult result);
ML_API MLResult ML_CALL MLInputCreate(MLHandle *out_handle);
ML_API MLResult ML_CALL MLInputSetControllerCallbacksEx(MLHandle handle, const MLInputControllerCallbacksEx *controller_callbacks, void *user_data);
ML_DEPRECATED_MSG("Replaced by MLInputGetControllerStateEx.")
ML_API MLResult ML_CALL MLInputGetControllerState(MLHandle handle, struct MLInputControllerState out_state[MLInput_MaxControllers]);
ML_API MLResult ML_CALL MLInputGetControllerStateEx(MLHandle handle, MLInputControllerStateEx out_state[MLInput_MaxControllers]);
ML_API MLResult ML_CALL MLInputGetConnectedDevices(MLHandle handle, MLInputConnectedDevicesList *inout_devices);
ML_API MLResult ML_CALL MLInputReleaseConnectedDevicesList(MLHandle handle, MLInputConnectedDevicesList *devices);
ML_API MLResult ML_CALL MLInputStartControllerFeedbackPreDefinedPattern(MLHandle handle, uint8_t controller_id, MLInputPreDefinedPattern* pattern);
ML_API MLResult ML_CALL MLInputStartControllerFeedbackBuzzCommand(MLHandle handle, uint8_t controller_id, const MLInputBuzzCommand* command);
ML_API MLResult ML_CALL MLInputCreateCustomHapticsPattern(MLHandle handle, MLInputCustomHapticsInfo *info, uint32_t *inout_pattern_id);
ML_API MLResult ML_CALL MLInputStartControllerFeedbackCustomHapticsPattern(MLHandle handle, uint8_t controller_id, uint32_t pattern_id);
ML_API MLResult ML_CALL MLInputDeleteCustomHapticsPattern(MLHandle handle, uint32_t pattern_id);
ML_API MLResult ML_CALL MLInputStopControllerFeedback(MLHandle handle, uint8_t controller_id);
ML_API MLResult ML_CALL MLInputDestroy(MLHandle handle);
ML_EXTERN_C_END