diff options
author | Kibum Kim <kb0929.kim@samsung.com> | 2012-01-07 00:42:36 +0900 |
---|---|---|
committer | Kibum Kim <kb0929.kim@samsung.com> | 2012-01-07 00:42:36 +0900 |
commit | de40936aca10c193eb7f41e997661e00f52d8808 (patch) | |
tree | 329b0bdbfb20fc8d32c914c12adf97da0125c7be | |
parent | c9d0e46c297165019455db0a7ea2d6d260306cdb (diff) | |
download | feedback-de40936aca10c193eb7f41e997661e00f52d8808.tar.gz feedback-de40936aca10c193eb7f41e997661e00f52d8808.tar.bz2 feedback-de40936aca10c193eb7f41e997661e00f52d8808.zip |
Git init
-rw-r--r-- | AUTHORS | 1 | ||||
-rwxr-xr-x | CMakeLists.txt | 90 | ||||
-rw-r--r-- | capi-uix-feedback.pc.in | 15 | ||||
-rw-r--r-- | debian/README | 0 | ||||
-rw-r--r-- | debian/capi-uix-feedback-dev.install | 4 | ||||
-rw-r--r-- | debian/capi-uix-feedback-dev.postinst | 1 | ||||
-rw-r--r-- | debian/capi-uix-feedback.install | 1 | ||||
-rw-r--r-- | debian/capi-uix-feedback.postinst | 1 | ||||
-rw-r--r-- | debian/changelog | 13 | ||||
-rw-r--r-- | debian/compat | 1 | ||||
-rw-r--r-- | debian/control | 22 | ||||
-rwxr-xr-x | debian/rules | 65 | ||||
-rw-r--r-- | include/feedback.h | 166 | ||||
-rw-r--r-- | packaging/capi-uix-feedback.spec | 52 | ||||
-rw-r--r-- | src/feedback.c | 138 |
15 files changed, 570 insertions, 0 deletions
@@ -0,0 +1 @@ +Pius Lee <pius.lee@samsung.com> diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100755 index 0000000..ac28b22 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,90 @@ + +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +SET(fw_name "capi-uix-feedback") + +PROJECT(${fw_name}) + +SET(CMAKE_INSTALL_PREFIX /usr) +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) + +SET(INC_DIR include) +INCLUDE_DIRECTORIES(${INC_DIR}) + +SET(dependents "svi dlog") + +INCLUDE(FindPkgConfig) +pkg_check_modules(${fw_name} REQUIRED ${dependents}) +FOREACH(flag ${${fw_name}_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") + +IF("${ARCH}" STREQUAL "arm") + ADD_DEFINITIONS("-DTARGET") +ENDIF("${ARCH}" STREQUAL "arm") + +ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") +ADD_DEFINITIONS("-DTIZEN_DEBUG") + +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib") + +aux_source_directory(src SOURCES) +ADD_LIBRARY(${fw_name} SHARED ${SOURCES}) + +TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS}) + +INSTALL(TARGETS ${fw_name} DESTINATION lib) +INSTALL( + DIRECTORY ${INC_DIR}/ DESTINATION include/uix + FILES_MATCHING + PATTERN "*_private.h" EXCLUDE + PATTERN "${INC_DIR}/*.h" + ) + +SET(PC_NAME ${fw_name}) +SET(PC_REQUIRED ${dependents}) +SET(PC_LDFLAGS -l${fw_name}) +SET(PC_CFLAGS -I\${includedir}/uix) + +CONFIGURE_FILE( + ${fw_name}.pc.in + ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc + @ONLY +) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig) + + +IF(UNIX) + +ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution) +ADD_CUSTOM_COMMAND( + DEPENDS clean + COMMENT "distribution clean" + COMMAND find + ARGS . + -not -name config.cmake -and \( + -name tester.c -or + -name Testing -or + -name CMakeFiles -or + -name cmake.depends -or + -name cmake.check_depends -or + -name CMakeCache.txt -or + -name cmake.check_cache -or + -name *.cmake -or + -name Makefile -or + -name core -or + -name core.* -or + -name gmon.out -or + -name install_manifest.txt -or + -name *.pc -or + -name *.edj -or + -name *~ \) + | grep -v TC | xargs rm -rf + TARGET distclean + VERBATIM +) + +ENDIF(UNIX) + diff --git a/capi-uix-feedback.pc.in b/capi-uix-feedback.pc.in new file mode 100644 index 0000000..917265a --- /dev/null +++ b/capi-uix-feedback.pc.in @@ -0,0 +1,15 @@ + +# Package Information for pkg-config + +prefix=@PREFIX@ +exec_prefix=/usr +libdir=/usr/lib +includedir=/usr/include/uix + +Name: @PC_NAME@ +Description: @PACKAGE_DESCRIPTION@ +Version: @VERSION@ +Requires: @PC_REQUIRED@ +Libs: -L${libdir} @PC_LDFLAGS@ +Cflags: -I${includedir} @PC_CFLAGS@ + diff --git a/debian/README b/debian/README new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/debian/README diff --git a/debian/capi-uix-feedback-dev.install b/debian/capi-uix-feedback-dev.install new file mode 100644 index 0000000..761a28b --- /dev/null +++ b/debian/capi-uix-feedback-dev.install @@ -0,0 +1,4 @@ +/usr/include/* +/usr/include/*/* +/usr/lib/pkgconfig/*.pc + diff --git a/debian/capi-uix-feedback-dev.postinst b/debian/capi-uix-feedback-dev.postinst new file mode 100644 index 0000000..1a24852 --- /dev/null +++ b/debian/capi-uix-feedback-dev.postinst @@ -0,0 +1 @@ +#!/bin/sh diff --git a/debian/capi-uix-feedback.install b/debian/capi-uix-feedback.install new file mode 100644 index 0000000..4a755a4 --- /dev/null +++ b/debian/capi-uix-feedback.install @@ -0,0 +1 @@ +/usr/lib/lib*.so* diff --git a/debian/capi-uix-feedback.postinst b/debian/capi-uix-feedback.postinst new file mode 100644 index 0000000..1a24852 --- /dev/null +++ b/debian/capi-uix-feedback.postinst @@ -0,0 +1 @@ +#!/bin/sh diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..f2da33c --- /dev/null +++ b/debian/changelog @@ -0,0 +1,13 @@ +capi-uix-feedback (0.1.0-4) unstable; urgency=low + + * version update + * Git: api/feedback + * Tag: capi-uix-feedback_0.1.0-4 + + -- Pius Lee <pius.lee@samsung.com> Thu, 15 Dec 2011 13:50:00 +0900 + +capi-uix-feedback (0.0.1-1) unstable; urgency=low + + * Initial release. (Closes: #XXXXXX) + + -- Pius Lee <pius.lee@samsung.com> Wed, 07 Dec 2011 12:45:23 +0900 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..4bd253c --- /dev/null +++ b/debian/control @@ -0,0 +1,22 @@ + +Source: capi-uix-feedback +Section: libs +Priority: extra +Maintainer: pius lee <pius.lee@samsung.com> +Build-Depends: debhelper (>= 5), libsvi-dev, libglib2.0-dev, capi-base-common-dev, dlog-dev + +Package: capi-uix-feedback +Architecture: any +Depends: ${shilbs:Depends}, ${misc:Depends} +Description: A Feedback library in Tizen Native API + +Package: capi-uix-feedback-dev +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, capi-uix-feedback (= ${Source-Version}), libsvi-dev, capi-base-common-dev, dlog-dev +Description: A Feedback library in Tizen Native API (DEV) + +Package: capi-uix-feedback-dbg +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, capi-uix-feedback (= ${Source-Version}) +Description: A Feedback library in Tizen Native API (DBG) + diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..57fdce9 --- /dev/null +++ b/debian/rules @@ -0,0 +1,65 @@ +#!/usr/bin/make -f + +CFLAGS = -Wall -g + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif +CMAKE_ROOT_DIR ?= $(CURDIR) +CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp + +configure: configure-stamp +configure-stamp: + dh_testdir + mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && cmake .. + touch configure-stamp + + +build: build-stamp +build-stamp: configure-stamp + dh_testdir + cd $(CMAKE_BUILD_DIR) && $(MAKE) + touch $@ + +clean: + cd $(CMAKE_ROOT_DIR) + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + rm -f `find . -name *.pc` + rm -rf $(CMAKE_BUILD_DIR) + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install + +binary-indep: build install + +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples + dh_install --sourcedir=debian/tmp + dh_installman + dh_link + dh_strip --dbg-package=capi-uix-feedback-dbg + dh_fixperms + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure + diff --git a/include/feedback.h b/include/feedback.h new file mode 100644 index 0000000..2012c0c --- /dev/null +++ b/include/feedback.h @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + + + + +#ifndef __TIZEN_UIX_FEEDBACK_H__ +#define __TIZEN_UIX_FEEDBACK_H__ + +#include <tizen_error.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file feedback.h + * @brief This file contains the feedback and that's resource API + */ + +/** + * @addtogroup CAPI_UIX_FEEDBACK_MODULE + * @{ + * @breif + * This is a feedback API of the UIX Service. + * @} + */ + +/** + * @addtogroup CAPI_UIX_FEEDBACK_MODULE + * @{ + */ + +/** + * @brief Enumerations of the system pre-defined patterns for feedback interface + * @details + * Each feedback pattern can have separate media files of each types. + * But Depending on vendor design, pattern may not have any type of file. + * + */ +typedef enum +{ + FEEDBACK_PATTERN_TOUCH_TAP, /**< feedback pattern when touch */ + FEEDBACK_PATTERN_TOUCH_MULTI_TAP, /**< feedback pattern when multi touch */ + FEEDBACK_PATTERN_TOUCH_KEY, /**< feedback pattern when touch key */ + FEEDBACK_PATTERN_TOUCH_HOLD, /**< feedback pattern when touch hold */ + FEEDBACK_PATTERN_HW_TAP, /**< feedback pattern when press hardware key */ + FEEDBACK_PATTERN_HW_HOLD, /**< feedback pattern when holding press hardware key */ +} feedback_pattern_e; + +/** + * @brief Enumerations of the type for feedback interface + * @details + * + */ +typedef enum +{ + FEEDBACK_TYPE_SOUND, /**< sound feedback pattern (.wav file) */ + FEEDBACK_TYPE_VIBRATION, /**< vibration feedback pattern (.ivt file) */ +} feedback_type_e; + +/** + * @brief Enumerations of error codes for the Feedback API. + */ +typedef enum +{ + FEEDBACK_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + FEEDBACK_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + FEEDBACK_ERROR_NOT_INITIALIZED = TIZEN_ERROR_SYSTEM_CLASS | 0x52, /**< Has not yet been Initialized */ + FEEDBACK_ERROR_OPERATION_FAILED = TIZEN_ERROR_SYSTEM_CLASS | 0x55, /**< Operation failed */ +} feedback_error_e; + +/** + * @brief Initializes feedback API. + * + * @remarks + * If this function is not called in advance, other function will return #FEEDBACK_ERROR_NOT_INITIALIZED. + * + * + * @return 0 on success, otherwise a negative error value. + * @retval #FEEDBACK_ERROR_NONE Successful + * @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation failed + * + * @see feedback_deinitialize() + */ +int feedback_initialize(void); + +/** + * @brief Deinitializes feedback API. + * + * @details This function must be called when feedback functions are no longer needed. + * + * @return 0 on success, otherwise a negative error value. + * @retval #FEEDBACK_ERROR_NONE Successful + * @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation failed + * + * @see feedback_initialize() + */ +int feedback_deinitialize(void); + +/** + * @brief Plays various types of reactions that are pre-defined. + * + * @details + * This functon can be used to react to pre-defined actions. \n + * It play various types of system pre-defined media or vibration patterns. + * + * @remarks + * Currently, there are two types of reactions: sound and vibration. \n + * Depending on the settings, some types cannot operate. + * For example, when set to silent mode, the device doesn't produce any sound. + * + * @param[in] pattern The pre-defined pattern + * + * @return 0 on success, otherwise a negative error value. + * @retval #FEEDBACK_ERROR_NONE Successful + * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter + */ +int feedback_play(feedback_pattern_e pattern); + +/** + * @brief Gets the file path of resource for the given feedback type and pattern. + * + * @details + * Depending on the type of each pattern resouorce has a different format. \n + * Currently, System supports two pattern types. \n + * #FEEDBACK_TYPE_SOUND type uses .wav format. \n + * #FEEDBACK_TYPE_VIBRATION type uses .ivt format. \n + * If the given pattern doesn't have a file for the type, @a path will return NULL. + * + * @remarks @a path must be released with free() by you. + * + * @param[in] type The pattern type + * @param[in] pattern The pre-defined pattern + * @param[out] path The file path of resource for feedback type and pattern + * + * @return 0 on success, otherwise a negative error value. + * @retval #FEEDBACK_ERROR_NONE Successful + * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation failed + * + */ +int feedback_get_resource_path(feedback_type_e type, feedback_pattern_e pattern, char **path); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif // __TIZEN_UIX_FEEDBACK_H__ diff --git a/packaging/capi-uix-feedback.spec b/packaging/capi-uix-feedback.spec new file mode 100644 index 0000000..5f21eed --- /dev/null +++ b/packaging/capi-uix-feedback.spec @@ -0,0 +1,52 @@ +Name: capi-uix-feedback +Summary: A Feedback library in Tizen Native API +Version: 0.0.1 +Release: 1 +Group: TO_BE/FILLED_IN +License: TO BE FILLED IN +Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(svi) +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(capi-base-common) +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig + +%description + + +%package devel +Summary: A Feedback library in Tizen Native API (Development) +Group: TO_BE/FILLED_IN +Requires: %{name} = %{version}-%{release} + +%description devel + +%prep +%setup -q + + +%build +cmake . -DCMAKE_INSTALL_PREFIX=/usr + + +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + + +%files +%{_libdir}/libcapi-uix-feedback.so + +%files devel +%{_includedir}/uix/*.h +%{_libdir}/pkgconfig/*.pc + + diff --git a/src/feedback.c b/src/feedback.c new file mode 100644 index 0000000..521a37f --- /dev/null +++ b/src/feedback.c @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 <string.h> +#include <svi.h> +#include <feedback.h> +#include <dlog.h> + +#define MAX_PATH_LENGTH 256 +#define NOT_ASSIGNED -1 + +static int _PTN_VIBE[] = { + SVI_VIB_TOUCH_TOUCH, + SVI_VIB_TOUCH_MULTI_TAP, + SVI_VIB_TOUCH_SIP, + SVI_VIB_TOUCH_HOLD, + SVI_VIB_TOUCH_HW_TAP, + SVI_VIB_TOUCH_HW_HOLD +}; + +static int _PTN_SND[] = { + SVI_SND_TOUCH_TOUCH1, + SVI_SND_TOUCH_MULTI_TAP, + SVI_SND_TOUCH_SIP, + SVI_SND_TOUCH_HOLD, + SVI_SND_TOUCH_HW_TAP, + SVI_SND_TOUCH_HW_HOLD +}; + +static int _TYPE[] = { + SVI_TYPE_SND, + SVI_TYPE_VIB +}; + +static int* _TYPE_PTN[] = { + _PTN_SND, + _PTN_VIBE +}; + +static int svi_handle = NOT_ASSIGNED; + +int feedback_initialize() +{ + int err; + + if(svi_handle == NOT_ASSIGNED){ + err = svi_init(&svi_handle); + if(err != SVI_SUCCESS){ + svi_fini(svi_handle); + + LOGE("[%s] Operation failed(0x%08x)", __FUNCTION__, FEEDBACK_ERROR_OPERATION_FAILED); + return FEEDBACK_ERROR_OPERATION_FAILED; + } + } + return FEEDBACK_ERROR_NONE; +} + +int feedback_deinitialize() +{ + int err; + + if(svi_handle != NOT_ASSIGNED){ + err = svi_fini(svi_handle); + if(err != SVI_SUCCESS){ + LOGE("[%s] Operation failed(0x%08x)", __FUNCTION__, FEEDBACK_ERROR_OPERATION_FAILED); + return FEEDBACK_ERROR_OPERATION_FAILED; + } + svi_handle = NOT_ASSIGNED; + } + + return FEEDBACK_ERROR_NONE; +} + +int feedback_play(feedback_pattern_e pattern) +{ + int err; + if(svi_handle == NOT_ASSIGNED){ + LOGE("[%s] Not Initialized(0x%08x)", __FUNCTION__, FEEDBACK_ERROR_NOT_INITIALIZED); + return FEEDBACK_ERROR_NOT_INITIALIZED; + } + + if(pattern < FEEDBACK_PATTERN_TOUCH_TAP || pattern > FEEDBACK_PATTERN_HW_HOLD){ + LOGE("[%s] Invalid parameter(0x%08x)", __FUNCTION__, FEEDBACK_ERROR_INVALID_PARAMETER); + return FEEDBACK_ERROR_INVALID_PARAMETER; + } + + err = svi_play(svi_handle, _PTN_VIBE[pattern], _PTN_SND[pattern]); + + if(err != SVI_SUCCESS){ + LOGE("[%s] Operation failed(0x%08x)", __FUNCTION__, FEEDBACK_ERROR_OPERATION_FAILED); + return FEEDBACK_ERROR_OPERATION_FAILED; + } + + return FEEDBACK_ERROR_NONE; +} + +int feedback_get_resource_path(feedback_type_e type, feedback_pattern_e pattern, char** path) +{ + int err; + char buf[MAX_PATH_LENGTH]; + + if(type < FEEDBACK_TYPE_SOUND || type > FEEDBACK_TYPE_VIBRATION){ + LOGE("[%s] Invalid parameter(0x%08x)", __FUNCTION__, FEEDBACK_ERROR_INVALID_PARAMETER); + return FEEDBACK_ERROR_INVALID_PARAMETER; + } + + if(pattern < FEEDBACK_PATTERN_TOUCH_TAP || pattern > FEEDBACK_PATTERN_HW_HOLD){ + LOGE("[%s] Invalid parameter(0x%08x)", __FUNCTION__, FEEDBACK_ERROR_INVALID_PARAMETER); + return FEEDBACK_ERROR_INVALID_PARAMETER; + } + + err = svi_get_path(_TYPE[type], _TYPE_PTN[type][pattern], buf, MAX_PATH_LENGTH); + + if(err != SVI_SUCCESS){ + LOGE("[%s] Operation failed(0x%08x)", __FUNCTION__, FEEDBACK_ERROR_OPERATION_FAILED); + return FEEDBACK_ERROR_OPERATION_FAILED; + } + + *path = strdup(buf); + + return FEEDBACK_ERROR_NONE; +} |