Tizen Native API  5.0

The Haptic API provides functions to control vibration.

Required Header

#include <device/haptic.h>

Overview

The Haptic API provides the way to control vibration functionality of a device. It allows the management of the device's vibrator parameters, such as the vibration count and level.

Related Features

This API is related with the following features:

  • http://tizen.org/feature/feedback.vibration

It is recommended to design feature related codes in your application for reliability.

You can check if a device supports the related features for this API by using System Information, thereby controlling the procedure of your application.

To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.

More details on featuring your application can be found from feature element description.

Functions

int device_haptic_get_count (int *device_number)
 Gets the number of vibrators.
int device_haptic_open (int device_index, haptic_device_h *device_handle)
 Opens a haptic-vibration device.
int device_haptic_close (haptic_device_h device_handle)
 Closes a haptic-vibration device.
int device_haptic_vibrate (haptic_device_h device_handle, int duration, int feedback, haptic_effect_h *effect_handle)
 Vibrates during the specified time with a constant intensity.
int device_haptic_stop (haptic_device_h device_handle, haptic_effect_h effect_handle)
 Stops all vibration effects which are being played.

Typedefs

typedef void * haptic_device_h
 The haptic device handle.
typedef void * haptic_effect_h
 The haptic effect handle.

Typedef Documentation

typedef void* haptic_device_h

The haptic device handle.

Since :
2.3
typedef void* haptic_effect_h

The haptic effect handle.

Since :
2.3

Function Documentation

int device_haptic_close ( haptic_device_h  device_handle)

Closes a haptic-vibration device.

Internally, it disconnects the connection to the vibrator.

Since :
2.3
Privilege Level:
public
Privilege:
http://tizen.org/privilege/haptic
Parameters:
[in]device_handleThe device handle from device_haptic_open()
Returns:
0 on success, otherwise a negative error value
Return values:
DEVICE_ERROR_NONESuccessful
DEVICE_ERROR_INVALID_PARAMETERInvalid parameter
DEVICE_ERROR_PERMISSION_DENIEDPermission denied
DEVICE_ERROR_OPERATION_FAILEDOperation failed
DEVICE_ERROR_NOT_SUPPORTEDNot supported device
See also:
device_haptic_open()
int device_haptic_get_count ( int *  device_number)

Gets the number of vibrators.

Since :
2.3
Privilege Level:
public
Privilege:
http://tizen.org/privilege/haptic
Parameters:
[in]device_numberThe number of vibrators
Returns:
0 on success, otherwise a negative error value
Return values:
DEVICE_ERROR_NONESuccessful
DEVICE_ERROR_INVALID_PARAMETERInvalid parameter
DEVICE_ERROR_PERMISSION_DENIEDPermission denied
DEVICE_ERROR_OPERATION_FAILEDOperation failed
DEVICE_ERROR_NOT_SUPPORTEDNot supported device
int device_haptic_open ( int  device_index,
haptic_device_h device_handle 
)

Opens a haptic-vibration device.

Internally, it makes a connection to the vibrator.

Since :
2.3
Privilege Level:
public
Privilege:
http://tizen.org/privilege/haptic
Remarks:
You must close the Haptic API using device_haptic_close().
Parameters:
[in]device_indexThe index of device what you want to vibrate
The index starts from 0
[out]device_handleThe handle of vibrator
Returns:
0 on success, otherwise a negative error value
Return values:
DEVICE_ERROR_NONESuccessful
DEVICE_ERROR_INVALID_PARAMETERInvalid parameter
DEVICE_ERROR_PERMISSION_DENIEDPermission denied
DEVICE_ERROR_OPERATION_FAILEDOperation failed
DEVICE_ERROR_NOT_SUPPORTEDNot supported device
See also:
device_haptic_close()
int device_haptic_stop ( haptic_device_h  device_handle,
haptic_effect_h  effect_handle 
)

Stops all vibration effects which are being played.

This function can be used to stop all effects started by device_haptic_vibrate().

Since :
2.3
Privilege Level:
public
Privilege:
http://tizen.org/privilege/haptic
Parameters:
[in]device_handleThe device handle from device_haptic_open()
[in]effect_handleThe effect handle from device_haptic_vibrate()
Returns:
0 on success, otherwise a negative error value
Return values:
DEVICE_ERROR_NONESuccessful
DEVICE_ERROR_INVALID_PARAMETERInvalid parameter
DEVICE_ERROR_PERMISSION_DENIEDPermission denied
DEVICE_ERROR_OPERATION_FAILEDOperation failed
DEVICE_ERROR_NOT_SUPPORTEDNot supported device
See also:
device_haptic_vibrate()
int device_haptic_vibrate ( haptic_device_h  device_handle,
int  duration,
int  feedback,
haptic_effect_h effect_handle 
)

Vibrates during the specified time with a constant intensity.

This function can be used to start monotonous vibration for the specified time.

Since :
2.3
Privilege Level:
public
Privilege:
http://tizen.org/privilege/haptic
Remarks:
feedback level is reserved for auto changing to save variable in the settings.
effect_handle effect_handle value can be 0(zero).
To prevent unexpected sleep (suspend) during vibration, please use Power.
Parameters:
[in]device_handleThe device handle from device_haptic_open()
[in]durationThe play duration in milliseconds
[in]feedbackThe amount of the intensity variation (0 ~ 100)
[out]effect_handleThe pointer to the variable that will receive a handle to the playing effect
Returns:
0 on success, otherwise a negative error value
Return values:
DEVICE_ERROR_NONESuccessful
DEVICE_ERROR_INVALID_PARAMETERInvalid parameter
DEVICE_ERROR_PERMISSION_DENIEDPermission denied
DEVICE_ERROR_OPERATION_FAILEDOperation failed
DEVICE_ERROR_NOT_SUPPORTEDNot supported device
See also:
device_haptic_stop()