Will try to open the device for read/write first, if that fails, trys

read only and displays a message about not being enabled for force
feedback
This commit is contained in:
endolf 2005-05-08 09:58:31 +00:00
parent eac5380da4
commit ab7bba58d6

View file

@ -40,13 +40,21 @@ EventDevice::EventDevice(char *deviceFileName) {
char tempName[Device::MAX_NAME_LENGTH-1] = "Unknown";
int i;
fd = open(deviceFileName, O_RDONLY | O_NONBLOCK);
fd = open(deviceFileName, O_RDWR | O_NONBLOCK);
if(fd<0) {
/*char errorMessage[512];
sprintf(errorMessage, "Error opening device %s\n", deviceFileName);
perror(errorMessage);*/
inited = 0;
return;
char errorMessage[512];
sprintf(errorMessage, "Error opening device %s read/write, Force Feedback disabled for this device\n", deviceFileName);
perror(errorMessage);
fd = open(deviceFileName, O_RDONLY | O_NONBLOCK);
if(fd<0) {
/*char errorMessage[512];
sprintf(errorMessage, "Error opening device %s\n", deviceFileName);
perror(errorMessage);*/
inited = 0;
return;
}
}
if(ioctl(fd, EVIOCGNAME(sizeof(tempName)), tempName) < 0) {