libGizmod/GizmoLIRC.cpp

Go to the documentation of this file.
00001 
00012 /*
00013   
00014   Copyright (c) 2007, Tim Burrell
00015   Licensed under the Apache License, Version 2.0 (the "License");
00016   you may not use this file except in compliance with the License.
00017   You may obtain a copy of the License at 
00018 
00019         http://www.apache.org/licenses/LICENSE-2.0
00020 
00021   Unless required by applicable law or agreed to in writing, software
00022   distributed under the License is distributed on an "AS IS" BASIS,
00023   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00024   See the License for the specific language governing permissions and 
00025   limitations under the License. 
00026   
00027 */
00028 
00029 #include "GizmoLIRC.hpp"
00030 #include "GizmoEventLIRC.hpp"
00031 #include "../libH/Debug.hpp"
00032 #include "../libH/Exception.hpp"
00033 #include "../libH/UtilTime.hpp"
00034 #include <boost/shared_ptr.hpp>
00035 
00036 using namespace std;
00037 using namespace boost;
00038 using namespace H;
00039 using namespace Gizmod;
00040 
00042 // Type Defs
00044 
00049 #define GIZMO_LIRC_TYPE "LIRC"
00050         
00052 // Type Defs
00054 
00056 // Construction
00058 
00062 GizmoLIRC::GizmoLIRC(const H::DeviceInfo & deviceInfo, int DeviceID, int DeviceClassID) : Gizmo(GIZMO_CLASS_LIRC, deviceInfo, DeviceID, DeviceClassID)  {
00063         mDisabledRepeats = 1;
00064         mLastEventTime = UtilTime::getTicks();
00065         mMinTimeBetweenEvents = 0.05f;
00066 }
00067 
00071 GizmoLIRC::GizmoLIRC()  {
00072         mDisabledRepeats = 1;
00073         mLastEventTime = UtilTime::getTicks();
00074         mMinTimeBetweenEvents = 0.05f;
00075 }
00076 
00080 GizmoLIRC::~GizmoLIRC() {
00081 }
00082 
00084 // Class Body
00086 
00091 std::string GizmoLIRC::getType() {
00092         return GIZMO_LIRC_TYPE;
00093 }
00094 
00100 bool GizmoLIRC::processEvent(GizmoEvent * pEvent) {
00101         float TimeBetweenEvents = float(UtilTime::getTicks() - mLastEventTime) / 1000000.0f;
00102         if (TimeBetweenEvents <= mMinTimeBetweenEvents)
00103                 return false;
00104         GizmoEventLIRC * pEventLIRC = static_cast<GizmoEventLIRC *>(pEvent);
00105         if ( (pEventLIRC->Repeat != 0) && (pEventLIRC->Repeat <= mDisabledRepeats) )
00106                 return false;
00107         cdbg5 << "LIRC Time Between Events: " << TimeBetweenEvents << " Seconds" << endl;
00108         mLastEventTime = UtilTime::getTicks();
00109         return true;
00110 }
00111 
00119 void GizmoLIRC::setDisableFirstRepeats(int Repeats) {
00120         mDisabledRepeats = Repeats;
00121 }
00122 
00130 void GizmoLIRC::setMinimumTimeBetweenEvents(float Seconds) {
00131         mMinTimeBetweenEvents = Seconds;
00132 }

Generated on Wed Nov 7 10:04:16 2007 for gizmod by  doxygen 1.5.3