Name: haptic-module-tizen
Summary: Haptic Module library
Version: 0.1.0
-Release: 4
+Release: 8
Group: System/Libraries
License: APLv2
Source0: %{name}-%{version}.tar.gz
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(haptic-plugin)
-BuildRequires: pkgconfig(devman)
+BuildRequires: pkgconfig(device-node)
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
--- /dev/null
+/*
+ * haptic-module-tizen
+ *
+ * Copyright (c) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jae-young Hwang <j-zero.hwang@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You agree and acknowledge
+ * that this software is owned by Samsung and you shall not disclose
+ * such Confidential Information and shall use it only in accordance with the
+ * terms of the license agreement you entered into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose,
+ * by licensee arising out of or releated to this software.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <vconf.h>
+#include <dlfcn.h>
+
+#include <haptic_plugin_intf.h>
+
+#define HAPTIC_MODULE_PATH "/usr/lib/libhaptic-module.so"
+
+static void *dlopen_handle;
+static const haptic_plugin_interface *plugin_intf;
+
+int main ()
+{
+ char *error = NULL;
+
+ printf("start!\n");
+ dlopen_handle = dlopen(HAPTIC_MODULE_PATH, RTLD_NOW);
+ if (!dlopen_handle) {
+ printf("fail dlopen\n");
+ printf("%s\n", dlerror());
+ return -1;
+ }
+
+ const haptic_plugin_interface *(*get_haptic_plugin_interface) ();
+ get_haptic_plugin_interface = dlsym(dlopen_handle, "get_haptic_plugin_interface");
+
+ if ((error = dlerror()) != NULL) {
+ printf("dlsym error\n");
+ printf("%s\n", error);
+ dlclose(dlopen_handle);
+ return -1;
+ }
+
+ plugin_intf = get_haptic_plugin_interface();
+ if (!plugin_intf) {
+ printf("plugin_intf error\n");
+ dlclose(dlopen_handle);
+ return -1;
+ }
+
+ while (1)
+ {
+ char input = -1;
+ int duration = -1;
+ int handle = -1;
+ int status = -1;
+
+ printf ("============================================\n");
+ printf ("haptic_internal_vibrate_monotone : a\n");
+ printf ("hatpic_internal_stop_all_effects : b\n");
+ printf ("Quit : z\n");
+ printf ("============================================\n");
+
+ status = scanf ("%c", &input);
+
+ switch (input)
+ {
+ case 'a' :
+ printf ("Handle : ");
+ status = scanf ("%d", &handle);
+ if (status < 0)
+ return status;
+
+ printf ("Duration : ");
+ status = scanf ("%d", &duration);
+ if (status < 0)
+ return status;
+
+ plugin_intf->haptic_internal_vibrate_monotone(handle, duration, HAPTIC_MODULE_FEEDBACK_MAX, HAPTIC_MODULE_PRIORITY_HIGH, &handle);
+ break;
+
+ case 'b':
+ printf ("Handle : ");
+ status = scanf ("%d", &handle);
+ if (status < 0)
+ return status;
+ plugin_intf->haptic_internal_stop_all_effects(handle);
+ break;
+
+ case 'c':
+ break;
+
+ case 'z':
+ return 0;
+ }
+ }
+
+ if (dlopen_handle) {
+ dlclose(dlopen_handle);
+ }
+
+ return 0;
+}
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-SET(DEPENDENTS "dlog vconf haptic-plugin devman")
-
SET(SRCS
- src/haptic_module_file.c
- src/haptic_module_internal.c)
+ src/haptic_module_internal.c
+ src/file.c
+ src/sysnoti.c)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+SET(DEPENDENTS "dlog vconf haptic-plugin device-node")
INCLUDE(FindPkgConfig)
pkg_check_modules(rpkgs REQUIRED ${DEPENDENTS})
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${rpkgs_LDFLAGS})
-
ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
ADD_DEFINITIONS("-DENABLE_DLOG_OUT -DSLP_DEBUG")
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${rpkgs_LDFLAGS})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib)
*/
-#ifndef __HAPTIC_FILE_H__
-#define __HAPTIC_FILE_H__
+#ifndef __FILE_H__
+#define __FILE_H__
#define GCC_PACK __attribute__((packed))
} GCC_PACK HapticFile;
typedef struct _HapticElement {
- int stime;
int duration;
+ int level;
} HapticElement;
int GetHapticLevelMax(int *max);
int InsertHapticElement(unsigned char *vibe_buffer, int max_bufsize, HapticElement *element);
int GetHapticBufferSize(const unsigned char *vibe_buffer, int *size);
int GetHapticBufferDuration(const unsigned char *vibe_buffer, int *duration);
-int PlayHapticBuffer(const unsigned char *vibe_buffer, int iteration, int *effect_handle);
+int PlayHapticBuffer(const unsigned char *vibe_buffer, int iteration, int level, int *effect_handle);
int OpenHapticDevice(void);
int CloseHapticDevice(void);
-#endif // __HAPTIC_FIEL_H__
+#endif // __FIEL_H__
#include <string.h>
#include <errno.h>
#include <pthread.h>
-#include <devman.h>
+#include <device-node.h>
+#include "file.h"
#include "haptic_module_log.h"
-#include "haptic_file.h"
-#define BITPERMS 50
-#define DEFAULT_EFFECT_HANDLE 0x02
+#define BITPERMS 50
+#define MAX_LEVEL 255.0f
+#define DEFAULT_EFFECT_HANDLE 0x02
+
+enum {
+ PLAY_HAPTIC = 0,
+ STOP_HAPTIC,
+ LEVEL_HAPTIC,
+};
typedef struct {
unsigned char **ppbuffer;
int i = 0;
MODULE_LOG("clean up handler!!! : %d", tid);
- SetHapticEnable(0);
+ __haptic_predefine_action(STOP_HAPTIC, NULL);
for (i = 0; i < pbuffer->channels; ++i) {
free(pbuffer->ppbuffer[i]);
{
BUFFER *pbuffer = (BUFFER*)arg;
int i = -1, j = -1, k = -1, value = -1;
+ unsigned char ch;
+ unsigned char prev = -1;
MODULE_LOG("Start thread");
pthread_cleanup_push(__clean_up, arg);
+ __haptic_predefine_action(PLAY_HAPTIC, NULL);
+
/* Copy buffer from source buffer */
for (i = 0; i < pbuffer->iteration; i++) {
for (j = 0; j < pbuffer->length; ++j) {
for (k = 0; k < pbuffer->channels; ++k) {
- value = (pbuffer->ppbuffer[k][j] > 0) ? 1 : 0;
- if (SetHapticEnable(value) < 0) {
- MODULE_ERROR("SetHapticEnable fail");
- pthread_exit((void *)-1);
+ ch = pbuffer->ppbuffer[k][j];
+ if (ch != prev) {
+ __haptic_predefine_action(LEVEL_HAPTIC, ch);
+ prev = ch;
}
-
usleep(BITPERMS * 1000);
}
}
int GetHapticLevelMax(int *max)
{
int status = -1;
- status = device_get_property(DEVTYPE_HAPTIC, HAPTIC_PROP_LEVEL_MAX, max);
+ status = device_get_property(DEVICE_TYPE_VIBRATOR, PROP_VIBRATOR_LEVEL_MAX, max);
if (status < 0) {
MODULE_ERROR("device_get_property fail : %d", status);
return -1;
int SetHapticEnable(int value)
{
int status = -1;
- status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_ENABLE, value);
+ status = device_set_property(DEVICE_TYPE_VIBRATOR, PROP_VIBRATOR_ENABLE, value);
if (status < 0) {
MODULE_ERROR("device_set_property fail : %d", status);
return -1;
int SetHapticLevel(int value)
{
int status = -1;
- status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_LEVEL, value);
+ status = device_set_property(DEVICE_TYPE_VIBRATOR, PROP_VIBRATOR_LEVEL, value);
if (status < 0) {
MODULE_ERROR("device_set_property fail : %d", status);
return -1;
int SetHapticOneshot(int value)
{
int status = -1;
- status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_ONESHOT, value);
+ status = device_set_property(DEVICE_TYPE_VIBRATOR, PROP_VIBRATOR_ONESHOT, value);
if (status < 0) {
MODULE_ERROR("device_set_property fail : %d", status);
return -1;
HapticFile *pfile = NULL;
int databuf = -1;
int needbuf = -1;
- int stime, duration;
- int i = -1, j = -1;
+ int duration;
+ unsigned char level;
+ int i = -1;
pfile = (HapticFile*)vibe_buffer;
if (_check_valid_haptic_format(pfile) < 0) {
return -1;
}
- stime = element->stime/BITPERMS;
duration = element->duration/BITPERMS;
+ level = (unsigned char)((unsigned int)element->level*MAX_LEVEL/100);
- databuf = max_bufsize-sizeof(HapticFile);
- needbuf = (stime+duration)*pfile->fmt.wBlockAlign;
- MODULE_LOG("Data buffer size : %d, Need buffer size : %d", databuf, needbuf);
+ databuf = max_bufsize - sizeof(HapticFile);
+ needbuf = (pfile->fmt.dwDuration + duration)*pfile->fmt.wBlockAlign;
+ MODULE_LOG("Need buffer size : %d", needbuf);
if (databuf < needbuf) {
MODULE_ERROR("buffer lacks a memory : data buf(%d), need buf(%d)", databuf, needbuf);
return -1;
}
- for (i = 0, j = stime; i < duration; ++i, j+=pfile->fmt.wBlockAlign) {
- pfile->data.pData[j] = 0xFF;
+ for (i = pfile->fmt.dwDuration; i < pfile->fmt.dwDuration+duration; i++) {
+ pfile->data.pData[i] = level;
}
- pfile->chunkSize = sizeof(HapticFile)+needbuf;
- pfile->fmt.dwDuration = element->stime+element->duration;
+ pfile->chunkSize = sizeof(HapticFile)+needbuf ;
+ pfile->fmt.dwDuration = pfile->fmt.dwDuration+duration;
pfile->data.chunkSize = sizeof(DataChunk)+needbuf;
return 0;
}
return 0;
}
-int PlayHapticBuffer(const unsigned char *vibe_buffer, int iteration, int *effect_handle)
+int PlayHapticBuffer(const unsigned char *vibe_buffer, int iteration, int level, int *effect_handle)
{
HapticFile *pfile = NULL;
unsigned char **ppbuffer = NULL;
- unsigned int channels, length, align, magnitude;
+ unsigned int channels, length, align;
+ unsigned char data;
int i = -1, j = -1;
pfile = (HapticFile*)vibe_buffer;
channels = pfile->fmt.wChannels;
align = pfile->fmt.wBlockAlign;
length = (pfile->data.chunkSize-8)/align;
- magnitude = pfile->fmt.dwMagnitude;
- MODULE_LOG("channels : %d, length : %d, align : %d, magnitude : %d", channels, length, align, magnitude);
+ MODULE_LOG("channels : %d, length : %d, align : %d, level : %d", channels, length, align, level);
/* Create buffer */
ppbuffer = (unsigned char**)malloc(sizeof(unsigned char*)*channels);
/* Copy buffer from source buffer */
for (i = 0; i < length; ++i) {
for (j = 0; j < channels; ++j) {
- ppbuffer[j][i] = (unsigned char)(pfile->data.pData[i*align+j]);
+ data = (unsigned char)(pfile->data.pData[i*align+j]);
+ ppbuffer[j][i] = (unsigned char)(data*level/0xFF);
+ MODULE_LOG("ppbuffer[%2d][%2d] : data(%x) -> (%x)", j, i, data, ppbuffer[j][i]);
}
}
#include <sys/stat.h>
#include <fcntl.h>
#include <assert.h>
+#include <vconf.h>
#include <haptic_plugin_intf.h>
#include "haptic_module_log.h"
-#include "haptic_file.h"
+#include "file.h"
#ifndef EXTAPI
#define EXTAPI __attribute__ ((visibility("default")))
#endif
-#define DEFAULT_MOTOR_COUNT 1
-#define DEFAULT_DEVICE_HANDLE 0x01
-#define DEFAULT_EFFECT_HANDLE 0x02
-
-#define HAPTIC_PLAY_FILE_EXT ".tht"
+#define DEFAULT_MOTOR_COUNT 1
+#define DEFAULT_DEVICE_HANDLE 0x01
+#define DEFAULT_EFFECT_HANDLE 0x02
+#define HAPTIC_FEEDBACK_AUTO 101
+#define HAPTIC_PLAY_FILE_EXT ".tht"
/* START of Static Function Section */
-static int __feedback_to_tizen_type(int feedback)
+static int __to_level(int feedback, int *type)
{
static int max = -1;
- int status = -1;
+ int t;
- if (max < 0) {
- status = GetHapticLevelMax(&max);
+ if (max == -1) {
+ int status = GetHapticLevelMax(&max);
if (status < 0) {
MODULE_ERROR("GetHapticLevelMax fail : %d", status);
- return -1;
+ return HAPTIC_MODULE_OPERATION_FAILED;
}
}
- MODULE_LOG("feedback value is changed : %d -> %d", feedback, (int)(feedback*max/HAPTIC_MODULE_FEEDBACK_MAX));
- return (int)(feedback*max/HAPTIC_MODULE_FEEDBACK_MAX);
+ t = feedback * max / HAPTIC_MODULE_FEEDBACK_MAX;
+ MODULE_LOG("feedback value is changed : %d -> %d", feedback, t);
+
+ if (type)
+ *type = t;
+
+ return 0;
+}
+
+static void __trim_name(const char *file_name, char *vibe_buffer, int size)
+{
+ int length;
+
+ assert(file_name);
+ assert(vibe_buffer);
+ assert(size > 0);
+
+ snprintf(vibe_buffer, size, "%s", file_name);
+
+ length = strlen(vibe_buffer);
+ while (vibe_buffer[--length] == ' ');
+ vibe_buffer[length + 1] = '\0';
}
-static char* __check_file (const char *name)
+static int __check_ext(const char *name)
{
- char *file_full_name = NULL;
- int name_length = -1;
- char match_ext[4];
- char *file_ext = NULL;
+ char *ext;
assert(name);
- assert(*name);
- file_full_name = strdup(name);
- if (!file_full_name) {
- MODULE_ERROR("strdup failed");
- return NULL;
+ ext = strrchr(name, '.');
+ if (ext && !strcmp(ext, HAPTIC_PLAY_FILE_EXT))
+ return 1;
+
+ return 0;
+}
+
+static int __get_size(FILE *pf, const char *fname)
+{
+ int status;
+ int size;
+
+ assert(pf);
+
+ status = fseek(pf, 0, SEEK_END);
+ if (status == -1) {
+ MODULE_ERROR("fseek failed: %s", fname);
+ return -1;
}
- name_length = strlen(file_full_name) - 1;
- while (file_full_name[name_length] == ' ')
- name_length--;
- file_full_name[name_length + 1] = '\0';
+ size = ftell(pf);
- file_ext = strrchr(file_full_name, '.');
- if (!(file_ext && !strcmp(file_ext, HAPTIC_PLAY_FILE_EXT))) {
- free(file_full_name);
- MODULE_ERROR("Not supported file");
- return NULL;
+ status = fseek(pf, 0, SEEK_SET);
+ if (status == -1) {
+ MODULE_ERROR("fseek failed: %s", fname);
+ return -1;
}
- return file_full_name;
+ return size;
}
-static unsigned char* __convert_file_to_vibe_buffer(const char *file_name)
+static unsigned char *__read_file(const char *fname)
{
- char *file_full_name;
+ int status;
FILE *pf;
- long file_size;
- unsigned char* pIVTData;
+ long size;
+ unsigned char *vibe_buffer;
- if (!file_name) {
- MODULE_ERROR("Wrowng file name");
- return NULL;
- }
+ assert(fname);
- file_full_name = __check_file(file_name);
- if(!file_full_name) {
- MODULE_ERROR("__check_file_faild");
- return NULL;
- }
-
- /* Get File Stream Pointer */
- pf = fopen(file_full_name, "rb");
- free(file_full_name);
+ pf = fopen(fname, "rb");
if (!pf) {
- MODULE_ERROR("file open failed");
+ MODULE_ERROR("fopen failed: %s", fname);
return NULL;
}
- if (fseek(pf, 0, SEEK_END)) {
- MODULE_ERROR("fseek failed");
+ size = __get_size(pf, fname);
+ if (size <= 0) {
fclose(pf);
return NULL;
}
- file_size = ftell(pf);
- if (file_size < 0) {
- MODULE_ERROR("ftell failed");
+ vibe_buffer = malloc(size);
+ if (!vibe_buffer) {
fclose(pf);
+ MODULE_ERROR("buffer alloc failed");
return NULL;
}
- if (fseek(pf, 0, SEEK_SET)) {
- MODULE_ERROR("fseek failed");
- fclose(pf);
- return NULL;
+ status = fread(vibe_buffer, 1, size, pf);
+ if (status != size) {
+ MODULE_ERROR("fread failed: expect %d read %d", size, status);
+ free(vibe_buffer);
+ vibe_buffer = NULL;
}
- pIVTData = (unsigned char*)malloc(file_size);
- if (!pIVTData) {
- fclose(pf);
+ fclose(pf);
+
+ return vibe_buffer;
+}
+
+static unsigned char* __convert_file_to_buffer(const char *file_name)
+{
+ char fname[FILENAME_MAX];
+ int status;
+
+ __trim_name(file_name, fname, sizeof(fname));
+ status = __check_ext(fname);
+ if (!status) {
+ MODULE_ERROR("__check_file faild");
return NULL;
}
- if (fread(pIVTData, 1, file_size, pf) != file_size) {
- fclose(pf);
- free(pIVTData);
- MODULE_ERROR("fread failed");
- return NULL;
+ return __read_file(fname);
+}
+
+static int __save_file(const unsigned char *vibe_buferf, int size, const char *file_name)
+{
+ int status;
+ FILE *pf;
+ int fd;
+
+ pf = fopen(file_name, "wb+");
+ if (pf == NULL) {
+ MODULE_ERROR("To open file is failed");
+ return HAPTIC_MODULE_OPERATION_FAILED;
+ }
+
+ status = fwrite(vibe_buferf, 1, size, pf);
+ if (status != size) {
+ MODULE_ERROR("To write file is failed");
+ return HAPTIC_MODULE_OPERATION_FAILED;
+ }
+
+ fd = fileno(pf);
+ if (fd == -1) {
+ MODULE_ERROR("To get file descriptor is failed");
+ return HAPTIC_MODULE_OPERATION_FAILED;
+ }
+
+ status = fsync(fd);
+ if (status == -1) {
+ MODULE_ERROR("To be synchronized with the disk is failed");
+ return HAPTIC_MODULE_OPERATION_FAILED;
}
fclose(pf);
- return pIVTData;
+
+ return 0;
+}
+
+static int __vibrate(const unsigned char *vibe_buffer, int iteration, int feedback, int priority, int *effect_handle)
+{
+ int status;
+ int level;
+ int handle;
+
+ assert(vibe_buffer);
+
+ status = __to_level(feedback, &level);
+ if (status != HAPTIC_MODULE_ERROR_NONE)
+ return status;
+
+ status = PlayHapticBuffer(vibe_buffer, iteration, level, &handle);
+ if (status < 0) {
+ MODULE_ERROR("PlayHapticBuffer fail: %d", status);
+ return HAPTIC_MODULE_OPERATION_FAILED;
+ }
+
+ if (effect_handle)
+ *effect_handle = handle;
+
+ return 0;
}
/* END of Static Function Section */
-int haptic_internal_get_device_count(int *count)
+
+static int _get_device_count(int *count)
{
if (count == NULL)
return HAPTIC_MODULE_INVALID_ARGUMENT;
*count = DEFAULT_MOTOR_COUNT;
+
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_open_device(int device_index, int *device_handle)
+static int _open_device(int device_index, int *device_handle)
{
if (device_index < HAPTIC_MODULE_DEVICE_0 || device_index > HAPTIC_MODULE_DEVICE_ALL)
return HAPTIC_MODULE_INVALID_ARGUMENT;
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_close_device(int device_handle)
+static int _close_device(int device_handle)
{
- int status = -1;
+ int status;
if (device_handle < 0)
return HAPTIC_MODULE_INVALID_ARGUMENT;
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_vibrate_monotone(int device_handle, int duration, int feedback, int priority, int *effect_handle)
+static int _vibrate_monotone(int device_handle, int duration, int feedback, int priority, int *effect_handle)
{
- int status = -1;
- int input_feedback = -1;
+ int status;
+ int input_feedback;
if (device_handle < 0)
return HAPTIC_MODULE_INVALID_ARGUMENT;
if (feedback == HAPTIC_MODULE_FEEDBACK_MIN)
return HAPTIC_MODULE_ERROR_NONE;
- input_feedback = __feedback_to_tizen_type(feedback);
- if (input_feedback < 0)
- return HAPTIC_MODULE_OPERATION_FAILED;
+ status = __to_level(feedback, &input_feedback);
+ if (status != HAPTIC_MODULE_ERROR_NONE)
+ return status;
status = SetHapticLevel(input_feedback);
if (status < 0) {
}
*effect_handle = DEFAULT_EFFECT_HANDLE;
+
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_vibrate_file(int device_handle, const char *file_path, int iteration, int feedback, int priority, int *effect_handle)
+static int _vibrate_file(int device_handle, const char *file_path, int iteration, int feedback, int priority, int *effect_handle)
{
- int status = -1;
- unsigned char *vibe_buffer = NULL;
- int input_feedback = -1;
- int handle = -1;
- int i = -1;
+ int status;
+ unsigned char *vibe_buffer;
if (device_handle < 0)
return HAPTIC_MODULE_INVALID_ARGUMENT;
if (feedback == HAPTIC_MODULE_FEEDBACK_MIN)
return HAPTIC_MODULE_ERROR_NONE;
- input_feedback = __feedback_to_tizen_type(feedback);
- if (input_feedback < 0)
- return HAPTIC_MODULE_OPERATION_FAILED;
-
- status = SetHapticLevel(input_feedback);
- if (status < 0) {
- MODULE_ERROR("SetHapticLevel fail : %d", status);
- return HAPTIC_MODULE_OPERATION_FAILED;
- }
-
- vibe_buffer = __convert_file_to_vibe_buffer(file_path);
+ vibe_buffer = __convert_file_to_buffer(file_path);
if (!vibe_buffer) {
MODULE_ERROR("File load filed");
return HAPTIC_MODULE_OPERATION_FAILED;
}
- status = PlayHapticBuffer(vibe_buffer, iteration, &handle);
- if (status < 0) {
- MODULE_ERROR("PlayHapticBuffer fail: %d", status);
- free(vibe_buffer);
- return HAPTIC_MODULE_OPERATION_FAILED;
- }
-
- *effect_handle = handle;
+ status = __vibrate(vibe_buffer, iteration, feedback , priority, effect_handle);
free(vibe_buffer);
- return HAPTIC_MODULE_ERROR_NONE;
+
+ return status;
}
-int haptic_internal_vibrate_buffer(int device_handle, const unsigned char *vibe_buffer, int iteration, int feedback, int priority, int *effect_handle)
+static int _vibrate_buffer(int device_handle, const unsigned char *vibe_buffer, int iteration, int feedback, int priority, int *effect_handle)
{
- int status = -1;
- int input_feedback = -1;
- int handle = -1;
- int i = -1;
-
if (device_handle < 0)
return HAPTIC_MODULE_INVALID_ARGUMENT;
if (feedback == HAPTIC_MODULE_FEEDBACK_MIN)
return HAPTIC_MODULE_ERROR_NONE;
- input_feedback = __feedback_to_tizen_type(feedback);
- if (input_feedback < 0)
- return HAPTIC_MODULE_OPERATION_FAILED;
-
- status = SetHapticLevel(input_feedback);
- if (status < 0) {
- MODULE_ERROR("SetHapticLevel fail : %d", status);
- return HAPTIC_MODULE_OPERATION_FAILED;
- }
-
- status = PlayHapticBuffer(vibe_buffer, iteration, &handle);
- if (status < 0) {
- MODULE_ERROR("PlayHapticBuffer fail: %d", status);
- return HAPTIC_MODULE_OPERATION_FAILED;
- }
-
- *effect_handle = handle;
- return HAPTIC_MODULE_ERROR_NONE;
+ return __vibrate(vibe_buffer, iteration, feedback, priority, effect_handle);
}
-int haptic_internal_stop_effect(int device_handle, int effect_handle)
+static int _stop_effect(int device_handle, int effect_handle)
{
- int status = -1;
+ int status;
if (device_handle < 0)
return HAPTIC_MODULE_INVALID_ARGUMENT;
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_stop_all_effects(int device_handle)
+static int _stop_all_effects(int device_handle)
{
- int status = -1;
+ int status;
if (device_handle < 0)
return HAPTIC_MODULE_INVALID_ARGUMENT;
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_pause_effect(int device_handle, int effect_handle)
+static int _pause_effect(int device_handle, int effect_handle)
{
+ if (device_handle < 0)
+ return HAPTIC_MODULE_INVALID_ARGUMENT;
+
+ if (effect_handle < 0)
+ return HAPTIC_MODULE_INVALID_ARGUMENT;
+
MODULE_ERROR("This device is not supported this function(%s)", __func__);
return HAPTIC_MODULE_NOT_SUPPORTED;
}
-int haptic_internal_resume_effect(int device_handle, int effect_handle)
+static int _resume_effect(int device_handle, int effect_handle)
{
+ if (device_handle < 0)
+ return HAPTIC_MODULE_INVALID_ARGUMENT;
+
+ if (effect_handle < 0)
+ return HAPTIC_MODULE_INVALID_ARGUMENT;
+
MODULE_ERROR("This device is not supported this function(%s)", __func__);
return HAPTIC_MODULE_NOT_SUPPORTED;
}
-int haptic_internal_get_effect_state(int device_handle, int effect_handle, int *state)
+static int _get_effect_state(int device_handle, int effect_handle, int *state)
{
+ if (device_handle < 0)
+ return HAPTIC_MODULE_INVALID_ARGUMENT;
+
+ if (effect_handle < 0)
+ return HAPTIC_MODULE_INVALID_ARGUMENT;
+
+ if (state == NULL)
+ return HAPTIC_MODULE_INVALID_ARGUMENT;
+
MODULE_ERROR("This device is not supported this function(%s)", __func__);
return HAPTIC_MODULE_NOT_SUPPORTED;
}
-int haptic_internal_create_effect(unsigned char *vibe_buffer, int max_bufsize, haptic_module_effect_element *elem_arr, int max_element)
+static int _create_effect(unsigned char *vibe_buffer, int max_bufsize, haptic_module_effect_element *elem_arr, int max_elemcnt)
{
- int status = -1;
+ int status;
+ int i;
HapticElement elem;
- int i = -1;
if (vibe_buffer == NULL)
return HAPTIC_MODULE_INVALID_ARGUMENT;
if (elem_arr == NULL)
return HAPTIC_MODULE_INVALID_ARGUMENT;
- if (max_element < 0)
+ if (max_elemcnt < 0)
return HAPTIC_MODULE_INVALID_ARGUMENT;
status = InitializeHapticBuffer(vibe_buffer, max_bufsize);
return HAPTIC_MODULE_OPERATION_FAILED;
}
- MODULE_LOG("effect count : %d", max_element);
- for (i = 0; i < max_element; ++i) {
- elem.stime = elem_arr[i].haptic_stime;
+ MODULE_LOG("effect count : %d", max_elemcnt);
+ for (i = 0; i < max_elemcnt; ++i) {
elem.duration = elem_arr[i].haptic_duration;
- MODULE_LOG("%d) time : %d, duration : %d", i, elem_arr[i].haptic_stime, elem_arr[i].haptic_duration);
+ if (elem_arr[i].haptic_level == HAPTIC_FEEDBACK_AUTO) {
+ vconf_get_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, &elem_arr[i].haptic_level);
+ elem.level = elem_arr[i].haptic_level*20;
+ }
+ else {
+ elem.level = elem_arr[i].haptic_level;
+ }
+ MODULE_LOG("%d) duration : %d, level : %d", i, elem_arr[i].haptic_duration, elem_arr[i].haptic_level);
status = InsertHapticElement(vibe_buffer, max_bufsize, &elem);
if (status < 0) {
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_save_effect(const unsigned char *vibe_buffer, int max_bufsize, const char *file_path)
+static int _save_effect(const unsigned char *vibe_buffer, int max_bufsize, const char *file_path)
{
- int status = -1;
- FILE *file = NULL;
- int fd = -1;
- int size = -1;
- int ret;
+ int status;
+ int size;
if (vibe_buffer == NULL)
return HAPTIC_MODULE_INVALID_ARGUMENT;
return HAPTIC_MODULE_OPERATION_FAILED;
}
- file = fopen(file_path, "wb");
- if (file == NULL) {
- MODULE_ERROR("To open file is failed");
- return HAPTIC_MODULE_OPERATION_FAILED;
- }
-
- ret = fwrite(vibe_buffer, 1, size, file);
- if (ret != size) {
- MODULE_ERROR("To write file is failed");
- fclose(file);
- return HAPTIC_MODULE_OPERATION_FAILED;
- }
-
- fd = fileno(file);
- if (fd < 0) {
- MODULE_ERROR("To get file descriptor is failed");
- fclose(file);
- return HAPTIC_MODULE_OPERATION_FAILED;
- }
-
- if (fsync(fd) < 0) {
- MODULE_ERROR("To be synchronized with the disk is failed");
- fclose(file);
- return HAPTIC_MODULE_OPERATION_FAILED;
- }
-
- fclose(file);
- return HAPTIC_MODULE_ERROR_NONE;
+ return __save_file(vibe_buffer, size, file_path);
}
-int haptic_internal_get_file_duration(int device_handle, const char *file_path, int *file_duration)
+static int _get_file_duration(int device_handle, const char *file_path, int *file_duration)
{
- int status = -1;
- unsigned char *vibe_buffer = NULL;
+ int status;
+ unsigned char *vibe_buffer;
int duration = -1;
if (device_handle < 0)
if (file_duration == NULL)
return HAPTIC_MODULE_INVALID_ARGUMENT;
- vibe_buffer = __convert_file_to_vibe_buffer(file_path);
+ vibe_buffer = __convert_file_to_buffer(file_path);
if (!vibe_buffer) {
MODULE_ERROR("File load filed");
return HAPTIC_MODULE_OPERATION_FAILED;
}
status = GetHapticBufferDuration(vibe_buffer, &duration);
+ free(vibe_buffer);
if (status < 0) {
MODULE_ERROR("GetHapticBufferDuration fail: %d", status);
free(vibe_buffer);
}
*file_duration = duration;
- free(vibe_buffer);
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_get_buffer_duration(int device_handle, const unsigned char *vibe_buffer, int *buffer_duration)
+static int _get_buffer_duration(int device_handle, const unsigned char *vibe_buffer, int *buffer_duration)
{
- int status = -1;
- int duration = -1;
+ int status;
+ int duration;
if (device_handle < 0)
return HAPTIC_MODULE_INVALID_ARGUMENT;
}
*buffer_duration = duration;
+
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_convert_binary (void)
+static int _convert_binary (void)
{
MODULE_ERROR("This device is not supported this function(%s)", __func__);
return HAPTIC_MODULE_NOT_SUPPORTED;
}
-static haptic_plugin_interface haptic_plugin_tizen;
+static const haptic_plugin_interface haptic_plugin_tizen = {
+ .haptic_internal_get_device_count = _get_device_count,
+ .haptic_internal_open_device = _open_device,
+ .haptic_internal_close_device = _close_device,
+ .haptic_internal_vibrate_monotone = _vibrate_monotone,
+ .haptic_internal_vibrate_file = _vibrate_file,
+ .haptic_internal_vibrate_buffer = _vibrate_buffer,
+ .haptic_internal_stop_effect = _stop_effect,
+ .haptic_internal_stop_all_effects = _stop_all_effects,
+ .haptic_internal_pause_effect = _pause_effect,
+ .haptic_internal_resume_effect = _resume_effect,
+ .haptic_internal_get_effect_state = _get_effect_state,
+ .haptic_internal_create_effect = _create_effect,
+ .haptic_internal_save_effect = _save_effect,
+ .haptic_internal_get_file_duration = _get_file_duration,
+ .haptic_internal_get_buffer_duration = _get_buffer_duration,
+ .haptic_internal_convert_binary = _convert_binary,
+};
EXTAPI
const haptic_plugin_interface *get_haptic_plugin_interface()
{
- haptic_plugin_tizen.haptic_internal_get_device_count= &haptic_internal_get_device_count;
- haptic_plugin_tizen.haptic_internal_open_device = &haptic_internal_open_device;
- haptic_plugin_tizen.haptic_internal_close_device = &haptic_internal_close_device;
- haptic_plugin_tizen.haptic_internal_vibrate_monotone= &haptic_internal_vibrate_monotone;
- haptic_plugin_tizen.haptic_internal_vibrate_file = &haptic_internal_vibrate_file;
- haptic_plugin_tizen.haptic_internal_vibrate_buffer = &haptic_internal_vibrate_buffer;
- haptic_plugin_tizen.haptic_internal_stop_effect = &haptic_internal_stop_effect;
- haptic_plugin_tizen.haptic_internal_stop_all_effects= &haptic_internal_stop_all_effects;
- haptic_plugin_tizen.haptic_internal_pause_effect = &haptic_internal_pause_effect;
- haptic_plugin_tizen.haptic_internal_resume_effect = &haptic_internal_resume_effect;
- haptic_plugin_tizen.haptic_internal_get_effect_state= &haptic_internal_get_effect_state;
- haptic_plugin_tizen.haptic_internal_create_effect = &haptic_internal_create_effect;
- haptic_plugin_tizen.haptic_internal_save_effect = &haptic_internal_save_effect;
- haptic_plugin_tizen.haptic_internal_get_file_duration = &haptic_internal_get_file_duration;
- haptic_plugin_tizen.haptic_internal_get_buffer_duration = &haptic_internal_get_buffer_duration;
- haptic_plugin_tizen.haptic_internal_convert_binary = &haptic_internal_convert_binary;
-
return &haptic_plugin_tizen;
}
--- /dev/null
+/*
+ * haptic-module-tizen
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <stdarg.h>
+#include <errno.h>
+
+#include "haptic_module_log.h"
+
+#define HAPTIC_RETRY_READ_COUNT 5
+#define HAPTIC_PARAM_CNT 3
+#define HAPTIC_MAXSTR 100
+#define HAPTIC_MAXARG 16
+#define PREDEF_HAPTIC "haptic"
+#define SYSNOTI_SOCKET_PATH "/tmp/sn"
+
+enum sysnoti_cmd {
+ ADD_HAPTIC_ACTION,
+ CALL_HAPTIC_ACTION,
+};
+
+struct sysnoti_type {
+ int pid;
+ int cmd;
+ char *type;
+ char *path;
+ int argc;
+ char *argv[HAPTIC_MAXARG];
+};
+
+static inline int __send_int(int fd, int val)
+{
+ return write(fd, &val, sizeof(int));
+}
+
+static inline int __send_str(int fd, char *str)
+{
+ int len;
+ int r;
+
+ if (str == NULL) {
+ len = 0;
+ r = write(fd, &len, sizeof(int));
+ } else {
+ len = strlen(str);
+ if (len > HAPTIC_MAXSTR)
+ len = HAPTIC_MAXSTR;
+ r = write(fd, &len, sizeof(int));
+ r = write(fd, str, len);
+ }
+
+ return r;
+}
+
+static int __sysnoti_send(struct sysnoti_type *msg)
+{
+ int sockfd;
+ int len;
+ struct sockaddr_un addr;
+ int retry_cnt;
+ int ret;
+ int i;
+ int r;
+
+ sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (sockfd == -1) {
+ MODULE_ERROR("socket create failed");
+ return -1;
+ }
+
+ bzero(&addr, sizeof(addr));
+ addr.sun_family = AF_UNIX;
+ strncpy(addr.sun_path, SYSNOTI_SOCKET_PATH, sizeof(addr.sun_path) - 1);
+ len = sizeof(addr);
+
+ if (connect(sockfd, (struct sockaddr *)&addr, len) < 0) {
+ MODULE_ERROR("connect failed");
+ close(sockfd);
+ return -1;
+ }
+
+ __send_int(sockfd, msg->pid);
+ __send_int(sockfd, msg->cmd);
+ __send_str(sockfd, msg->type);
+ __send_str(sockfd, msg->path);
+ __send_int(sockfd, msg->argc);
+ for (i = 0; i < msg->argc; i++)
+ __send_str(sockfd, msg->argv[i]);
+
+ retry_cnt = 0;
+ while ((r = read(sockfd, &ret, sizeof(int))) < 0) {
+
+ if (errno != EINTR) {
+ MODULE_LOG("read fail : %s(%d)", strerror(errno), errno);
+ ret = -1;
+ break;
+ }
+
+ if (retry_cnt == HAPTIC_RETRY_READ_COUNT) {
+ MODULE_ERROR("retry(%d) fail", retry_cnt);
+ ret = -1;
+ break;
+ }
+
+ MODULE_ERROR("Re-read for error(EINTR)");
+ ++retry_cnt;
+ }
+
+ close(sockfd);
+ return ret;
+}
+
+static int __haptic_call_predef_action(const char *type, int num, ...)
+{
+ struct sysnoti_type msg;
+ char *args;
+ va_list argptr;
+ int i;
+
+ if (type == NULL || num > HAPTIC_MAXARG) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ msg.pid = getpid();
+ msg.cmd = CALL_HAPTIC_ACTION;
+ msg.type = (char *)type;
+ msg.path = NULL;
+ msg.argc = num;
+
+ va_start(argptr, num);
+ for (i = 0; i < num; i++) {
+ args = va_arg(argptr, char *);
+ msg.argv[i] = args;
+ }
+ va_end(argptr);
+
+ return __sysnoti_send(&msg);
+}
+
+void __haptic_predefine_action(int prop, int val)
+{
+ char pid_buf[255];
+ char prop_buf[255];
+ char val_buf[255];
+
+ snprintf(pid_buf, sizeof(pid_buf), "%d", getpid());
+ snprintf(prop_buf, sizeof(prop_buf), "%d", prop);
+ snprintf(val_buf, sizeof(val_buf), "%d", val);
+
+ MODULE_LOG("pid : %d, type : %d, val : %d", getpid(), prop, val);
+ __haptic_call_predef_action(PREDEF_HAPTIC, HAPTIC_PARAM_CNT, pid_buf, prop_buf, val_buf);
+}
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-SET(DEPENDENTS "dlog vconf haptic-plugin devman")
+SET(DEPENDENTS "dlog haptic-plugin")
SET(SRCS
src/haptic_module_internal.c)
/*
* haptic-module-tizen
- * Copyright (c) 2012 Samsung Electronics Co., Ltd.
*
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Copyright (c) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * Contact: Jae-young Hwang <j-zero.hwang@samsung.com>
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You agree and acknowledge
+ * that this software is owned by Samsung and you shall not disclose
+ * such Confidential Information and shall use it only in accordance with the
+ * terms of the license agreement you entered into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose,
+ * by licensee arising out of or releated to this software.
+*/
#include <stdio.h>
#include <stdlib.h>
#define DEFAULT_DEVICE_HANDLE 0x01
#define DEFAULT_EFFECT_HANDLE 0x02
-int haptic_internal_get_device_count(int *count)
+static int _get_device_count(int *count)
{
if (count == NULL)
return HAPTIC_MODULE_INVALID_ARGUMENT;
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_open_device(int device_index, int *device_handle)
+static int _open_device(int device_index, int *device_handle)
{
if (device_index < HAPTIC_MODULE_DEVICE_0 || device_index > HAPTIC_MODULE_DEVICE_ALL)
return HAPTIC_MODULE_INVALID_ARGUMENT;
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_close_device(int device_handle)
+static int _close_device(int device_handle)
{
if (device_handle < 0)
return HAPTIC_MODULE_INVALID_ARGUMENT;
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_vibrate_monotone(int device_handle, int duration, int feedback, int priority, int *effect_handle)
+static int _vibrate_monotone(int device_handle, int duration, int feedback, int priority, int *effect_handle)
{
if (device_handle < 0)
return HAPTIC_MODULE_INVALID_ARGUMENT;
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_vibrate_file(int device_handle, const char *file_path, int iteration, int feedback, int priority, int *effect_handle)
+static int _vibrate_file(int device_handle, const char *file_path, int iteration, int feedback, int priority, int *effect_handle)
{
if (device_handle < 0)
return HAPTIC_MODULE_INVALID_ARGUMENT;
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_vibrate_buffer(int device_handle, const unsigned char *vibe_buffer, int iteration, int feedback, int priority, int *effect_handle)
+static int _vibrate_buffer(int device_handle, const unsigned char *vibe_buffer, int iteration, int feedback, int priority, int *effect_handle)
{
if (device_handle < 0)
return HAPTIC_MODULE_INVALID_ARGUMENT;
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_stop_effect(int device_handle, int effect_handle)
+static int _stop_effect(int device_handle, int effect_handle)
{
if (device_handle < 0)
return HAPTIC_MODULE_INVALID_ARGUMENT;
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_stop_all_effects(int device_handle)
+static int _stop_all_effects(int device_handle)
{
if (device_handle < 0)
return HAPTIC_MODULE_INVALID_ARGUMENT;
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_pause_effect(int device_handle, int effect_handle)
+static int _pause_effect(int device_handle, int effect_handle)
{
if (device_handle < 0)
return HAPTIC_MODULE_INVALID_ARGUMENT;
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_resume_effect(int device_handle, int effect_handle)
+static int _resume_effect(int device_handle, int effect_handle)
{
if (device_handle < 0)
return HAPTIC_MODULE_INVALID_ARGUMENT;
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_get_effect_state(int device_handle, int effect_handle, int *effect_state)
+static int _get_effect_state(int device_handle, int effect_handle, int *effect_state)
{
if (device_handle < 0)
return HAPTIC_MODULE_INVALID_ARGUMENT;
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_create_effect(const unsigned char *vibe_buffer, int max_bufsize, haptic_module_effect_element *elem_arr, int max_elemcnt)
+static int _create_effect(const unsigned char *vibe_buffer, int max_bufsize, haptic_module_effect_element *elem_arr, int max_elemcnt)
{
if (vibe_buffer == NULL)
return HAPTIC_MODULE_INVALID_ARGUMENT;
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_save_effect(const unsigned char *vibe_buffer, int max_bufsize, const char *file_path)
+static int _save_effect(const unsigned char *vibe_buffer, int max_bufsize, const char *file_path)
{
if (vibe_buffer == NULL)
return HAPTIC_MODULE_INVALID_ARGUMENT;
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_get_file_duration(int device_handle, const char *file_path, int *file_duration)
+static int _get_file_duration(int device_handle, const char *file_path, int *file_duration)
{
if (device_handle < 0)
return HAPTIC_MODULE_INVALID_ARGUMENT;
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_get_buffer_duration(int device_handle, const unsigned char *vibe_buffer, int *buffer_duration)
+static int _get_buffer_duration(int device_handle, const unsigned char *vibe_buffer, int *buffer_duration)
{
if (device_handle < 0)
return HAPTIC_MODULE_INVALID_ARGUMENT;
return HAPTIC_MODULE_ERROR_NONE;
}
-int haptic_internal_convert_binary (void)
+static int _convert_binary (void)
{
MODULE_ERROR("This device is not supported this function(%s)", __func__);
return HAPTIC_MODULE_NOT_SUPPORTED;
}
-static haptic_plugin_interface haptic_plugin_emul;
+static haptic_plugin_interface haptic_plugin_emul = {
+ .haptic_internal_get_device_count = _get_device_count,
+ .haptic_internal_open_device = _open_device,
+ .haptic_internal_close_device = _close_device,
+ .haptic_internal_vibrate_monotone = _vibrate_monotone,
+ .haptic_internal_vibrate_file = _vibrate_file,
+ .haptic_internal_vibrate_buffer = _vibrate_buffer,
+ .haptic_internal_stop_effect = _stop_effect,
+ .haptic_internal_stop_all_effects = _stop_all_effects,
+ .haptic_internal_pause_effect = _pause_effect,
+ .haptic_internal_resume_effect = _resume_effect,
+ .haptic_internal_get_effect_state = _get_effect_state,
+ .haptic_internal_create_effect = _create_effect,
+ .haptic_internal_save_effect = _save_effect,
+ .haptic_internal_get_file_duration = _get_file_duration,
+ .haptic_internal_get_buffer_duration = _get_buffer_duration,
+ .haptic_internal_convert_binary = _convert_binary,
+};
EXTAPI
const haptic_plugin_interface *get_haptic_plugin_interface()
{
- haptic_plugin_emul.haptic_internal_get_device_count = &haptic_internal_get_device_count;
- haptic_plugin_emul.haptic_internal_open_device = &haptic_internal_open_device;
- haptic_plugin_emul.haptic_internal_close_device = &haptic_internal_close_device;
- haptic_plugin_emul.haptic_internal_vibrate_monotone = &haptic_internal_vibrate_monotone;
- haptic_plugin_emul.haptic_internal_vibrate_file = &haptic_internal_vibrate_file;
- haptic_plugin_emul.haptic_internal_vibrate_buffer = &haptic_internal_vibrate_buffer;
- haptic_plugin_emul.haptic_internal_stop_effect = &haptic_internal_stop_effect;
- haptic_plugin_emul.haptic_internal_stop_all_effects = &haptic_internal_stop_all_effects;
- haptic_plugin_emul.haptic_internal_pause_effect = &haptic_internal_pause_effect;
- haptic_plugin_emul.haptic_internal_resume_effect = &haptic_internal_resume_effect;
- haptic_plugin_emul.haptic_internal_get_effect_state = &haptic_internal_get_effect_state;
- haptic_plugin_emul.haptic_internal_create_effect = &haptic_internal_create_effect;
- haptic_plugin_emul.haptic_internal_save_effect = &haptic_internal_save_effect;
- haptic_plugin_emul.haptic_internal_get_file_duration = &haptic_internal_get_file_duration;
- haptic_plugin_emul.haptic_internal_get_buffer_duration = &haptic_internal_get_buffer_duration;
- haptic_plugin_emul.haptic_internal_convert_binary = &haptic_internal_convert_binary;
-
return &haptic_plugin_emul;
}