LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HapticsController.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2008-2012 Hewlett-Packard Development Company, L.P.
4 *
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
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
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.
16 *
17 * LICENSE@@@ */
18 
19 
20 
21 
22 #ifndef __HAPTICS_CONTROLLER_H__
23 #define __HAPTICS_CONTROLLER_H__
24 #include "Common.h"
25 
26 #include <stdio.h>
27 #include <sys/time.h>
28 #include <sys/resource.h>
29 #include <sys/types.h>
30 #include <unistd.h>
31 #include <lunaservice.h>
32 #include <glib.h>
33 #include "HostBase.h"
34 
35 #define VIBE_ERROR(x) (x != 0)
36 
37 void *vibetonz_thread(void*);
38 
40 {
41 public:
42  static HapticsController *instance();
43 
44  virtual ~HapticsController() { }
45 
46  virtual int vibrate(int period,int duration) {return -1;}
47  virtual int vibrate(const char *name) { return -1;}
48  virtual int vibrateWithAudioFeedback(const char *name, const char *audiosample) { return -1; };
49  virtual int cancel(int id) {return -1;}
50  virtual void cancelAll() {}
51  void addMapping(const char *key,void *value) {
52  g_hash_table_insert(m_mappingTable,(void*)key,value);
53  }
54  int getAndRemoveMapping(const char *key) {
55  int id;
56  id = (int)g_hash_table_lookup(m_mappingTable,(void*)key);
57  g_hash_table_remove(m_mappingTable,(void*)key);
58  return id;
59  }
60  void startService();
61 protected:
63  LSHandle *m_service;
64 private:
65  static HapticsController *s_instance;
66  GHashTable *m_mappingTable;
67 };
68 
69 #endif