Home | History | Annotate | Download | only in libsensors
      1 /*
      2  * Copyright (C) 2011 Samsung
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef SAMSUNG_SENSORBASE_H
     18 #define SAMSUNG_SENSORBASE_H
     19 
     20 #include <stdint.h>
     21 #include <errno.h>
     22 #include <sys/cdefs.h>
     23 #include <sys/types.h>
     24 
     25 #include "sensors.h"
     26 #include "SensorBase.h"
     27 #include "SamsungSensorBase.h"
     28 #include "InputEventReader.h"
     29 
     30 /*****************************************************************************/
     31 
     32 class SamsungSensorBase:public SensorBase {
     33 protected:
     34     bool mEnabled;
     35     bool mHasPendingEvent;
     36     InputEventCircularReader mInputReader;
     37     sensors_event_t mPendingEvent;
     38     char *mInputSysfsEnable;
     39     char *mInputSysfsPollDelay;
     40     int mSensorCode;
     41     pthread_mutex_t mLock;
     42 
     43     char *makeSysfsName(const char *input_name,
     44                         const char *input_file);
     45 
     46     virtual int handleEnable(int en);
     47     virtual bool handleEvent(input_event const * event);
     48 
     49 public:
     50     SamsungSensorBase(const char* dev_name,
     51                       const char* data_name,
     52                       int sensor_code);
     53 
     54     virtual ~SamsungSensorBase();
     55     virtual int enable(int32_t handle, int en);
     56     virtual int setDelay(int32_t handle, int64_t ns);
     57     virtual int readEvents(sensors_event_t *data, int count);
     58 };
     59 #endif /* SAMSUNG_SENSORBASE_H */
     60