Skip to main content

Skinetic::SkineticDevice

Component to handle the Haptic Device's global behavior.

Inherits from MonoBehaviour

Public Classes

Name
structDeviceInfo
Struct representing device information.
structEffectProperties
Haptic Structure to describe how effect instances reproduce a pattern with variations.

Public Types

Name
enum classOutputType { E_AUTODETECT = 0, E_BLUETOOTH = 1, E_USB = 2, E_WIFI = 3}
Type of connection to Skinetic.
enum classDeviceType { E_UNKNOWN = ~0x0, E_SKINETICVEST = 0x01100101, E_HSDMK2 = 0x0122FFFF}
Type of Skinetic device.
enum classConnectionState { E_RECONNECTING = 3, E_DISCONNECTING = 2, E_CONNECTING = 1, E_CONNECTED = 0, E_DISCONNECTED = -1}
Connection state.

Public Functions

Name
stringgetSDKError(int error)
Describe the error cause.
StringSerialNumberToString(System.UInt32 serialNumber)
Convert Skinetic serial number to a formatted string.
intScanDevices(SkineticDevice.OutputType output)
Initialize a scanning routine to find all available Skinetic device.
intScanStatus()
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.
intConnect(SkineticDevice.OutputType output, System.UInt32 serialNumber)
Initialize an asynchronous connection to a Skinetic device using the selected type of connection.
intDisconnect()
Disconnect the current Skinetic device.
SkineticDevice.ConnectionStateConnectionStatus()
Check the current status of the connection.
delegate voidConnectionCallbackDelegate(ConnectionState state, int error, System.UInt32 serialNumber)
Delegate of the connection callback.
intSetConnectionCallback(ConnectionCallbackDelegate callback)
Set a callback function fired upon connection changes.
stringGetSDKVersion()
Get SDK version as a string.
stringGetDeviceVersion()
Get the connected device's version as a string.
System.UInt32GetDeviceSerialNumber()
Get the connected device's serial number.
stringGetDeviceSerialNumberAsString()
Get the connected device's serial number as string.
SkineticDevice.DeviceTypeGetDeviceType()
Get the connected device's type.
intGetGlobalIntensityBoost()
Get the amount of effect's intensity boost.
intSetGlobalIntensityBoost(int globalBoost)
Set the amount of global intensity boost.
boolLoadPattern(PatternAsset pattern)
Load a pattern into the device from a PatternAsset.
boolUnloadPattern(PatternAsset pattern)
Unload a pattern into the device from a PatternAsset.
intGetPatternBoost(PatternAsset pattern)
Get the pattern boost value which serves as a default value for the playing effect.
boolSetAccumulationWindowToPattern(PatternAsset mainPattern, PatternAsset fallbackPattern, float timeWindow, int maxAccumulation)
Enable the effect accumulation strategy.
boolEraseAccumulationWindowToPattern(PatternAsset mainPattern)
Disable the effect accumulation strategy on a specific pattern if any set.
boolPlayEffect(HapticEffect hapticEffect)
Play an haptic effect based on a loaded pattern.
boolStopEffect(HapticEffect hapticEffect, float time)
Stop the effect instance.
HapticEffect.StateGetEffectState(HapticEffect hapticEffect)
Get the current state of an effect.
boolPauseAll()
Pause all haptic effect that are currently playing.
boolResumeAll()
Resume the paused haptic effects.
boolStopAll()
Stop all playing haptic effect.
intExpConnectAudio(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

EnumeratorValueDescription
E_AUTODETECT0Try all available type of connection.
E_BLUETOOTH1Bluetooth connection.
E_USB2USB connection.
E_WIFI3Wifi connection.

Type of connection to Skinetic.

E_AUTODETECT will try all available type of connection in the following order:

  • Bluetooth
  • USB
  • WIFI

enum DeviceType

EnumeratorValueDescription
E_UNKNOWN~0x0Type is Unknown or undefined.
E_SKINETICVEST0x01100101Skinetic Vest.
E_HSDMK20x0122FFFFHSD mk.II development kit.

Type of Skinetic device.

enum ConnectionState

EnumeratorValueDescription
E_RECONNECTING3Device connection was broken, trying to reconnect.
E_DISCONNECTING2Device is disconnecting, releasing all resources.
E_CONNECTING1Connection to the device is being established, connection routine is active.
E_CONNECTED0Device is connected.
E_DISCONNECTED-1Device 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