// rdgpio.cpp // // A driver for General-Purpose I/O devices. // // (C) Copyright 2002-2003,2016 Fred Gleason // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU Library General Public License // version 2 as published by the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public // License along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // // #include #include #include #include #include #include #include RDGpio::RDGpio(QObject *parent) : QObject(parent) { Clear(); // // Input Timer // gpio_input_timer=new QTimer(this,"input_timer"); connect(gpio_input_timer,SIGNAL(timeout()),this,SLOT(inputTimerData())); gpio_revert_mapper=NULL; for(int i=0;istart(GPIO_CLOCK_INTERVAL); return true; } void RDGpio::close() { if(!gpio_open) { return; } gpio_input_timer->stop(); ::close(gpio_fd); gpio_open=false; if(gpio_revert_mapper!=NULL) { delete gpio_revert_mapper; gpio_revert_mapper=NULL; } for(int i=0;i0) { if((input.type==EV_KEY)&&(gpio_key_map[input.code]>=0)) { if(input.value==0) { input_mask&=~(1<setMapping(gpio_revert_timer[i],i); connect(gpio_revert_timer[i],SIGNAL(timeout()), gpio_revert_mapper,SLOT(map())); } } void RDGpio::SetReversion(int line,unsigned interval) { if(interval==0) { if(gpio_revert_timer[line]->isActive()) { gpio_revert_timer[line]->stop(); } return; } if(gpio_revert_timer[line]->isActive()) { gpio_revert_timer[line]->changeInterval(interval); } else { gpio_revert_timer[line]->start(interval,true); } } void RDGpio::Clear() { gpio_open=false; gpio_description="Unknown Device"; memset(&gpio_info,0,sizeof(struct gpio_info)); gpio_input_mask=0; gpio_api=RDGpio::ApiGpio; for(int i=0;i=0) { gpio_description=desc; } if(ioctl(gpio_fd,EVIOCGBIT(0,EV_MAX),bitmask)<0) { return; } if((bitmask[0]&(1<