Skinetic::SkineticDevice
Component to handle the Haptic Device's global behavior.
Inherits from MonoBehaviour
Public Classes
Name | |
---|---|
struct | DeviceInfo Struct representing device information. |
struct | EffectProperties Haptic Structure to describe how effect instances reproduce a pattern with variations. |
Public Types
Name | |
---|---|
enum class | OutputType { E_AUTODETECT = 0, E_BLUETOOTH = 1, E_USB = 2, E_WIFI = 3} Type of connection to Skinetic. |
enum class | DeviceType { E_UNKNOWN = ~0x0, E_SKINETICVEST = 0x01100101, E_HSDMK2 = 0x0122FFFF} Type of Skinetic device. |
enum class | ConnectionState { E_RECONNECTING = 3, E_DISCONNECTING = 2, E_CONNECTING = 1, E_CONNECTED = 0, E_DISCONNECTED = -1} Connection state. |
Public Functions
Name | |
---|---|
string | getSDKError(int error) Describe the error cause. |
String | SerialNumberToString(System.UInt32 serialNumber) Convert Skinetic serial number to a formatted string. |
int | ScanDevices(SkineticDevice.OutputType output) Initialize a scanning routine to find all available Skinetic device. |
int | ScanStatus() Check the status of the asynchronous scanning routine. |
List< SkineticDevice.DeviceInfo > | GetScannedDevices() This function returns a list of all DeviceInfo of each Skinetic devices found during the scan which match the specified output type. |
int | Connect(SkineticDevice.OutputType output, System.UInt32 serialNumber) Initialize an asynchronous connection to a Skinetic device using the selected type of connection. |
int | Disconnect() Disconnect the current Skinetic device. |
SkineticDevice.ConnectionState | ConnectionStatus() Check the current status of the connection. |
delegate void | ConnectionCallbackDelegate(ConnectionState state, int error, System.UInt32 serialNumber) Delegate of the connection callback. |
int | SetConnectionCallback(ConnectionCallbackDelegate callback) Set a callback function fired upon connection changes. |
string | GetSDKVersion() Get SDK version as a string. |
string | GetDeviceVersion() Get the connected device's version as a string. |
System.UInt32 | GetDeviceSerialNumber() Get the connected device's serial number. |
string | GetDeviceSerialNumberAsString() Get the connected device's serial number as string. |
SkineticDevice.DeviceType | GetDeviceType() Get the connected device's type. |
int | GetGlobalIntensityBoost() Get the amount of effect's intensity boost. |
int | SetGlobalIntensityBoost(int globalBoost) Set the amount of global intensity boost. |
bool | LoadPattern(PatternAsset pattern) Load a pattern into the device from a PatternAsset. |
bool | UnloadPattern(PatternAsset pattern) Unload a pattern into the device from a PatternAsset. |
int | GetPatternBoost(PatternAsset pattern) Get the pattern boost value which serves as a default value for the playing effect. |
bool | SetAccumulationWindowToPattern(PatternAsset mainPattern, PatternAsset fallbackPattern, float timeWindow, int maxAccumulation) Enable the effect accumulation strategy. |
bool | EraseAccumulationWindowToPattern(PatternAsset mainPattern) Disable the effect accumulation strategy on a specific pattern if any set. |
bool | PlayEffect(HapticEffect hapticEffect) Play an haptic effect based on a loaded pattern. |
bool | StopEffect(HapticEffect hapticEffect, float time) Stop the effect instance. |
HapticEffect.State | GetEffectState(HapticEffect hapticEffect) Get the current state of an effect. |
bool | PauseAll() Pause all haptic effect that are currently playing. |
bool | ResumeAll() Resume the paused haptic effects. |
bool | StopAll() Stop all playing haptic effect. |
int | ExpConnectAudio(Experimental.AudioStreamConfiguration.AudioPreset audioPreset, Experimental.AudioStreamConfiguration.AudioSettings audioSettings) Initialize an asynchronous connection to an audio device using the provided settings. |
Public Properties
Name | |
---|---|
IReadOnlyList< PatternAsset > | LoadedPatterns Access list of already loaded pattern. |
Public Types Documentation
enum OutputType
Enumerator | Value | Description |
---|---|---|
E_AUTODETECT | 0 | Try all available type of connection. |
E_BLUETOOTH | 1 | Bluetooth connection. |
E_USB | 2 | USB connection. |
E_WIFI | 3 | Wifi connection. |
Type of connection to Skinetic.
E_AUTODETECT will try all available type of connection in the following order:
- Bluetooth
- USB
- WIFI
enum DeviceType
Enumerator | Value | Description |
---|---|---|
E_UNKNOWN | ~0x0 | Type is Unknown or undefined. |
E_SKINETICVEST | 0x01100101 | Skinetic Vest. |
E_HSDMK2 | 0x0122FFFF | HSD mk.II development kit. |
Type of Skinetic device.
enum ConnectionState
Enumerator | Value | Description |
---|---|---|
E_RECONNECTING | 3 | Device connection was broken, trying to reconnect. |
E_DISCONNECTING | 2 | Device is disconnecting, releasing all resources. |
E_CONNECTING | 1 | Connection to the device is being established, connection routine is active. |
E_CONNECTED | 0 | Device is connected. |
E_DISCONNECTED | -1 | Device is disconnected. |
Connection state.
Public Functions Documentation
function getSDKError
static string getSDKError(
int error
)
Describe the error cause.
Parameters:
- error value
Return: Error message.
function SerialNumberToString
static String SerialNumberToString(
System.UInt32 serialNumber
)
Convert Skinetic serial number to a formatted string.
Parameters:
- serialNumber serial number to convert
Return: string representation of the serial number
function ScanDevices
int ScanDevices(
SkineticDevice.OutputType output
)
Initialize a scanning routine to find all available Skinetic device.
Parameters:
- output
Return: 0 on success, an Error code on failure.
the state of the routine can be obtain from ScanStatus(). Once completed, the result can be accessed using GetScannedDevices().
function ScanStatus
int ScanStatus()
Check the status of the asynchronous scanning routine.
Return: the current status or an error on failure.
The method returns:
- '1' if the scan is ongoing.
- '0' if the scan is completed.
- a negative error code if the connection failed. The asynchronous scan routine is terminated on failure. Once the scan is completed, the result can be obtain by calling GetScannedDevices().
function GetScannedDevices
List< SkineticDevice.DeviceInfo > GetScannedDevices()
This function returns a list of all DeviceInfo of each Skinetic devices found during the scan which match the specified output type.
Return: a list of DeviceInfo, empty if no match or an error occurs.
function Connect
int Connect(
SkineticDevice.OutputType output,
System.UInt32 serialNumber
)
Initialize an asynchronous connection to a Skinetic device using the selected type of connection.
Parameters:
- output output type
- serialNumber serial number of the Skinetic device to connect to
Return: 0 on success, an error otherwise.
The state of the routine can be obtain from ConnectionStatus(). If the serial number is set to '0', the connection will be performed on the first found device.
function Disconnect
int Disconnect()
Disconnect the current Skinetic device.
Return: 0 on success, an error otherwise.
The disconnection is effective once all resources are released. The state of the routine can be obtain from ConnectionStatus().
function ConnectionStatus
SkineticDevice.ConnectionState ConnectionStatus()
Check the current status of the connection.
Return: the current status of the connection.
The asynchronous connection routine is terminated on failure.
function ConnectionCallbackDelegate
delegate void ConnectionCallbackDelegate(
ConnectionState state,
int error,
System.UInt32 serialNumber
)
Delegate of the connection callback.
Parameters:
- state status of the connection
- error of error occurring
- serialNumber serial number of the device firing the callback
Functions of type ski_ConnectionCallback are implemented by clients. The callback is fired at the end of the connection routine whether it succeeds or failed. It is also fired if a connection issue arise.
function SetConnectionCallback
int SetConnectionCallback(
ConnectionCallbackDelegate callback
)
Set a callback function fired upon connection changes.
Parameters:
- callback callback client's callback
Return: 0 on success, an Error code on failure.
Functions of type ski_ConnectionCallback are implemented by clients. The callback is fired at the end of the connection routine whether it succeeds or failed.It is also fired if a connection issue arise. The callback is not fired if none was passed to setConnectionCallback(). The callback is not executed by the main thread. Hence, the actions that can be performed by it are restricted by Unity.
function GetSDKVersion
string GetSDKVersion()
Get SDK version as a string.
Return: The version string.
The format of the string is: major.minor.revision
function GetDeviceVersion
string GetDeviceVersion()
Get the connected device's version as a string.
Return: The version string if a Skinetic device is connected, an error message otherwise.
The format of the string is: major.minor.revision
function GetDeviceSerialNumber
System.UInt32 GetDeviceSerialNumber()
Get the connected device's serial number.
Return: The serial number of the connected Skinetic device if any, 0xFFFFFFFF otherwise.
function GetDeviceSerialNumberAsString
string GetDeviceSerialNumberAsString()
Get the connected device's serial number as string.
Return: The serial number as string of the connected Skinetic device if any, "noDeviceConnected" otherwise.
function GetDeviceType
SkineticDevice.DeviceType GetDeviceType()
Get the connected device's type.
Return: The type of the connected Skinetic device if it is connected, an ERROR message otherwise.
function GetGlobalIntensityBoost
int GetGlobalIntensityBoost()
Get the amount of effect's intensity boost.
Return: The percentage of effect's intensity boost, an ERROR otherwise.
The boost increase the overall intensity of all haptic effects. However, the higher the boost activation is, the more the haptic effects are degraded. The global boost is meant to be set by the user as an application setting.
function SetGlobalIntensityBoost
int SetGlobalIntensityBoost(
int globalBoost
)
Set the amount of global intensity boost.
Parameters:
- globalBoost boostPercent percentage of the boost.
Return: 0 on success, an ERROR otherwise.
The boost increase the overall intensity of all haptic effects. However, the higher the boost activation is, the more the haptic effects are degraded. The global boost is meant to be set by the user as an application setting.
function LoadPattern
bool LoadPattern(
PatternAsset pattern
)
Load a pattern into the device from a PatternAsset.
Parameters:
- pattern PatternAsset to load.
Return: True on success, false otherwise.
function UnloadPattern
bool UnloadPattern(
PatternAsset pattern
)
Unload a pattern into the device from a PatternAsset.
Parameters:
- pattern PatternAsset to unload.
Return: True if the pattern is successfully found and removed, false otherwise.
function GetPatternBoost
int GetPatternBoost(
PatternAsset pattern
)
Get the pattern boost value which serves as a default value for the playing effect.
The value is ranged in [-100; 100]. If the pattern ID is invalid, zero is still returned.
function SetAccumulationWindowToPattern
bool SetAccumulationWindowToPattern(
PatternAsset mainPattern,
PatternAsset fallbackPattern,
float timeWindow,
int maxAccumulation
)
Enable the effect accumulation strategy.
Parameters:
- mainPattern main pattern of the accumulation.
- fallbackPattern fallback pattern of the accumulation
- timeWindow the time window during which the accumulation should happen.
- maxAccumulation max number of extra accumulated effect instances.
Return: True if the accumulation is successfully set, false otherwise.
Whenever an effect is triggered on the main pattern, the fallback one is used instead, if the main is already playing. More details can be found the additional documentation. For the maxAccumulation, setting to 0 removes the limit.
If a new call to this function is done for a specific pattern, the previous association is overridden.
function EraseAccumulationWindowToPattern
bool EraseAccumulationWindowToPattern(
PatternAsset mainPattern
)
Disable the effect accumulation strategy on a specific pattern if any set.
Parameters:
- mainPattern Main pattern asset
Return: 0 on success, an ERROR otherwise.
function PlayEffect
bool PlayEffect(
HapticEffect hapticEffect
)
Play an haptic effect based on a loaded pattern.
Parameters:
- hapticEffect reference to the haptic effect instance.
Return: true on success, false otherwise.
The instance index is positive. Each call to playEffect() using the same patternID generates a new haptic effect instance totally uncorrelated to the previous ones. The instance is destroyed once it stops playing.
The haptic effect instance reproduces the pattern with variations describes in the structure ski_effect_properties_t.More information on these parameters and how to used them can be found in the structure's description.
If the pattern is unloaded, the haptic effect is not interrupted.
function StopEffect
bool StopEffect(
HapticEffect hapticEffect,
float time
)
Stop the effect instance.
Parameters:
- hapticEffect reference to the haptic effect instance.
- time duration of the fadeout in second.
Return: true on success, false otherwise.
The effect is stop in "time" seconds with a fade out to prevent abrupt transition. If time is set to 0, no fadeout are applied and the effect is stopped as soon as possible.
function GetEffectState
HapticEffect.State GetEffectState(
HapticEffect hapticEffect
)
Get the current state of an effect.
Parameters:
- hapticEffect reference to the haptic effect instance.
Return: the current state of the effect.
If the haptic effect is invalid, the 'stop' state will be return.
function PauseAll
bool PauseAll()
Pause all haptic effect that are currently playing.
Return: true on success, false otherwise.
function ResumeAll
bool ResumeAll()
Resume the paused haptic effects.
Return: true on success, false otherwise.
function StopAll
bool StopAll()
Stop all playing haptic effect.
Return: true on success, false otherwise.
function ExpConnectAudio
int ExpConnectAudio(
Experimental.AudioStreamConfiguration.AudioPreset audioPreset,
Experimental.AudioStreamConfiguration.AudioSettings audioSettings
)
Initialize an asynchronous connection to an audio device using the provided settings.
Parameters:
- audioPreset preset of audio device.
- audioSettings stream settings.
Return: 0 on success, an error otherwise.
This method allows to handle the settings on your own through scripting. If audioPreset is set to anything else other than AudioPreset::E_CUSTOMDEVICE, the provided settings are ignored and the ones corresponding to the preset are used instead. Not available for Android.
Public Property Documentation
property LoadedPatterns
IReadOnlyList< PatternAsset > LoadedPatterns;
Access list of already loaded pattern.
This list cannot be modified, use LoadPattern()/UnloadPattern() instead.
Updated on 2024-01-05 at 15:08:44 +0000