diff --git a/src/constant.h b/src/constant.h index fd05ec9..e33c763 100644 --- a/src/constant.h +++ b/src/constant.h @@ -25,5 +25,10 @@ #define NAME "QJoyPad 4.0-pre" #define MOUSE_OFFSET 400 +#ifdef _DEBUG +#define DEBUG(str) printf(str); +#else +#define DEBUG +#endif #endif diff --git a/src/joypad.cpp b/src/joypad.cpp index 47ec700..ccda929 100644 --- a/src/joypad.cpp +++ b/src/joypad.cpp @@ -22,6 +22,7 @@ JoyPad::JoyPad( int i, int dev ) { } void JoyPad::resetToDev(int dev ) { + DEBUG("resetting to dev\n"); //remember the device file descriptor joydev = dev; @@ -47,19 +48,24 @@ void JoyPad::resetToDev(int dev ) { read_struct.fd = joydev; read_struct.events = POLLIN; char buf[10]; - while(poll(&read_struct, 1, 2)!=0) { + while(poll(&read_struct, 1, 5)!=0) { printf("reading junk data\n"); read(joydev, buf, 10); } setupJoyDeviceListener(dev); + DEBUG("done resetting to dev\n"); } void JoyPad::setupJoyDeviceListener(int dev) { + DEBUG("Setting up joyDeviceListener\n"); if(joydevFileHandle != NULL) { delete joydevFileHandle; } joydevFileHandle = new QSocketNotifier(dev, QSocketNotifier::Read, this); connect(joydevFileHandle, SIGNAL(activated(int)), this, SLOT(handleJoyEvents(int))); + joydevFileException = new QSocketNotifier(dev, QSocketNotifier::Exception, this); + connect(joydevFileException, SIGNAL(activated(int)), this, SLOT(errorRead(int))) + DEBUG("Done setting up joyDeviceListener\n"); } void JoyPad::toDefault() { @@ -270,6 +276,7 @@ void JoyPad::unsetDev() { } void JoyPad::errorRead(int fd) { + DEBUG("There was an error reading off of the device, disabling\n"); joydevFileHandle->blockSignals(true); joydevFileHandle->setEnabled(false); close(joydev); @@ -283,4 +290,5 @@ void JoyPad::errorRead(int fd) { joydevFileException = NULL; } joydev = -1; + DEBUG("Done disabling\n"); } diff --git a/src/layout.cpp b/src/layout.cpp index d7809b8..6451a7f 100644 --- a/src/layout.cpp +++ b/src/layout.cpp @@ -314,7 +314,9 @@ void LayoutManager::fillPopup() { } void LayoutManager::updateJoyDevs() { + DEBUG("updating joydevs\n"); QString devdir = DEVDIR; + //reset all joydevs to sentinal value (-1) do { QHashIterator it( joypads ); @@ -375,4 +377,5 @@ void LayoutManager::updateJoyDevs() { //the actual update process is handled by main.cpp, we just need to signal //ourselves to do it. //raise(SIGUSR1); + DEBUG("done updating joydevs\n"); }