3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
22 #define GCC_PACK __attribute__((packed))
24 /* little-endian form */
25 #define mmioHeaderID(ch0,ch1,ch2,ch3) \
26 ((unsigned int)(unsigned char)(ch0) | ((unsigned int)(unsigned char)(ch1) << 8) | \
27 ((unsigned int)(unsigned char)(ch2) << 16) | ((unsigned int)(unsigned char)(ch3) << 24))
29 #define HEADER_ID mmioHeaderID('T','H','F','M') // 0x4D464854
30 #define FMT_ID mmioHeaderID('f','m','t',' ') // 0x20746D66
31 #define DATA_ID mmioHeaderID('d','a','t','a') // 0x61746164
33 typedef unsigned int ID; /* a four character code */
35 typedef struct _FormatChunk {
36 ID chunkID; /* chunk ID */
37 int chunkSize; /* chunk Size */
38 unsigned short wChannels; /* number of channels (Mono = 1, Stereo = 2, etc.) */
39 unsigned short wBlockAlign; /* block size of data (wChannels*1byte) */
40 unsigned int dwMagnitude; /* max magnitude */
41 unsigned int dwDuration; /* duration */
42 } GCC_PACK FormatChunk;
44 typedef struct _DataChunk {
47 unsigned char pData[];
50 typedef struct _HapticFile {
51 ID chunkID; /* chunk ID */
52 int chunkSize; /* chunk Size */
53 FormatChunk fmt; /* Format chunk */
54 DataChunk data; /* Data chunk */
55 } GCC_PACK HapticFile;
57 typedef struct _HapticElement {
62 int GetHapticLevelMax(int *max);
63 int SetHapticEnable(int value);
64 int SetHapticLevel(int value);
65 int SetHapticOneshot(int value);
67 int InitializeHapticBuffer(unsigned char *vibe_buffer, int max_bufsize);
68 int InsertHapticElement(unsigned char *vibe_buffer, int max_bufsize, HapticElement *element);
69 int GetHapticBufferSize(const unsigned char *vibe_buffer, int *size);
70 int GetHapticBufferDuration(const unsigned char *vibe_buffer, int *duration);
71 int PlayHapticBuffer(const unsigned char *vibe_buffer, int iteration, int level, int *effect_handle);
72 int OpenHapticDevice(void);
73 int CloseHapticDevice(void);