adds a new compile time option for debugging output, brings the timeout for reading junk data back into line between joypad.cpp and layout.cpp, and adds in read exception handling when setupjoydevs is called (previously only set up in the joypad constructor)
git-svn-id: svn://svn.code.sf.net/p/qjoypad/code/trunk@101 c05e91a0-76c8-4ec0-b377-ef19ce7cc080
This commit is contained in:
committed by
virtuoussin13
parent
8363313fd2
commit
30ed817389
@ -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
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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<int, JoyPad*> 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");
|
||||
}
|
||||
|
Reference in New Issue
Block a user